]> git.parisson.com Git - teleforma.git/commitdiff
add more period filters, reorganize tabs
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 25 Jun 2014 21:30:35 +0000 (23:30 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 25 Jun 2014 21:30:35 +0000 (23:30 +0200)
teleforma/exam/templates/exam/scripts.html
teleforma/exam/views.py
teleforma/templates/telemeta/base.html
teleforma/templatetags/teleforma_tags.py
teleforma/views/core.py

index 46131582e48ce557481f61a4b9ba6110ebe2e8cf..56aaa94ec1d78ffbd131642ea19b11833c8ad678 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 %}{% 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 %}{% 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.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-rejected period.id %}">{% trans "Rejected" %}</a></li>
   {% endblock courses %}
   </ul>
index de0ddc830aff652826175bc70ede1c43f1456838..d907ff0dfd640847a4c168e926fbbfee1a491ad9 100644 (file)
@@ -65,7 +65,8 @@ class ScriptsPendingView(ScriptsView):
 
     def get_queryset(self):
         user = self.request.user
-        scripts = Script.objects.filter(Q(status=3, author=user) | Q(status=3, corrector=user))
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        scripts = Script.objects.filter(Q(status=3, author=user, period=period) | Q(status=3, corrector=user, period=period))
         return scripts
 
     def get_context_data(self, **kwargs):
index a1fd6a88568d143c46f64bd4df0cee772fa60f1b..3b5e8f41d5646c0f25ca9c88f92e68e6fe243619 100644 (file)
@@ -96,7 +96,9 @@ alt="logo" />
       </ul>
     </li>
   {% else %}
-   <li><a href="{% url teleforma-home %}" class="red">{% trans "Desk" %}</a></li>
+  {% with periods.0 as period %}
+   <li><a href="{% url teleforma-desk-period-list period.id %}" class="red">{% trans "Desk" %}</a></li>
+  {% endwith %}
   {% endif %}
 
  {% else %}
@@ -107,33 +109,31 @@ alt="logo" />
 
  <li><a href="{% url postman_inbox %}" class="orange">{% trans "Messaging" %}{% if postman_unread_count %} ({{ postman_unread_count }}){% endif %}</a></li>
 
- {% if user.is_staff %}
-  <li><a href="{% url teleforma-users 0 0 0 %}" class="yellow">{% trans "Users" %}</a></li>
- {% else %}
   <li><a href="{% url teleforma-annals %}" class="yellow">{% trans "Annals" %}</a></li>
- {% endif %}
 
+  {% 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>
+   {% 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 %}
-     {% else %}{% treated_scripts_count user.username %}{% endif %}</a>
+     {% 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>
       <ul>
        {% for period in periods %}
         <li><a href="{% url teleforma-exam-scripts-pending period.id %}" class="green">{{ period.name }}</a></li>
        {% endfor %}
       </ul>
     </li>
+  {% endif %}
 
  {% if user.is_authenticated %}
   {% if user.is_staff %}
-   <li><a href="#archives#" class="green">{% trans "Archives" %}</a>
- <ul>
- <li><a href="{% url telemeta-search-criteria %}">{% trans "Search" %}</a></li>
- <li><a href="{% url telemeta-collections %}">{% trans "Collections" %}</a></li>
- <li><a href="{% url telemeta-items %}">{% trans "Items" %}</a></li>
- <li><a href="{% url teleforma-annals %}">{% trans "Annals" %}</a></li>
- </ul>
- </li>
- <li><a href="{% url telemeta-admin-general %}" class="blue">{% trans "Admin" %}</a></li>
+  <li><a href="{% url teleforma-users 0 0 0 %}" class="blue">{% trans "Users" %}</a></li>
+  <li><a href="{% url telemeta-admin-general %}" class="blue">{% trans "Admin" %}</a></li>
   {% else %}
    <li><a href="{% url teleforma-help %}" class="green">{% trans "Help" %}</a></li>
  {% endif %}
index 6d445e35e7d852abc39766f4dc4665ef49bf2bfb..35285b0708c949dd8f1f48a56506f9864ffbdff8 100644 (file)
@@ -209,18 +209,20 @@ def published(doc):
         return doc.filter(is_published=True)
 
 @register.simple_tag
-def untreated_scripts_count(username):
+def untreated_scripts_count(username, period_id):
     user = User.objects.get(username=username)
-    scripts = Script.objects.filter(Q(status=3, author=user) | Q(status=3, corrector=user))
+    period = Period.objects.get(id=period_id)
+    scripts = Script.objects.filter(Q(status=3, author=user, period=period) | Q(status=3, corrector=user, period=period))
     if scripts:
         return ' (' + str(len(scripts)) + ')'
     else:
         return ''
 
 @register.simple_tag
-def treated_scripts_count(username):
+def treated_scripts_count(username, period_id):
     user = User.objects.get(username=username)
-    scripts = Script.objects.filter(Q(status=4, author=user) | Q(status=4, corrector=user))
+    period = Period.objects.get(id=period_id)
+    scripts = Script.objects.filter(Q(status=4, author=user, period=period) | Q(status=4, corrector=user, period=period))
     if scripts:
         return ' (' + str(len(scripts)) + ')'
     else:
index da12fb9255034f877a5aaa6096ab19e36b90aa3e..eee33a7d223300b066af3b939535de7515f2adce 100644 (file)
@@ -173,7 +173,7 @@ def get_periods(user):
         periods = Period.objects.all()
 
     quotas = user.quotas.all()
-    if quotas:
+    if quotas and not (user.is_superuser or user.is_staff):
         periods = [quota.period for quota in quotas]
 
     return periods