Skip to content

Commit

Permalink
chore: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutV committed Apr 4, 2024
1 parent 8b7e5c0 commit 68461a0
Show file tree
Hide file tree
Showing 53 changed files with 342 additions and 1,058 deletions.
2 changes: 0 additions & 2 deletions backend/api/views/course_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def search(self, request: Request) -> Response:
name__icontains=search
)

print(years, faculties)

# Filter the queryset based on selected years
if years:
queryset = queryset.filter(academic_startyear__in=years)
Expand Down
2 changes: 1 addition & 1 deletion backend/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def login(self, request: Request) -> Response:
should_echo = request.query_params.get('echo', False)

if should_echo == "1" and settings.DEBUG:
client._service_url = 'https://localhost:8080/api/auth/cas/echo'
client._service_url = settings.CAS_DEBUG_RESPONSE

return redirect(client.get_login_url())

Expand Down
1 change: 1 addition & 0 deletions backend/ypovoli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
PORT = environ.get("DJANGO_CAS_PORT", "8080")
CAS_ENDPOINT = "https://login.ugent.be"
CAS_RESPONSE = f"https://{DOMAIN_NAME}:{PORT}/auth/verify"
CAS_DEBUG_RESPONSE = f"https://{DOMAIN_NAME}:{PORT}/api/auth/cas/echo"
API_ENDPOINT = f"https://{DOMAIN_NAME}/api"

