Skip to content

Commit

Permalink
Merge pull request #299 from SELab-2/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
francisvaut authored Apr 12, 2024
2 parents fc2ac86 + 15fe976 commit 0b75a21
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 24 deletions.
9 changes: 5 additions & 4 deletions backend/api/management/commands/make_teacher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand
from api.models.student import Student
from api.models.teacher import Teacher
from authentication.models import User


class Command(BaseCommand):
Expand All @@ -12,12 +12,13 @@ def add_arguments(self, parser):

def handle(self, *args, **options):
username = options['username']
student = Student.objects.filter(username=username)
user = User.objects.filter(username=username)

if student.count() == 0:
if user.count() == 0:
self.stdout.write(self.style.ERROR('User not found, first log in !'))
return

Teacher.create(student.get(), create_time=student.create_time)
user = user.get()
Teacher(user_ptr=user).save_base(raw=True)

self.stdout.write(self.style.SUCCESS('Successfully made the user teacher!'))
2 changes: 1 addition & 1 deletion backend/authentication/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ msgstr "Psychologie en Pedagogische Wetenschappen"
msgid "faculties.law_criminology"
msgstr "Recht en Criminologie"

msgid "faculties.science"
msgid "faculties.sciences"
msgstr "Wetenschappen"
36 changes: 32 additions & 4 deletions frontend/src/assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"logo": "Ghent University logo",
"login": "login",
"view": "View as {0}",
"user": "Logged in as {0}",
"navigation": {
"dashboard": "Dashboard",
"calendar": "Calendar",
Expand All @@ -24,7 +25,8 @@
"projects": "Current projects",
"no_projects": "No projects available for this academic year.",
"no_courses": "No courses available for this academic year.",
"select_course": "Select the course for which you want to create a project:"
"select_course": "Select the course for which you want to create a project:",
"showPastProjects": "Projects with passed deadline"
},
"login": {
"title": "Login",
Expand All @@ -37,7 +39,8 @@
}
},
"calendar": {
"title": "Calendar"
"title": "Calendar",
"noProjects": "No projects on selected date."
},
"projects": {
"deadline": "Deadline",
Expand Down Expand Up @@ -69,7 +72,16 @@
"edit": "Edit course",
"name": "Course name",
"description": "Description",
"faculty": "Faculty"
"faculty": "Faculty",
"year": "Academic year",
"search": {
"search": "Search",
"faculty": "Faculty",
"year": "Academic year",
"placeholder": "Search a course by name",
"title": "Search a course",
"results": "{0} courses found for set filters"
}
}
},
"composables": {
Expand Down Expand Up @@ -106,7 +118,23 @@
},
"toasts": {
"messages": {
"unknown": "An unknown error has occurred."
"success": "Success",
"error": "Error",
"unknown": "An unknown error has occurred.",
"courses": {
"enrollment": {
"success": "You have been successfully enrolled for the course '{0}'.",
"error": "An error occurred while enrolling for the course '{0}'."
},
"leave": {
"success": "You have been successfully unenrolled for the course '{0}'",
"error": "An error occurred while unenrolling for the course '{0}'."
}
},
"login": {
"success": "You have successfully logged in.",
"error": "An error occurred while logging in."
}
}
},
"validations": {
Expand Down
30 changes: 16 additions & 14 deletions frontend/src/assets/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"dashboard": {
"courses": "Mijn vakken",
"projects": "Lopende projecten",
"no_projects": "Geen projecten beschikbaar voor dit academiejaar.",
"no_courses": "Geen vakken beschikbaar voor dit academiejaar.",
"select_course": "Selecteer het vak waarvoor je een project wil maken:",
"showPastProjects": "Projecten met verstreken deadline"
},
Expand Down Expand Up @@ -71,6 +73,7 @@
"name": "Vaknaam",
"description": "Beschrijving",
"faculty": "Faculteit",
"year": "Academiejaar",
"search": {
"search": "Zoeken",
"faculty": "Faculteit",
Expand All @@ -82,21 +85,20 @@
}
},
"composables": {
"helpers": {
"errors": {
"notFound": "Niet Gevonden",
"notFoundDetail": "Bron niet gevonden.",
"unauthorized": "Onbevoegd",
"unauthorizedDetail": "Je bent niet bevoegd om deze bron te bereiken.",
"server": "Server Fout",
"serverDetail": "Er vond een fout plaats op de server.",
"network": "Netwerk Fout",
"networkDetail": "Kan de server niet bereiken.",

"request": "Fout verzoek",
"requestDetail": "Een fout vond plaats tijdens het maken van het verzoek."
"helpers": {
"errors": {
"notFound": "Niet Gevonden",
"notFoundDetail": "Bron niet gevonden.",
"unauthorized": "Onbevoegd",
"unauthorizedDetail": "Je bent niet bevoegd om deze bron te bereiken.",
"server": "Server Fout",
"serverDetail": "Er vond een fout plaats op de server.",
"network": "Netwerk Fout",
"networkDetail": "Kan de server niet bereiken.",
"request": "Fout verzoek",
"requestDetail": "Een fout vond plaats tijdens het maken van het verzoek."
}
}
}
},
"components": {
"buttons": {
Expand Down
25 changes: 24 additions & 1 deletion frontend/src/views/calendar/CalendarView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ const projectsWithDeadline = computed(() => {
});
});
/* Courses that take place on the selected date in the calendar => no display when the date is in the past */
const coursesWithProjectCreationPossibility = computed(() => {
if (user.value !== null && moment(selectedDate.value).isAfter(moment())) {
return (user.value as RoleUser).courses.filter((course) => {
return course.academic_startyear === selectedAcademicYear();
});
} else {
return [];
}
});
/**
* Load the projects of the user.
*/
Expand Down Expand Up @@ -116,6 +127,18 @@ function countDeadlines(date: CalendarDateSlotOptions): number {
);
}
/**
* Get the academic year of the selected date.
*
* @returns The academic year of the selected date.
*/
const selectedAcademicYear = (): number => {
const selectedYear = moment(selectedDate.value).year();
const selectedMonth = moment(selectedDate.value).month();
return selectedMonth < 8 ? selectedYear - 1 : selectedYear;
};
/* Watch the user and load the projects */
watch(
user,
Expand Down Expand Up @@ -197,7 +220,7 @@ watch(selectedDate, (date) => {

<template v-if="user?.isTeacher() || user?.isAssistant()">
<!-- Add project button -->
<ProjectCreateButton :courses="(user as RoleUser).courses" />
<ProjectCreateButton :courses="coursesWithProjectCreationPossibility" />
</template>
</div>
</div>
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/views/courses/UpdateCourseView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { reactive, computed, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useCourses } from '@/composables/services/courses.service';
import { useFaculty } from '@/composables/services/faculties.service.ts';
import { Faculty } from '@/types/Faculty';
import InputText from 'primevue/inputtext';
import Textarea from 'primevue/textarea';
import Button from 'primevue/button';
import Dropdown from 'primevue/dropdown';
import { required, helpers } from '@vuelidate/validators';
import { useVuelidate } from '@vuelidate/core';
import ErrorMessage from '@/components/forms/ErrorMessage.vue';
Expand All @@ -17,15 +20,18 @@ const { params } = useRoute();
const { t } = useI18n();
const { push } = useRouter();
const { course, getCourseByID } = useCourses();
const { faculties, getFaculties } = useFaculty();
/* Load course data */
onMounted(async () => {
await getFaculties();
await getCourseByID(params.courseId as string);
/* Set the form values */
if (course.value !== null) {
form.name = course.value.name;
form.description = course.value.description ?? '';
form.faculty = course.value.faculty ?? new Faculty('', '');
form.year = `${course.value.academic_startyear} - ${course.value.academic_startyear + 1}`;
}
});
Expand All @@ -34,13 +40,15 @@ onMounted(async () => {
const form = reactive({
name: '',
description: '',
faculty: new Faculty('', ''), // Default value for the dropdown
year: '',
});
// Define validation rules for each form field
const rules = computed(() => {
return {
name: { required: helpers.withMessage(t('validations.required'), required) },
faculty: { required: helpers.withMessage(t('validations.required'), required) },
};
});
Expand Down Expand Up @@ -92,6 +100,19 @@ const submitCourse = async (): Promise<void> => {
<Textarea id="courseDescription" v-model="form.description" autoResize rows="5" cols="30" />
</div>

<!-- Course faculty -->
<div class="mb-4">
<label for="courseFaculty">{{ t('views.courses.faculty') }}</label>
<Dropdown
id="courseFaculty"
v-model="form.faculty"
:options="faculties"
optionLabel="name"
v-if="faculties"
/>
<ErrorMessage :field="v$.faculty" />
</div>

<!-- Course academic year, not editable -->
<div class="mb-4">
<label for="courseYear">{{ t('views.courses.year') }}</label>
Expand Down

0 comments on commit 0b75a21

Please sign in to comment.