Ajout formulaire de commentaire élève
This commit is contained in:
parent
29d5f6e310
commit
703c217ec2
8 changed files with 133 additions and 5 deletions
|
|
@ -32,6 +32,7 @@ urlpatterns = [
|
|||
path('classes/<int:pk>/import_reports/', views.ImportReportsView.as_view(),
|
||||
name='import-reports'),
|
||||
path('classes/print_klass_list/', views.PrintKlassList.as_view(), name='print-klass-list'),
|
||||
path('student/<int:pk>/comment/', views.StudentCommentView.as_view(), name='student-comment'),
|
||||
|
||||
path('candidate/<int:pk>/send_convocation/', candidats_views.ConvocationView.as_view(),
|
||||
name='candidate-convocation'),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from django.urls import reverse
|
|||
from django.utils.html import format_html
|
||||
|
||||
from .models import (
|
||||
Teacher, Option, Student, Section, Level, Klass, Corporation,
|
||||
Teacher, Option, Student, StudentFile, Section, Level, Klass, Corporation,
|
||||
CorpContact, Domain, Period, Availability, Training, Course,
|
||||
LogBookReason, LogBook, ExamEDESession, SupervisionBill
|
||||
)
|
||||
|
|
@ -329,6 +329,7 @@ admin.site.register(Level)
|
|||
admin.site.register(Klass, KlassAdmin)
|
||||
admin.site.register(Option)
|
||||
admin.site.register(Student, StudentAdmin)
|
||||
admin.site.register(StudentFile)
|
||||
admin.site.register(Teacher, TeacherAdmin)
|
||||
admin.site.register(Course, CourseAdmin)
|
||||
admin.site.register(Corporation, CorporationAdmin)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ from django import forms
|
|||
from django.contrib.admin.widgets import AutocompleteSelect
|
||||
from django.db import transaction
|
||||
from django.db.models.deletion import Collector
|
||||
from django.forms import inlineformset_factory
|
||||
from django.urls import reverse
|
||||
|
||||
from tabimport import FileFactory, UnsupportedFileFormat
|
||||
|
||||
from .models import Corporation, Section, Period
|
||||
from .models import Corporation, Period, Section, Student, StudentFile
|
||||
|
||||
|
||||
class StudentImportForm(forms.Form):
|
||||
|
|
@ -113,3 +114,24 @@ class CorporationMergeForm(forms.Form):
|
|||
).update(corporation=self.cleaned_data['corp_merge_to'])
|
||||
check_no_links(self.cleaned_data['corp_merge_from'])
|
||||
self.cleaned_data['corp_merge_from'].delete()
|
||||
|
||||
|
||||
class StudentCommentForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Student
|
||||
fields = ('mc_comment',)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
FilesFormSet = inlineformset_factory(self._meta.model, StudentFile, fields='__all__', extra=1)
|
||||
self.files_fset = FilesFormSet(
|
||||
instance=self.instance, data=kwargs.get('data'), files=kwargs.get('files')
|
||||
)
|
||||
|
||||
def is_valid(self):
|
||||
return all([super().is_valid(), self.files_fset.is_valid()])
|
||||
|
||||
def save(self, **kwargs):
|
||||
obj = super().save(**kwargs)
|
||||
self.files_fset.save()
|
||||
return obj
|
||||
|
|
|
|||
25
stages/migrations/0018_student_comments.py
Normal file
25
stages/migrations/0018_student_comments.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stages', '0017_add_login_field_for_student'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='StudentFile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('student', models.ForeignKey(on_delete=models.deletion.CASCADE, to='stages.Student')),
|
||||
('fichier', models.FileField(upload_to='etudiants')),
|
||||
('titre', models.CharField(max_length=200, verbose_name='Titre')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='student',
|
||||
name='mc_comment',
|
||||
field=models.TextField(blank=True, verbose_name='Commentaires'),
|
||||
),
|
||||
]
|
||||
|
|
@ -307,6 +307,8 @@ class Student(models.Model):
|
|||
date_soutenance_mailed = models.DateTimeField("Convoc. env.", blank=True, null=True)
|
||||
date_confirm_received = models.DateTimeField("Récept. confirm", blank=True, null=True)
|
||||
# ============== Fields for examination ======================
|
||||
mc_comment = models.TextField("Commentaires", blank=True)
|
||||
|
||||
support_tabimport = True
|
||||
|
||||
class Meta:
|
||||
|
|
@ -369,6 +371,15 @@ class Student(models.Model):
|
|||
return missing
|
||||
|
||||
|
||||
class StudentFile(models.Model):
|
||||
student = models.ForeignKey(Student, on_delete=models.CASCADE)
|
||||
fichier = models.FileField(upload_to='etudiants')
|
||||
titre = models.CharField("Titre", max_length=200)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class Corporation(models.Model):
|
||||
ext_id = models.IntegerField(null=True, blank=True, verbose_name='ID externe')
|
||||
name = models.CharField(max_length=100, verbose_name='Nom')
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ from django.urls import reverse, reverse_lazy
|
|||
from django.utils import timezone
|
||||
from django.utils.dateformat import format as django_format
|
||||
from django.utils.text import slugify
|
||||
from django.views.generic import DetailView, FormView, TemplateView, ListView
|
||||
from django.views.generic import DetailView, FormView, ListView, TemplateView, UpdateView
|
||||
|
||||
from .base import EmailConfirmationBaseView, ZippedFilesBaseView
|
||||
from .export import OpenXMLExport
|
||||
from .imports import HPContactsImportView, HPImportView, ImportReportsView, StudentImportView
|
||||
from ..forms import CorporationMergeForm, EmailBaseForm
|
||||
from ..forms import CorporationMergeForm, EmailBaseForm, StudentCommentForm
|
||||
from ..models import (
|
||||
Klass, Section, Student, Teacher, Corporation, CorpContact, Period,
|
||||
Training, Availability
|
||||
|
|
@ -149,6 +149,18 @@ class KlassView(DetailView):
|
|||
return export.get_http_response('%s_export' % self.object.name.replace(' ', '_'))
|
||||
|
||||
|
||||
class StudentCommentView(UpdateView):
|
||||
template_name = 'student_comment.html'
|
||||
model = Student
|
||||
form_class = StudentCommentForm
|
||||
|
||||
def get_success_url(self):
|
||||
messages.success(
|
||||
self.request, "L'enregistrement des commentaires pour %s a réussi." % self.object
|
||||
)
|
||||
return reverse('class', args=[self.object.klass.pk])
|
||||
|
||||
|
||||
class AttributionView(TemplateView):
|
||||
"""
|
||||
Base view for the attribution screen. Populate sections and referents.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
</thead>
|
||||
{% for student in students %}
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
<td><a href="{% url 'admin:stages_student_change' student.pk %}">{{ student }}</a></td>
|
||||
<td><a href="{% url 'student-comment' student.pk %}">{{ student }}</a></td>
|
||||
<td>{{ student.birth_date }}</td>
|
||||
{% if show_option_ase %}
|
||||
<td>{{ student.option_ase|default_if_none:'-' }}</td>
|
||||
|
|
|
|||
56
templates/student_comment.html
Normal file
56
templates/student_comment.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block extrastyle %}{{ block.super }}
|
||||
<style>
|
||||
span.label { font-weight: bold; }
|
||||
div.block { width: 45%; display: inline-block; vertical-align: top; }
|
||||
textarea { width: 90%; }
|
||||
button.button { padding: 10px 15px; }
|
||||
fieldset { border: 1px solid #ccc; padding: 8px; }
|
||||
fieldset p { margin: 0; }
|
||||
input[name$='titre'] { width: 40em; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="{% url 'admin:index' %}">Accueil</a>
|
||||
› <a href="{% url 'classes' %}">Liste des classes</a>
|
||||
› <a href="{% url 'class' student.klass.pk %}">{{ student.klass.name }}</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{{ student }}
|
||||
{% if perms.stages.change_student %}<a class="changelink" href="{% url 'admin:stages_student_change' student.pk %}"> </a>{% endif %}
|
||||
</h2>
|
||||
|
||||
<div class="block">
|
||||
<table>
|
||||
<tr><td><span class="label">Date de naissance :</span></td><td>{{ student.birth_date }}</td></tr>
|
||||
<tr><td><span class="label">Adresse :</span></td><td>{{ student.street }}, {{ student.pcode }} {{ student.city }} {{ student.district }}</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="block">
|
||||
<table>
|
||||
<tr><td><span class="label">Courriel :</span></td><td>{{ student.email }}</td></tr>
|
||||
<tr><td><span class="label">Tél :</span></td><td>{{ student.tel }}</td></tr>
|
||||
<tr><td><span class="label">Portable :</span></td><td>{{ student.mobile }}</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
{% if student.option_ase %}
|
||||
<div class="block"><span class="label">Orientation :</span> {{ student.option_ase }}</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="." enctype="multipart/form-data">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
|
||||
{{ form.files_fset.management_form }}
|
||||
{% for frm in form.files_fset %}
|
||||
<fieldset>{{ frm.as_p }}</fieldset>
|
||||
{% endfor %}
|
||||
<button class="button" type="submit">Enregistrer</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue