From: Guillaume Pellerin Date: Wed, 25 Jun 2014 21:39:12 +0000 (+0200) Subject: simplify period assignment X-Git-Tag: 1.1~458 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6af4b6fcc5ff7f87cdb3bbd194de7f3ffaef16d6;p=teleforma.git simplify period assignment --- diff --git a/teleforma/exam/templates/exam/scripts.html b/teleforma/exam/templates/exam/scripts.html index 56aaa94e..f62357ad 100644 --- a/teleforma/exam/templates/exam/scripts.html +++ b/teleforma/exam/templates/exam/scripts.html @@ -22,8 +22,8 @@
diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index 3b5e8f41..9158d3b9 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -113,15 +113,15 @@ alt="logo" /> {% if periods|length == 1 %} {% with periods.0 as period %} -
  •  {% trans "Scripts" %}  - {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username period.id %} - {% else %}{% treated_scripts_count user.username period.id %}{% endif %} +
  •  {% trans "Scripts" %}  + {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user period %} + {% else %}{% treated_scripts_count user period %}{% endif %}
  • {% endwith %} {% else %}
  •  {% trans "Scripts" %}  - {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username period.id %} - {% else %}{% treated_scripts_count user.username period.id %}{% endif %} + {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user period %} + {% else %}{% treated_scripts_count user period %}{% endif %}
      {% for period in periods %}
    • {{ period.name }}
    • diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 35285b07..bd1a596f 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -209,9 +209,7 @@ def published(doc): return doc.filter(is_published=True) @register.simple_tag -def untreated_scripts_count(username, period_id): - user = User.objects.get(username=username) - period = Period.objects.get(id=period_id) +def untreated_scripts_count(user, period): scripts = Script.objects.filter(Q(status=3, author=user, period=period) | Q(status=3, corrector=user, period=period)) if scripts: return ' (' + str(len(scripts)) + ')' @@ -219,9 +217,7 @@ def untreated_scripts_count(username, period_id): return '' @register.simple_tag -def treated_scripts_count(username, period_id): - user = User.objects.get(username=username) - period = Period.objects.get(id=period_id) +def treated_scripts_count(user, period): scripts = Script.objects.filter(Q(status=4, author=user, period=period) | Q(status=4, corrector=user, period=period)) if scripts: return ' (' + str(len(scripts)) + ')'