From 17a375f89c20132b4019e24f0737016c62940c44 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Thu, 16 May 2019 16:51:30 +0200 Subject: [PATCH 01/96] pedagogy: structure of the app --- pedagogy/__init__.py | 23 ++++++ pedagogy/admin.py | 27 +++++++ pedagogy/migrations/__init__.py | 0 pedagogy/models.py | 67 +++++++++++++++++ pedagogy/tests.py | 27 +++++++ pedagogy/urls.py | 62 ++++++++++++++++ pedagogy/views.py | 124 ++++++++++++++++++++++++++++++++ sith/settings.py | 1 + sith/urls.py | 4 ++ 9 files changed, 335 insertions(+) create mode 100644 pedagogy/__init__.py create mode 100644 pedagogy/admin.py create mode 100644 pedagogy/migrations/__init__.py create mode 100644 pedagogy/models.py create mode 100644 pedagogy/tests.py create mode 100644 pedagogy/urls.py create mode 100644 pedagogy/views.py diff --git a/pedagogy/__init__.py b/pedagogy/__init__.py new file mode 100644 index 00000000..7ea16950 --- /dev/null +++ b/pedagogy/__init__.py @@ -0,0 +1,23 @@ +# -*- coding:utf-8 -* +# +# Copyright 2019 +# - Sli +# +# 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. +# +# diff --git a/pedagogy/admin.py b/pedagogy/admin.py new file mode 100644 index 00000000..24eb52b8 --- /dev/null +++ b/pedagogy/admin.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -* +# +# Copyright 2019 +# - Sli +# +# 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. diff --git a/pedagogy/migrations/__init__.py b/pedagogy/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pedagogy/models.py b/pedagogy/models.py new file mode 100644 index 00000000..57ee8576 --- /dev/null +++ b/pedagogy/models.py @@ -0,0 +1,67 @@ +# -*- coding:utf-8 -* +# +# Copyright 2019 +# - Sli +# +# 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 + +# Create your models here. + + +class UV(models.Model): + """ + Contains infos about an UV (course) + """ + + pass + + +class UVComment(models.Model): + """ + A comment about an UV + """ + + pass + + +class UVCommentReport(models.Model): + """ + Report an inapropriate comment + """ + + pass + + +class TeachingDepartment(models.Model): + """ + Teaching department of the school + """ + + pass + + +class Study(models.Model): + """ + Speciality inside a Teaching Department + """ + + pass diff --git a/pedagogy/tests.py b/pedagogy/tests.py new file mode 100644 index 00000000..02ee7ae5 --- /dev/null +++ b/pedagogy/tests.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -* +# +# Copyright 2019 +# - Sli +# +# 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.test import TestCase + +# Create your tests here. diff --git a/pedagogy/urls.py b/pedagogy/urls.py new file mode 100644 index 00000000..71a17a57 --- /dev/null +++ b/pedagogy/urls.py @@ -0,0 +1,62 @@ +# -*- coding:utf-8 -* +# +# Copyright 2019 +# - Sli +# +# 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 = [ + url(r"^$", UVListView.as_view(), name="guide"), + url(r"^uv/(?P[0-9]+)$", UVDetailFormView.as_view(), name="uv_detail"), + url( + r"^comment/(?P[0-9]+)$", + UVCommentDetailView.as_view(), + name="comment_detail", + ), + url( + r"^comment/(?P[0-9]+)/report$", + UVCommentReportCreateView.as_view(), + name="comment_report", + ), + url(r"^reported$", UVCommentReportListView.as_view(), name="comment_report_list"), + url(r"^moderation$", UVModerationFormView.as_view(), name="moderation"), + url(r"^uv/create$", UVCreateView.as_view(), name="uv_create"), + url(r"^uv/(?P[0-9]+)/delete$", UVDeleteView.as_view(), name="uv_delete"), + url( + r"^department/create$", + TeachingDepartmentCreateView.as_view(), + name="department_create", + ), + url( + r"^department/(?P[0-9]+)/delete$", + TeachingDepartmentDeleteView.as_view(), + name="department_delete", + ), + url(r"^study/create$", StudyCreateView.as_view(), name="study_create"), + url( + r"^study/(?P[0-9]+)/delete$", + StudyDeleteView.as_view(), + name="study_delete", + ), +] diff --git a/pedagogy/views.py b/pedagogy/views.py new file mode 100644 index 00000000..ed5a728e --- /dev/null +++ b/pedagogy/views.py @@ -0,0 +1,124 @@ +# -*- coding:utf-8 -* +# +# Copyright 2017 +# - Sli +# +# 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, DetailView, ListView, FormView + +from core.views import DetailFormView + + +class UVDetailFormView(DetailFormView): + """ + Dispaly every comment of an UV and detailed infos about it + Allow to comment the UV + """ + + pass + + +class UVCommentDetailView(DetailView): + """ + Display a specified UVComment (for easy sharing of the comment) + """ + + pass + + +class UVListView(ListView): + """ + UV guide main page + """ + + pass + + +class UVCommentReportCreateView(CreateView): + """ + Create a new report for an inapropriate comment + """ + + pass + + +class UVCommentReportListView(ListView): + """ + List all UV reports for moderation (Privileged) + """ + + pass + + +class UVModerationFormView(FormView): + """ + List all UVs to moderate and allow to moderate them (Privileged) + """ + + pass + + +class UVCreateView(CreateView): + """ + Add a new UV (Privileged) + """ + + pass + + +class UVDeleteView(DeleteView): + """ + Allow to delete an UV (Privileged) + """ + + pass + + +class TeachingDepartmentCreateView(CreateView): + """ + Add a new TeachingDepartment (Privileged) + """ + + pass + + +class TeachingDepartmentDeleteView(DeleteView): + """ + Allow to delete an TeachingDepartment (Privileged) + """ + + pass + + +class StudyCreateView(CreateView): + """ + Add a new Study (Privileged) + """ + + pass + + +class StudyDeleteView(DeleteView): + """ + Allow to delete an Study (Privileged) + """ + + pass diff --git a/sith/settings.py b/sith/settings.py index 22acf99e..cd4af6da 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -93,6 +93,7 @@ INSTALLED_APPS = ( "stock", "trombi", "matmat", + "pedagogy", ) MIDDLEWARE_CLASSES = ( diff --git a/sith/urls.py b/sith/urls.py index 179724b8..23f82469 100644 --- a/sith/urls.py +++ b/sith/urls.py @@ -84,6 +84,10 @@ urlpatterns = [ url( 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"^ajax_select/", include(ajax_select_urls)), url(r"^i18n/", include("django.conf.urls.i18n")), From 36831b4f4ad7021c1d10e1e79e3e8c90da502f96 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 29 May 2019 01:30:23 +0200 Subject: [PATCH 02/96] pedagogy: rename TeachingDepartment into EducationDepartment --- pedagogy/models.py | 6 +++--- pedagogy/urls.py | 4 ++-- pedagogy/views.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pedagogy/models.py b/pedagogy/models.py index 57ee8576..40efaa59 100644 --- a/pedagogy/models.py +++ b/pedagogy/models.py @@ -51,9 +51,9 @@ class UVCommentReport(models.Model): pass -class TeachingDepartment(models.Model): +class EducationDepartment(models.Model): """ - Teaching department of the school + Education department of the school """ pass @@ -61,7 +61,7 @@ class TeachingDepartment(models.Model): class Study(models.Model): """ - Speciality inside a Teaching Department + Speciality inside an Education Department """ pass diff --git a/pedagogy/urls.py b/pedagogy/urls.py index 71a17a57..a853cb7d 100644 --- a/pedagogy/urls.py +++ b/pedagogy/urls.py @@ -45,12 +45,12 @@ urlpatterns = [ url(r"^uv/(?P[0-9]+)/delete$", UVDeleteView.as_view(), name="uv_delete"), url( r"^department/create$", - TeachingDepartmentCreateView.as_view(), + EducationDepartmentCreateView.as_view(), name="department_create", ), url( r"^department/(?P[0-9]+)/delete$", - TeachingDepartmentDeleteView.as_view(), + EducationDepartmentDeleteView.as_view(), name="department_delete", ), url(r"^study/create$", StudyCreateView.as_view(), name="study_create"), diff --git a/pedagogy/views.py b/pedagogy/views.py index ed5a728e..7e15e3c3 100644 --- a/pedagogy/views.py +++ b/pedagogy/views.py @@ -92,17 +92,17 @@ class UVDeleteView(DeleteView): pass -class TeachingDepartmentCreateView(CreateView): +class EducationDepartmentCreateView(CreateView): """ - Add a new TeachingDepartment (Privileged) + Add a new Education Department (Privileged) """ pass -class TeachingDepartmentDeleteView(DeleteView): +class EducationDepartmentDeleteView(DeleteView): """ - Allow to delete an TeachingDepartment (Privileged) + Allow to delete an Education Department (Privileged) """ pass From 57f2a5c2608f5f2873f08b3b24d28b17b45a0a9f Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 29 May 2019 01:33:50 +0200 Subject: [PATCH 03/96] pedagogy: rename Study into StudyField --- pedagogy/models.py | 2 +- pedagogy/urls.py | 4 ++-- pedagogy/views.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pedagogy/models.py b/pedagogy/models.py index 40efaa59..c6a29816 100644 --- a/pedagogy/models.py +++ b/pedagogy/models.py @@ -59,7 +59,7 @@ class EducationDepartment(models.Model): pass -class Study(models.Model): +class StudyField(models.Model): """ Speciality inside an Education Department """ diff --git a/pedagogy/urls.py b/pedagogy/urls.py index a853cb7d..2a7c4990 100644 --- a/pedagogy/urls.py +++ b/pedagogy/urls.py @@ -53,10 +53,10 @@ urlpatterns = [ EducationDepartmentDeleteView.as_view(), name="department_delete", ), - url(r"^study/create$", StudyCreateView.as_view(), name="study_create"), + url(r"^study/create$", StudyFieldCreateView.as_view(), name="study_create"), url( r"^study/(?P[0-9]+)/delete$", - StudyDeleteView.as_view(), + StudyFieldDeleteView.as_view(), name="study_delete", ), ] diff --git a/pedagogy/views.py b/pedagogy/views.py index 7e15e3c3..41cd6c08 100644 --- a/pedagogy/views.py +++ b/pedagogy/views.py @@ -108,17 +108,17 @@ class EducationDepartmentDeleteView(DeleteView): pass -class StudyCreateView(CreateView): +class StudyFieldCreateView(CreateView): """ - Add a new Study (Privileged) + Add a new Study Field (Privileged) """ pass -class StudyDeleteView(DeleteView): +class StudyFieldDeleteView(DeleteView): """ - Allow to delete an Study (Privileged) + Allow to delete an Study Field (Privileged) """ pass From b49f204e207d0b048a921194e3d270e179d674f3 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 29 May 2019 01:36:51 +0200 Subject: [PATCH 04/96] pedagogy: more comprehensible urls for development --- pedagogy/urls.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pedagogy/urls.py b/pedagogy/urls.py index 2a7c4990..7f826428 100644 --- a/pedagogy/urls.py +++ b/pedagogy/urls.py @@ -27,6 +27,7 @@ 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[0-9]+)$", UVDetailFormView.as_view(), name="uv_detail"), url( @@ -39,8 +40,10 @@ urlpatterns = [ UVCommentReportCreateView.as_view(), name="comment_report", ), + # Moderation url(r"^reported$", UVCommentReportListView.as_view(), name="comment_report_list"), 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[0-9]+)/delete$", UVDeleteView.as_view(), name="uv_delete"), url( From 31f6ee9ca4248ef52382ca53c381f5429957caf4 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Sat, 15 Jun 2019 14:17:39 +0200 Subject: [PATCH 05/96] pedagogy: create first iteration of UV model --- pedagogy/migrations/0001_initial.py | 218 ++++++++++++++++++++++++++++ pedagogy/models.py | 101 ++++++++++++- sith/settings.py | 24 +++ 3 files changed, 342 insertions(+), 1 deletion(-) create mode 100644 pedagogy/migrations/0001_initial.py diff --git a/pedagogy/migrations/0001_initial.py b/pedagogy/migrations/0001_initial.py new file mode 100644 index 00000000..f5a5b5bf --- /dev/null +++ b/pedagogy/migrations/0001_initial.py @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-06-15 12:13 +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="EducationDepartment", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ) + ], + ), + migrations.CreateModel( + name="StudyField", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ) + ], + ), + 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"), + ("EC", "EC"), + ("CG", "CG"), + ("RN", "RN"), + ("EXT", "EXT"), + ], + default="FREE", + max_length=10, + verbose_name="credit type", + ), + ), + ( + "semester", + models.CharField( + choices=[ + ("CLOSED", "Closed"), + ("AUTUMN", "Autumn"), + ("SPRING", "Spring"), + ("AUTOMN_AND_SPRING", "Autumn and spring"), + ], + default="CLOSED", + max_length=10, + 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", + ), + ), + ("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( + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="hours CM", + ), + ), + ( + "hours_TD", + models.IntegerField( + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="hours TD", + ), + ), + ( + "hours_TP", + models.IntegerField( + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="hours TP", + ), + ), + ( + "hours_THE", + models.IntegerField( + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="hours THE", + ), + ), + ( + "hours_TE", + models.IntegerField( + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="hours TE", + ), + ), + ( + "author", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="created_UVs", + to=settings.AUTH_USER_MODEL, + verbose_name="created UVs", + ), + ), + ( + "moderator", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="moderated_UVs", + to=settings.AUTH_USER_MODEL, + verbose_name="moderated UVs", + ), + ), + ], + ), + migrations.CreateModel( + name="UVComment", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ) + ], + ), + migrations.CreateModel( + name="UVCommentReport", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ) + ], + ), + ] diff --git a/pedagogy/models.py b/pedagogy/models.py index c6a29816..3385337e 100644 --- a/pedagogy/models.py +++ b/pedagogy/models.py @@ -23,6 +23,11 @@ # from django.db import models +from django.utils.translation import ugettext_lazy as _ +from django.core import validators +from django.conf import settings + +from core.models import User # Create your models here. @@ -32,7 +37,101 @@ class UV(models.Model): Contains infos about an UV (course) """ - pass + 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" + ), + ) + ], + ) + moderator = models.ForeignKey( + User, + related_name="moderated_UVs", + verbose_name=_("moderated UVs"), + null=True, + blank=True, + ) + author = models.ForeignKey( + User, + related_name="created_UVs", + verbose_name=_("created UVs"), + 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=10, + 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 + # Departments not implemented yet + + # 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, + ) + hours_TD = models.IntegerField( + _("hours TD"), + validators=[validators.MinValueValidator(0)], + blank=False, + null=False, + ) + hours_TP = models.IntegerField( + _("hours TP"), + validators=[validators.MinValueValidator(0)], + blank=False, + null=False, + ) + hours_THE = models.IntegerField( + _("hours THE"), + validators=[validators.MinValueValidator(0)], + blank=False, + null=False, + ) + hours_TE = models.IntegerField( + _("hours TE"), + validators=[validators.MinValueValidator(0)], + blank=False, + null=False, + ) class UVComment(models.Model): diff --git a/sith/settings.py b/sith/settings.py index cd4af6da..39e0e517 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -404,6 +404,30 @@ SITH_COUNTER_BANK = [ ("LA-POSTE", "La Poste"), ] +SITH_PEDAGOGY_UV_TYPE = [ + ("FREE", _("Free")), + ("CS", _("CS")), + ("TM", _("TM")), + ("EC", _("EC")), + ("CG", _("CG")), + ("RN", _("RN")), + ("EXT", _("EXT")), +] + +SITH_PEDAGOGY_UV_SEMESTER = [ + ("CLOSED", _("Closed")), + ("AUTUMN", _("Autumn")), + ("SPRING", _("Spring")), + ("AUTOMN_AND_SPRING", _("Autumn and spring")), +] + +SITH_PEDAGOGY_UV_LANGUAGE = [ + ("FR", _("French")), + ("EN", _("English")), + ("DE", _("German")), + ("SP", _("Spanich")), +] + SITH_ECOCUP_CONS = 1152 SITH_ECOCUP_DECO = 1151 From 5bf5d0277cf79d27bdbf3ce6092f39a96ef0c2d9 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Sat, 15 Jun 2019 17:01:25 +0200 Subject: [PATCH 06/96] pedagogy: create view and form for UV WARNING: A new group has been created, to be set by the infra team at deployment !!! --- core/management/commands/populate.py | 1 + pedagogy/forms.py | 70 ++++++++++++++++++++++++++++ pedagogy/migrations/0001_initial.py | 28 +++++------ pedagogy/models.py | 24 ++++++---- pedagogy/views.py | 26 +++++++++-- sith/settings.py | 5 +- 6 files changed, 124 insertions(+), 30 deletions(-) create mode 100644 pedagogy/forms.py diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 312744c6..96aa1a8e 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -84,6 +84,7 @@ class Command(BaseCommand): Group(name="Banned to subscribe").save() Group(name="SAS admin").save() Group(name="Forum admin").save() + Group(name="Pedagogy admin").save() self.reset_index("core", "auth") root = User( id=0, diff --git a/pedagogy/forms.py b/pedagogy/forms.py new file mode 100644 index 00000000..57b75385 --- /dev/null +++ b/pedagogy/forms.py @@ -0,0 +1,70 @@ +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Skia +# +# 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 core.views.forms import MarkdownInput +from core.models import User + +from pedagogy.models import UV + + +class UVForm(forms.ModelForm): + """ + Form handeling creation and edit of an UV + """ + + class Meta: + model = UV + fields = ( + "code", + "author", + "credit_type", + "semester", + "language", + "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 diff --git a/pedagogy/migrations/0001_initial.py b/pedagogy/migrations/0001_initial.py index f5a5b5bf..9f8f8e76 100644 --- a/pedagogy/migrations/0001_initial.py +++ b/pedagogy/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.20 on 2019-06-15 12:13 +# Generated by Django 1.11.20 on 2019-06-15 15:00 from __future__ import unicode_literals from django.conf import settings @@ -76,9 +76,11 @@ class Migration(migrations.Migration): ("FREE", "Free"), ("CS", "CS"), ("TM", "TM"), + ("OM", "OM"), + ("QC", "QC"), ("EC", "EC"), - ("CG", "CG"), ("RN", "RN"), + ("ST", "ST"), ("EXT", "EXT"), ], default="FREE", @@ -96,7 +98,7 @@ class Migration(migrations.Migration): ("AUTOMN_AND_SPRING", "Autumn and spring"), ], default="CLOSED", - max_length=10, + max_length=20, verbose_name="semester", ), ), @@ -129,10 +131,11 @@ class Migration(migrations.Migration): ("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")), + ("key_concepts", models.TextField(verbose_name="key concepts")), ( "hours_CM", models.IntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)], verbose_name="hours CM", ), @@ -140,6 +143,7 @@ class Migration(migrations.Migration): ( "hours_TD", models.IntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)], verbose_name="hours TD", ), @@ -147,6 +151,7 @@ class Migration(migrations.Migration): ( "hours_TP", models.IntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)], verbose_name="hours TP", ), @@ -154,6 +159,7 @@ class Migration(migrations.Migration): ( "hours_THE", models.IntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)], verbose_name="hours THE", ), @@ -161,6 +167,7 @@ class Migration(migrations.Migration): ( "hours_TE", models.IntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)], verbose_name="hours TE", ), @@ -171,18 +178,7 @@ class Migration(migrations.Migration): on_delete=django.db.models.deletion.CASCADE, related_name="created_UVs", to=settings.AUTH_USER_MODEL, - verbose_name="created UVs", - ), - ), - ( - "moderator", - models.ForeignKey( - blank=True, - null=True, - on_delete=django.db.models.deletion.CASCADE, - related_name="moderated_UVs", - to=settings.AUTH_USER_MODEL, - verbose_name="moderated UVs", + verbose_name="author", ), ), ], diff --git a/pedagogy/models.py b/pedagogy/models.py index 3385337e..92474722 100644 --- a/pedagogy/models.py +++ b/pedagogy/models.py @@ -37,6 +37,12 @@ class UV(models.Model): Contains infos about an UV (course) """ + 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) + code = models.CharField( _("code"), max_length=10, @@ -50,17 +56,10 @@ class UV(models.Model): ) ], ) - moderator = models.ForeignKey( - User, - related_name="moderated_UVs", - verbose_name=_("moderated UVs"), - null=True, - blank=True, - ) author = models.ForeignKey( User, related_name="created_UVs", - verbose_name=_("created UVs"), + verbose_name=_("author"), null=False, blank=False, ) @@ -73,7 +72,7 @@ class UV(models.Model): manager = models.CharField(_("uv manager"), max_length=300) semester = models.CharField( _("semester"), - max_length=10, + max_length=20, choices=settings.SITH_PEDAGOGY_UV_SEMESTER, default=settings.SITH_PEDAGOGY_UV_SEMESTER[0][0], ) @@ -98,7 +97,7 @@ class UV(models.Model): objectives = models.TextField(_("objectives")) program = models.TextField(_("program")) skills = models.TextField(_("skills")) - key_concepts = models.TextField(_("key_concepts")) + 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 @@ -107,30 +106,35 @@ class UV(models.Model): 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, ) diff --git a/pedagogy/views.py b/pedagogy/views.py index 41cd6c08..e1e2f93d 100644 --- a/pedagogy/views.py +++ b/pedagogy/views.py @@ -23,8 +23,18 @@ # from django.views.generic import CreateView, DeleteView, DetailView, ListView, FormView +from django.core.urlresolvers import reverse_lazy -from core.views import DetailFormView +from core.views import ( + DetailFormView, + CanCreateMixin, + CanEditMixin, + CanViewMixin, + CanEditPropMixin, +) + +from pedagogy.forms import UVForm +from pedagogy.models import UV class UVDetailFormView(DetailFormView): @@ -76,12 +86,22 @@ class UVModerationFormView(FormView): pass -class UVCreateView(CreateView): +class UVCreateView(CanCreateMixin, CreateView): """ Add a new UV (Privileged) """ - pass + 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(DeleteView): diff --git a/sith/settings.py b/sith/settings.py index 39e0e517..643d01ca 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -322,6 +322,7 @@ SITH_GROUP_BANNED_COUNTER_ID = 9 SITH_GROUP_BANNED_SUBSCRIPTION_ID = 10 SITH_GROUP_SAS_ADMIN_ID = 11 SITH_GROUP_FORUM_ADMIN_ID = 12 +SITH_GROUP_PEDAGOGY_ADMIN_ID = 13 SITH_CLUB_REFOUND_ID = 89 @@ -408,9 +409,11 @@ SITH_PEDAGOGY_UV_TYPE = [ ("FREE", _("Free")), ("CS", _("CS")), ("TM", _("TM")), + ("OM", _("OM")), + ("QC", _("QC")), ("EC", _("EC")), - ("CG", _("CG")), ("RN", _("RN")), + ("ST", _("ST")), ("EXT", _("EXT")), ] From ec333117153e07288eb354458709cb8ac1a58892 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Sat, 15 Jun 2019 23:31:31 +0200 Subject: [PATCH 07/96] pedagogy: basic display list of UV --- core/management/commands/populate.py | 32 +++++++++++++++++++++++++ core/models.py | 4 ++++ core/templates/core/base.jinja | 2 +- pedagogy/models.py | 3 +++ pedagogy/templates/pedagogy/guide.jinja | 12 ++++++++++ pedagogy/views.py | 8 +++++-- 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 pedagogy/templates/pedagogy/guide.jinja diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 96aa1a8e..a97c6bc3 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -52,6 +52,7 @@ from counter.models import Customer, ProductType, Product, Counter, Selling, Stu from com.models import Sith, Weekmail, News, NewsDate from election.models import Election, Role, Candidature, ElectionList from forum.models import Forum, ForumTopic +from pedagogy.models import UV class Command(BaseCommand): @@ -1078,3 +1079,34 @@ Welcome to the wiki page! start_date=friday + timedelta(hours=24 * 7 * i), end_date=friday + timedelta(hours=24 * 7 * i + 8), ).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], + 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() diff --git a/core/models.py b/core/models.py index f96b7881..b1def45c 100644 --- a/core/models.py +++ b/core/models.py @@ -670,6 +670,10 @@ class AnonymousUser(AuthAnonymousUser): def was_subscribed(self): return False + @property + def is_subscribed(self): + return False + @property def subscribed(self): return False diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 8ff8b2e4..9d0e53cc 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -185,7 +185,7 @@ {% trans %}Matmatronch{% endtrans %} {% trans %}Launderette{% endtrans %} {% trans %}Files{% endtrans %} - {# {% trans %}Pedagogy{% endtrans %} #} + {% trans %}Pedagogy{% endtrans %}