<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>
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):
</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 %}
<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"> {% 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 %}</a>
+ </li>
+ {% endwith %}
+ {% else %}
<li><a href="#scripts#" class="green"> {% trans "Scripts" %}
- {% 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 %}
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:
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