mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Merge branch 'pedagogy_v2' into 'master'
New version of the pedagogy See merge request ae/Sith!212
This commit is contained in:
commit
a2b431b1ab
@ -52,6 +52,7 @@ from counter.models import Customer, ProductType, Product, Counter, Selling, Stu
|
|||||||
from com.models import Sith, Weekmail, News, NewsDate
|
from com.models import Sith, Weekmail, News, NewsDate
|
||||||
from election.models import Election, Role, Candidature, ElectionList
|
from election.models import Election, Role, Candidature, ElectionList
|
||||||
from forum.models import Forum, ForumTopic
|
from forum.models import Forum, ForumTopic
|
||||||
|
from pedagogy.models import UV
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@ -84,6 +85,7 @@ class Command(BaseCommand):
|
|||||||
Group(name="Banned to subscribe").save()
|
Group(name="Banned to subscribe").save()
|
||||||
Group(name="SAS admin").save()
|
Group(name="SAS admin").save()
|
||||||
Group(name="Forum admin").save()
|
Group(name="Forum admin").save()
|
||||||
|
Group(name="Pedagogy admin").save()
|
||||||
self.reset_index("core", "auth")
|
self.reset_index("core", "auth")
|
||||||
root = User(
|
root = User(
|
||||||
id=0,
|
id=0,
|
||||||
@ -857,6 +859,18 @@ Welcome to the wiki page!
|
|||||||
start_date=timezone.now(),
|
start_date=timezone.now(),
|
||||||
role=settings.SITH_CLUB_ROLES_ID["Board member"],
|
role=settings.SITH_CLUB_ROLES_ID["Board member"],
|
||||||
).save()
|
).save()
|
||||||
|
# Adding user tutu
|
||||||
|
tutu = User(
|
||||||
|
username="tutu",
|
||||||
|
last_name="Tu",
|
||||||
|
first_name="Tu",
|
||||||
|
email="tutu@git.an",
|
||||||
|
date_of_birth="1942-06-12",
|
||||||
|
)
|
||||||
|
tutu.set_password("plop")
|
||||||
|
tutu.save()
|
||||||
|
tutu.groups = [settings.SITH_GROUP_PEDAGOGY_ADMIN_ID]
|
||||||
|
tutu.save()
|
||||||
|
|
||||||
# Adding subscription for sli
|
# Adding subscription for sli
|
||||||
s = Subscription(
|
s = Subscription(
|
||||||
@ -895,6 +909,18 @@ Welcome to the wiki page!
|
|||||||
start=s.subscription_start,
|
start=s.subscription_start,
|
||||||
)
|
)
|
||||||
s.save()
|
s.save()
|
||||||
|
# Tutu
|
||||||
|
s = Subscription(
|
||||||
|
member=tutu,
|
||||||
|
subscription_type=default_subscription,
|
||||||
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0],
|
||||||
|
)
|
||||||
|
s.subscription_start = s.compute_start()
|
||||||
|
s.subscription_end = s.compute_end(
|
||||||
|
duration=settings.SITH_SUBSCRIPTIONS[s.subscription_type]["duration"],
|
||||||
|
start=s.subscription_start,
|
||||||
|
)
|
||||||
|
s.save()
|
||||||
|
|
||||||
Selling(
|
Selling(
|
||||||
label=dcons.name,
|
label=dcons.name,
|
||||||
@ -1077,3 +1103,35 @@ Welcome to the wiki page!
|
|||||||
start_date=friday + timedelta(hours=24 * 7 * i),
|
start_date=friday + timedelta(hours=24 * 7 * i),
|
||||||
end_date=friday + timedelta(hours=24 * 7 * i + 8),
|
end_date=friday + timedelta(hours=24 * 7 * i + 8),
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
|
# Create som data for pedagogy
|
||||||
|
|
||||||
|
UV(
|
||||||
|
code="PA00",
|
||||||
|
author=User.objects.get(id=0),
|
||||||
|
credit_type=settings.SITH_PEDAGOGY_UV_TYPE[3][0],
|
||||||
|
manager="Laurent HEYBERGER",
|
||||||
|
semester=settings.SITH_PEDAGOGY_UV_SEMESTER[3][0],
|
||||||
|
language=settings.SITH_PEDAGOGY_UV_LANGUAGE[0][0],
|
||||||
|
department=settings.SITH_PROFILE_DEPARTMENTS[-2][0],
|
||||||
|
credits=5,
|
||||||
|
title="Participation dans une association étudiante",
|
||||||
|
objectives="* Permettre aux étudiants de réaliser, pendant un semestre, un projet culturel ou associatif et de le valoriser.",
|
||||||
|
program="""* Semestre précédent proposition d'un projet et d'un cahier des charges
|
||||||
|
* Evaluation par un jury de six membres
|
||||||
|
* Si accord réalisation dans le cadre de l'UV
|
||||||
|
* Compte-rendu de l'expérience
|
||||||
|
* Présentation""",
|
||||||
|
skills="""* Gérer un projet associatif ou une action éducative en autonomie:
|
||||||
|
* en produisant un cahier des charges qui -définit clairement le contexte du projet personnel -pose les jalons de ce projet -estime de manière réaliste les moyens et objectifs du projet -définit exactement les livrables attendus
|
||||||
|
* en étant capable de respecter ce cahier des charges ou, le cas échéant, de réviser le cahier des charges de manière argumentée.
|
||||||
|
* Relater son expérience dans un rapport:
|
||||||
|
* qui permettra à d'autres étudiants de poursuivre les actions engagées
|
||||||
|
* qui montre la capacité à s'auto-évaluer et à adopter une distance critique sur son action.""",
|
||||||
|
key_concepts="""* Autonomie
|
||||||
|
* Responsabilité
|
||||||
|
* Cahier des charges
|
||||||
|
* Gestion de projet""",
|
||||||
|
hours_THE=121,
|
||||||
|
hours_TE=4,
|
||||||
|
).save()
|
||||||
|
40
core/migrations/0030_auto_20190704_1500.py
Normal file
40
core/migrations/0030_auto_20190704_1500.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.20 on 2019-07-04 13:00
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [("core", "0029_auto_20180426_2013")]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="notification",
|
||||||
|
name="type",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("POSTER_MODERATION", "A new poster needs to be moderated"),
|
||||||
|
("MAILING_MODERATION", "A new mailing list needs to be moderated"),
|
||||||
|
(
|
||||||
|
"PEDAGOGY_MODERATION",
|
||||||
|
"A new pedagogy comment has been signaled for moderation",
|
||||||
|
),
|
||||||
|
("NEWS_MODERATION", "There are %s fresh news to be moderated"),
|
||||||
|
("FILE_MODERATION", "New files to be moderated"),
|
||||||
|
(
|
||||||
|
"SAS_MODERATION",
|
||||||
|
"There are %s pictures to be moderated in the SAS",
|
||||||
|
),
|
||||||
|
("NEW_PICTURES", "You've been identified on some pictures"),
|
||||||
|
("REFILLING", "You just refilled of %s €"),
|
||||||
|
("SELLING", "You just bought %s"),
|
||||||
|
("GENERIC", "You have a notification"),
|
||||||
|
],
|
||||||
|
default="GENERIC",
|
||||||
|
max_length=32,
|
||||||
|
verbose_name="type",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
@ -670,6 +670,10 @@ class AnonymousUser(AuthAnonymousUser):
|
|||||||
def was_subscribed(self):
|
def was_subscribed(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_subscribed(self):
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subscribed(self):
|
def subscribed(self):
|
||||||
return False
|
return False
|
||||||
|
@ -30,6 +30,12 @@ $shadow-color: rgb(223, 223, 223);
|
|||||||
|
|
||||||
$background-bouton-color: hsl(0, 0%, 90%);
|
$background-bouton-color: hsl(0, 0%, 90%);
|
||||||
|
|
||||||
|
/*--------------------------MEDIA QUERY HELPERS------------------------*/
|
||||||
|
$small-devices: 576px;
|
||||||
|
$medium-devices: 768px;
|
||||||
|
$large-devices: 992px;
|
||||||
|
$extra-large-devices: 1200px;
|
||||||
|
|
||||||
/*--------------------------------GENERAL------------------------------*/
|
/*--------------------------------GENERAL------------------------------*/
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@ -1564,7 +1570,6 @@ footer {
|
|||||||
form {
|
form {
|
||||||
margin: 0px auto;
|
margin: 0px auto;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
width: 60%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
@ -1668,3 +1673,445 @@ label {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------pedagogy-----------------------------------*/
|
||||||
|
|
||||||
|
$pedagogy-blue: #1bb9ea;
|
||||||
|
$pedagogy-orange: #ea7900;
|
||||||
|
$pedagogy-hover-blue: #0e97ce;
|
||||||
|
$pedagogy-light-blue: #caf0ff;
|
||||||
|
$pedagogy-white-text: #f0f0f0;
|
||||||
|
|
||||||
|
.pedagogy {
|
||||||
|
&.star-not-checked {
|
||||||
|
color : #f7f7f7;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
&.star-checked {
|
||||||
|
color: $pedagogy-orange;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
&.star-not-checked {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
&.star-checked {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#dynamic_view {
|
||||||
|
font-size: 1.1em;
|
||||||
|
|
||||||
|
table {
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
text-align: center;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#search_form {
|
||||||
|
margin: 0px;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.input-search {
|
||||||
|
background: $pedagogy-light-blue;
|
||||||
|
width: 300px;
|
||||||
|
height: 21px;
|
||||||
|
}
|
||||||
|
.button-search {
|
||||||
|
background: $pedagogy-orange;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.radio-guide input[type="radio"],input[type="checkbox"] {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
.radio-guide {
|
||||||
|
margin-top: 10px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.radio-guide label {
|
||||||
|
display:inline-block;
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
padding: 10px 20px;
|
||||||
|
font-family:Arial;
|
||||||
|
font-size:16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.radio-guide input[type="radio"]:checked + label {
|
||||||
|
background-color:$pedagogy-orange;
|
||||||
|
}
|
||||||
|
.radio-guide input[type="checkbox"]:checked + label {
|
||||||
|
background-color:$pedagogy-orange;
|
||||||
|
}
|
||||||
|
.radio-guide label:hover {
|
||||||
|
background-color: $pedagogy-hover-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#radioAUTUMN + label {
|
||||||
|
margin-left: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#uv_detail {
|
||||||
|
color: #062f38;
|
||||||
|
|
||||||
|
.uv-quick-info-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 20% 20% 20% 20% auto;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"hours-cm hours-td hours-tp hours-te hours-the"
|
||||||
|
"department credit-type semester . ." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.department {
|
||||||
|
grid-area: department;
|
||||||
|
}
|
||||||
|
|
||||||
|
.credit-type {
|
||||||
|
grid-area: credit-type;
|
||||||
|
}
|
||||||
|
|
||||||
|
.semester {
|
||||||
|
grid-area: semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hours-cm {
|
||||||
|
grid-area: hours-cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hours-td {
|
||||||
|
grid-area: hours-td;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hours-tp {
|
||||||
|
grid-area: hours-tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hours-te {
|
||||||
|
grid-area: hours-te;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hours-the {
|
||||||
|
grid-area: hours-the;
|
||||||
|
}
|
||||||
|
|
||||||
|
#leave_comment {
|
||||||
|
.leave-comment-grid-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 270px auto;
|
||||||
|
grid-template-rows: 100%;
|
||||||
|
grid-template-areas: "stars comment";
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
grid-template-columns: 100%;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"stars"
|
||||||
|
"comment";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-accordion-content {
|
||||||
|
background-color: $white-color;
|
||||||
|
border-color: $pedagogy-orange;
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-stars {
|
||||||
|
grid-area: stars;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-comment {
|
||||||
|
grid-area: comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-accordion-header {
|
||||||
|
background-color: $pedagogy-orange;
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
clip-path: polygon(0 0%, 0 100%, 30% 100%, 33% 0);
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
clip-path: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-accordion-header-icon {
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-stars {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"] {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.uv-details-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 150px 100px auto;
|
||||||
|
grid-template-rows: 156px 1fr;
|
||||||
|
grid-template-areas:
|
||||||
|
"grade grade-stars uv-infos"
|
||||||
|
". . uv-infos";
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
grid-template-columns: 50% 50%;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"grade grade-stars"
|
||||||
|
"uv-infos uv-infos";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade {
|
||||||
|
grid-area: grade;
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
padding-right: 10px;
|
||||||
|
|
||||||
|
> p {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-stars {
|
||||||
|
grid-area: grade-stars;
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uv-infos {
|
||||||
|
grid-area: uv-infos;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 300px auto;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"grade-block comment"
|
||||||
|
"grade-block info"
|
||||||
|
"comment-end-bar comment-end-bar";
|
||||||
|
margin-bottom: 30px;
|
||||||
|
margin-top: 10px;
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"grade-block"
|
||||||
|
"comment"
|
||||||
|
"info"
|
||||||
|
"comment-end-bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-block {
|
||||||
|
grid-area: grade-block;
|
||||||
|
width: 300px;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 150px 150px;
|
||||||
|
grid-template-rows: 156px auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"grade-type grade-stars"
|
||||||
|
"grade-extension grade-extension";
|
||||||
|
grid-gap: 15px;
|
||||||
|
|
||||||
|
clip-path: polygon(0 0, 0 100%, 100% 100%, 100% 30px, 270px 0);
|
||||||
|
align-items: start;
|
||||||
|
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
grid-template-columns: 50% auto;
|
||||||
|
grid-template-rows: auto;
|
||||||
|
grid-template-areas:"grade-type grade-stars";
|
||||||
|
width: auto;
|
||||||
|
clip-path: none;
|
||||||
|
align-content: space-evenly;
|
||||||
|
align-items: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-extension {
|
||||||
|
grid-area: grade-extension;
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-type {
|
||||||
|
grid-area: grade-type;
|
||||||
|
|
||||||
|
> p {
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-stars {
|
||||||
|
grid-area: grade-stars;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment {
|
||||||
|
grid-area: comment;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"anchor"
|
||||||
|
"markdown";
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
border-left: solid;
|
||||||
|
border-right: solid;
|
||||||
|
border-color: $pedagogy-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.anchor {
|
||||||
|
grid-area: anchor;
|
||||||
|
text-align: right;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown {
|
||||||
|
grid-area: markdown;
|
||||||
|
|
||||||
|
min-height: 139px;
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-right: 0px;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: justify;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
grid-area: info;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
border-left: solid;
|
||||||
|
border-right: solid;
|
||||||
|
border-color: $pedagogy-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-reported {
|
||||||
|
color: red;
|
||||||
|
float: left;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-end-bar {
|
||||||
|
grid-area: comment-end-bar;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 33% auto auto;
|
||||||
|
grid-template-rows: 2.5em;
|
||||||
|
grid-template-areas: "author date report";
|
||||||
|
|
||||||
|
background-color: $pedagogy-blue;
|
||||||
|
margin-top: -1px;
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"report"
|
||||||
|
"date"
|
||||||
|
"author";
|
||||||
|
margin-top: 0px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author {
|
||||||
|
grid-area: author;
|
||||||
|
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-left: 20px;
|
||||||
|
|
||||||
|
background-color: $pedagogy-orange;
|
||||||
|
clip-path: polygon(0 10px, 0 100%, 350px 200%, 300px 10px);
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
clip-path: none;
|
||||||
|
padding: 0px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: $pedagogy-hover-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
grid-area: date;
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.report {
|
||||||
|
grid-area: report;
|
||||||
|
justify-self: right;
|
||||||
|
padding-right: 30px;
|
||||||
|
padding-left: 30px;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $pedagogy-white-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: $pedagogy-hover-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: $large-devices){
|
||||||
|
text-align: center;
|
||||||
|
justify-self: inherit;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
background-color: $white-color;
|
||||||
|
|
||||||
|
border-left: solid;
|
||||||
|
border-right: solid;
|
||||||
|
border-color: $pedagogy-blue;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $black-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -185,7 +185,7 @@
|
|||||||
<a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a>
|
<a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a>
|
||||||
<a href="/launderette">{% trans %}Launderette{% endtrans %}</a>
|
<a href="/launderette">{% trans %}Launderette{% endtrans %}</a>
|
||||||
<a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a>
|
<a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a>
|
||||||
{# <a href="https://ae2.utbm.fr/uvs/">{% trans %}Pedagogy{% endtrans %}</a> #}
|
<a href="{{ url('pedagogy:guide') }}">{% trans %}Pedagogy{% endtrans %}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
|
@ -104,6 +104,16 @@
|
|||||||
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
|
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<h4>{% trans %}Pedagogy{% endtrans %}</h4>
|
||||||
|
<ul>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_PEDAGOGY_ADMIN_ID) or user.is_root %}
|
||||||
|
<li><a href="{{ url('pedagogy:uv_create') }}">{% trans %}Create UV{% endtrans %}</a></li>
|
||||||
|
<li><a href="{{ url('pedagogy:moderation') }}">{% trans %}Moderate comments{% endtrans %}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<h4>{% trans %}Elections{% endtrans %}</h4>
|
<h4>{% trans %}Elections{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
@ -113,6 +123,8 @@
|
|||||||
<li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li>
|
<li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
<h4>{% trans %}Other tools{% endtrans %}</h4>
|
<h4>{% trans %}Other tools{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ url('core:to_markdown') }}">{% trans %}Convert dokuwiki/BBcode syntax to Markdown{% endtrans %}</a></li>
|
<li><a href="{{ url('core:to_markdown') }}">{% trans %}Convert dokuwiki/BBcode syntax to Markdown{% endtrans %}</a></li>
|
||||||
|
File diff suppressed because it is too large
Load Diff
102
migrate.py
102
migrate.py
@ -77,6 +77,7 @@ from forum.models import (
|
|||||||
ForumMessageMeta,
|
ForumMessageMeta,
|
||||||
ForumUserInfo,
|
ForumUserInfo,
|
||||||
)
|
)
|
||||||
|
from pedagogy.models import UV, UVComment, UVResult
|
||||||
|
|
||||||
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
|
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
|
||||||
start = datetime.datetime.now()
|
start = datetime.datetime.now()
|
||||||
@ -1568,6 +1569,103 @@ def migrate_club_again():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_pedagogy():
|
||||||
|
cur = db.cursor(MySQLdb.cursors.SSDictCursor)
|
||||||
|
|
||||||
|
print("Migrating UVs")
|
||||||
|
root = User.objects.get(id=0)
|
||||||
|
semester_conversion = {
|
||||||
|
"closed": "CLOSED",
|
||||||
|
"A": "AUTUMN",
|
||||||
|
"P": "SPRING",
|
||||||
|
"AP": "AUTUMN_AND_SPRING",
|
||||||
|
}
|
||||||
|
|
||||||
|
def department_conversion(department):
|
||||||
|
# Default of this enum is HUMA
|
||||||
|
if not department or department == "Humas":
|
||||||
|
return "HUMA"
|
||||||
|
return department
|
||||||
|
|
||||||
|
def convert_number(num, default=0):
|
||||||
|
if not num:
|
||||||
|
return default
|
||||||
|
return num
|
||||||
|
|
||||||
|
def convert_text(text):
|
||||||
|
if not text:
|
||||||
|
return ""
|
||||||
|
return doku_to_markdown(to_unicode(text))
|
||||||
|
|
||||||
|
cur.execute(
|
||||||
|
"""
|
||||||
|
SELECT * FROM pedag_uv
|
||||||
|
LEFT JOIN pedag_uv_dept dept
|
||||||
|
ON dept.id_uv = pedag_uv.id_uv
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
for uv in cur:
|
||||||
|
UV(
|
||||||
|
id=uv["id_uv"],
|
||||||
|
code=uv["code"],
|
||||||
|
author=root,
|
||||||
|
credit_type=uv["type"],
|
||||||
|
semester=semester_conversion[uv["semestre"]],
|
||||||
|
language="FR", # No infos in previous guide about that
|
||||||
|
credits=convert_number(uv["guide_credits"]),
|
||||||
|
department=department_conversion(uv["departement"]),
|
||||||
|
title=convert_text(uv["intitule"]),
|
||||||
|
manager=convert_text(uv["responsable"]),
|
||||||
|
objectives=convert_text(uv["guide_objectifs"]),
|
||||||
|
program=convert_text(uv["guide_programme"]),
|
||||||
|
skills="", # No info in previous guide about that
|
||||||
|
key_concepts="", # No info either
|
||||||
|
hours_CM=convert_number(uv["guide_c"]),
|
||||||
|
hours_TD=convert_number(uv["guide_td"]),
|
||||||
|
hours_TP=convert_number(uv["guide_tp"]),
|
||||||
|
hours_THE=convert_number(uv["guide_the"]),
|
||||||
|
hours_TE=0, # No info either
|
||||||
|
).save()
|
||||||
|
|
||||||
|
print("Migrating UV Comments")
|
||||||
|
|
||||||
|
cur.execute("SELECT * FROM pedag_uv_commentaire")
|
||||||
|
|
||||||
|
for comment in cur:
|
||||||
|
author = User.objects.filter(id=comment["id_utilisateur"]).first()
|
||||||
|
uv = UV.objects.filter(id=comment["id_uv"]).first()
|
||||||
|
if not author or not uv:
|
||||||
|
continue
|
||||||
|
UVComment(
|
||||||
|
id=comment["id_commentaire"],
|
||||||
|
author=author,
|
||||||
|
uv=uv,
|
||||||
|
comment=convert_text(comment["content"]),
|
||||||
|
grade_global=convert_number(comment["note_generale"], -1),
|
||||||
|
grade_utility=convert_number(comment["note_utilite"], -1),
|
||||||
|
grade_interest=convert_number(comment["note_interet"], -1),
|
||||||
|
grade_teaching=convert_number(comment["note_enseignement"], -1),
|
||||||
|
grade_work_load=convert_number(comment["note_travail"], -1),
|
||||||
|
publish_date=comment["date"].replace(tzinfo=timezone("Europe/Paris")),
|
||||||
|
).save()
|
||||||
|
|
||||||
|
print("Migrating UV Results")
|
||||||
|
cur.execute("SELECT * FROM pedag_resultat")
|
||||||
|
|
||||||
|
for result in cur:
|
||||||
|
author = User.objects.filter(id=comment["id_utilisateur"]).first()
|
||||||
|
uv = UV.objects.filter(id=comment["id_uv"]).first()
|
||||||
|
if not author or not uv:
|
||||||
|
continue
|
||||||
|
UVResult(
|
||||||
|
id=result["id_resultat"],
|
||||||
|
uv=uv,
|
||||||
|
user=author,
|
||||||
|
grade=result["note"],
|
||||||
|
semester=result["semestre"],
|
||||||
|
).save()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Start at %s" % start)
|
print("Start at %s" % start)
|
||||||
# Core
|
# Core
|
||||||
@ -1590,7 +1688,9 @@ def main():
|
|||||||
# migrate_forum()
|
# migrate_forum()
|
||||||
# reset_index('forum')
|
# reset_index('forum')
|
||||||
# migrate_mailings()
|
# migrate_mailings()
|
||||||
migrate_club_again()
|
# migrate_club_again()
|
||||||
|
migrate_pedagogy()
|
||||||
|
reset_index("pedagogy")
|
||||||
end = datetime.datetime.now()
|
end = datetime.datetime.now()
|
||||||
print("End at %s" % end)
|
print("End at %s" % end)
|
||||||
print("Running time: %s" % (end - start))
|
print("Running time: %s" % (end - start))
|
||||||
|
23
pedagogy/__init__.py
Normal file
23
pedagogy/__init__.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2019
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
27
pedagogy/admin.py
Normal file
27
pedagogy/admin.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2019
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
166
pedagogy/forms.py
Normal file
166
pedagogy/forms.py
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.forms.widgets import Widget
|
||||||
|
from django.templatetags.static import static
|
||||||
|
|
||||||
|
from core.views.forms import MarkdownInput
|
||||||
|
from core.models import User
|
||||||
|
|
||||||
|
from pedagogy.models import UV, UVComment, UVCommentReport
|
||||||
|
|
||||||
|
|
||||||
|
class UVForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
Form handeling creation and edit of an UV
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = UV
|
||||||
|
fields = (
|
||||||
|
"code",
|
||||||
|
"author",
|
||||||
|
"credit_type",
|
||||||
|
"semester",
|
||||||
|
"language",
|
||||||
|
"department",
|
||||||
|
"credits",
|
||||||
|
"hours_CM",
|
||||||
|
"hours_TD",
|
||||||
|
"hours_TP",
|
||||||
|
"hours_THE",
|
||||||
|
"hours_TE",
|
||||||
|
"manager",
|
||||||
|
"title",
|
||||||
|
"objectives",
|
||||||
|
"program",
|
||||||
|
"skills",
|
||||||
|
"key_concepts",
|
||||||
|
)
|
||||||
|
widgets = {
|
||||||
|
"objectives": MarkdownInput,
|
||||||
|
"program": MarkdownInput,
|
||||||
|
"skills": MarkdownInput,
|
||||||
|
"key_concepts": MarkdownInput,
|
||||||
|
"author": forms.HiddenInput,
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, author_id, *args, **kwargs):
|
||||||
|
super(UVForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields["author"].queryset = User.objects.filter(id=author_id).all()
|
||||||
|
self.fields["author"].initial = author_id
|
||||||
|
|
||||||
|
|
||||||
|
class StarList(forms.NumberInput):
|
||||||
|
template_name = "pedagogy/starlist.jinja"
|
||||||
|
|
||||||
|
def __init__(self, nubmer_of_stars=0):
|
||||||
|
super(StarList, self).__init__(None)
|
||||||
|
self.number_of_stars = nubmer_of_stars
|
||||||
|
|
||||||
|
def get_context(self, name, value, attrs):
|
||||||
|
context = super(StarList, self).get_context(name, value, attrs)
|
||||||
|
context["number_of_stars"] = range(0, self.number_of_stars)
|
||||||
|
context["translations"] = {"do_not_vote": _("Do not vote")}
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
Form handeling creation and edit of an UVComment
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = UVComment
|
||||||
|
fields = (
|
||||||
|
"author",
|
||||||
|
"uv",
|
||||||
|
"grade_global",
|
||||||
|
"grade_utility",
|
||||||
|
"grade_interest",
|
||||||
|
"grade_teaching",
|
||||||
|
"grade_work_load",
|
||||||
|
"comment",
|
||||||
|
)
|
||||||
|
widgets = {
|
||||||
|
"comment": MarkdownInput,
|
||||||
|
"author": forms.HiddenInput,
|
||||||
|
"uv": forms.HiddenInput,
|
||||||
|
"grade_global": StarList(5),
|
||||||
|
"grade_utility": StarList(5),
|
||||||
|
"grade_interest": StarList(5),
|
||||||
|
"grade_teaching": StarList(5),
|
||||||
|
"grade_work_load": StarList(5),
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, author_id, uv_id, *args, **kwargs):
|
||||||
|
super(UVCommentForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields["author"].queryset = User.objects.filter(id=author_id).all()
|
||||||
|
self.fields["author"].initial = author_id
|
||||||
|
self.fields["uv"].queryset = UV.objects.filter(id=uv_id).all()
|
||||||
|
self.fields["uv"].initial = uv_id
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentReportForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
Form handeling creation and edit of an UVReport
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = UVCommentReport
|
||||||
|
fields = ("comment", "reporter", "reason")
|
||||||
|
widgets = {
|
||||||
|
"comment": forms.HiddenInput,
|
||||||
|
"reporter": forms.HiddenInput,
|
||||||
|
"reason": MarkdownInput,
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, reporter_id, comment_id, *args, **kwargs):
|
||||||
|
super(UVCommentReportForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields["reporter"].queryset = User.objects.filter(id=reporter_id).all()
|
||||||
|
self.fields["reporter"].initial = reporter_id
|
||||||
|
self.fields["comment"].queryset = UVComment.objects.filter(id=comment_id).all()
|
||||||
|
self.fields["comment"].initial = comment_id
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentModerationForm(forms.Form):
|
||||||
|
"""
|
||||||
|
Form handeling bulk comment deletion
|
||||||
|
"""
|
||||||
|
|
||||||
|
accepted_reports = forms.ModelMultipleChoiceField(
|
||||||
|
UVCommentReport.objects.all(),
|
||||||
|
label=_("Accepted reports"),
|
||||||
|
widget=forms.CheckboxSelectMultiple,
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
denied_reports = forms.ModelMultipleChoiceField(
|
||||||
|
UVCommentReport.objects.all(),
|
||||||
|
label=_("Denied reports"),
|
||||||
|
widget=forms.CheckboxSelectMultiple,
|
||||||
|
required=False,
|
||||||
|
)
|
366
pedagogy/migrations/0001_initial.py
Normal file
366
pedagogy/migrations/0001_initial.py
Normal file
@ -0,0 +1,366 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.20 on 2019-07-05 14:32
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="UV",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"code",
|
||||||
|
models.CharField(
|
||||||
|
max_length=10,
|
||||||
|
unique=True,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.RegexValidator(
|
||||||
|
message="The code of an UV must only contains uppercase characters without accent and numbers",
|
||||||
|
regex="([A-Z0-9]+)",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
verbose_name="code",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"credit_type",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("FREE", "Free"),
|
||||||
|
("CS", "CS"),
|
||||||
|
("TM", "TM"),
|
||||||
|
("OM", "OM"),
|
||||||
|
("QC", "QC"),
|
||||||
|
("EC", "EC"),
|
||||||
|
("RN", "RN"),
|
||||||
|
("ST", "ST"),
|
||||||
|
("EXT", "EXT"),
|
||||||
|
],
|
||||||
|
default="FREE",
|
||||||
|
max_length=10,
|
||||||
|
verbose_name="credit type",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"semester",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("CLOSED", "Closed"),
|
||||||
|
("AUTUMN", "Autumn"),
|
||||||
|
("SPRING", "Spring"),
|
||||||
|
("AUTUMN_AND_SPRING", "Autumn and spring"),
|
||||||
|
],
|
||||||
|
default="CLOSED",
|
||||||
|
max_length=20,
|
||||||
|
verbose_name="semester",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"language",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("FR", "French"),
|
||||||
|
("EN", "English"),
|
||||||
|
("DE", "German"),
|
||||||
|
("SP", "Spanich"),
|
||||||
|
],
|
||||||
|
default="FR",
|
||||||
|
max_length=10,
|
||||||
|
verbose_name="language",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"credits",
|
||||||
|
models.IntegerField(
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="credits",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"department",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("TC", "TC"),
|
||||||
|
("IMSI", "IMSI"),
|
||||||
|
("IMAP", "IMAP"),
|
||||||
|
("INFO", "INFO"),
|
||||||
|
("GI", "GI"),
|
||||||
|
("E", "E"),
|
||||||
|
("EE", "EE"),
|
||||||
|
("GESC", "GESC"),
|
||||||
|
("GMC", "GMC"),
|
||||||
|
("MC", "MC"),
|
||||||
|
("EDIM", "EDIM"),
|
||||||
|
("HUMA", "Humanities"),
|
||||||
|
("NA", "N/A"),
|
||||||
|
],
|
||||||
|
default="NA",
|
||||||
|
max_length=10,
|
||||||
|
verbose_name="departmenmt",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("title", models.CharField(max_length=300, verbose_name="title")),
|
||||||
|
(
|
||||||
|
"manager",
|
||||||
|
models.CharField(max_length=300, verbose_name="uv manager"),
|
||||||
|
),
|
||||||
|
("objectives", models.TextField(verbose_name="objectives")),
|
||||||
|
("program", models.TextField(verbose_name="program")),
|
||||||
|
("skills", models.TextField(verbose_name="skills")),
|
||||||
|
("key_concepts", models.TextField(verbose_name="key concepts")),
|
||||||
|
(
|
||||||
|
"hours_CM",
|
||||||
|
models.IntegerField(
|
||||||
|
default=0,
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="hours CM",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"hours_TD",
|
||||||
|
models.IntegerField(
|
||||||
|
default=0,
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="hours TD",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"hours_TP",
|
||||||
|
models.IntegerField(
|
||||||
|
default=0,
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="hours TP",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"hours_THE",
|
||||||
|
models.IntegerField(
|
||||||
|
default=0,
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="hours THE",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"hours_TE",
|
||||||
|
models.IntegerField(
|
||||||
|
default=0,
|
||||||
|
validators=[django.core.validators.MinValueValidator(0)],
|
||||||
|
verbose_name="hours TE",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"author",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="uv_created",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="author",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="UVComment",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("comment", models.TextField(blank=True, verbose_name="comment")),
|
||||||
|
(
|
||||||
|
"grade_global",
|
||||||
|
models.IntegerField(
|
||||||
|
default=-1,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.MinValueValidator(-1),
|
||||||
|
django.core.validators.MaxValueValidator(4),
|
||||||
|
],
|
||||||
|
verbose_name="global grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"grade_utility",
|
||||||
|
models.IntegerField(
|
||||||
|
default=-1,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.MinValueValidator(-1),
|
||||||
|
django.core.validators.MaxValueValidator(4),
|
||||||
|
],
|
||||||
|
verbose_name="utility grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"grade_interest",
|
||||||
|
models.IntegerField(
|
||||||
|
default=-1,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.MinValueValidator(-1),
|
||||||
|
django.core.validators.MaxValueValidator(4),
|
||||||
|
],
|
||||||
|
verbose_name="interest grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"grade_teaching",
|
||||||
|
models.IntegerField(
|
||||||
|
default=-1,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.MinValueValidator(-1),
|
||||||
|
django.core.validators.MaxValueValidator(4),
|
||||||
|
],
|
||||||
|
verbose_name="teaching grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"grade_work_load",
|
||||||
|
models.IntegerField(
|
||||||
|
default=-1,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.MinValueValidator(-1),
|
||||||
|
django.core.validators.MaxValueValidator(4),
|
||||||
|
],
|
||||||
|
verbose_name="work load grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"publish_date",
|
||||||
|
models.DateTimeField(blank=True, verbose_name="publish date"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"author",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="uv_comments",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="author",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"uv",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="comments",
|
||||||
|
to="pedagogy.UV",
|
||||||
|
verbose_name="uv",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="UVCommentReport",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("reason", models.TextField(verbose_name="reason")),
|
||||||
|
(
|
||||||
|
"comment",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="reports",
|
||||||
|
to="pedagogy.UVComment",
|
||||||
|
verbose_name="report",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"reporter",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="reported_uv_comment",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="reporter",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="UVResult",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"grade",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("A", "A"),
|
||||||
|
("B", "B"),
|
||||||
|
("C", "C"),
|
||||||
|
("D", "D"),
|
||||||
|
("E", "E"),
|
||||||
|
("FX", "FX"),
|
||||||
|
("F", "F"),
|
||||||
|
("ABS", "Abs"),
|
||||||
|
],
|
||||||
|
default="A",
|
||||||
|
max_length=10,
|
||||||
|
verbose_name="grade",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"semester",
|
||||||
|
models.CharField(
|
||||||
|
max_length=5,
|
||||||
|
validators=[
|
||||||
|
django.core.validators.RegexValidator("[AP][0-9]{3}")
|
||||||
|
],
|
||||||
|
verbose_name="semester",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="uv_results",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="user",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"uv",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="results",
|
||||||
|
to="pedagogy.UV",
|
||||||
|
verbose_name="uv",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
0
pedagogy/migrations/__init__.py
Normal file
0
pedagogy/migrations/__init__.py
Normal file
337
pedagogy/models.py
Normal file
337
pedagogy/models.py
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2019
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.core import validators
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils.functional import cached_property
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.models import User
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
|
class UV(models.Model):
|
||||||
|
"""
|
||||||
|
Contains infos about an UV (course)
|
||||||
|
"""
|
||||||
|
|
||||||
|
code = models.CharField(
|
||||||
|
_("code"),
|
||||||
|
max_length=10,
|
||||||
|
unique=True,
|
||||||
|
validators=[
|
||||||
|
validators.RegexValidator(
|
||||||
|
regex="([A-Z0-9]+)",
|
||||||
|
message=_(
|
||||||
|
"The code of an UV must only contains uppercase characters without accent and numbers"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
author = models.ForeignKey(
|
||||||
|
User,
|
||||||
|
related_name="uv_created",
|
||||||
|
verbose_name=_("author"),
|
||||||
|
null=False,
|
||||||
|
blank=False,
|
||||||
|
)
|
||||||
|
credit_type = models.CharField(
|
||||||
|
_("credit type"),
|
||||||
|
max_length=10,
|
||||||
|
choices=settings.SITH_PEDAGOGY_UV_TYPE,
|
||||||
|
default=settings.SITH_PEDAGOGY_UV_TYPE[0][0],
|
||||||
|
)
|
||||||
|
manager = models.CharField(_("uv manager"), max_length=300)
|
||||||
|
semester = models.CharField(
|
||||||
|
_("semester"),
|
||||||
|
max_length=20,
|
||||||
|
choices=settings.SITH_PEDAGOGY_UV_SEMESTER,
|
||||||
|
default=settings.SITH_PEDAGOGY_UV_SEMESTER[0][0],
|
||||||
|
)
|
||||||
|
language = models.CharField(
|
||||||
|
_("language"),
|
||||||
|
max_length=10,
|
||||||
|
choices=settings.SITH_PEDAGOGY_UV_LANGUAGE,
|
||||||
|
default=settings.SITH_PEDAGOGY_UV_LANGUAGE[0][0],
|
||||||
|
)
|
||||||
|
credits = models.IntegerField(
|
||||||
|
_("credits"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
)
|
||||||
|
# Double star type not implemented yet
|
||||||
|
|
||||||
|
department = models.CharField(
|
||||||
|
_("departmenmt"),
|
||||||
|
max_length=10,
|
||||||
|
choices=settings.SITH_PROFILE_DEPARTMENTS,
|
||||||
|
default=settings.SITH_PROFILE_DEPARTMENTS[-1][0],
|
||||||
|
)
|
||||||
|
|
||||||
|
# All texts about the UV
|
||||||
|
title = models.CharField(_("title"), max_length=300)
|
||||||
|
manager = models.CharField(_("uv manager"), max_length=300)
|
||||||
|
objectives = models.TextField(_("objectives"))
|
||||||
|
program = models.TextField(_("program"))
|
||||||
|
skills = models.TextField(_("skills"))
|
||||||
|
key_concepts = models.TextField(_("key concepts"))
|
||||||
|
|
||||||
|
# Hours types CM, TD, TP, THE and TE
|
||||||
|
# Kind of dirty but I have nothing else in mind for now
|
||||||
|
hours_CM = models.IntegerField(
|
||||||
|
_("hours CM"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
hours_TD = models.IntegerField(
|
||||||
|
_("hours TD"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
hours_TP = models.IntegerField(
|
||||||
|
_("hours TP"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
hours_THE = models.IntegerField(
|
||||||
|
_("hours THE"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
hours_TE = models.IntegerField(
|
||||||
|
_("hours TE"),
|
||||||
|
validators=[validators.MinValueValidator(0)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
"""
|
||||||
|
Can be created by superuser, root or pedagogy admin user
|
||||||
|
"""
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_PEDAGOGY_ADMIN_ID)
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
"""
|
||||||
|
Only visible by subscribers
|
||||||
|
"""
|
||||||
|
return user.is_subscribed
|
||||||
|
|
||||||
|
def __grade_average_generic(self, field):
|
||||||
|
comments = self.comments.filter(**{field + "__gte": 0})
|
||||||
|
if not comments.exists():
|
||||||
|
return -1
|
||||||
|
|
||||||
|
return int(sum(comments.values_list(field, flat=True)) / comments.count())
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse("pedagogy:uv_detail", kwargs={"uv_id": self.id})
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_global_average(self):
|
||||||
|
return self.__grade_average_generic("grade_global")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_utility_average(self):
|
||||||
|
return self.__grade_average_generic("grade_utility")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_interest_average(self):
|
||||||
|
return self.__grade_average_generic("grade_interest")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_teaching_average(self):
|
||||||
|
return self.__grade_average_generic("grade_teaching")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_work_load_average(self):
|
||||||
|
return self.__grade_average_generic("grade_work_load")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.code
|
||||||
|
|
||||||
|
|
||||||
|
class UVComment(models.Model):
|
||||||
|
"""
|
||||||
|
A comment about an UV
|
||||||
|
"""
|
||||||
|
|
||||||
|
author = models.ForeignKey(
|
||||||
|
User,
|
||||||
|
related_name="uv_comments",
|
||||||
|
verbose_name=_("author"),
|
||||||
|
null=False,
|
||||||
|
blank=False,
|
||||||
|
)
|
||||||
|
uv = models.ForeignKey(UV, related_name="comments", verbose_name=_("uv"))
|
||||||
|
comment = models.TextField(_("comment"), blank=True)
|
||||||
|
grade_global = models.IntegerField(
|
||||||
|
_("global grade"),
|
||||||
|
validators=[validators.MinValueValidator(-1), validators.MaxValueValidator(4)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=-1,
|
||||||
|
)
|
||||||
|
grade_utility = models.IntegerField(
|
||||||
|
_("utility grade"),
|
||||||
|
validators=[validators.MinValueValidator(-1), validators.MaxValueValidator(4)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=-1,
|
||||||
|
)
|
||||||
|
grade_interest = models.IntegerField(
|
||||||
|
_("interest grade"),
|
||||||
|
validators=[validators.MinValueValidator(-1), validators.MaxValueValidator(4)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=-1,
|
||||||
|
)
|
||||||
|
grade_teaching = models.IntegerField(
|
||||||
|
_("teaching grade"),
|
||||||
|
validators=[validators.MinValueValidator(-1), validators.MaxValueValidator(4)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=-1,
|
||||||
|
)
|
||||||
|
grade_work_load = models.IntegerField(
|
||||||
|
_("work load grade"),
|
||||||
|
validators=[validators.MinValueValidator(-1), validators.MaxValueValidator(4)],
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
default=-1,
|
||||||
|
)
|
||||||
|
publish_date = models.DateTimeField(_("publish date"), blank=True)
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
"""
|
||||||
|
Is owned by a pedagogy admin, a superuser or the author himself
|
||||||
|
"""
|
||||||
|
return self.author == user or user.is_owner(self.uv)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def is_reported(self):
|
||||||
|
"""
|
||||||
|
Return True if someone reported this UV
|
||||||
|
"""
|
||||||
|
return self.reports.exists()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s - %s" % (self.uv, self.author)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.publish_date is None:
|
||||||
|
self.publish_date = timezone.now()
|
||||||
|
super(UVComment, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class UVResult(models.Model):
|
||||||
|
"""
|
||||||
|
Results got to an UV
|
||||||
|
Views will be implemented after the first release
|
||||||
|
Will list every UV done by an user
|
||||||
|
Linked to user
|
||||||
|
uv
|
||||||
|
Contains a grade settings.SITH_PEDAGOGY_UV_RESULT_GRADE
|
||||||
|
a semester (P/A)20xx
|
||||||
|
"""
|
||||||
|
|
||||||
|
uv = models.ForeignKey(UV, related_name="results", verbose_name=_("uv"))
|
||||||
|
user = models.ForeignKey(User, related_name="uv_results", verbose_name=("user"))
|
||||||
|
grade = models.CharField(
|
||||||
|
_("grade"),
|
||||||
|
max_length=10,
|
||||||
|
choices=settings.SITH_PEDAGOGY_UV_RESULT_GRADE,
|
||||||
|
default=settings.SITH_PEDAGOGY_UV_RESULT_GRADE[0][0],
|
||||||
|
)
|
||||||
|
semester = models.CharField(
|
||||||
|
_("semester"),
|
||||||
|
max_length=5,
|
||||||
|
validators=[validators.RegexValidator("[AP][0-9]{3}")],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentReport(models.Model):
|
||||||
|
"""
|
||||||
|
Report an inapropriate comment
|
||||||
|
"""
|
||||||
|
|
||||||
|
comment = models.ForeignKey(
|
||||||
|
UVComment,
|
||||||
|
related_name="reports",
|
||||||
|
verbose_name=_("report"),
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
reporter = models.ForeignKey(
|
||||||
|
User, related_name="reported_uv_comment", verbose_name=_("reporter")
|
||||||
|
)
|
||||||
|
reason = models.TextField(_("reason"))
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
"""
|
||||||
|
Can be created by a pedagogy admin, a superuser or a subscriber
|
||||||
|
"""
|
||||||
|
return user.is_subscribed or user.is_owner(self.comment.uv)
|
||||||
|
|
||||||
|
|
||||||
|
# Custom serializers
|
||||||
|
|
||||||
|
|
||||||
|
class UVSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
Custom seralizer for UVs
|
||||||
|
Allow adding more informations like absolute_url
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = UV
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
absolute_url = serializers.SerializerMethodField()
|
||||||
|
update_url = serializers.SerializerMethodField()
|
||||||
|
delete_url = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_absolute_url(self, obj):
|
||||||
|
return obj.get_absolute_url()
|
||||||
|
|
||||||
|
def get_update_url(self, obj):
|
||||||
|
return reverse("pedagogy:uv_update", kwargs={"uv_id": obj.id})
|
||||||
|
|
||||||
|
def get_delete_url(self, obj):
|
||||||
|
return reverse("pedagogy:uv_delete", kwargs={"uv_id": obj.id})
|
58
pedagogy/search_indexes.py
Normal file
58
pedagogy/search_indexes.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2019
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from haystack import indexes, signals
|
||||||
|
|
||||||
|
from core.search_indexes import BigCharFieldIndex
|
||||||
|
from pedagogy.models import UV
|
||||||
|
|
||||||
|
|
||||||
|
class IndexSignalProcessor(signals.BaseSignalProcessor):
|
||||||
|
"""
|
||||||
|
Auto update index on CRUD operations
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
# Listen only to the ``UV`` model.
|
||||||
|
models.signals.post_save.connect(self.handle_save, sender=UV)
|
||||||
|
models.signals.post_delete.connect(self.handle_delete, sender=UV)
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
# Disconnect only to the ``UV`` model.
|
||||||
|
models.signals.post_save.disconnect(self.handle_save, sender=UV)
|
||||||
|
models.signals.post_delete.disconnect(self.handle_delete, sender=UV)
|
||||||
|
|
||||||
|
|
||||||
|
class UVIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
|
"""
|
||||||
|
Indexer class for UVs
|
||||||
|
"""
|
||||||
|
|
||||||
|
text = BigCharFieldIndex(document=True, use_template=True)
|
||||||
|
auto = indexes.EdgeNgramField(use_template=True)
|
||||||
|
|
||||||
|
def get_model(self):
|
||||||
|
return UV
|
230
pedagogy/templates/pedagogy/guide.jinja
Normal file
230
pedagogy/templates/pedagogy/guide.jinja
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
|
||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}UV Guide{% endtrans %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="pedagogy">
|
||||||
|
<form id="search_form" action="{{ url('pedagogy:guide') }}" method="get">
|
||||||
|
{% if can_create_uv(user) %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ url('pedagogy:uv_create') }}">{% trans %}Create UV{% endtrans %}</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="{{ url('pedagogy:moderation') }}">{% trans %}Moderate comments{% endtrans %}</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<p>
|
||||||
|
<input id="search_input" class="input-search" type="text" name="search">
|
||||||
|
<button class="button-search">{% trans %}Search{% endtrans %}</button>
|
||||||
|
</p>
|
||||||
|
<div class="radio-guide">
|
||||||
|
{% for (display_name, real_name) in [("EDIM", "EDIM"), ("ENERGIE", "EE"), ("IMSI", "IMSI"), ("INFO", "GI"), ("GMC", "MC"), ("HUMA", "HUMA"), ("TC", "TC")] %}
|
||||||
|
<input type="radio" name="department" id="radio{{ real_name }}" value="{{ real_name }}"><label for="radio{{ real_name }}">{% trans %}{{ display_name }}{% endtrans %}</label>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="radio-guide">
|
||||||
|
{% for credit_type in ["CS", "TM", "EC", "QC", "OM"] %}
|
||||||
|
<input type="radio" name="credit_type" id="radio{{ credit_type }}" value="{{ credit_type }}"><label for="radio{{ credit_type }}">{% trans %}{{ credit_type }}{% endtrans %}</label>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<input type="checkbox" name="semester" id="radioAUTUMN" value="AUTUMN"><label for="radioAUTUMN"><i class="fa fa-leaf"></i></label>
|
||||||
|
<input type="checkbox" name="semester" id="radioSPRING" value="SPRING"><label for="radioSPRING"><i class="fa fa-sun-o"></i></label>
|
||||||
|
<span><input type="checkbox" name="semester" id="radioAP" value="AUTUMN_AND_SPRING"><label for="radioAP">AP</label></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" name="json" hidden>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<table id="dynamic_view">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}UV{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Title{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Department{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Credit type{% endtrans %}</td>
|
||||||
|
<td><i class="fa fa-leaf"></i></td>
|
||||||
|
<td><i class="fa fa-sun-o"></i></td>
|
||||||
|
{% if can_create_uv(user) %}
|
||||||
|
<td>{% trans %}Edit{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Delete{% endtrans %}</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="dynamic_view_content">
|
||||||
|
{% for uv in object_list %}
|
||||||
|
<tr onclick="window.location.href = `{{ url('pedagogy:uv_detail', uv_id=uv.id) }}`">
|
||||||
|
<td><a href="{{ url('pedagogy:uv_detail', uv_id=uv.id) }}">{{ uv.code }}</a></td>
|
||||||
|
<td>{{ uv.title }}</td>
|
||||||
|
<td>{{ uv.department }}</td>
|
||||||
|
<td>{{ uv.credit_type }}</td>
|
||||||
|
<td>
|
||||||
|
{% if uv.semester in ["AUTUMN", "AUTUMN_AND_SPRING"] %}
|
||||||
|
<i class="fa fa-leaf"></i>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if uv.semester in ["SPRING", "AUTUMN_AND_SPRING"] %}
|
||||||
|
<i class="fa fa-sun-o"></i>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% if user.is_owner(uv) -%}
|
||||||
|
<td><a href="{{ url('pedagogy:uv_update', uv_id=uv.id) }}">{% trans %}Edit{% endtrans %}</a></td>
|
||||||
|
<td><a href="{{ url('pedagogy:uv_delete', uv_id=uv.id) }}">{% trans %}Delete{% endtrans %}</a></td>
|
||||||
|
{%- endif -%}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function autofillCheckboxRadio(name){
|
||||||
|
if (urlParams.has(name)){ $("input[name='" + name + "']").each(function(){
|
||||||
|
if ($(this).attr("value") == urlParams.get(name))
|
||||||
|
$(this).prop("checked", true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function uvJSONToHTML(uv){
|
||||||
|
var autumn = "";
|
||||||
|
var spring = "";
|
||||||
|
if (uv.semester == "AUTUMN" || uv.semester == "AUTUMN_AND_SPRING")
|
||||||
|
autumn = "<i class='fa fa-leaf'></i>";
|
||||||
|
if (uv.semester == "SPRING" || uv.semester == "AUTUMN_AND_SPRING")
|
||||||
|
spring = "<i class='fa fa-sun-o'></i>";
|
||||||
|
|
||||||
|
var html = `
|
||||||
|
<tr onclick="window.location.href = '${uv.absolute_url}';">
|
||||||
|
<td><a href="${uv.absolute_url}">${uv.code}</a></td>
|
||||||
|
<td>${uv.title}</td>
|
||||||
|
<td>${uv.department}</td>
|
||||||
|
<td>${uv.credit_type}</td>
|
||||||
|
<td>${autumn}</td>
|
||||||
|
<td>${spring}</td>
|
||||||
|
`;
|
||||||
|
{% if can_create_uv(user) %}
|
||||||
|
html += `
|
||||||
|
<td><a href="${uv.update_url}">{% trans %}Edit{% endtrans %}</a></td>
|
||||||
|
<td><a href="${uv.delete_url}">{% trans %}Delete{% endtrans %}</a></td>
|
||||||
|
`;
|
||||||
|
{% endif %}
|
||||||
|
return html + "</td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastTypedLetter;
|
||||||
|
$("#search_input").on("keyup", function(){
|
||||||
|
// Auto submit when user pauses it's typing
|
||||||
|
clearTimeout(lastTypedLetter);
|
||||||
|
lastTypedLetter = setTimeout(function (){
|
||||||
|
$("#search_form").submit();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
$("#search_input").on("change", function(e){
|
||||||
|
// Don't send request when leaving the text area
|
||||||
|
// It has already been send by the keypress event
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Auto fill from get arguments
|
||||||
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
if (urlParams.has("search"))
|
||||||
|
$("input[name='search']").first().prop("value", urlParams.get("search"));
|
||||||
|
autofillCheckboxRadio("department");
|
||||||
|
autofillCheckboxRadio("credit_type");
|
||||||
|
autofillCheckboxRadio("semester");
|
||||||
|
|
||||||
|
// Allow unchecking a radio button when we click on it
|
||||||
|
// Keep a state of what is checked
|
||||||
|
var formStates = {};
|
||||||
|
function radioCheckToggle(e){
|
||||||
|
if (formStates[this.name] == this.value){
|
||||||
|
this.checked = false;
|
||||||
|
formStates[this.name] = "";
|
||||||
|
// Fire an update since the browser does not do it in this situation
|
||||||
|
$("#search_form").submit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formStates[this.name] = this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("input[type='radio']").each(function() {
|
||||||
|
$(this).on("click", radioCheckToggle);
|
||||||
|
// Get current state
|
||||||
|
if ($(this).prop("checked")){
|
||||||
|
formStates[$(this).attr("name")] = $(this).attr("value");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var autumn_and_spring = $("input[value='AUTUMN_AND_SPRING']").first();
|
||||||
|
var autumn = $("input[value='AUTUMN']").first();
|
||||||
|
var spring = $("input[value='SPRING']").first();
|
||||||
|
|
||||||
|
// Make autumn and spring hidden if js is enabled
|
||||||
|
autumn_and_spring.parent().hide();
|
||||||
|
|
||||||
|
// Fill json field if js is enabled
|
||||||
|
$("input[name='json']").first().prop("value", "true");
|
||||||
|
|
||||||
|
// Set correctly state of what is checked
|
||||||
|
if (autumn_and_spring.prop("checked")){
|
||||||
|
autumn.prop("checked", true);
|
||||||
|
spring.prop("checked", true);
|
||||||
|
autumn_and_spring.prop("checked", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle submit here and modify autumn and spring here
|
||||||
|
$("#search_form").submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (autumn.prop("checked") && spring.prop("checked")){
|
||||||
|
autumn_and_spring.prop("checked", true);
|
||||||
|
autumn.prop("checked", false);
|
||||||
|
spring.prop("checked", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do query
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "{{ url('pedagogy:guide') }}",
|
||||||
|
data: $(this).serialize(),
|
||||||
|
tryCount: 0,
|
||||||
|
retryLimit: 10,
|
||||||
|
xhr: function(){
|
||||||
|
return xhr;
|
||||||
|
},
|
||||||
|
success: function(data){
|
||||||
|
// Update URL
|
||||||
|
history.pushState({}, null, xhr.responseURL.replace("&json=true", ""));
|
||||||
|
// Update content
|
||||||
|
$("#dynamic_view_content").html("");
|
||||||
|
for (key in data){
|
||||||
|
$("#dynamic_view_content").append(uvJSONToHTML(data[key]));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(){
|
||||||
|
console.log(`try ${this.tryCount}`);
|
||||||
|
if (this.tryCount++ <= this.retryLimit){
|
||||||
|
$("dynamic_view_content").html("");
|
||||||
|
$.ajax(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#dynamic_view_content").html("<tr><td></td><td>{% trans %}Error connecting to the server{% endtrans %}</td></tr>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restore autumn and spring for perfect illusion
|
||||||
|
if (autumn_and_spring.prop("checked")){
|
||||||
|
autumn_and_spring.prop("checked", false);
|
||||||
|
autumn.prop("checked", true);
|
||||||
|
spring.prop("checked", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Auto send on change
|
||||||
|
$("#search_form").on("change", function(e){
|
||||||
|
$(this).submit();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock content %}
|
15
pedagogy/templates/pedagogy/macros.jinja
Normal file
15
pedagogy/templates/pedagogy/macros.jinja
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% macro display_star(grade) -%}
|
||||||
|
|
||||||
|
{% if grade >= 0 %}
|
||||||
|
{% for i in range(5) %}
|
||||||
|
{% if i <= grade %}
|
||||||
|
<span class="fa fa-star pedagogy star-checked"></span>
|
||||||
|
{% else %}
|
||||||
|
<span class="fa fa-star pedagogy star-not-checked"></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<span class="grade-text"> {% trans %} not rated {% endtrans %} </span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- endmacro %}
|
37
pedagogy/templates/pedagogy/moderation.jinja
Normal file
37
pedagogy/templates/pedagogy/moderation.jinja
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}UV comment moderation{% endtrans %}
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ form.errors }}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}UV{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Comment{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Reason{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Action{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% set queryset = form.accepted_reports.field.queryset %}
|
||||||
|
{% for widget in form.accepted_reports.subwidgets %}
|
||||||
|
{% set report = queryset.get(id=widget.data.value) %}
|
||||||
|
<form action="{{ url('pedagogy:moderation') }}" method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url('pedagogy:uv_detail', uv_id=report.comment.uv.id) }}#{{ report.comment.uv.id }}">{{ report.comment.uv }}</a></td>
|
||||||
|
<td>{{ report.comment.comment|markdown }}</td>
|
||||||
|
<td>{{ report.reason|markdown }}</td>
|
||||||
|
<td>
|
||||||
|
<button name="accepted_reports" type="submit" value="{{ report.id }}">{% trans %}Delete comment{% endtrans %}</button>
|
||||||
|
<button name="denied_reports" type="submit" value="{{ report.id }}">{% trans %}Delete report{% endtrans %}</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</form>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock content %}
|
50
pedagogy/templates/pedagogy/starlist.jinja
Normal file
50
pedagogy/templates/pedagogy/starlist.jinja
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<div>
|
||||||
|
<style>
|
||||||
|
.checked {
|
||||||
|
color : orange;
|
||||||
|
}
|
||||||
|
.unchecked {
|
||||||
|
color : gray;
|
||||||
|
}
|
||||||
|
.star input[type="radio"] {
|
||||||
|
display : none;
|
||||||
|
}
|
||||||
|
.star {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<label class="star">
|
||||||
|
<input type="radio" name="{{ widget.name }}" value="-1" onclick='
|
||||||
|
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||||
|
for (var i = 0; i < stars.length; i++){
|
||||||
|
var attrs = stars[i].getAttribute("class");
|
||||||
|
attrs = attrs.replace("unchecked", "");
|
||||||
|
attrs = attrs.replace("checked", "");
|
||||||
|
stars[i].setAttribute("class", attrs + " unchecked");
|
||||||
|
}
|
||||||
|
' checked>
|
||||||
|
<span class="fa fa-times-circle"> {{ translations.do_not_vote }}</span>
|
||||||
|
</label>
|
||||||
|
{% for i in number_of_stars %}
|
||||||
|
<label class="star">
|
||||||
|
<input type="radio" name="{{ widget.name }}" value="{{ forloop.counter0 }}" onclick='
|
||||||
|
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||||
|
|
||||||
|
for (var i = 0; i < stars.length; i++){
|
||||||
|
var attrs = stars[i].getAttribute("class");
|
||||||
|
attrs = attrs.replace("unchecked", "");
|
||||||
|
attrs = attrs.replace("checked", "");
|
||||||
|
if (i > {{ forloop.counter0 }}){
|
||||||
|
stars[i].setAttribute("class", attrs + " unchecked");
|
||||||
|
} else {
|
||||||
|
stars[i].setAttribute("class", attrs + " checked");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'>
|
||||||
|
<i class="{{ widget.name }} fa fa-star unchecked"></i>
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</div>
|
219
pedagogy/templates/pedagogy/uv_detail.jinja
Normal file
219
pedagogy/templates/pedagogy/uv_detail.jinja
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
{% from "core/macros.jinja" import user_profile_link %}
|
||||||
|
{% from "pedagogy/macros.jinja" import display_star %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}UV Details{% endtrans %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="pedagogy">
|
||||||
|
<div id="uv_detail">
|
||||||
|
<p id="return_noscript"><a href="{{ url('pedagogy:guide') }}">{% trans %}Back{% endtrans %}</a></p>
|
||||||
|
<button id="return_js" 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>
|
||||||
|
<br>
|
||||||
|
<div class="uv-quick-info-container">
|
||||||
|
<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">
|
||||||
|
{{ object.department }}
|
||||||
|
</div>
|
||||||
|
<div class="credit-type">
|
||||||
|
{{ object.credit_type }}
|
||||||
|
</div>
|
||||||
|
<div class="semester">
|
||||||
|
{{ object.get_semester_display() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div class="uv-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="uv-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 %}UV manager: {% endtrans %}</b>{{ object.manager }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div id="leave_comment">
|
||||||
|
<h2>{% trans %}Leave comment{% endtrans %}</h2>
|
||||||
|
<div>
|
||||||
|
<form action="{{ url('pedagogy:uv_detail', uv_id=object.id) }}" method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="leave-comment-grid-container">
|
||||||
|
<div class="form-stars">
|
||||||
|
{{ form.author.errors }}
|
||||||
|
{{ form.uv.errors }}
|
||||||
|
|
||||||
|
{{ form.author }}
|
||||||
|
{{ form.uv }}
|
||||||
|
|
||||||
|
<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><input type="submit" value="{% trans %}Comment{% endtrans %}" /></p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
{% if object.comments.exists() %}
|
||||||
|
<h2>{% trans %}Comments{% endtrans %}</h2>
|
||||||
|
{% for comment in object.comments.order_by("-publish_date").all() %}
|
||||||
|
<div id="{{ 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:uv_detail', uv_id=uv.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 user.is_owner(comment) %}
|
||||||
|
<p class="actions">
|
||||||
|
<a href="{{ url('pedagogy:comment_update', comment_id=comment.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||||
|
<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>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#return_noscript").hide();
|
||||||
|
$("#return_js").show();
|
||||||
|
var icons = {
|
||||||
|
header: "fa fa-toggle-right",
|
||||||
|
activeHeader: "fa fa-toggle-down"
|
||||||
|
};
|
||||||
|
$(function(){
|
||||||
|
$("#leave_comment").accordion({
|
||||||
|
icons: icons,
|
||||||
|
heightStyle: "content",
|
||||||
|
active: false,
|
||||||
|
collapsible: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Remove jquery-ui icons to make fontawesome work
|
||||||
|
$(document).ready(function(){
|
||||||
|
$(".ui-accordion-header-icon").first().removeClass("ui-icon");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
3
pedagogy/templates/search/indexes/pedagogy/uv_auto.txt
Normal file
3
pedagogy/templates/search/indexes/pedagogy/uv_auto.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{ object.code }}
|
||||||
|
{{ object.manager }}
|
||||||
|
{{ object.title }}
|
3
pedagogy/templates/search/indexes/pedagogy/uv_text.txt
Normal file
3
pedagogy/templates/search/indexes/pedagogy/uv_text.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{ object.code }}
|
||||||
|
{{ object.manager }}
|
||||||
|
{{ object.title }}
|
1060
pedagogy/tests.py
Normal file
1060
pedagogy/tests.py
Normal file
File diff suppressed because it is too large
Load Diff
54
pedagogy/urls.py
Normal file
54
pedagogy/urls.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2019
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
from pedagogy.views import *
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# Urls displaying the actual application for visitors
|
||||||
|
url(r"^$", UVListView.as_view(), name="guide"),
|
||||||
|
url(r"^uv/(?P<uv_id>[0-9]+)$", UVDetailFormView.as_view(), name="uv_detail"),
|
||||||
|
url(
|
||||||
|
r"^comment/(?P<comment_id>[0-9]+)/edit$",
|
||||||
|
UVCommentUpdateView.as_view(),
|
||||||
|
name="comment_update",
|
||||||
|
),
|
||||||
|
url(
|
||||||
|
r"^comment/(?P<comment_id>[0-9]+)/delete$",
|
||||||
|
UVCommentDeleteView.as_view(),
|
||||||
|
name="comment_delete",
|
||||||
|
),
|
||||||
|
url(
|
||||||
|
r"^comment/(?P<comment_id>[0-9]+)/report$",
|
||||||
|
UVCommentReportCreateView.as_view(),
|
||||||
|
name="comment_report",
|
||||||
|
),
|
||||||
|
# Moderation
|
||||||
|
url(r"^moderation$", UVModerationFormView.as_view(), name="moderation"),
|
||||||
|
# Administration : Create Update Delete Edit
|
||||||
|
url(r"^uv/create$", UVCreateView.as_view(), name="uv_create"),
|
||||||
|
url(r"^uv/(?P<uv_id>[0-9]+)/delete$", UVDeleteView.as_view(), name="uv_delete"),
|
||||||
|
url(r"^uv/(?P<uv_id>[0-9]+)/edit$", UVUpdateView.as_view(), name="uv_update"),
|
||||||
|
]
|
335
pedagogy/views.py
Normal file
335
pedagogy/views.py
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2017
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.views.generic import (
|
||||||
|
CreateView,
|
||||||
|
DeleteView,
|
||||||
|
UpdateView,
|
||||||
|
ListView,
|
||||||
|
FormView,
|
||||||
|
View,
|
||||||
|
)
|
||||||
|
from django.utils import html
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||||
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from haystack.query import SearchQuerySet
|
||||||
|
from rest_framework.renderers import JSONRenderer
|
||||||
|
|
||||||
|
from core.views import (
|
||||||
|
DetailFormView,
|
||||||
|
CanCreateMixin,
|
||||||
|
CanEditMixin,
|
||||||
|
CanViewMixin,
|
||||||
|
CanEditPropMixin,
|
||||||
|
)
|
||||||
|
from core.models import RealGroup, Notification
|
||||||
|
|
||||||
|
from pedagogy.forms import (
|
||||||
|
UVForm,
|
||||||
|
UVCommentForm,
|
||||||
|
UVCommentReportForm,
|
||||||
|
UVCommentModerationForm,
|
||||||
|
)
|
||||||
|
from pedagogy.models import UV, UVComment, UVCommentReport, UVSerializer
|
||||||
|
|
||||||
|
# Some mixins
|
||||||
|
|
||||||
|
|
||||||
|
class CanCreateUVFunctionMixin(View):
|
||||||
|
"""
|
||||||
|
Add the function can_create_uv(user) into the template
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def can_create_uv(user):
|
||||||
|
"""
|
||||||
|
Creates a dummy instance of UV and test is_owner
|
||||||
|
"""
|
||||||
|
return user.is_owner(UV())
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Pass the function to the template
|
||||||
|
"""
|
||||||
|
kwargs = super(CanCreateUVFunctionMixin, self).get_context_data(**kwargs)
|
||||||
|
kwargs["can_create_uv"] = self.can_create_uv
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
# Acutal views
|
||||||
|
|
||||||
|
|
||||||
|
class UVDetailFormView(CanViewMixin, CanCreateUVFunctionMixin, DetailFormView):
|
||||||
|
"""
|
||||||
|
Dispaly every comment of an UV and detailed infos about it
|
||||||
|
Allow to comment the UV
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UV
|
||||||
|
pk_url_kwarg = "uv_id"
|
||||||
|
template_name = "pedagogy/uv_detail.jinja"
|
||||||
|
form_class = UVCommentForm
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UVDetailFormView, self).get_form_kwargs()
|
||||||
|
kwargs["author_id"] = self.request.user.id
|
||||||
|
kwargs["uv_id"] = self.get_object().id
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.save()
|
||||||
|
return super(UVDetailFormView, self).form_valid(form)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy(
|
||||||
|
"pedagogy:uv_detail", kwargs={"uv_id": self.get_object().id}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentUpdateView(CanEditPropMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Allow edit of a given comment
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UVComment
|
||||||
|
form_class = UVCommentForm
|
||||||
|
pk_url_kwarg = "comment_id"
|
||||||
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UVCommentUpdateView, self).get_form_kwargs()
|
||||||
|
obj = self.get_object()
|
||||||
|
kwargs["author_id"] = obj.author.id
|
||||||
|
kwargs["uv_id"] = obj.uv.id
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:uv_detail", kwargs={"uv_id": self.object.uv.id})
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentDeleteView(CanEditPropMixin, DeleteView):
|
||||||
|
"""
|
||||||
|
Allow delete of a given comment
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UVComment
|
||||||
|
pk_url_kwarg = "comment_id"
|
||||||
|
template_name = "core/delete_confirm.jinja"
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:uv_detail", kwargs={"uv_id": self.object.uv.id})
|
||||||
|
|
||||||
|
|
||||||
|
class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
|
||||||
|
"""
|
||||||
|
UV guide main page
|
||||||
|
"""
|
||||||
|
|
||||||
|
# This is very basic and is prone to changment
|
||||||
|
|
||||||
|
model = UV
|
||||||
|
ordering = ["code"]
|
||||||
|
template_name = "pedagogy/guide.jinja"
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
if not self.request.GET.get("json", None):
|
||||||
|
# Return normal full template response
|
||||||
|
return super(UVListView, self).get(*args, **kwargs)
|
||||||
|
|
||||||
|
# Return serialized response
|
||||||
|
return HttpResponse(
|
||||||
|
JSONRenderer().render(UVSerializer(self.get_queryset(), many=True).data),
|
||||||
|
content_type="application/json",
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
queryset = super(UVListView, self).get_queryset()
|
||||||
|
search = self.request.GET.get("search", None)
|
||||||
|
|
||||||
|
additional_filters = {}
|
||||||
|
|
||||||
|
for filter_type in ["credit_type", "language", "department"]:
|
||||||
|
arg = self.request.GET.get(filter_type, None)
|
||||||
|
if arg:
|
||||||
|
additional_filters[filter_type] = arg
|
||||||
|
|
||||||
|
semester = self.request.GET.get("semester", None)
|
||||||
|
if semester:
|
||||||
|
if semester in ["AUTUMN", "SPRING"]:
|
||||||
|
additional_filters["semester__in"] = [semester, "AUTUMN_AND_SPRING"]
|
||||||
|
else:
|
||||||
|
additional_filters["semester"] = semester
|
||||||
|
|
||||||
|
queryset = queryset.filter(**additional_filters)
|
||||||
|
if not search:
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
if len(search) == 1:
|
||||||
|
# It's a search with only one letter
|
||||||
|
# Haystack doesn't work well with only one letter
|
||||||
|
return queryset.filter(code__istartswith=search)
|
||||||
|
|
||||||
|
try:
|
||||||
|
qs = (
|
||||||
|
SearchQuerySet()
|
||||||
|
.models(self.model)
|
||||||
|
.autocomplete(auto=html.escape(search))
|
||||||
|
)
|
||||||
|
except TypeError:
|
||||||
|
return self.model.objects.none()
|
||||||
|
|
||||||
|
return queryset.filter(id__in=([o.object.id for o in qs]))
|
||||||
|
|
||||||
|
|
||||||
|
class UVCommentReportCreateView(CanCreateMixin, CreateView):
|
||||||
|
"""
|
||||||
|
Create a new report for an inapropriate comment
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UVCommentReport
|
||||||
|
form_class = UVCommentReportForm
|
||||||
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
self.uv_comment = get_object_or_404(UVComment, pk=kwargs["comment_id"])
|
||||||
|
return super(UVCommentReportCreateView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UVCommentReportCreateView, self).get_form_kwargs()
|
||||||
|
kwargs["reporter_id"] = self.request.user.id
|
||||||
|
kwargs["comment_id"] = self.uv_comment.id
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
resp = super(UVCommentReportCreateView, self).form_valid(form)
|
||||||
|
|
||||||
|
# Send a message to moderation admins
|
||||||
|
for user in (
|
||||||
|
RealGroup.objects.filter(id=settings.SITH_GROUP_PEDAGOGY_ADMIN_ID)
|
||||||
|
.first()
|
||||||
|
.users.all()
|
||||||
|
):
|
||||||
|
if not user.notifications.filter(
|
||||||
|
type="PEDAGOGY_MODERATION", viewed=False
|
||||||
|
).exists():
|
||||||
|
Notification(
|
||||||
|
user=user,
|
||||||
|
url=reverse("pedagogy:moderation"),
|
||||||
|
type="PEDAGOGY_MODERATION",
|
||||||
|
).save()
|
||||||
|
|
||||||
|
return resp
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy(
|
||||||
|
"pedagogy:uv_detail", kwargs={"uv_id": self.uv_comment.uv.id}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UVModerationFormView(FormView):
|
||||||
|
"""
|
||||||
|
Moderation interface (Privileged)
|
||||||
|
"""
|
||||||
|
|
||||||
|
form_class = UVCommentModerationForm
|
||||||
|
template_name = "pedagogy/moderation.jinja"
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not request.user.is_owner(UV()):
|
||||||
|
raise PermissionDenied
|
||||||
|
return super(UVModerationFormView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form_clean = form.clean()
|
||||||
|
for report in form_clean.get("accepted_reports", []):
|
||||||
|
try:
|
||||||
|
report.comment.delete() # Delete the related comment
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# To avoid errors when two reports points the same comment
|
||||||
|
pass
|
||||||
|
for report in form_clean.get("denied_reports", []):
|
||||||
|
try:
|
||||||
|
report.delete() # Delete the report itself
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# To avoid errors when two reports points the same comment
|
||||||
|
pass
|
||||||
|
return super(UVModerationFormView, self).form_valid(form)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:moderation")
|
||||||
|
|
||||||
|
|
||||||
|
class UVCreateView(CanCreateMixin, CreateView):
|
||||||
|
"""
|
||||||
|
Add a new UV (Privileged)
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UV
|
||||||
|
form_class = UVForm
|
||||||
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UVCreateView, self).get_form_kwargs()
|
||||||
|
kwargs["author_id"] = self.request.user.id
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:uv_detail", kwargs={"uv_id": self.object.id})
|
||||||
|
|
||||||
|
|
||||||
|
class UVDeleteView(CanEditPropMixin, DeleteView):
|
||||||
|
"""
|
||||||
|
Allow to delete an UV (Privileged)
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UV
|
||||||
|
pk_url_kwarg = "uv_id"
|
||||||
|
template_name = "core/delete_confirm.jinja"
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:guide")
|
||||||
|
|
||||||
|
|
||||||
|
class UVUpdateView(CanEditPropMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Allow to edit an UV (Privilegied)
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = UV
|
||||||
|
form_class = UVForm
|
||||||
|
pk_url_kwarg = "uv_id"
|
||||||
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UVUpdateView, self).get_form_kwargs()
|
||||||
|
kwargs["author_id"] = self.request.user.id
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("pedagogy:uv_detail", kwargs={"uv_id": self.object.id})
|
@ -93,6 +93,7 @@ INSTALLED_APPS = (
|
|||||||
"stock",
|
"stock",
|
||||||
"trombi",
|
"trombi",
|
||||||
"matmat",
|
"matmat",
|
||||||
|
"pedagogy",
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
@ -321,6 +322,7 @@ SITH_GROUP_BANNED_COUNTER_ID = 9
|
|||||||
SITH_GROUP_BANNED_SUBSCRIPTION_ID = 10
|
SITH_GROUP_BANNED_SUBSCRIPTION_ID = 10
|
||||||
SITH_GROUP_SAS_ADMIN_ID = 11
|
SITH_GROUP_SAS_ADMIN_ID = 11
|
||||||
SITH_GROUP_FORUM_ADMIN_ID = 12
|
SITH_GROUP_FORUM_ADMIN_ID = 12
|
||||||
|
SITH_GROUP_PEDAGOGY_ADMIN_ID = 13
|
||||||
|
|
||||||
|
|
||||||
SITH_CLUB_REFOUND_ID = 89
|
SITH_CLUB_REFOUND_ID = 89
|
||||||
@ -403,6 +405,43 @@ SITH_COUNTER_BANK = [
|
|||||||
("LA-POSTE", "La Poste"),
|
("LA-POSTE", "La Poste"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SITH_PEDAGOGY_UV_TYPE = [
|
||||||
|
("FREE", _("Free")),
|
||||||
|
("CS", _("CS")),
|
||||||
|
("TM", _("TM")),
|
||||||
|
("OM", _("OM")),
|
||||||
|
("QC", _("QC")),
|
||||||
|
("EC", _("EC")),
|
||||||
|
("RN", _("RN")),
|
||||||
|
("ST", _("ST")),
|
||||||
|
("EXT", _("EXT")),
|
||||||
|
]
|
||||||
|
|
||||||
|
SITH_PEDAGOGY_UV_SEMESTER = [
|
||||||
|
("CLOSED", _("Closed")),
|
||||||
|
("AUTUMN", _("Autumn")),
|
||||||
|
("SPRING", _("Spring")),
|
||||||
|
("AUTUMN_AND_SPRING", _("Autumn and spring")),
|
||||||
|
]
|
||||||
|
|
||||||
|
SITH_PEDAGOGY_UV_LANGUAGE = [
|
||||||
|
("FR", _("French")),
|
||||||
|
("EN", _("English")),
|
||||||
|
("DE", _("German")),
|
||||||
|
("SP", _("Spanich")),
|
||||||
|
]
|
||||||
|
|
||||||
|
SITH_PEDAGOGY_UV_RESULT_GRADE = [
|
||||||
|
("A", _("A")),
|
||||||
|
("B", _("B")),
|
||||||
|
("C", _("C")),
|
||||||
|
("D", _("D")),
|
||||||
|
("E", _("E")),
|
||||||
|
("FX", _("FX")),
|
||||||
|
("F", _("F")),
|
||||||
|
("ABS", _("Abs")),
|
||||||
|
]
|
||||||
|
|
||||||
SITH_ECOCUP_CONS = 1152
|
SITH_ECOCUP_CONS = 1152
|
||||||
|
|
||||||
SITH_ECOCUP_DECO = 1151
|
SITH_ECOCUP_DECO = 1151
|
||||||
@ -521,6 +560,10 @@ SITH_LAUNDERETTE_PRICES = {"WASHING": 1.0, "DRYING": 0.75}
|
|||||||
SITH_NOTIFICATIONS = [
|
SITH_NOTIFICATIONS = [
|
||||||
("POSTER_MODERATION", _("A new poster needs to be moderated")),
|
("POSTER_MODERATION", _("A new poster needs to be moderated")),
|
||||||
("MAILING_MODERATION", _("A new mailing list needs to be moderated")),
|
("MAILING_MODERATION", _("A new mailing list needs to be moderated")),
|
||||||
|
(
|
||||||
|
"PEDAGOGY_MODERATION",
|
||||||
|
_("A new pedagogy comment has been signaled for moderation"),
|
||||||
|
),
|
||||||
("NEWS_MODERATION", _("There are %s fresh news to be moderated")),
|
("NEWS_MODERATION", _("There are %s fresh news to be moderated")),
|
||||||
("FILE_MODERATION", _("New files to be moderated")),
|
("FILE_MODERATION", _("New files to be moderated")),
|
||||||
("SAS_MODERATION", _("There are %s pictures to be moderated in the SAS")),
|
("SAS_MODERATION", _("There are %s pictures to be moderated in the SAS")),
|
||||||
|
@ -84,6 +84,10 @@ urlpatterns = [
|
|||||||
url(
|
url(
|
||||||
r"^matmatronch/", include("matmat.urls", namespace="matmat", app_name="matmat")
|
r"^matmatronch/", include("matmat.urls", namespace="matmat", app_name="matmat")
|
||||||
),
|
),
|
||||||
|
url(
|
||||||
|
r"^pedagogy/",
|
||||||
|
include("pedagogy.urls", namespace="pedagogy", app_name="pedagogy"),
|
||||||
|
),
|
||||||
url(r"^admin/", include(admin.site.urls)),
|
url(r"^admin/", include(admin.site.urls)),
|
||||||
url(r"^ajax_select/", include(ajax_select_urls)),
|
url(r"^ajax_select/", include(ajax_select_urls)),
|
||||||
url(r"^i18n/", include("django.conf.urls.i18n")),
|
url(r"^i18n/", include("django.conf.urls.i18n")),
|
||||||
|
Loading…
Reference in New Issue
Block a user