]> git.parisson.com Git - teleforma.git/commitdiff
simplify period assignment
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 25 Jun 2014 21:39:12 +0000 (23:39 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 25 Jun 2014 21:39:12 +0000 (23:39 +0200)
teleforma/exam/templates/exam/scripts.html
teleforma/templates/telemeta/base.html
teleforma/templatetags/teleforma_tags.py

index 56aaa94ec1d78ffbd131642ea19b11833c8ad678..f62357ad06a7dc5cca77ae814ff45356282b5853 100644 (file)
@@ -22,8 +22,8 @@
  <div style="background: white;">
   <ul>
   {% block courses %}
-   <li><a href="{% url teleforma-exam-scripts-pending period.id %}">{% trans "Pending" %}{% if user.is_staff or user.quotass.all %}{% untreated_scripts_count user.username period.id %}{% endif %}</a></li>
-   <li><a href="{% url teleforma-exam-scripts-treated period.id %}">{% trans "Marked" %}{% if not user.is_staff and not user.quotas.all %}{% treated_scripts_count user.username period.id %}{% endif %}</a></li>
+   <li><a href="{% url teleforma-exam-scripts-pending period.id %}">{% trans "Pending" %}{% if user.is_staff or user.quotass.all %}{% untreated_scripts_count user period %}{% endif %}</a></li>
+   <li><a href="{% url teleforma-exam-scripts-treated period.id %}">{% trans "Marked" %}{% if not user.is_staff and not user.quotas.all %}{% treated_scripts_count user period %}{% endif %}</a></li>
    <li><a href="{% url teleforma-exam-scripts-rejected period.id %}">{% trans "Rejected" %}</a></li>
   {% endblock courses %}
   </ul>
index 3b5e8f41d5646c0f25ca9c88f92e68e6fe243619..9158d3b924e51bfd77ef670031109dfa08ffcd15 100644 (file)
@@ -113,15 +113,15 @@ alt="logo" />
 
   {% if periods|length == 1 %}
    {% with periods.0 as period %}
-      <li><a href="{% url teleforma-exam-scripts-pending period.id %}" class="green">&nbsp;{% trans "Scripts" %}&nbsp;
-      {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username period.id %}
-     {% else %}{% treated_scripts_count user.username period.id %}{% endif %}</a>
+      <li><a href="{% url teleforma-exam-scripts-pending period %}" class="green">&nbsp;{% trans "Scripts" %}&nbsp;
+      {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user period %}
+     {% else %}{% treated_scripts_count user period %}{% endif %}</a>
      </li>
    {% endwith %}
   {% else %}
     <li><a href="#scripts#" class="green">&nbsp;{% trans "Scripts" %}&nbsp;
-     {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username period.id %}
-     {% else %}{% treated_scripts_count user.username period.id %}{% endif %}</a>
+     {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user period %}
+     {% else %}{% treated_scripts_count user period %}{% endif %}</a>
       <ul>
        {% for period in periods %}
         <li><a href="{% url teleforma-exam-scripts-pending period.id %}" class="green">{{ period.name }}</a></li>
index 35285b0708c949dd8f1f48a56506f9864ffbdff8..bd1a596ff2d9e3b67b6ca90e9108500236d92b90 100644 (file)
@@ -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)) + ')'