From c884c92136eff7a73f8f5320ddb370f401c289e3 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 25 Jun 2014 23:30:35 +0200 Subject: [PATCH] add more period filters, reorganize tabs --- teleforma/exam/templates/exam/scripts.html | 4 +-- teleforma/exam/views.py | 3 +- teleforma/templates/telemeta/base.html | 32 +++++++++++----------- teleforma/templatetags/teleforma_tags.py | 10 ++++--- teleforma/views/core.py | 2 +- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/teleforma/exam/templates/exam/scripts.html b/teleforma/exam/templates/exam/scripts.html index 46131582..56aaa94e 100644 --- a/teleforma/exam/templates/exam/scripts.html +++ b/teleforma/exam/templates/exam/scripts.html @@ -22,8 +22,8 @@
diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index de0ddc83..d907ff0d 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -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): diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index a1fd6a88..3b5e8f41 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -96,7 +96,9 @@ alt="logo" /> {% else %} -
  • {% trans "Desk" %}
  • + {% with periods.0 as period %} +
  • {% trans "Desk" %}
  • + {% endwith %} {% endif %} {% else %} @@ -107,33 +109,31 @@ alt="logo" />
  • {% trans "Messaging" %}{% if postman_unread_count %} ({{ postman_unread_count }}){% endif %}
  • - {% if user.is_staff %} -
  • {% trans "Users" %}
  • - {% else %}
  • {% trans "Annals" %}
  • - {% endif %} + {% 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 %} +
  • + {% endwith %} + {% else %}
  •  {% trans "Scripts" %}  - {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username %} - {% else %}{% treated_scripts_count user.username %}{% endif %} + {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user.username period.id %} + {% else %}{% treated_scripts_count user.username period.id %}{% endif %}
  • + {% endif %} {% if user.is_authenticated %} {% if user.is_staff %} -
  • {% trans "Archives" %} - -
  • -
  • {% trans "Admin" %}
  • +
  • {% trans "Users" %}
  • +
  • {% trans "Admin" %}
  • {% else %}
  • {% trans "Help" %}
  • {% endif %} diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 6d445e35..35285b07 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -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: diff --git a/teleforma/views/core.py b/teleforma/views/core.py index da12fb92..eee33a7d 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -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 -- 2.39.5