# Database
Expand Down
9 changes: 3 additions & 6 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"tabWidth": 4,
"printWidth": 80,
"max_line_length": 80,
"printWidth": 120,
"max_line_length": 120,
"semi": true,
"singleQuote": true,
"arrowParens": "always",
"endOfLine": "auto",
"jsxBracketSameLine": true,
"bracketSameLine": true
"endOfLine": "auto"
}
8 changes: 3 additions & 5 deletions frontend/src/components/LanguageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ onMounted(() => {
class="w-auto"
:options="availableLocales"
@change="updateLocale($event.value)"
variant="outlined">
variant="outlined"
>
<template #option="{ option }">
<div class="flex align-items-center">
<img
:alt="t('layout.header.language.' + option)"
:src="getFlag(option)"
class="h-1rem mr-2" />
<img :alt="t('layout.header.language.' + option)" :src="getFlag(option)" class="h-1rem mr-2" />
<span>{{ t('layout.header.language.' + option) }}</span>
</div>
</template>
Expand Down
16 changes: 3 additions & 13 deletions frontend/src/components/RoleSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,16 @@ const { view, user } = storeToRefs(useAuthStore());

<template>
<template v-if="user !== null">
<Dropdown
id="view"
v-model="view"
class="w-auto"
:options="user.roles"
variant="outlined">
<Dropdown id="view" v-model="view" class="w-auto" :options="user.roles" variant="outlined">
<template #option="{ option }">
<div class="flex align-items-center">
<div>
{{
t('layout.header.view', [
t('types.roles.' + option).toLowerCase(),
])
}}
{{ t('layout.header.view', [t('types.roles.' + option).toLowerCase()]) }}
</div>
</div>
</template>
<template #value="{ value }">
<div
class="h-full flex justify-content-center align-items-center">
<div class="h-full flex justify-content-center align-items-center">
<div class="text-sm">{{ t('types.roles.' + value) }}</div>
</div>
</template>
Expand Down
15 changes: 3 additions & 12 deletions frontend/src/components/YearSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,15 @@ const year = defineModel();
</script>

<template>
<Dropdown
v-model="year"
:options="years"
optionLabel="label"
optionValue="value"
class="custom-dropdown">
<Dropdown v-model="year" :options="years" optionLabel="label" optionValue="value" class="custom-dropdown">
<template #value="{ value }">
<span class="text-primary font-semibold"
>{{ t('components.buttons.academic_year') }} {{ value }} -
{{ value + 1 }}</span
>{{ t('components.buttons.academic_year') }} {{ value }} - {{ value + 1 }}</span
>
</template>
<template #option="{ option }">
<span class="pi pi-calendar mr-2" />
<span
>{{ t('components.buttons.academic_year') }}
{{ (option as any).label }}</span
>
<span>{{ t('components.buttons.academic_year') }} {{ (option as any).label }}</span>
</template>
<template #dropdownicon>
<i class="pi pi-chevron-down pr-1 text-primary"></i>
Expand Down
16 changes: 4 additions & 12 deletions frontend/src/components/courses/CourseDetailCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ const images = Object.keys(
class="w-full h-12rem border-round-top"
style="object-fit: cover; margin-bottom: -4px"
:alt="course.name ?? ''"
:src="
images[
Math.ceil(Math.random() * images.length) % images.length
]
" />
:src="images[Math.ceil(Math.random() * images.length) % images.length]"
/>
</template>
<template #title>
<h2 class="text-primary m-0 text-xl">{{ course.name }}</h2>
Expand All @@ -44,13 +41,8 @@ const images = Object.keys(
{{ course.getExcerpt() }}
</template>
<template #footer>
<RouterLink
:to="{ name: 'course', params: { courseId: course.id } }">
<Button
:icon="PrimeIcons.ARROW_RIGHT"
:label="t('components.card.open')"
icon-pos="right"
outlined />
<RouterLink :to="{ name: 'course', params: { courseId: course.id } }">
<Button :icon="PrimeIcons.ARROW_RIGHT" :label="t('components.card.open')" icon-pos="right" outlined />
</RouterLink>
</template>
</Card>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/courses/CourseGeneralCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function getFacultyIcon(faculty: Faculty): string {
:src="getFacultyIcon(course.faculty)"
:alt="course.faculty.name"
class="absolute top-0 left-0 w-3rem"
v-if="course.faculty !== null" />
v-if="course.faculty !== null"
/>
<div class="h-full flex flex-column justify-content-between">
<div>
<div class="text-primary font-semibold text-lg">
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/components/courses/CourseList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const { t } = useI18n();
class="col-12 md:col-6 lg:col-4"
:class="'xl:col-' + 12 / cols"
v-for="course in courses"
:key="course.id">
:key="course.id"
>
<CourseDetailCard :course="course" v-if="detail" />
<CourseGeneralCard class="h-full" :course="course" v-else />
</div>
Expand All @@ -41,11 +42,7 @@ const { t } = useI18n();
</template>
</template>
<template v-else>
<div
class="col-12 md:col-6 lg:col-4"
:class="'xl:col-' + 12 / cols"
v-for="index in cols"
:key="index">
<div class="col-12 md:col-6 lg:col-4" :class="'xl:col-' + 12 / cols" v-for="index in cols" :key="index">
<Skeleton :height="detail ? '25rem' : '10rem'" />
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ async function joinCourse(): Promise<void> {
addSuccessMessage(
t('toasts.messages.success'),
t('toasts.messages.courses.enrollment.success', [
props.course.name,
]),
t('toasts.messages.courses.enrollment.success', [props.course.name]),
);
await refreshUser();
} catch (error) {
addErrorMessage(
t('toasts.messages.error'),
t('toasts.messages.courses.enrollment.error', [props.course.name]),
);
addErrorMessage(t('toasts.messages.error'), t('toasts.messages.courses.enrollment.error', [props.course.name]));
}
}
Expand All @@ -53,10 +48,7 @@ async function leaveCourse(): Promise<void> {
await refreshUser();
} catch (error) {
addErrorMessage(
t('toasts.messages.error'),
t('toasts.messages.courses.leave.error', [props.course.name]),
);
addErrorMessage(t('toasts.messages.error'), t('toasts.messages.courses.leave.error', [props.course.name]));
}
}
</script>
Expand All @@ -69,15 +61,17 @@ async function leaveCourse(): Promise<void> {
icon="pi pi-arrow-right"
@click="joinCourse"
v-if="!student.hasCourse(course)"
link />
link
/>
<Button
class="text-sm p-0"
label="Uitschrijven"
icon-pos="right"
icon="pi pi-arrow-right"
@click="leaveCourse"
v-else
link />
link
/>
</template>

<style scoped lang="scss"></style>
5 changes: 1 addition & 4 deletions frontend/src/components/layout/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ const logo: Record<string, string> = { nl, en };
<template>
<div id="footer" class="p-4 py-3">
<div class="w-full lg:w-2 flex align-items-center py-3">
<img
class="w-full max-w-9rem"
:src="logo[locale]"
:alt="t('layout.header.logo')" />
<img class="w-full max-w-9rem" :src="logo[locale]" :alt="t('layout.header.logo')" />
</div>
</div>
</template>
Expand Down
27 changes: 9 additions & 18 deletions frontend/src/components/layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,24 @@ const items = computed(() => [
<template>
<div class="flex w-full">
<div class="w-full lg:w-2 flex align-items-center p-3 lg:pl-0">
<img
class="w-full max-w-9rem"
:src="logo"
:alt="t('layout.header.logo')" />
<img class="w-full max-w-9rem" :src="logo" :alt="t('layout.header.logo')" />
</div>
<div class="flex flex-column w-full lg:w-10">
<div id="header" class="w-full flex text-white p-4">
<div class="flex align-items-end">
<h1 class="text-white m-0">Ypovoli</h1>
</div>
<div
class="text-right ml-auto text-sm flex flex-column align-items-end gap-3">
<div class="text-right ml-auto text-sm flex flex-column align-items-end gap-3">
<div class="flex align-items-center gap-3">
<!-- Role selector -->
<RoleSelector
v-if="user !== null && user.roles.length > 1" />
<RoleSelector v-if="user !== null && user.roles.length > 1" />
<!-- Language selector -->
<LanguageSelector />
</div>
<div>
<!-- User information -->
<template v-if="isAuthenticated && user">
<RouterLink
:to="{ name: 'logout' }"
class="text-white">
<RouterLink :to="{ name: 'logout' }" class="text-white">
Ingelogd als {{ user.getFullName() }}
</RouterLink>
</template>
Expand All @@ -80,7 +73,8 @@ const items = computed(() => [
icon="pi pi-unlock"
:label="t('layout.header.login')"
severity="secondary"
class="text-sm" />
class="text-sm"
/>
</RouterLink>
</template>
</div>
Expand All @@ -89,13 +83,10 @@ const items = computed(() => [
<!-- Navigation -->
<div id="navigation" class="w-full h-full flex">
<template v-if="isAuthenticated">
<RouterLink
:to="{ name: item.route }"
v-for="item in items"
:key="item.route"
class="nav-item">
<RouterLink :to="{ name: item.route }" v-for="item in items" :key="item.route" class="nav-item">
<div
class="flex align-items-center uppercase flex justify-content-center p-3 pl-0 cursor-pointer text-primary font-medium">
class="flex align-items-center uppercase flex justify-content-center p-3 pl-0 cursor-pointer text-primary font-medium"
>
<span class="mr-2" :class="'pi pi-' + item.icon" />
{{ item.label }}
</div>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/projects/GroupCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ onMounted(async () => {
<div class="groupcard">
<h2>{{ t('views.projects.groupMembers') }}</h2>
<div>
<p v-for="student in students" :key="student.id">
{{ student.first_name }} {{ student.last_name }}
</p>
<p v-for="student in students" :key="student.id">{{ student.first_name }} {{ student.last_name }}</p>
</div>
</div>
</div>
Expand Down
24 changes: 7 additions & 17 deletions frontend/src/components/projects/ProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,18 @@ const { t } = useI18n();
<template>
<Card class="border-round project-card">
<template #header>
<h2 class="text-primary m-0 text-xl">
<span class="pi pi-book text-xl mr-2" /> {{ course.name }}
</h2>
<h2 class="text-primary m-0 text-xl"><span class="pi pi-book text-xl mr-2" /> {{ course.name }}</h2>
</template>
<template #subtitle>
{{ project.name }}
</template>
<template #content>
<div class="mb-2">
<i
:class="['pi', PrimeIcons.CALENDAR_PLUS, 'icon-color']"
class="mr-2"></i>
{{ t('views.projects.deadline') }}: {{ formattedDeadline
}}<br />
<i :class="['pi', PrimeIcons.CALENDAR_PLUS, 'icon-color']" class="mr-2"></i>
{{ t('views.projects.deadline') }}: {{ formattedDeadline }}<br />
</div>
<div>
<i
:class="['pi', PrimeIcons.INFO_CIRCLE, 'icon-color']"
class="mr-2"></i>
<i :class="['pi', PrimeIcons.INFO_CIRCLE, 'icon-color']" class="mr-2"></i>
{{ t('views.projects.submissionStatus') }}: ok
</div>
</template>
Expand All @@ -60,12 +53,9 @@ const { t } = useI18n();
courseId: course.id,
projectId: project.id,
},
}">
<Button
:icon="PrimeIcons.ARROW_RIGHT"
:label="t('components.card.open')"
icon-pos="right"
outlined />
}"
>
<Button :icon="PrimeIcons.ARROW_RIGHT" :label="t('components.card.open')" icon-pos="right" outlined />
</RouterLink>
</template>
</Card>
Expand Down
14 changes: 3 additions & 11 deletions frontend/src/components/projects/ProjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ const { t } = useI18n();
const { projects, getProjectsByCourse } = useProject();
/* State */
const allProjects = computed(() =>
props.courses.flatMap((course) => course.projects),
);
const allProjects = computed(() => props.courses.flatMap((course) => course.projects));
watch(
() => props.courses,
Expand All @@ -49,14 +47,8 @@ watch(
<template>
<template v-if="allProjects.length > 0">
<div class="grid align-items-stretch">
<div
class="col-12 md:col-6 lg:col-4 xl:col-3"
v-for="project in allProjects"
:key="project.id">
<ProjectCard
class="h-100"
:project="project"
:course="project.course" />
<div class="col-12 md:col-6 lg:col-4 xl:col-3" v-for="project in allProjects" :key="project.id">
<ProjectCard class="h-100" :project="project" :course="project.course" />
</div>
</div>
</template>
Expand Down
Loading

0 comments on commit 68461a0

Please sign in to comment.