mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-04 19:44:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec5b964ac3
|
||
|
|
2832e76a31
|
||
|
|
71ba949cb5
|
||
|
|
641f692d75
|
+11
@@ -3,6 +3,7 @@ from typing import Annotated, Literal
|
|||||||
from annotated_types import Ge, Le, MinLen
|
from annotated_types import Ge, Le, MinLen
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
|
from django.http import HttpResponse
|
||||||
from ninja import File, Query
|
from ninja import File, Query
|
||||||
from ninja.security import SessionAuth
|
from ninja.security import SessionAuth
|
||||||
from ninja_extra import ControllerBase, api_controller, paginate, route
|
from ninja_extra import ControllerBase, api_controller, paginate, route
|
||||||
@@ -17,6 +18,7 @@ from core.models import Group, QuickUploadImage, SithFile, User
|
|||||||
from core.schemas import (
|
from core.schemas import (
|
||||||
FamilyGodfatherSchema,
|
FamilyGodfatherSchema,
|
||||||
GroupSchema,
|
GroupSchema,
|
||||||
|
MarkdownSchema,
|
||||||
SithFileSchema,
|
SithFileSchema,
|
||||||
UploadedFileSchema,
|
UploadedFileSchema,
|
||||||
UploadedImage,
|
UploadedImage,
|
||||||
@@ -26,9 +28,18 @@ from core.schemas import (
|
|||||||
UserSchema,
|
UserSchema,
|
||||||
ValidationErrorSchema,
|
ValidationErrorSchema,
|
||||||
)
|
)
|
||||||
|
from core.templatetags.renderer import markdown
|
||||||
from counter.utils import is_logged_in_counter
|
from counter.utils import is_logged_in_counter
|
||||||
|
|
||||||
|
|
||||||
|
@api_controller("/markdown")
|
||||||
|
class MarkdownController(ControllerBase):
|
||||||
|
@route.post("", url_name="markdown")
|
||||||
|
def render_markdown(self, body: MarkdownSchema):
|
||||||
|
"""Convert the markdown text into html."""
|
||||||
|
return HttpResponse(markdown(body.text), content_type="text/html")
|
||||||
|
|
||||||
|
|
||||||
@api_controller("/upload")
|
@api_controller("/upload")
|
||||||
class UploadController(ControllerBase):
|
class UploadController(ControllerBase):
|
||||||
@route.post(
|
@route.post(
|
||||||
|
|||||||
@@ -161,6 +161,10 @@ class UserFilterSchema(FilterSchema):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class MarkdownSchema(Schema):
|
||||||
|
text: str
|
||||||
|
|
||||||
|
|
||||||
class FamilyGodfatherSchema(Schema):
|
class FamilyGodfatherSchema(Schema):
|
||||||
godfather: int
|
godfather: int
|
||||||
godchild: int
|
godchild: int
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Must be loaded before Apline
|
// Must be loaded before Apline
|
||||||
import htmx from "htmx.org";
|
import htmx, { HtmxResponse } from "htmx.org";
|
||||||
import "htmx.org/dist/ext/hx-alpine-compat.js";
|
import "htmx.org/dist/ext/hx-alpine-compat.js";
|
||||||
import "htmx.org/dist/ext/hx-prompt.js";
|
import "htmx.org/dist/ext/hx-prompt.js";
|
||||||
import "htmx.org/dist/ext/hx-download.js";
|
import "htmx.org/dist/ext/hx-download.js";
|
||||||
@@ -48,19 +48,13 @@ polyfillCountryFlagEmojis();
|
|||||||
/**
|
/**
|
||||||
* HTMX
|
* HTMX
|
||||||
*/
|
*/
|
||||||
document.body.addEventListener(
|
document.body.addEventListener("htmx:before:request", (event) => {
|
||||||
"htmx:before:request" as keyof HTMLElementEventMap,
|
event.target.ariaBusy = true;
|
||||||
(event) => {
|
});
|
||||||
(event as CustomEvent).detail.ctx.target.ariaBusy = true;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
document.body.addEventListener(
|
document.body.addEventListener("htmx:before:swap", (event) => {
|
||||||
"htmx:before:swap" as keyof HTMLElementEventMap,
|
event.target.ariaBusy = null;
|
||||||
(event) => {
|
});
|
||||||
(event as CustomEvent).detail.ctx.target.ariaBusy = null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Object.assign(window, { htmx });
|
Object.assign(window, { htmx });
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,16 @@
|
|||||||
import "codemirror/lib/codemirror.css";
|
import "codemirror/lib/codemirror.css";
|
||||||
// @ts-expect-error 2307
|
// @ts-expect-error 2307
|
||||||
import "easymde/src/css/easymde.css";
|
import "easymde/src/css/easymde.css";
|
||||||
import { markdown } from "@ae_utbm/aemark";
|
|
||||||
// biome-ignore lint/correctness/noUndeclaredDependencies: Imported by EasyMDE
|
// biome-ignore lint/correctness/noUndeclaredDependencies: Imported by EasyMDE
|
||||||
import type CodeMirror from "codemirror"; // biome-ignore lint/style/useNamingConvention: This is how they called their namespace
|
import type CodeMirror from "codemirror";
|
||||||
|
// biome-ignore lint/style/useNamingConvention: This is how they called their namespace
|
||||||
import EasyMDE from "easymde";
|
import EasyMDE from "easymde";
|
||||||
import { inheritHtmlElement, registerComponent } from "#core:utils/web-components";
|
import { inheritHtmlElement, registerComponent } from "#core:utils/web-components";
|
||||||
import { type UploadUploadImageErrors, uploadUploadImage } from "#openapi";
|
import {
|
||||||
|
markdownRenderMarkdown,
|
||||||
|
type UploadUploadImageErrors,
|
||||||
|
uploadUploadImage,
|
||||||
|
} from "#openapi";
|
||||||
|
|
||||||
const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
||||||
const easymde = new EasyMDE({
|
const easymde = new EasyMDE({
|
||||||
@@ -60,7 +64,19 @@ const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
|||||||
});
|
});
|
||||||
easymde.codemirror.replaceSelection("\n");
|
easymde.codemirror.replaceSelection("\n");
|
||||||
},
|
},
|
||||||
previewRender: (plainText) => markdown(plainText),
|
previewRender: (plainText, preview) => {
|
||||||
|
/* This is wrapped this way to allow time for Alpine to be loaded on the page */
|
||||||
|
return Alpine.debounce(() => {
|
||||||
|
const func = async () => {
|
||||||
|
preview.innerHTML = (
|
||||||
|
await markdownRenderMarkdown({ body: { text: plainText } })
|
||||||
|
).data as string;
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
func().then();
|
||||||
|
return null;
|
||||||
|
}, 300)();
|
||||||
|
},
|
||||||
forceSync: true, // Avoid validation error on generic create view
|
forceSync: true, // Avoid validation error on generic create view
|
||||||
imageTexts: {
|
imageTexts: {
|
||||||
sbInit: gettext("Attach files by drag and dropping or pasting from clipboard."),
|
sbInit: gettext("Attach files by drag and dropping or pasting from clipboard."),
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
|
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<h3>{% trans %}404, Not Found{% endtrans %}</h3>
|
<h3>{% trans %}404, Not Found{% endtrans %}</h3>
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
{% trans %}Impossible, perhaps the archives are incomplete{% endtrans %}
|
|
||||||
</blockquote>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
+1
-1
@@ -473,7 +473,7 @@ class UserClubView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
class UserVisibilityFormFragment(FragmentMixin, SuccessMessageMixin, UpdateView):
|
class UserVisibilityFormFragment(FragmentMixin, SuccessMessageMixin, UpdateView):
|
||||||
model = User
|
model = User
|
||||||
form_class = UserVisibilityForm
|
form_class = UserVisibilityForm
|
||||||
template_name = "core/fragment/user_visibility.jinja"
|
template_name = "core/fragments/user_visibility.jinja"
|
||||||
pk_url_kwarg = "user_id"
|
pk_url_kwarg = "user_id"
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
## syntaxe aemark
|
|
||||||
|
|
||||||
Le site AE utilise markdown pour le rendu de la plupart
|
|
||||||
des textes saisis par les utilisateurs.
|
|
||||||
Cependant, la syntaxe utilisée n'est pas celle officielle
|
|
||||||
telle que définie par John Gruber,
|
|
||||||
mais est basée sur [CommonMark](https://commonmark.org/),
|
|
||||||
avec quelques variations pour les usages particuliers du site AE.
|
|
||||||
|
|
||||||
Les deux principaux ajouts sont :
|
|
||||||
|
|
||||||
- Les urls commençant par `page://` sont modifiées pour commencer par `/page/`
|
|
||||||
- Des modificateurs de taille peuvent être indiqués directement dans la source
|
|
||||||
d'une image
|
|
||||||
|
|
||||||
Les variations d'aemark sont documentées sur
|
|
||||||
[le site AE](https://ae.utbm.fr/page/Aide_sur_la_syntaxe/).
|
|
||||||
|
|
||||||
Le code est hébergé sur le dépôt Git [aemark](https://github.com/ae-utbm/ae-markdown).
|
|
||||||
|
|
||||||
## Utiliser aemark
|
|
||||||
|
|
||||||
Le code du parser aemark est écrit en Rust dans une librairie
|
|
||||||
indépendante, avec des bindings vers différents langages.
|
|
||||||
Les librairies mises à disposition exposent une seule fonction,
|
|
||||||
qui prend simplement du markdown en entrée et renvoie l'HTML correspondant.
|
|
||||||
|
|
||||||
Les librairies pour les différents langages sont toutes
|
|
||||||
basées sur le même code Rust.
|
|
||||||
La seule différence entre chacune tient uniquement dans la manière
|
|
||||||
d'intégrer ce code dans les bindings.
|
|
||||||
De cette manière, le comportement est assuré d'être le même
|
|
||||||
sur toutes les plateformes disponibles, avec en prime des performances
|
|
||||||
respectables.
|
|
||||||
|
|
||||||
|
|
||||||
=== ":simple-python: Python"
|
|
||||||
|
|
||||||
```python
|
|
||||||
from aemark import markdown
|
|
||||||
|
|
||||||
result = markdown("this is some *markdown text* with __formatting__")
|
|
||||||
```
|
|
||||||
|
|
||||||
=== ":simple-javascript: Javascript"
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { markdown } from "@ae_utbm/aemark"
|
|
||||||
|
|
||||||
const result = markdown("this is some *markdown text* with __formatting__");
|
|
||||||
```
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2026-09-04 11:24+0200\n"
|
"POT-Creation-Date: 2026-08-21 14:10+0200\n"
|
||||||
"PO-Revision-Date: 2016-07-18\n"
|
"PO-Revision-Date: 2016-07-18\n"
|
||||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||||
@@ -2049,10 +2049,6 @@ msgstr "403, Non autorisé"
|
|||||||
msgid "404, Not Found"
|
msgid "404, Not Found"
|
||||||
msgstr "404. Non trouvé"
|
msgstr "404. Non trouvé"
|
||||||
|
|
||||||
#: core/templates/core/404.jinja
|
|
||||||
msgid "Impossible, perhaps the archives are incomplete"
|
|
||||||
msgstr "Impossible, les archives sont peut-être incomplètes"
|
|
||||||
|
|
||||||
#: core/templates/core/500.jinja
|
#: core/templates/core/500.jinja
|
||||||
msgid "500, Server Error"
|
msgid "500, Server Error"
|
||||||
msgstr "500, Erreur Serveur"
|
msgstr "500, Erreur Serveur"
|
||||||
@@ -5093,10 +5089,6 @@ msgstr "signalant"
|
|||||||
msgid "A guide of courses available at UTBM."
|
msgid "A guide of courses available at UTBM."
|
||||||
msgstr "Un guide de tous les cours disponibles à l'UTBM."
|
msgstr "Un guide de tous les cours disponibles à l'UTBM."
|
||||||
|
|
||||||
#: pedagogy/templates/pedagogy/guide.jinja
|
|
||||||
msgid "Search UE"
|
|
||||||
msgstr "Recherche d'UE"
|
|
||||||
|
|
||||||
#: pedagogy/templates/pedagogy/guide.jinja
|
#: pedagogy/templates/pedagogy/guide.jinja
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "%(display_name)s"
|
msgid "%(display_name)s"
|
||||||
@@ -5766,18 +5758,6 @@ msgstr "fin de la cotisation"
|
|||||||
msgid "location"
|
msgid "location"
|
||||||
msgstr "lieu"
|
msgstr "lieu"
|
||||||
|
|
||||||
#: subscription/models.py
|
|
||||||
msgid "created_at"
|
|
||||||
msgstr "créé le"
|
|
||||||
|
|
||||||
#: subscription/models.py
|
|
||||||
msgid ""
|
|
||||||
"When this subscription was created. This date may differ from the start of "
|
|
||||||
"the subscription."
|
|
||||||
msgstr ""
|
|
||||||
"Quand la cotisation a été créée. Cette date peut différer du début effectif "
|
|
||||||
"de la cotisation."
|
|
||||||
|
|
||||||
#: subscription/models.py
|
#: subscription/models.py
|
||||||
msgid "You can not subscribe many time for the same period"
|
msgid "You can not subscribe many time for the same period"
|
||||||
msgstr "Vous ne pouvez pas cotiser plusieurs fois pour la même période"
|
msgstr "Vous ne pouvez pas cotiser plusieurs fois pour la même période"
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ nav:
|
|||||||
- API:
|
- API:
|
||||||
- Développement: tutorial/api/dev.md
|
- Développement: tutorial/api/dev.md
|
||||||
- Connexion à l'API: tutorial/api/connect.md
|
- Connexion à l'API: tutorial/api/connect.md
|
||||||
- Markdown AE: tutorial/markdown.md
|
|
||||||
- Etransactions: tutorial/etransaction.md
|
- Etransactions: tutorial/etransaction.md
|
||||||
- How-to:
|
- How-to:
|
||||||
- L'ORM de Django: howto/querysets.md
|
- L'ORM de Django: howto/querysets.md
|
||||||
|
|||||||
Generated
-6
@@ -9,7 +9,6 @@
|
|||||||
"version": "3",
|
"version": "3",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ae_utbm/aemark": "^0.1.3",
|
|
||||||
"@alpinejs/sort": "^3.16.2",
|
"@alpinejs/sort": "^3.16.2",
|
||||||
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
||||||
"@floating-ui/dom": "^1.8.0",
|
"@floating-ui/dom": "^1.8.0",
|
||||||
@@ -57,11 +56,6 @@
|
|||||||
"vite": "^8.2.2"
|
"vite": "^8.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@ae_utbm/aemark": {
|
|
||||||
"version": "0.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@ae_utbm/aemark/-/aemark-0.1.3.tgz",
|
|
||||||
"integrity": "sha512-JHb9XDgYxy9J0f7bUWtS7eVptKbeB/4+VQoHO3g1ASwNHZpIpW+RRdJPXA+oi2/RDrdPbEtCMkkVROc+8ifFYQ=="
|
|
||||||
},
|
|
||||||
"node_modules/@alpinejs/sort": {
|
"node_modules/@alpinejs/sort": {
|
||||||
"version": "3.16.2",
|
"version": "3.16.2",
|
||||||
"resolved": "https://registry.npmjs.org/@alpinejs/sort/-/sort-3.16.2.tgz",
|
"resolved": "https://registry.npmjs.org/@alpinejs/sort/-/sort-3.16.2.tgz",
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
"vite": "^8.2.2"
|
"vite": "^8.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ae_utbm/aemark": "^0.1.3",
|
|
||||||
"@alpinejs/sort": "^3.16.2",
|
"@alpinejs/sort": "^3.16.2",
|
||||||
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
||||||
"@floating-ui/dom": "^1.8.0",
|
"@floating-ui/dom": "^1.8.0",
|
||||||
|
|||||||
+5
-1
@@ -126,7 +126,11 @@ class UE(models.Model):
|
|||||||
Returns:
|
Returns:
|
||||||
True if the user has already posted a comment on this UE, else False.
|
True if the user has already posted a comment on this UE, else False.
|
||||||
"""
|
"""
|
||||||
return self.comments.filter(author=user).exists()
|
self._has_user_commented = getattr(self, "_has_user_commented", {})
|
||||||
|
self._has_user_commented[user] = self._has_user_commented.get(
|
||||||
|
user, self.comments.filter(author=user).exists()
|
||||||
|
)
|
||||||
|
return self._has_user_commented[user]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def grade_global_average(self):
|
def grade_global_average(self):
|
||||||
|
|||||||
+51
-37
@@ -1,5 +1,9 @@
|
|||||||
import { getCurrentUrlParams, updateQueryString } from "#core:utils/history";
|
import {
|
||||||
import { type SimpleUeSchema, ueFetchUeList } from "#openapi";
|
getCurrentUrlParams,
|
||||||
|
History,
|
||||||
|
updateQueryString,
|
||||||
|
} from "#core:utils/history.ts";
|
||||||
|
import { ueFetchUeList } from "#openapi";
|
||||||
|
|
||||||
const pageDefault = 1;
|
const pageDefault = 1;
|
||||||
const pageSizeDefault = 100;
|
const pageSizeDefault = 100;
|
||||||
@@ -8,42 +12,38 @@ document.addEventListener("alpine:init", () => {
|
|||||||
Alpine.data("ue_search", () => ({
|
Alpine.data("ue_search", () => ({
|
||||||
ues: {
|
ues: {
|
||||||
count: 0,
|
count: 0,
|
||||||
next: null as string | null,
|
next: null,
|
||||||
previous: null as string | null,
|
previous: null,
|
||||||
results: [] as SimpleUeSchema[],
|
results: [],
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
page: pageDefault,
|
page: pageDefault,
|
||||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||||
page_size: pageSizeDefault,
|
page_size: pageSizeDefault,
|
||||||
search: "",
|
search: "",
|
||||||
department: [] as string[],
|
department: [],
|
||||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||||
credit_type: [] as string[],
|
credit_type: [],
|
||||||
semester: [] as string[],
|
semester: [],
|
||||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||||
to_change: [] as { param: string; value: string }[],
|
to_change: [],
|
||||||
|
pushstate: History.Push,
|
||||||
|
|
||||||
// dummy implementation to make TS happy.
|
update: undefined,
|
||||||
// The real function is initialized in init
|
|
||||||
update: () => {
|
|
||||||
console.warn("Update not yet initialized");
|
|
||||||
},
|
|
||||||
|
|
||||||
initializeArgs() {
|
initializeArgs() {
|
||||||
const url = getCurrentUrlParams();
|
const url = getCurrentUrlParams();
|
||||||
this.page = Number.parseInt(url.get("page") || pageDefault.toString(), 10);
|
this.pushstate = History.Replace;
|
||||||
this.page_size = Number.parseInt(
|
|
||||||
url.get("page_size") || pageSizeDefault.toString(),
|
this.page = Number.parseInt(url.get("page"), 10) || pageDefault;
|
||||||
10,
|
this.page_size = Number.parseInt(url.get("page_size"), 10) || pageSizeDefault;
|
||||||
);
|
|
||||||
this.search = url.get("search") || "";
|
this.search = url.get("search") || "";
|
||||||
this.department = url.getAll("department");
|
this.department = url.getAll("department");
|
||||||
this.credit_type = url.getAll("credit_type");
|
this.credit_type = url.getAll("credit_type");
|
||||||
/* The semester is easier to use on the backend as an enum (spring/autumn/both/none)
|
/* The semester is easier to use on the backend as an enum (spring/autumn/both/none)
|
||||||
and easier to use on the frontend as an array ([spring, autumn]).
|
and easier to use on the frontend as an array ([spring, autumn]).
|
||||||
Thus there is some conversion involved when both communicate together */
|
Thus there is some conversion involved when both communicate together */
|
||||||
this.semester = url.get("semester")?.split("_AND_") || [];
|
this.semester = url.has("semester") ? url.get("semester").split("_AND_") : [];
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
@@ -51,11 +51,15 @@ document.addEventListener("alpine:init", () => {
|
|||||||
async init() {
|
async init() {
|
||||||
this.update = Alpine.debounce(async () => {
|
this.update = Alpine.debounce(async () => {
|
||||||
/* Create the whole url before changing everything all at once */
|
/* Create the whole url before changing everything all at once */
|
||||||
for (const val of this.to_change) {
|
const first = this.to_change.shift();
|
||||||
updateQueryString(val.param, val.value);
|
let url = updateQueryString(first.param, first.value, History.None);
|
||||||
|
for (const value of this.to_change) {
|
||||||
|
url = updateQueryString(value.param, value.value, History.None, url);
|
||||||
}
|
}
|
||||||
|
updateQueryString(first.param, first.value, this.pushstate, url);
|
||||||
await this.fetchData(); /* reload data on form change */
|
await this.fetchData(); /* reload data on form change */
|
||||||
this.to_change = [];
|
this.to_change = [];
|
||||||
|
this.pushstate = History.Push;
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
const searchParams = ["search", "department", "credit_type", "semester"];
|
const searchParams = ["search", "department", "credit_type", "semester"];
|
||||||
@@ -63,37 +67,47 @@ document.addEventListener("alpine:init", () => {
|
|||||||
|
|
||||||
for (const param of searchParams) {
|
for (const param of searchParams) {
|
||||||
this.$watch(param, () => {
|
this.$watch(param, () => {
|
||||||
|
if (this.pushstate !== History.Push) {
|
||||||
|
/* This means that we are doing a mass param edit */
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* Reset pagination on search */
|
/* Reset pagination on search */
|
||||||
this.page = pageDefault;
|
this.page = pageDefault;
|
||||||
this.page_size = pageSizeDefault;
|
this.page_size = pageSizeDefault;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (const param of searchParams.concat(paginationParams)) {
|
for (const param of searchParams.concat(paginationParams)) {
|
||||||
this.$watch(param, (value: string) => {
|
this.$watch(param, (value) => {
|
||||||
this.to_change.push({ param: param, value: value });
|
this.to_change.push({ param: param, value: value });
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
window.addEventListener("popstate", () => {
|
||||||
|
this.initializeArgs();
|
||||||
|
});
|
||||||
this.initializeArgs();
|
this.initializeArgs();
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchData() {
|
async fetchData() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
const args = {
|
||||||
const res = await ueFetchUeList({
|
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||||
query: {
|
page_size: this.page_size,
|
||||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
};
|
||||||
page_size: this.page_size,
|
for (const [param, value] of new URL(
|
||||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
window.location.href,
|
||||||
credit_type: this.credit_type.length > 0 ? this.credit_type : undefined,
|
).searchParams.entries()) {
|
||||||
semester: this.semester.length > 0 ? this.semester : undefined,
|
// Deal with array type params
|
||||||
department: this.department.length > 0 ? this.department : undefined,
|
if (["credit_type", "department", "semester"].includes(param)) {
|
||||||
search: this.search || undefined,
|
if (args[param] === undefined) {
|
||||||
},
|
args[param] = [];
|
||||||
});
|
}
|
||||||
if (res.data !== undefined) {
|
args[param].push(value);
|
||||||
this.ues = res.data;
|
} else {
|
||||||
|
args[param] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.ues = (await ueFetchUeList({ query: args })).data;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -128,14 +128,14 @@ $pedagogy-white-text: #f0f0f0;
|
|||||||
grid-area: hours-the;
|
grid-area: hours-the;
|
||||||
}
|
}
|
||||||
|
|
||||||
#leave_comment_not_allowed {
|
.leave-comment-not-allowed {
|
||||||
p {
|
p {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#leave_comment {
|
.leave-comment {
|
||||||
.leave-comment-grid-container {
|
.leave-comment-grid-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 270px auto;
|
grid-template-columns: 270px auto;
|
||||||
@@ -168,10 +168,6 @@ $pedagogy-white-text: #f0f0f0;
|
|||||||
.input-stars {
|
.input-stars {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"] {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ue-details-container {
|
.ue-details-container {
|
||||||
@@ -333,8 +329,9 @@ $pedagogy-white-text: #f0f0f0;
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.actions {
|
.action {
|
||||||
float: right;
|
float: right;
|
||||||
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,4 +440,9 @@ details.accordion>.accordion-content {
|
|||||||
background-color: $white-color;
|
background-color: $white-color;
|
||||||
border-color: $pedagogy-orange;
|
border-color: $pedagogy-orange;
|
||||||
border-right: none;
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<form
|
||||||
|
hx-post="{{ request.get_full_path() }}"
|
||||||
|
hx-ext="error-callbacks"
|
||||||
|
hx-target="this"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-disabled-elt="input[type='submit']"
|
||||||
|
hx-trigger="submit"
|
||||||
|
hx-callback-404="target.remove()"
|
||||||
|
>
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.non_field_errors() }}
|
||||||
|
{{ form.reason.errors }}
|
||||||
|
{{ form.reason }}
|
||||||
|
|
||||||
|
{# Hidden fields #}
|
||||||
|
{{ form.reporter }}
|
||||||
|
{{ form.comment }}
|
||||||
|
|
||||||
|
<button
|
||||||
|
hx-get="{{ url('pedagogy:comment_detail', comment_id=comment_id) }}"
|
||||||
|
hx-target="closest form"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
>
|
||||||
|
{% trans %}Cancel{% endtrans %}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<p class="right" id="nique">
|
||||||
|
<input type="submit" value="{% trans %}Report{% endtrans %}" />
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
{% from "pedagogy/macros.jinja" import display_star %}
|
||||||
|
{% from "core/macros.jinja" import user_profile_link %}
|
||||||
|
|
||||||
|
<div id="comment-{{ comment.id }}" class="comment-container">
|
||||||
|
|
||||||
|
<div class="grade-block">
|
||||||
|
<div class="grade-type">
|
||||||
|
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Utility{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Interest{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Work load{% endtrans %}</p>
|
||||||
|
</div>
|
||||||
|
<div class="grade-stars">
|
||||||
|
<p>{{ display_star(comment.grade_global) }}</p>
|
||||||
|
<p>{{ display_star(comment.grade_utility) }}</p>
|
||||||
|
<p>{{ display_star(comment.grade_interest) }}</p>
|
||||||
|
<p>{{ display_star(comment.grade_teaching) }}</p>
|
||||||
|
<p>{{ display_star(comment.grade_work_load) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="grade-extension"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="comment">
|
||||||
|
<div class="anchor">
|
||||||
|
<a href="{{ url('pedagogy:ue_detail', ue_id=ue.id) }}#comment-{{ comment.id }}"><i class="fa fa-paragraph"></i></a>
|
||||||
|
</div>
|
||||||
|
{{ comment.comment|markdown }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
{% if comment.is_reported %}
|
||||||
|
<p class="status-reported">
|
||||||
|
{% trans %}This comment has been reported{% endtrans %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if comment.author_id == user.id or user.has_perm("pedagogy.change_comment") %}
|
||||||
|
<button
|
||||||
|
class="btn btn-orange action"
|
||||||
|
hx-get="{{ url('pedagogy:comment_update', comment_id=comment.id) }}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-target="#comment-{{ comment.id }}"
|
||||||
|
>
|
||||||
|
<i class="fa fa-pencil"></i> {% trans %}Edit{% endtrans %}
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if comment.author_id == user.id or user.has_perm("pedagogy.delete_comment") %}
|
||||||
|
<form class="action"
|
||||||
|
hx-ext="error-callbacks"
|
||||||
|
hx-post="{{ url('pedagogy:comment_delete', comment_id=comment.id) }}"
|
||||||
|
hx-confirm='{% trans obj=object %}Are you sure you want to delete "{{ obj }}"?{% endtrans %}'
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-target="#comment-{{ comment.id }}"
|
||||||
|
hx-callback-404="document.getElementsByTagName('body')[0].dispatchEvent(new CustomEvent('CommentUpdate'));target.remove()"
|
||||||
|
>
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="btn btn-red action">
|
||||||
|
<i class="fa fa-trash-can"></i> {% trans %}Delete{% endtrans %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="comment-end-bar">
|
||||||
|
<div class="report">
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
hx-get="{{ url('pedagogy:comment_report', comment_id=comment.id) }}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-target="#comment-{{ comment.id }}"
|
||||||
|
>
|
||||||
|
{% trans %}Report this comment{% endtrans %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="date"><p>{{ comment.publish_date.strftime('%d/%m/%Y') }}</p></div>
|
||||||
|
|
||||||
|
<div class="author"><p>{{ user_profile_link(comment.author) }}</p></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<div class="leave-comment">
|
||||||
|
{% if form.is_creation %}
|
||||||
|
<details class="accordion" id="leave_comment" {% if form.errors %}open{% endif %}>
|
||||||
|
<summary>{% trans %}Leave comment{% endtrans %}</summary>
|
||||||
|
<div class="accordion-content">
|
||||||
|
{% endif %}
|
||||||
|
<form
|
||||||
|
hx-post="{{ action }}"
|
||||||
|
hx-target="closest .leave-comment"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-disabled-elt="find input[type='submit']"
|
||||||
|
>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="leave-comment-grid-container">
|
||||||
|
<div class="form-stars">
|
||||||
|
{{ form.non_field_errors() }}
|
||||||
|
{{ form.author.errors }}
|
||||||
|
{{ form.ue.errors }}
|
||||||
|
|
||||||
|
{{ form.author }}
|
||||||
|
{{ form.ue }}
|
||||||
|
|
||||||
|
<div class="input-stars">
|
||||||
|
<label for="{{ form.grade_global.id_for_label }}">{{ form.grade_global.label }} :</label>
|
||||||
|
{{ form.grade_global.errors }}
|
||||||
|
{{ form.grade_global }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-stars">
|
||||||
|
<label for="{{ form.grade_utility.id_for_label }}">{{ form.grade_utility.label }} :</label>
|
||||||
|
{{ form.grade_utility.errors }}
|
||||||
|
{{ form.grade_utility }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-stars">
|
||||||
|
<label for="{{ form.grade_interest.id_for_label }}">{{ form.grade_interest.label }} :</label>
|
||||||
|
{{ form.grade_interest.errors }}
|
||||||
|
{{ form.grade_interest }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-stars">
|
||||||
|
<label for="{{ form.grade_teaching.id_for_label }}">{{ form.grade_teaching.label }} :</label>
|
||||||
|
{{ form.grade_teaching.errors }}
|
||||||
|
{{ form.grade_teaching }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-stars">
|
||||||
|
<label for="{{ form.grade_work_load.id_for_label }}">{{ form.grade_work_load.label }} :</label>
|
||||||
|
{{ form.grade_work_load.errors }}
|
||||||
|
{{ form.grade_work_load }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-comment">
|
||||||
|
<label for="{{ form.comment.id_for_label }}">{{ form.comment.label }} :</label>
|
||||||
|
{{ form.comment.errors }}
|
||||||
|
{{ form.comment }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="right">
|
||||||
|
<input type="submit" value="{% trans %}Comment{% endtrans %}" />
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if form.is_creation %}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{% if comments %}
|
||||||
|
<h2>{% trans %}Comments{% endtrans %}</h2>
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<section>
|
||||||
|
{% for comment in comments %}
|
||||||
|
{% include "pedagogy/fragments/ue_comment.jinja" %}
|
||||||
|
{% endfor %}
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{% if object.has_user_already_commented(user) %}
|
||||||
|
<div class="leave-comment-not-allowed">
|
||||||
|
<p>{% trans %}You already posted a comment on this UE. If you want to comment again, please modify or delete your previous comment.{% endtrans %}</p>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not object.has_user_already_commented(user) and user.has_perm("pedagogy.add_uecomment") %}
|
||||||
|
{{ add_comment_form }}
|
||||||
|
{% endif %}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<div class="ue-details-container">
|
||||||
|
<div class="grade">
|
||||||
|
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Utility{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Interest{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||||
|
<p>{% trans %}Work load{% endtrans %}</p>
|
||||||
|
</div>
|
||||||
|
<div class="grade-stars">
|
||||||
|
<p>{{ display_star(object.grade_global_average) }}</p>
|
||||||
|
<p>{{ display_star(object.grade_utility_average) }}</p>
|
||||||
|
<p>{{ display_star(object.grade_interest_average) }}</p>
|
||||||
|
<p>{{ display_star(object.grade_teaching_average) }}</p>
|
||||||
|
<p>{{ display_star(object.grade_work_load_average) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="ue-infos">
|
||||||
|
<p><b>{% trans %}Objectives{% endtrans %}</b></p>
|
||||||
|
<p>{{ object.objectives|markdown }}</p>
|
||||||
|
<p><b>{% trans %}Program{% endtrans %}</b></p>
|
||||||
|
<p>{{ object.program|markdown }}</p>
|
||||||
|
<p><b>{% trans %}Earned skills{% endtrans %}</b></p>
|
||||||
|
<p>{{ object.skills|markdown }}</p>
|
||||||
|
<p><b>{% trans %}Key concepts{% endtrans %}</b></p>
|
||||||
|
<p>{{ object.key_concepts|markdown }}</p>
|
||||||
|
<p><b>{% trans %}UE manager: {% endtrans %}</b>{{ object.manager }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -13,4 +13,4 @@
|
|||||||
<span class="grade-text"> {% trans %} not rated {% endtrans %} </span>
|
<span class="grade-text"> {% trans %} not rated {% endtrans %} </span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|||||||
@@ -1,220 +1,93 @@
|
|||||||
{% extends "core/base.jinja" %}
|
|
||||||
{% from "core/macros.jinja" import user_profile_link %}
|
|
||||||
{% from "pedagogy/macros.jinja" import display_star %}
|
{% from "pedagogy/macros.jinja" import display_star %}
|
||||||
|
|
||||||
{% block additional_css %}
|
{% if is_fragment %}
|
||||||
<link rel="stylesheet" href="{{ static('pedagogy/css/pedagogy.scss') }}">
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block title %}
|
<hx-partial id="ue-grade">
|
||||||
{% trans %}UE Details{% endtrans %}
|
{% include "pedagogy/fragments/ue_details/grade.jinja" %}
|
||||||
{% endblock %}
|
</hx-partial>
|
||||||
|
|
||||||
{% block content %}
|
<hx-partial id="comment-form">
|
||||||
<div class="pedagogy">
|
{% include "pedagogy/fragments/ue_details/form.jinja" %}
|
||||||
<div id="ue_detail">
|
</hx-partial>
|
||||||
<button onclick='(function(){
|
|
||||||
// If comes from the guide page, go back with history
|
|
||||||
if (document.referrer.replace(/\?(.+)/gm,"").endsWith(`{{ url("pedagogy:guide") }}`)){
|
|
||||||
window.history.back();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Simply goes to the guide page
|
|
||||||
window.location.href = `{{ url("pedagogy:guide") }}`;
|
|
||||||
})()' hidden>{% trans %}Back{% endtrans %}</button>
|
|
||||||
|
|
||||||
<h1>{{ object.code }} - {{ object.title }}</h1>
|
<hx-partial id="comments" hx-swap="innerMorph">
|
||||||
<br>
|
{% include "pedagogy/fragments/ue_details/comments.jinja" %}
|
||||||
<div class="ue-quick-info-container">
|
</hx-partial>
|
||||||
<div class="hours-cm">
|
|
||||||
<b>{% trans %}CM: {% endtrans %}</b>{{ object.hours_CM }}
|
|
||||||
</div>
|
|
||||||
<div class="hours-td">
|
|
||||||
<b>{% trans %}TD: {% endtrans %}</b>{{ object.hours_TD }}
|
|
||||||
</div>
|
|
||||||
<div class="hours-tp">
|
|
||||||
<b>{% trans %}TP: {% endtrans %}</b>{{ object.hours_TP }}
|
|
||||||
</div>
|
|
||||||
<div class="hours-te">
|
|
||||||
<b>{% trans %}TE: {% endtrans %}</b>{{ object.hours_TE }}
|
|
||||||
</div>
|
|
||||||
<div class="hours-the">
|
|
||||||
<b>{% trans %}THE: {% endtrans %}</b>{{ object.hours_THE }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="department">
|
{% else %}
|
||||||
{{ object.department }}
|
{% extends "core/base.jinja" %}
|
||||||
</div>
|
|
||||||
<div class="credit-type">
|
|
||||||
{{ object.credit_type }}
|
|
||||||
</div>
|
|
||||||
<div class="semester">
|
|
||||||
{{ object.get_semester_display() }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
{% block additional_css %}
|
||||||
|
<link rel="stylesheet" href="{{ static('pedagogy/css/pedagogy.scss') }}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
<div class="ue-details-container">
|
{% block title %}
|
||||||
<div class="grade">
|
{% trans %}UE Details{% endtrans %}
|
||||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
{% endblock %}
|
||||||
<p>{% trans %}Utility{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Interest{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Work load{% endtrans %}</p>
|
|
||||||
</div>
|
|
||||||
<div class="grade-stars">
|
|
||||||
<p>{{ display_star(object.grade_global_average) }}</p>
|
|
||||||
<p>{{ display_star(object.grade_utility_average) }}</p>
|
|
||||||
<p>{{ display_star(object.grade_interest_average) }}</p>
|
|
||||||
<p>{{ display_star(object.grade_teaching_average) }}</p>
|
|
||||||
<p>{{ display_star(object.grade_work_load_average) }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="ue-infos">
|
|
||||||
<p><b>{% trans %}Objectives{% endtrans %}</b></p>
|
|
||||||
<p>{{ object.objectives|markdown }}</p>
|
|
||||||
<p><b>{% trans %}Program{% endtrans %}</b></p>
|
|
||||||
<p>{{ object.program|markdown }}</p>
|
|
||||||
<p><b>{% trans %}Earned skills{% endtrans %}</b></p>
|
|
||||||
<p>{{ object.skills|markdown }}</p>
|
|
||||||
<p><b>{% trans %}Key concepts{% endtrans %}</b></p>
|
|
||||||
<p>{{ object.key_concepts|markdown }}</p>
|
|
||||||
<p><b>{% trans %}UE manager: {% endtrans %}</b>{{ object.manager }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
{% block content %}
|
||||||
{% if object.has_user_already_commented(user) %}
|
|
||||||
<div id="leave_comment_not_allowed">
|
|
||||||
<p>{% trans %}You already posted a comment on this UE. If you want to comment again, please modify or delete your previous comment.{% endtrans %}</p>
|
|
||||||
</div>
|
|
||||||
{% elif user.has_perm("pedagogy.add_uecomment") %}
|
|
||||||
<details class="accordion" id="leave_comment" {% if form.errors %}open{%endif%}>
|
|
||||||
<summary>{% trans %}Leave comment{% endtrans %}</summary>
|
|
||||||
<div class="accordion-content">
|
|
||||||
<form action="{{ url('pedagogy:ue_detail', ue_id=object.id) }}" method="post" enctype="multipart/form-data">
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="leave-comment-grid-container">
|
|
||||||
<div class="form-stars">
|
|
||||||
{{ form.non_field_errors() }}
|
|
||||||
{{ form.author.errors }}
|
|
||||||
{{ form.ue.errors }}
|
|
||||||
|
|
||||||
{{ form.author }}
|
<div class="pedagogy">
|
||||||
{{ form.ue }}
|
<div id="ue_detail">
|
||||||
|
<button onclick='(function(){
|
||||||
|
// If comes from the guide page, go back with history
|
||||||
|
if (document.referrer.replace(/\?(.+)/gm,"").endsWith(`{{ url("pedagogy:guide") }}`)){
|
||||||
|
window.history.back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Simply goes to the guide page
|
||||||
|
window.location.href = `{{ url("pedagogy:guide") }}`;
|
||||||
|
})()' hidden>{% trans %}Back{% endtrans %}</button>
|
||||||
|
|
||||||
<div class="input-stars">
|
<h1>{{ object.code }} - {{ object.title }}</h1>
|
||||||
<label for="{{ form.grade_global.id_for_label }}">{{ form.grade_global.label }} :</label>
|
<br>
|
||||||
{{ form.grade_global.errors }}
|
<div class="ue-quick-info-container">
|
||||||
{{ form.grade_global }}
|
<div class="hours-cm">
|
||||||
</div>
|
<b>{% trans %}CM: {% endtrans %}</b>{{ object.hours_CM }}
|
||||||
|
|
||||||
<div class="input-stars">
|
|
||||||
<label for="{{ form.grade_utility.id_for_label }}">{{ form.grade_utility.label }} :</label>
|
|
||||||
{{ form.grade_utility.errors }}
|
|
||||||
{{ form.grade_utility }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-stars">
|
|
||||||
<label for="{{ form.grade_interest.id_for_label }}">{{ form.grade_interest.label }} :</label>
|
|
||||||
{{ form.grade_interest.errors }}
|
|
||||||
{{ form.grade_interest }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-stars">
|
|
||||||
<label for="{{ form.grade_teaching.id_for_label }}">{{ form.grade_teaching.label }} :</label>
|
|
||||||
{{ form.grade_teaching.errors }}
|
|
||||||
{{ form.grade_teaching }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-stars">
|
|
||||||
<label for="{{ form.grade_work_load.id_for_label }}">{{ form.grade_work_load.label }} :</label>
|
|
||||||
{{ form.grade_work_load.errors }}
|
|
||||||
{{ form.grade_work_load }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-comment">
|
|
||||||
<label for="{{ form.comment.id_for_label }}">{{ form.comment.label }} :</label>
|
|
||||||
{{ form.comment.errors }}
|
|
||||||
{{ form.comment }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p><input type="submit" value="{% trans %}Comment{% endtrans %}" /></p>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</details>
|
<div class="hours-td">
|
||||||
{% endif %}
|
<b>{% trans %}TD: {% endtrans %}</b>{{ object.hours_TD }}
|
||||||
<br>
|
</div>
|
||||||
|
<div class="hours-tp">
|
||||||
{% if comments %}
|
<b>{% trans %}TP: {% endtrans %}</b>{{ object.hours_TP }}
|
||||||
<h2>{% trans %}Comments{% endtrans %}</h2>
|
</div>
|
||||||
{% for comment in comments %}
|
<div class="hours-te">
|
||||||
<div id="{{ comment.id }}" class="comment-container">
|
<b>{% trans %}TE: {% endtrans %}</b>{{ object.hours_TE }}
|
||||||
|
</div>
|
||||||
<div class="grade-block">
|
<div class="hours-the">
|
||||||
<div class="grade-type">
|
<b>{% trans %}THE: {% endtrans %}</b>{{ object.hours_THE }}
|
||||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Utility{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Interest{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
|
||||||
<p>{% trans %}Work load{% endtrans %}</p>
|
|
||||||
</div>
|
|
||||||
<div class="grade-stars">
|
|
||||||
<p>{{ display_star(comment.grade_global) }}</p>
|
|
||||||
<p>{{ display_star(comment.grade_utility) }}</p>
|
|
||||||
<p>{{ display_star(comment.grade_interest) }}</p>
|
|
||||||
<p>{{ display_star(comment.grade_teaching) }}</p>
|
|
||||||
<p>{{ display_star(comment.grade_work_load) }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="grade-extension"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="comment">
|
|
||||||
<div class="anchor">
|
|
||||||
<a href="{{ url('pedagogy:ue_detail', ue_id=ue.id) }}#{{ comment.id }}"><i class="fa fa-paragraph"></i></a>
|
|
||||||
</div>
|
|
||||||
{{ comment.comment|markdown }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="info">
|
|
||||||
{% if comment.is_reported %}
|
|
||||||
<p class="status-reported">
|
|
||||||
{% trans %}This comment has been reported{% endtrans %}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if comment.author_id == user.id or user.has_perm("pedagogy.change_comment") %}
|
|
||||||
<p class="actions">
|
|
||||||
<a href="{{ url('pedagogy:comment_update', comment_id=comment.id) }}">
|
|
||||||
{% trans %}Edit{% endtrans %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if comment.author_id == user.id or user.has_perm("pedagogy.delete_comment") %}
|
|
||||||
<a href="{{ url('pedagogy:comment_delete', comment_id=comment.id) }}">
|
|
||||||
{% trans %}Delete{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="comment-end-bar">
|
|
||||||
<div class="report">
|
|
||||||
<p>
|
|
||||||
<a href="{{ url('pedagogy:comment_report', comment_id=comment.id) }}">
|
|
||||||
{% trans %}Report this comment{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="date"><p>{{ comment.publish_date.strftime('%d/%m/%Y') }}</p></div>
|
|
||||||
|
|
||||||
<div class="author"><p>{{ user_profile_link(comment.author) }}</p></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
<div class="department">
|
||||||
|
{{ object.department }}
|
||||||
|
</div>
|
||||||
|
<div class="credit-type">
|
||||||
|
{{ object.credit_type }}
|
||||||
|
</div>
|
||||||
|
<div class="semester">
|
||||||
|
{{ object.get_semester_display() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div id="ue-grade">
|
||||||
|
{% include "pedagogy/fragments/ue_details/grade.jinja" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div id="comment-form">
|
||||||
|
{% include "pedagogy/fragments/ue_details/form.jinja" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="comments">
|
||||||
|
{% for comment in comments %}
|
||||||
|
{% include "pedagogy/fragments/ue_comment.jinja" %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endif %}
|
||||||
|
|||||||
+14
-2
@@ -24,12 +24,14 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from pedagogy.views import (
|
from pedagogy.views import (
|
||||||
|
UECommentCreateView,
|
||||||
UECommentDeleteView,
|
UECommentDeleteView,
|
||||||
|
UECommentDetailView,
|
||||||
UECommentReportCreateView,
|
UECommentReportCreateView,
|
||||||
UECommentUpdateView,
|
UECommentUpdateView,
|
||||||
UECreateView,
|
UECreateView,
|
||||||
UEDeleteView,
|
UEDeleteView,
|
||||||
UEDetailFormView,
|
UEDetailView,
|
||||||
UEGuideView,
|
UEGuideView,
|
||||||
UEModerationFormView,
|
UEModerationFormView,
|
||||||
UEUpdateView,
|
UEUpdateView,
|
||||||
@@ -38,7 +40,17 @@ from pedagogy.views import (
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Urls displaying the actual application for visitors
|
# Urls displaying the actual application for visitors
|
||||||
path("", UEGuideView.as_view(), name="guide"),
|
path("", UEGuideView.as_view(), name="guide"),
|
||||||
path("ue/<int:ue_id>/", UEDetailFormView.as_view(), name="ue_detail"),
|
path("ue/<int:ue_id>/", UEDetailView.as_view(), name="ue_detail"),
|
||||||
|
path(
|
||||||
|
"ue/<int:ue_id>/comment",
|
||||||
|
UECommentCreateView.as_view(),
|
||||||
|
name="comment_create",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"comment/<int:comment_id>/",
|
||||||
|
UECommentDetailView.as_view(),
|
||||||
|
name="comment_detail",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"comment/<int:comment_id>/edit/",
|
"comment/<int:comment_id>/edit/",
|
||||||
UECommentUpdateView.as_view(),
|
UECommentUpdateView.as_view(),
|
||||||
|
|||||||
+89
-35
@@ -16,7 +16,7 @@
|
|||||||
# details.
|
# details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along with
|
# You should have received a copy of the GNU General Public License along with
|
||||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -29,6 +29,7 @@ from django.urls import reverse, reverse_lazy
|
|||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
|
DetailView,
|
||||||
FormView,
|
FormView,
|
||||||
TemplateView,
|
TemplateView,
|
||||||
UpdateView,
|
UpdateView,
|
||||||
@@ -36,7 +37,7 @@ from django.views.generic import (
|
|||||||
|
|
||||||
from core.auth.mixins import PermissionOrAuthorRequiredMixin
|
from core.auth.mixins import PermissionOrAuthorRequiredMixin
|
||||||
from core.models import Notification, User
|
from core.models import Notification, User
|
||||||
from core.views import DetailFormView
|
from core.views.mixins import AllowFragment, FragmentMixin, UseFragmentsMixin
|
||||||
from pedagogy.forms import (
|
from pedagogy.forms import (
|
||||||
UECommentForm,
|
UECommentForm,
|
||||||
UECommentModerationForm,
|
UECommentModerationForm,
|
||||||
@@ -46,37 +47,59 @@ from pedagogy.forms import (
|
|||||||
from pedagogy.models import UE, UEComment, UECommentReport
|
from pedagogy.models import UE, UEComment, UECommentReport
|
||||||
|
|
||||||
|
|
||||||
class UEDetailFormView(PermissionRequiredMixin, DetailFormView):
|
class UECommentCreateView(PermissionRequiredMixin, FragmentMixin, CreateView):
|
||||||
"""Display every comment of an UE and detailed infos about it.
|
model = UEComment
|
||||||
|
template_name = "pedagogy/fragments/ue_comment_form.jinja"
|
||||||
Allow to comment the UE.
|
|
||||||
"""
|
|
||||||
|
|
||||||
model = UE
|
|
||||||
pk_url_kwarg = "ue_id"
|
|
||||||
template_name = "pedagogy/ue_detail.jinja"
|
|
||||||
form_class = UECommentForm
|
form_class = UECommentForm
|
||||||
permission_required = "pedagogy.view_ue"
|
permission_required = "pedagogy.add_uecomment"
|
||||||
|
object = None # Avoid initialisation bug with FragmentMixin
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ue(self):
|
||||||
|
if hasattr(self, "_ue"):
|
||||||
|
return self._ue
|
||||||
|
self._ue = get_object_or_404(UE, id=self.kwargs.get("ue_id"))
|
||||||
|
return self._ue
|
||||||
|
|
||||||
def has_permission(self):
|
def has_permission(self):
|
||||||
if self.request.method == "POST" and not self.request.user.has_perm(
|
if self.ue.has_user_already_commented(self.request.user):
|
||||||
"pedagogy.add_uecomment"
|
|
||||||
):
|
|
||||||
# if it's a POST request, the user is trying to add a new UEComment
|
|
||||||
# thus he also needs the "add_uecomment" permission
|
|
||||||
return False
|
return False
|
||||||
return super().has_permission()
|
return super().has_permission()
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
kwargs["author_id"] = self.request.user.id
|
kwargs["author_id"] = self.request.user.id
|
||||||
kwargs["ue_id"] = self.object.id
|
kwargs["ue_id"] = self.ue.id
|
||||||
kwargs["is_creation"] = True
|
kwargs["is_creation"] = True
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def form_valid(self, form):
|
def get_context_data(self, **kwargs):
|
||||||
form.save()
|
return super().get_context_data(**kwargs) | {
|
||||||
return super().form_valid(form)
|
"action": reverse("pedagogy:comment_create", kwargs={"ue_id": self.ue.id}),
|
||||||
|
"object": self.ue,
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse("pedagogy:ue_detail", kwargs={"ue_id": self.ue.id})
|
||||||
|
|
||||||
|
|
||||||
|
class UEDetailView(
|
||||||
|
PermissionRequiredMixin, UseFragmentsMixin, AllowFragment, DetailView
|
||||||
|
):
|
||||||
|
"""Display every comment of an UE and detailed infos about it."""
|
||||||
|
|
||||||
|
model = UE
|
||||||
|
pk_url_kwarg = "ue_id"
|
||||||
|
template_name = "pedagogy/ue_detail.jinja"
|
||||||
|
permission_required = "pedagogy.view_ue"
|
||||||
|
fragments = {
|
||||||
|
"add_comment_form": UECommentCreateView,
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_fragment_data(self):
|
||||||
|
return {
|
||||||
|
"add_comment_form": {"ue_id": self.object.id},
|
||||||
|
}
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
return super().get_context_data(**kwargs) | {
|
return super().get_context_data(**kwargs) | {
|
||||||
@@ -85,22 +108,35 @@ class UEDetailFormView(PermissionRequiredMixin, DetailFormView):
|
|||||||
.annotate_is_reported()
|
.annotate_is_reported()
|
||||||
.select_related("author")
|
.select_related("author")
|
||||||
.order_by("-publish_date")
|
.order_by("-publish_date")
|
||||||
)
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
# once the new ue comment has been saved
|
class UECommentDetailView(PermissionRequiredMixin, DetailView):
|
||||||
# redirect to the same page we are currently
|
model = UEComment
|
||||||
return self.request.path
|
pk_url_kwarg = "comment_id"
|
||||||
|
template_name = "pedagogy/fragments/ue_comment.jinja"
|
||||||
|
permission_required = "pedagogy.view_ue"
|
||||||
|
context_object_name = "comment"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return (
|
||||||
|
super().get_queryset().viewable_by(self.request.user).annotate_is_reported()
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
return super().get_context_data(**kwargs) | {
|
||||||
|
"ue": getattr(self.object, "ue", None)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class UECommentUpdateView(PermissionOrAuthorRequiredMixin, UpdateView):
|
class UECommentUpdateView(PermissionOrAuthorRequiredMixin, AllowFragment, UpdateView):
|
||||||
"""Allow edit of a given comment."""
|
"""Allow edit of a given comment."""
|
||||||
|
|
||||||
model = UEComment
|
model = UEComment
|
||||||
form_class = UECommentForm
|
form_class = UECommentForm
|
||||||
pk_url_kwarg = "comment_id"
|
pk_url_kwarg = "comment_id"
|
||||||
template_name = "core/edit.jinja"
|
template_name = "pedagogy/fragments/ue_comment_form.jinja"
|
||||||
permission_required = "pedagogy.change_uecomment"
|
permission_required = "pedagogy.change_uecomment"
|
||||||
author_field = "author"
|
author_field = "author"
|
||||||
|
|
||||||
@@ -111,11 +147,18 @@ class UECommentUpdateView(PermissionOrAuthorRequiredMixin, UpdateView):
|
|||||||
kwargs["is_creation"] = False
|
kwargs["is_creation"] = False
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
return super().get_context_data(**kwargs) | {
|
||||||
|
"action": reverse(
|
||||||
|
"pedagogy:comment_update", kwargs={"comment_id": self.object.id}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("pedagogy:ue_detail", kwargs={"ue_id": self.object.ue_id})
|
return reverse("pedagogy:comment_detail", kwargs={"comment_id": self.object.id})
|
||||||
|
|
||||||
|
|
||||||
class UECommentDeleteView(PermissionOrAuthorRequiredMixin, DeleteView):
|
class UECommentDeleteView(PermissionOrAuthorRequiredMixin, AllowFragment, DeleteView):
|
||||||
"""Allow to delete a given comment."""
|
"""Allow to delete a given comment."""
|
||||||
|
|
||||||
model = UEComment
|
model = UEComment
|
||||||
@@ -124,8 +167,13 @@ class UECommentDeleteView(PermissionOrAuthorRequiredMixin, DeleteView):
|
|||||||
permission_required = "pedagogy.delete_uecomment"
|
permission_required = "pedagogy.delete_uecomment"
|
||||||
author_field = "author"
|
author_field = "author"
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
response = super().form_valid(form)
|
||||||
|
response.headers["HX-Trigger"] = "CommentUpdate"
|
||||||
|
return response
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("pedagogy:ue_detail", kwargs={"ue_id": self.object.ue_id})
|
return reverse("pedagogy:comment_detail", kwargs={"comment_id": self.object.id})
|
||||||
|
|
||||||
|
|
||||||
class UEGuideView(PermissionRequiredMixin, TemplateView):
|
class UEGuideView(PermissionRequiredMixin, TemplateView):
|
||||||
@@ -135,12 +183,12 @@ class UEGuideView(PermissionRequiredMixin, TemplateView):
|
|||||||
permission_required = "pedagogy.view_ue"
|
permission_required = "pedagogy.view_ue"
|
||||||
|
|
||||||
|
|
||||||
class UECommentReportCreateView(PermissionRequiredMixin, CreateView):
|
class UECommentReportCreateView(PermissionRequiredMixin, AllowFragment, CreateView):
|
||||||
"""Create a new report for an inappropriate comment."""
|
"""Create a new report for an inappropriate comment."""
|
||||||
|
|
||||||
model = UECommentReport
|
model = UECommentReport
|
||||||
form_class = UECommentReportForm
|
form_class = UECommentReportForm
|
||||||
template_name = "core/edit.jinja"
|
template_name = "pedagogy/fragments/comment_report.jinja"
|
||||||
permission_required = "pedagogy.add_uecommentreport"
|
permission_required = "pedagogy.add_uecommentreport"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@@ -153,6 +201,11 @@ class UECommentReportCreateView(PermissionRequiredMixin, CreateView):
|
|||||||
kwargs["comment_id"] = self.ue_comment.id
|
kwargs["comment_id"] = self.ue_comment.id
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
return super().get_context_data() | {
|
||||||
|
"comment_id": self.ue_comment.id,
|
||||||
|
}
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
resp = super().form_valid(form)
|
resp = super().form_valid(form)
|
||||||
# Send a message to moderation admins
|
# Send a message to moderation admins
|
||||||
@@ -168,11 +221,12 @@ class UECommentReportCreateView(PermissionRequiredMixin, CreateView):
|
|||||||
url=reverse("pedagogy:moderation"),
|
url=reverse("pedagogy:moderation"),
|
||||||
type="PEDAGOGY_MODERATION",
|
type="PEDAGOGY_MODERATION",
|
||||||
)
|
)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("pedagogy:ue_detail", kwargs={"ue_id": self.ue_comment.ue_id})
|
return reverse(
|
||||||
|
"pedagogy:comment_detail", kwargs={"comment_id": self.ue_comment.id}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UEModerationFormView(PermissionRequiredMixin, FormView):
|
class UEModerationFormView(PermissionRequiredMixin, FormView):
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
# Generated by Django 5.2.17 on 2026-09-01 08:44
|
|
||||||
|
|
||||||
import django.utils.timezone
|
|
||||||
from django.db import migrations, models
|
|
||||||
from django.db.migrations.state import StateApps
|
|
||||||
from django.db.models import F, Value
|
|
||||||
from django.db.models.functions import Least
|
|
||||||
from django.utils.timezone import now
|
|
||||||
|
|
||||||
|
|
||||||
def make_default_creation_date(apps: StateApps, schema_editor):
|
|
||||||
Subscription = apps.get_model("subscription", "Subscription")
|
|
||||||
Subscription.objects.update(
|
|
||||||
created_at=Least(
|
|
||||||
F("subscription_start"), Value(now()), output_field=models.DateTimeField()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [("subscription", "0016_alter_subscription_subscription_type")]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="subscription",
|
|
||||||
name="created_at",
|
|
||||||
field=models.DateTimeField(
|
|
||||||
auto_now_add=True,
|
|
||||||
default=django.utils.timezone.now,
|
|
||||||
help_text=(
|
|
||||||
"When this subscription was created. "
|
|
||||||
"This date may differ from the start of the subscription."
|
|
||||||
),
|
|
||||||
verbose_name="created_at",
|
|
||||||
),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.RunPython(
|
|
||||||
make_default_creation_date,
|
|
||||||
reverse_code=migrations.RunPython.noop,
|
|
||||||
elidable=True,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -64,14 +64,6 @@ class Subscription(models.Model):
|
|||||||
max_length=20,
|
max_length=20,
|
||||||
verbose_name=_("location"),
|
verbose_name=_("location"),
|
||||||
)
|
)
|
||||||
created_at = models.DateTimeField(
|
|
||||||
_("created_at"),
|
|
||||||
help_text=_(
|
|
||||||
"When this subscription was created. "
|
|
||||||
"This date may differ from the start of the subscription."
|
|
||||||
),
|
|
||||||
auto_now_add=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["subscription_start"]
|
ordering = ["subscription_start"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import html2canvas from "html2canvas";
|
import html2canvas from "html2canvas";
|
||||||
|
|
||||||
// see https://regex101.com/r/QHSaPM/3
|
// see https://regex101.com/r/QHSaPM/2
|
||||||
const TIMETABLE_ROW_RE: RegExp =
|
const TIMETABLE_ROW_RE: RegExp =
|
||||||
/^(?<ueCode>\w.+\w)\s+(?<courseType>[A-Z]{2}\d)\s+((?<weekGroup>[AB])\s+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\s+(?<startHour>\d{2}:\d{2})\s+(?<endHour>\d{2}:\d{2})\s+[\dA-B]\s+((?<attendance>[\wé]*)\s+)?(?<room>\w+(?:, \w+)*)$/;
|
/^(?<ueCode>\w.+\w)\s+(?<courseType>[A-Z]{2}\d)\s+((?<weekGroup>[AB])\s+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\s+(?<startHour>\d{2}:\d{2})\s+(?<endHour>\d{2}:\d{2})\s+[\dA-B]\s+((?<attendance>[\wé]*)\s+)?(?<room>\w+(?:, \w+)?)$/;
|
||||||
|
|
||||||
const DEFAULT_TIMETABLE: string = `DS52\t\tCM1\t\tlundi\t08:00\t10:00\t1\tPrésentiel\tA113
|
const DEFAULT_TIMETABLE: string = `DS52\t\tCM1\t\tlundi\t08:00\t10:00\t1\tPrésentiel\tA113
|
||||||
DS53\t\tCM1\t\tlundi\t10:15\t12:15\t1\tPrésentiel\tA101
|
DS53\t\tCM1\t\tlundi\t10:15\t12:15\t1\tPrésentiel\tA101
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
# Create your views here.
|
# Create your views here.
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
from core.auth.mixins import FormerSubscriberMixin
|
||||||
|
|
||||||
class GeneratorView(TemplateView):
|
|
||||||
|
class GeneratorView(FormerSubscriberMixin, TemplateView):
|
||||||
template_name = "timetable/generator.jinja"
|
template_name = "timetable/generator.jinja"
|
||||||
|
|||||||
Reference in New Issue
Block a user