Style and PEP8
- Drop `%` in favour of `.format` which has a better specification - Remove a string concatenation - Remove the trailing slashes according to the PEP8: https://www.python.org/dev/peps/pep-0008/#maximum-line-length NB. We let some which will disappear in the next commit. - Remove an unused import and change the imports order
This commit is contained in:
parent
bb4e9dde4f
commit
2bc5f3d646
2 changed files with 36 additions and 28 deletions
|
@ -1,5 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.core import mail
|
||||
from django.core.mail import EmailMessage
|
||||
|
@ -16,18 +19,15 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.db.models import Min
|
||||
|
||||
from gestioncof.models import CofProfile
|
||||
from gestioncof.petits_cours_models import PetitCoursDemande, \
|
||||
PetitCoursAttribution, PetitCoursAttributionCounter, PetitCoursAbility, \
|
||||
PetitCoursSubject
|
||||
from gestioncof.petits_cours_models import (
|
||||
PetitCoursDemande, PetitCoursAttribution, PetitCoursAttributionCounter,
|
||||
PetitCoursAbility, PetitCoursSubject
|
||||
)
|
||||
from gestioncof.decorators import buro_required
|
||||
from gestioncof.shared import lock_table, unlock_tables
|
||||
|
||||
from captcha.fields import ReCaptchaField
|
||||
|
||||
from datetime import datetime
|
||||
import base64
|
||||
import json
|
||||
|
||||
|
||||
class DemandeListView(ListView):
|
||||
model = PetitCoursDemande
|
||||
|
@ -174,17 +174,19 @@ def _traitement_other_preparing(request, demande):
|
|||
proposals[matiere] = []
|
||||
for choice_id in range(min(3, len(candidates))):
|
||||
choice = int(
|
||||
request.POST["proposal-%d-%d" % (matiere.id, choice_id)])
|
||||
request.POST["proposal-{:d}-{:d}"
|
||||
.format(matiere.id, choice_id)]
|
||||
)
|
||||
if choice == -1:
|
||||
continue
|
||||
if choice not in candidates:
|
||||
errors.append("Choix invalide pour la proposition %d"
|
||||
"en %s" % (choice_id + 1, matiere))
|
||||
errors.append("Choix invalide pour la proposition {:d}"
|
||||
"en {!s}".format(choice_id + 1, matiere))
|
||||
continue
|
||||
user = candidates[choice]
|
||||
if user in proposals[matiere]:
|
||||
errors.append("La proposition %d en %s est un doublon"
|
||||
% (choice_id + 1, matiere))
|
||||
errors.append("La proposition {:d} en {!s} est un doublon"
|
||||
.format(choice_id + 1, matiere))
|
||||
continue
|
||||
proposals[matiere].append(user)
|
||||
attribdata[matiere.id].append(user.id)
|
||||
|
@ -193,12 +195,13 @@ def _traitement_other_preparing(request, demande):
|
|||
else:
|
||||
proposed_for[user].append(matiere)
|
||||
if not proposals[matiere]:
|
||||
errors.append("Aucune proposition pour %s" % (matiere,))
|
||||
errors.append("Aucune proposition pour {!s}".format(matiere))
|
||||
elif len(proposals[matiere]) < 3:
|
||||
errors.append("Seulement %d proposition%s pour %s"
|
||||
% (len(proposals[matiere]),
|
||||
"s" if len(proposals[matiere]) > 1 else "",
|
||||
matiere))
|
||||
errors.append("Seulement {:d} proposition{:s} pour {!s}"
|
||||
.format(
|
||||
len(proposals[matiere]),
|
||||
"s" if len(proposals[matiere]) > 1 else "",
|
||||
matiere))
|
||||
else:
|
||||
unsatisfied.append(matiere)
|
||||
return _finalize_traitement(request, demande, proposals, proposed_for,
|
||||
|
@ -350,8 +353,9 @@ def inscription(request):
|
|||
profile.save()
|
||||
lock_table(PetitCoursAttributionCounter, PetitCoursAbility, User,
|
||||
PetitCoursSubject)
|
||||
abilities = PetitCoursAbility.objects \
|
||||
.filter(user=request.user).all()
|
||||
abilities = (
|
||||
PetitCoursAbility.objects.filter(user=request.user).all()
|
||||
)
|
||||
for ability in abilities:
|
||||
_get_attrib_counter(ability.user, ability.matiere)
|
||||
unlock_tables()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue