Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterjanin committed May 17, 2024
2 parents 538c357 + a813608 commit 3c5bfbb
Show file tree
Hide file tree
Showing 43 changed files with 931 additions and 545 deletions.
2 changes: 1 addition & 1 deletion backend/src/auth/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def token(
mail=attributes["mail"],
),
)
if resolved_user.surname == 'SURNAME_DEFAULT':
elif resolved_user.surname == 'SURNAME_DEFAULT':
resolved_user.surname = attributes["surname"]

# Create JWT token
Expand Down
19 changes: 14 additions & 5 deletions frontend/src/components/buttons/GroupButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
<v-btn v-else-if="canJoinGroup" @click="joinGroupAndRedirect">
{{ $t("group.join_group") }}
</v-btn>
<v-btn v-if="isTeacher" @click="() => removeGroup({ groupId: group.id })">
<v-btn
v-if="isTeacher"
@click="
() =>
removeGroup({
groupId: group.id,
projectId: project.id,
})
"
>
{{ $t("group.remove_group") }}
</v-btn>
</template>
Expand All @@ -18,7 +27,7 @@ import { computed, toRefs } from "vue";
import {
useJoinGroupUserMutation,
useLeaveGroupUserMutation,
useRemoveGroupMutation,
useDeleteGroupMutation,
useUserGroupsQuery,
} from "@/queries/Group";
import router from "@/router";
Expand Down Expand Up @@ -63,15 +72,15 @@ const { mutateAsync: leaveGroup } = useLeaveGroupUserMutation();
const { mutateAsync: joinGroup } = useJoinGroupUserMutation();
const { mutateAsync: removeGroup } = useRemoveGroupMutation();
const { mutateAsync: removeGroup } = useDeleteGroupMutation();
const joinGroupAndRedirect = async () => {
await joinGroup({ groupId: group.value.id });
await joinGroup({ groupId: group.value.id, projectId: project.value.id });
router.push(`/groups/${group.value.id}`);
};
const leaveGroupAndRedirect = async () => {
await leaveGroup({ groupId: group.value.id });
await leaveGroup({ groupId: group.value.id, projectId: project.value.id });
router.push(`/project/${project.value.id}/groups`);
};
</script>
Expand Down
44 changes: 11 additions & 33 deletions frontend/src/components/home/cards/DeadlinesCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,15 @@
import HomeScreenCard from "@/components/home/cards/HomeScreenCard.vue";
import DeadlineItem from "@/components/home/listcontent/DeadlineItem.vue";
import { type Deadline } from "@/models/Project";
import { ref } from "vue";
const deadlines = ref<Deadline[]>([
{
project: {
id: 1,
name: "project A",
subject_id: 1,
deadline: new Date(2024, 4, 28, 23, 59),
description: "a description",
},
status: "none",
},
{
project: {
id: 2,
name: "project B",
subject_id: 2,
deadline: new Date(2024, 6, 2, 17, 0),
description: "another description",
},
status: "accepted",
},
{
project: {
id: 3,
name: "project C",
subject_id: 3,
deadline: new Date(2024, 5, 5, 22, 0),
description: "last description",
},
status: "rejected",
},
]);
import { useProjectsQuery } from "@/queries/Project";
import { computed } from "vue";
const { data: projects } = useProjectsQuery();
const deadlines = computed<Deadline[]>(
() =>
projects.value?.map((project) => ({
project,
status: "none",
})) || []
);
</script>
6 changes: 5 additions & 1 deletion frontend/src/components/home/cards/SubjectsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<!-- TODO: Add error handling -->
<h1 v-else-if="isSubjectsError">Error loading subjects</h1>
<HomeScreenCard v-else :title="'homescreen.subjects'">
<SubjectItem v-for="subject in subjects" :subject="subject" :key="subject.id" />
<SubjectItem
v-for="subject in [...subjects!.as_student, ...subjects!.as_instructor]"
:subject="subject"
:key="subject.id"
/>
</HomeScreenCard>
</template>

Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/project/ProjectSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
{{ $t("project.group_button") }}
</v-btn>
</router-link>
<router-link v-else-if="isTeacher" :to="`/project/${project!.id}/groups`">
<v-btn class="group-button" prepend-icon="mdi-account-group">
{{ $t("project.to_groups") }}
</v-btn>
</router-link>
<NeedHelpButton
v-if="!isTeacher && subject!.email"
class="group-button"
Expand All @@ -33,7 +38,7 @@ import type Subject from "@/models/Subject";
import NeedHelpButton from "@/components/buttons/NeedHelpButton.vue";
import { computed, toRefs } from "vue";
import type User from "@/models/User";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";
const props = defineProps<{
project: Project;
Expand All @@ -44,7 +49,7 @@ const props = defineProps<{
const { project, group, subject, instructors } = toRefs(props);
const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();
const isTeacher = computed(() => {
if (!user.value || !instructors.value) {
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/components/submission/SubmissionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
{{ $t("submission.download_info") }}
</v-card-subtitle>
<v-container>
<v-alert v-if="isError" title="Error" color="error" :text="error.message"></v-alert>
<v-alert
v-if="isError"
title="Error"
color="error"
:text="error!.message"
></v-alert>
<v-skeleton-loader v-else :loading="isLoading" type="card" color="white">
<v-col>
<v-chip
Expand All @@ -65,11 +70,12 @@
</template>

<script setup lang="ts">
import { Status, type Submission } from "@/models/Submission";
import type { Status } from "@/models/Submission";
import { useFilesQuery } from "@/queries/Submission";
import { toRefs, computed } from "vue";
import { download_file } from "@/utils.ts";
import Project from "@/models/Project";
import { download_file } from "@/utils";
import type Project from "@/models/Project";
import type Submission from "@/models/Submission";
const props = defineProps<{
submission: Submission;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/submission/SubmitForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { computed, ref, toRefs } from "vue";
import FilesInput from "@/components/form_elements/FilesInput.vue";
import { useRouter } from "vue-router";
import { useCreateSubmissionMutation } from "@/queries/Submission";
import { useUserGroupQuery } from "@/queries/Group";
import { useProjectGroupQuery } from "@/queries/Group";
import { useI18n } from "vue-i18n";
import RequirementsCard from "@/components/project/RequirementsCard.vue";
import type Project from "@/models/Project";
Expand All @@ -38,7 +38,7 @@ const inputFiles = ref<File[]>([]);
const remarksInput = ref<string | null>(null);
const unmetRequirements = ref<UnmetRequirement[]>([]);
const { data: group } = useUserGroupQuery(projectId);
const { data: group } = useProjectGroupQuery(projectId);
const groupId = computed(() => group.value?.id);
const { mutateAsync } = useCreateSubmissionMutation(groupId);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/submission/SubmitInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</template>

<script setup lang="ts">
import { useSubmissionsQuery } from "@/queries/Group";
import { useSubmissionsQuery } from "@/queries/Submission";
import { toRefs, computed } from "vue";
import type Project from "@/models/Project";
import type Group from "@/models/Group";
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/composables/useIsAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computed } from "vue";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";

export default function useIsAdmin() {
const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();
const isAdmin = computed(() => user.value?.is_admin || false);
return { isAdmin };
}
4 changes: 2 additions & 2 deletions frontend/src/composables/useIsTeacher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computed } from "vue";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";

export default function useIsTeacher() {
const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();
const isTeacher = computed(() => user.value?.is_teacher || false);
return { isTeacher };
}
12 changes: 9 additions & 3 deletions frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ export default {
needhelp_button: "Need help",
group: "Group {number}",
assignment: "Assignment:",
myProject: "My projects:",
myProject: "My projects",
capacity_group: "Capacity: ",
edit: "Edit project",
submissions_list: "All submissions",
not_found: "No projects found.",
archived: "Archived",
not_finished: "Not Finished",
finished: "Finished",
not_found2: "Project not found",
requirements: "File requirements",
mandatory: "Mandatory",
Expand All @@ -67,6 +66,7 @@ export default {
unmet_forbidden: "These submitted files are not allowed:",
unmet_reqs_warning: "Your submission did not satisfy all file requirements.",
to_subject: "To subject",
to_groups: "To groups",
},
navigation: {
home: "Home",
Expand Down Expand Up @@ -132,4 +132,10 @@ export default {
all_students: "All students",
all_students_course: "All students in course:",
},
about: {
about: "About this project",
p_1: "This project was made as part of the course",
p_2: "The source code is publicly available at",
developers: "Our developers",
},
};
12 changes: 9 additions & 3 deletions frontend/src/i18n/locales/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ export default {
needhelp_button: "Hulp nodig",
group: "Groep {number}",
assignment: "Opdracht:",
myProject: "Mijn projecten:",
myProject: "Mijn projecten",
capacity_group: "Capaciteit: ",
edit: "Bewerk project",
submissions_list: "Alle indieningen",
not_found: "Geen projecten teruggevonden.",
archived: "Gearchiveerd",
not_finished: "Onafgewerkt",
finished: "Afgerond",
not_found2: "Project niet teruggevonden",
requirements: "Bestandsvereisten",
mandatory: "Verplicht",
Expand All @@ -67,6 +66,7 @@ export default {
unmet_forbidden: "Deze ingediende bestanden zijn verboden:",
unmet_reqs_warning: "Opgelet: je indiening voldoet niet aan alle bestandsvereisten.",
to_subject: "Naar vak",
to_groups: "Naar groepen",
},
navigation: {
home: "Hoofdscherm",
Expand Down Expand Up @@ -133,4 +133,10 @@ export default {
all_students: "Alle studenten",
all_students_course: "Alle studenten in vak:",
},
about: {
about: "Over dit project",
p_1: "Dit project is gemaakt in het kader van het vak",
p_2: "De broncode is publiek beschikbaar op",
developers: "Onze developers",
},
};
2 changes: 1 addition & 1 deletion frontend/src/models/Group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import User from "@/models/User";
import type User from "@/models/User";

export default interface Group {
id: number;
Expand Down
Loading

0 comments on commit 3c5bfbb

Please sign in to comment.