Merge branch 'Elarnon/petitscours_app' into 'master'

Extrait les petits cours dans une application séparée

See merge request klub-dev-ens/gestioCOF!331
This commit is contained in:
Martin Pepin 2018-11-26 23:00:56 +01:00
commit d58d08a4d4
27 changed files with 112 additions and 113 deletions

View file

@ -68,6 +68,7 @@ INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.admindocs",
"bda",
"petitscours",
"captcha",
"django_cas_ng",
"bootstrapform",

View file

@ -20,7 +20,6 @@ from gestioncof.urls import (
clubs_patterns,
events_patterns,
export_patterns,
petitcours_patterns,
surveys_patterns,
)
@ -34,7 +33,7 @@ urlpatterns = [
# Les exports
url(r"^export/", include(export_patterns)),
# Les petits cours
url(r"^petitcours/", include(petitcours_patterns)),
url(r"^petitcours/", include("petitscours.urls")),
# Les sondages
url(r"^survey/", include(surveys_patterns)),
# Evenements

View file

@ -7,6 +7,13 @@ from django.core.urlresolvers import reverse
from django.db.models import Q
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from petitscours.models import (
PetitCoursAbility,
PetitCoursAttribution,
PetitCoursAttributionCounter,
PetitCoursDemande,
PetitCoursSubject,
)
from gestioncof.models import (
Club,
@ -20,13 +27,6 @@ from gestioncof.models import (
SurveyQuestion,
SurveyQuestionAnswer,
)
from gestioncof.petits_cours_models import (
PetitCoursAbility,
PetitCoursAttribution,
PetitCoursAttributionCounter,
PetitCoursDemande,
PetitCoursSubject,
)
def add_link_field(target_model="", field="", link_text=str, desc_text=str):

View file

@ -12,15 +12,15 @@ import random
from django.contrib.auth.models import User
from django.core.management import call_command
from gestioncof.management.base import MyBaseCommand
from gestioncof.petits_cours_models import (
from petitscours.models import (
LEVELS_CHOICES,
PetitCoursAbility,
PetitCoursAttributionCounter,
PetitCoursSubject,
)
from gestioncof.management.base import MyBaseCommand
# Où sont stockés les fichiers json
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")

View file

@ -3,9 +3,9 @@ from django.db import models
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from petitscours.models import choices_length
from bda.models import Spectacle
from gestioncof.petits_cours_models import choices_length
TYPE_COMMENT_FIELD = (("text", _("Texte long")), ("char", _("Texte court")))

View file

@ -15,7 +15,7 @@ def messages_on_out_login(request, user, **kwargs):
@receiver(cas_user_authenticated)
def mesagges_on_cas_login(request, user, **kwargs):
def messages_on_cas_login(request, user, **kwargs):
msg = _("Connexion à GestioCOF par CAS réussie. Bienvenue {}.").format(
user.get_short_name()
)

View file

@ -1,15 +1,4 @@
import os
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.management import call_command
from gestioncof.petits_cours_models import (
PetitCoursAbility,
PetitCoursAttributionCounter,
PetitCoursDemande,
PetitCoursSubject,
)
User = get_user_model()
@ -77,31 +66,3 @@ def create_root(username, attrs=None):
attrs.setdefault("is_staff", True)
attrs.setdefault("is_superuser", True)
return _create_user(username, attrs=attrs)
def create_petitcours_ability(**kwargs):
if "user" not in kwargs:
kwargs["user"] = create_user()
if "matiere" not in kwargs:
kwargs["matiere"] = create_petitcours_subject()
if "niveau" not in kwargs:
kwargs["niveau"] = "college"
ability = PetitCoursAbility.objects.create(**kwargs)
PetitCoursAttributionCounter.get_uptodate(ability.user, ability.matiere)
return ability
def create_petitcours_demande(**kwargs):
return PetitCoursDemande.objects.create(**kwargs)
def create_petitcours_subject(**kwargs):
return PetitCoursSubject.objects.create(**kwargs)
class PetitCoursTestHelpers:
def require_custommails(self):
data_file = os.path.join(
settings.BASE_DIR, "gestioncof", "management", "data", "custommail.json"
)
call_command("syncmails", data_file, verbosity=0)

View file

@ -1,8 +1,7 @@
from django.conf.urls import url
from gestioncof import petits_cours_views, views
from gestioncof import views
from gestioncof.decorators import buro_required
from gestioncof.petits_cours_views import DemandeDetailView, DemandeListView
export_patterns = [
url(r"^members$", views.export_members, name="cof.membres_export"),
@ -21,40 +20,6 @@ export_patterns = [
url(r"^mega$", views.export_mega, name="cof.mega_export"),
]
petitcours_patterns = [
url(
r"^inscription$",
petits_cours_views.inscription,
name="petits-cours-inscription",
),
url(r"^demande$", petits_cours_views.demande, name="petits-cours-demande"),
url(
r"^demande-raw$",
petits_cours_views.demande_raw,
name="petits-cours-demande-raw",
),
url(
r"^demandes$",
buro_required(DemandeListView.as_view()),
name="petits-cours-demandes-list",
),
url(
r"^demandes/(?P<pk>\d+)$",
buro_required(DemandeDetailView.as_view()),
name="petits-cours-demande-details",
),
url(
r"^demandes/(?P<demande_id>\d+)/traitement$",
petits_cours_views.traitement,
name="petits-cours-demande-traitement",
),
url(
r"^demandes/(?P<demande_id>\d+)/retraitement$",
petits_cours_views.retraitement,
name="petits-cours-demande-retraitement",
),
]
surveys_patterns = [
url(
r"^(?P<survey_id>\d+)/status$",

0
petitscours/__init__.py Normal file
View file

View file

@ -3,8 +3,7 @@ from django import forms
from django.contrib.auth.models import User
from django.forms import ModelForm
from django.forms.models import BaseInlineFormSet, inlineformset_factory
from gestioncof.petits_cours_models import PetitCoursAbility, PetitCoursDemande
from petitscours.models import PetitCoursAbility, PetitCoursDemande
class BaseMatieresFormSet(BaseInlineFormSet):

View file

@ -27,6 +27,7 @@ class PetitCoursSubject(models.Model):
)
class Meta:
app_label = "gestioncof"
verbose_name = "Matière de petits cours"
verbose_name_plural = "Matières des petits cours"
@ -45,6 +46,7 @@ class PetitCoursAbility(models.Model):
agrege = models.BooleanField(_("Agrégé"), default=False)
class Meta:
app_label = "gestioncof"
verbose_name = "Compétence petits cours"
verbose_name_plural = "Compétences des petits cours"
@ -127,6 +129,7 @@ class PetitCoursDemande(models.Model):
yield (matiere, candidates)
class Meta:
app_label = "gestioncof"
verbose_name = "Demande de petits cours"
verbose_name_plural = "Demandes de petits cours"
@ -147,6 +150,7 @@ class PetitCoursAttribution(models.Model):
selected = models.BooleanField(_("Sélectionné par le demandeur"), default=False)
class Meta:
app_label = "gestioncof"
verbose_name = "Attribution de petits cours"
verbose_name_plural = "Attributions de petits cours"
@ -182,6 +186,7 @@ class PetitCoursAttributionCounter(models.Model):
return counter
class Meta:
app_label = "gestioncof"
verbose_name = "Compteur d'attribution de petits cours"
verbose_name_plural = "Compteurs d'attributions de petits cours"

View file

@ -1,11 +1,11 @@
{% extends "base_title_petitscours.html" %}
{% extends "petitscours/base_title.html" %}
{% load staticfiles %}
{% block page_size %}col-sm-8{% endblock %}
{% block realcontent %}
<h2>Demande de petits cours</h2>
{% include "details_demande_petit_cours_infos.html" %}
{% include "petitscours/details_demande_infos.html" %}
<hr />
<table class="table table-striped">
<tr><td><strong>Traitée</strong></td><td> <img src="{% if demande.traitee %}{% static "images/yes.png" %}{% else %}{% static "images/no.png" %}{% endif %}" /></td></tr>

View file

@ -1,4 +1,4 @@
{% extends "base_title_petitscours.html" %}
{% extends "petitscours/base_title.html" %}
{% load staticfiles %}
{% block realcontent %}

View file

@ -94,7 +94,7 @@ var django = {
<form class="form-horizontal petit-cours_form" id="bda_form" method="post" action="{% url 'petits-cours-inscription' %}">
{% csrf_token %}
<div class="table-top" style="margin-left:0px; margin-right:0px; font-size: 1.25em; font-weight: bold; color: #DE826B;"><input type="checkbox" name="receive_proposals" {% if receive_proposals %}checked="checked"{% endif %} /> Recevoir des propositions de petits cours</div>
{% include "inscription-petit-cours-formset.html" %}
{% include "petitscours/inscription_formset.html" %}
<div class="inscription-bottom">
<input type="button" class="btn btn-default pull-right" value="Ajouter une autre matière" id="add_more" />
<script>

View file

@ -1,8 +1,8 @@
{% extends "base_title_petitscours.html" %}
{% extends "petitscours/base_title.html" %}
{% block realcontent %}
<h2>Traitement de la demande de petits cours {{ demande.id }}</h2>
{% include "details_demande_petit_cours_infos.html" %}
{% include "petitscours/details_demande_infos.html" %}
<hr />
{% if errors %}
<div class="error">

View file

@ -1,9 +1,9 @@
{% extends "base_title_petitscours.html" %}
{% extends "petitscours/base_title.html" %}
{% load staticfiles %}
{% block realcontent %}
<h2>Traitement de la demande de petits cours {{ demande.id }}</h2>
{% include "details_demande_petit_cours_infos.html" %}
{% include "petitscours/details_demande_infos.html" %}
<hr />
<div class="error">
Attention: demande de petits cours spécifiant le niveau "Autre niveau": choisissez les candidats correspondant aux remarques de la demande. S'il y a moins de 3 candidats adaptés, ne mettre que ceux qui conviennent, pas besoin de faire du bourrage :)

View file

@ -1,4 +1,4 @@
{% extends "base_title_petitscours.html" %}
{% extends "petitscours/base_title.html" %}
{% block realcontent %}
<h2>Traitement de la demande de petits cours {{ demande.id }}</h2>

View file

View file

@ -0,0 +1,38 @@
import os
from django.conf import settings
from django.core.management import call_command
from petitscours.models import (
PetitCoursAbility,
PetitCoursAttributionCounter,
PetitCoursDemande,
PetitCoursSubject,
)
def create_petitcours_ability(**kwargs):
if "user" not in kwargs:
kwargs["user"] = create_user()
if "matiere" not in kwargs:
kwargs["matiere"] = create_petitcours_subject()
if "niveau" not in kwargs:
kwargs["niveau"] = "college"
ability = PetitCoursAbility.objects.create(**kwargs)
PetitCoursAttributionCounter.get_uptodate(ability.user, ability.matiere)
return ability
def create_petitcours_demande(**kwargs):
return PetitCoursDemande.objects.create(**kwargs)
def create_petitcours_subject(**kwargs):
return PetitCoursSubject.objects.create(**kwargs)
class PetitCoursTestHelpers:
def require_custommails(self):
data_file = os.path.join(
settings.BASE_DIR, "gestioncof", "management", "data", "custommail.json"
)
call_command("syncmails", data_file, verbosity=0)

31
petitscours/urls.py Normal file
View file

@ -0,0 +1,31 @@
from django.conf.urls import url
from petitscours import views
from petitscours.views import DemandeDetailView, DemandeListView
from gestioncof.decorators import buro_required
urlpatterns = [
url(r"^inscription$", views.inscription, name="petits-cours-inscription"),
url(r"^demande$", views.demande, name="petits-cours-demande"),
url(r"^demande-raw$", views.demande_raw, name="petits-cours-demande-raw"),
url(
r"^demandes$",
buro_required(DemandeListView.as_view()),
name="petits-cours-demandes-list",
),
url(
r"^demandes/(?P<pk>\d+)$",
buro_required(DemandeDetailView.as_view()),
name="petits-cours-demande-details",
),
url(
r"^demandes/(?P<demande_id>\d+)/traitement$",
views.traitement,
name="petits-cours-demande-traitement",
),
url(
r"^demandes/(?P<demande_id>\d+)/retraitement$",
views.retraitement,
name="petits-cours-demande-retraitement",
),
]

View file

@ -11,23 +11,23 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import DetailView, ListView
from gestioncof.decorators import buro_required
from gestioncof.models import CofProfile
from gestioncof.petits_cours_forms import DemandeForm, MatieresFormSet
from gestioncof.petits_cours_models import (
from petitscours.forms import DemandeForm, MatieresFormSet
from petitscours.models import (
PetitCoursAbility,
PetitCoursAttribution,
PetitCoursAttributionCounter,
PetitCoursDemande,
)
from gestioncof.decorators import buro_required
from gestioncof.models import CofProfile
class DemandeListView(ListView):
queryset = PetitCoursDemande.objects.prefetch_related("matieres").order_by(
"traitee", "-id"
)
template_name = "petits_cours_demandes_list.html"
template_name = "petitscours/demande_list.html"
paginate_by = 20
@ -36,7 +36,7 @@ class DemandeDetailView(DetailView):
queryset = PetitCoursDemande.objects.prefetch_related(
"petitcoursattribution_set", "matieres"
)
template_name = "gestioncof/details_demande_petit_cours.html"
template_name = "petitscours/demande_detail.html"
context_object_name = "demande"
def get_context_data(self, **kwargs):
@ -122,7 +122,7 @@ def _finalize_traitement(
messages.error(request, error)
return render(
request,
"gestioncof/traitement_demande_petit_cours.html",
"petitscours/traitement_demande.html",
{
"demande": demande,
"unsatisfied": unsatisfied,
@ -250,7 +250,7 @@ def _traitement_other(request, demande, redo):
proposed_for = proposed_for.items()
return render(
request,
"gestioncof/traitement_demande_petit_cours_autre_niveau.html",
"petitscours/traitement_demande_autre_niveau.html",
{
"demande": demande,
"unsatisfied": unsatisfied,
@ -332,7 +332,7 @@ def _traitement_post(request, demande):
demande.save()
return render(
request,
"gestioncof/traitement_demande_petit_cours_success.html",
"petitscours/traitement_demande_success.html",
{"demande": demande, "redo": redo},
)
@ -362,7 +362,7 @@ def inscription(request):
formset = MatieresFormSet(instance=request.user)
return render(
request,
"inscription-petit-cours.html",
"petitscours/inscription.html",
{
"formset": formset,
"success": success,
@ -383,7 +383,7 @@ def demande(request):
else:
form = DemandeForm()
return render(
request, "demande-petit-cours.html", {"form": form, "success": success}
request, "petitscours/demande.html", {"form": form, "success": success}
)
@ -398,5 +398,5 @@ def demande_raw(request):
else:
form = DemandeForm()
return render(
request, "demande-petit-cours-raw.html", {"form": form, "success": success}
request, "petitscours/demande_raw.html", {"form": form, "success": success}
)