Replaced total_result* fields by a total_result property
This commit is contained in:
parent
b46c377919
commit
5ef320455e
4 changed files with 39 additions and 8 deletions
|
|
@ -45,8 +45,7 @@ class CandidateAdmin(admin.ModelAdmin):
|
|||
list_filter = ('section', 'option')
|
||||
search_fields = ('last_name', 'city')
|
||||
readonly_fields = (
|
||||
'total_result_points', 'total_result_mark', 'confirmation_date',
|
||||
'convocation_date', 'candidate_actions',
|
||||
'total_result', 'confirmation_date', 'convocation_date', 'candidate_actions',
|
||||
)
|
||||
actions = [export_candidates]
|
||||
fieldsets = (
|
||||
|
|
@ -74,8 +73,7 @@ class CandidateAdmin(admin.ModelAdmin):
|
|||
('promise', 'contract', 'activity_rate'),
|
||||
('inscr_other_school',),
|
||||
('interview', 'examination_teacher'),
|
||||
('examination_result', 'interview_result', 'file_result', 'total_result_points',
|
||||
'total_result_mark'),
|
||||
('examination_result', 'interview_result', 'file_result', 'total_result'),
|
||||
('confirmation_date', 'validation_date', 'convocation_date'),
|
||||
),
|
||||
}),
|
||||
|
|
|
|||
19
candidats/migrations/0009_remove_total_fields.py
Normal file
19
candidats/migrations/0009_remove_total_fields.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('candidats', '0008_add_examination_teacher'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='candidate',
|
||||
name='total_result_mark',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='candidate',
|
||||
name='total_result_points',
|
||||
),
|
||||
]
|
||||
|
|
@ -109,8 +109,6 @@ class Candidate(models.Model):
|
|||
examination_result = models.PositiveSmallIntegerField('Points examen', blank=True, null=True)
|
||||
interview_result = models.PositiveSmallIntegerField('Points entretien prof.', blank=True, null=True)
|
||||
file_result = models.PositiveSmallIntegerField('Points dossier', blank=True, null=True)
|
||||
total_result_points = models.PositiveSmallIntegerField('Total points', blank=True, null=True)
|
||||
total_result_mark = models.PositiveSmallIntegerField('Note finale', blank=True, null=True)
|
||||
|
||||
inscr_other_school = models.CharField("Inscr. autre école", max_length=30, blank=True)
|
||||
certif_of_800_childhood = models.BooleanField("Attest. 800h. enfance", default=False)
|
||||
|
|
@ -152,6 +150,10 @@ class Candidate(models.Model):
|
|||
else:
|
||||
return '{0}, option «{1}»'.format(self.get_section_display(), self.get_option_display())
|
||||
|
||||
@property
|
||||
def total_result(self):
|
||||
return (self.examination_result or 0) + (self.interview_result or 0) + (self.file_result or 0)
|
||||
|
||||
def get_ok(self, fieldname):
|
||||
return 'OK' if getattr(self, fieldname) is True else 'NON'
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,21 @@ class CandidateTests(TestCase):
|
|||
'me', 'me@example.org', 'mepassword', first_name='Hans', last_name='Schmid',
|
||||
)
|
||||
|
||||
def test_total_result(self):
|
||||
ede = Section.objects.create(name='EDE')
|
||||
cand = Candidate(
|
||||
first_name='Henri', last_name='Dupond', gender='M', section=ede,
|
||||
email='henri@example.org', deposite_date=date.today()
|
||||
)
|
||||
self.assertEqual(cand.total_result, 0)
|
||||
cand.examination_result = 7
|
||||
cand.interview_result = 4
|
||||
cand.file_result = 5
|
||||
self.assertEqual(cand.total_result, 16)
|
||||
|
||||
def test_interview(self):
|
||||
inter = Interview.objects.create(date=datetime(2018, 3, 10, 10, 30), room='B103')
|
||||
self.assertEqual(str(inter), 'samedi 10 mars 2018 à 10h30 : ?/? - (N) -salle:B103-???')
|
||||
self.assertEqual(str(inter), 'samedi 10 mars 2018 à 10h30 : ? (Ent.) / ? (Dos.) - (N) -salle:B103-???')
|
||||
ede = Section.objects.create(name='EDE')
|
||||
cand = Candidate.objects.create(
|
||||
first_name='Henri', last_name='Dupond', gender='M', section=ede,
|
||||
|
|
@ -33,7 +45,7 @@ class CandidateTests(TestCase):
|
|||
inter.save()
|
||||
self.assertEqual(
|
||||
str(inter),
|
||||
'samedi 10 mars 2018 à 10h30 : JCA/JDU - (N) -salle:B103-Dupond Henri'
|
||||
'samedi 10 mars 2018 à 10h30 : JCA (Ent.) / JDU (Dos.) - (N) -salle:B103-Dupond Henri'
|
||||
)
|
||||
self.assertEqual(cand.interview, inter)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue