]> git.parisson.com Git - teleforma.git/commitdiff
add "Read" script status (5), update queries
authorGuillaume Pellerin <yomguy@parisson.com>
Sun, 29 Jun 2014 22:09:41 +0000 (00:09 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Sun, 29 Jun 2014 22:09:41 +0000 (00:09 +0200)
teleforma/exam/models.py
teleforma/exam/templates/exam/inc/script_list.html
teleforma/exam/views.py
teleforma/templates/telemeta/base.html
teleforma/templatetags/teleforma_tags.py

index 376eb36a736ea9a15928a2312c08636a0ae60605..98b8e10944aaaf33bc6edc5fc2899f83a882ccdd 100644 (file)
@@ -58,7 +58,7 @@ import crocodoc
 crocodoc.api_token = settings.BOX_API_TOKEN
 
 SCRIPT_STATUS = ((0, _('rejected')), (1, _('draft')), (2, _('submitted')),
-                (3, _('pending')),(4, _('marked')) )
+                (3, _('pending')),(4, _('marked')), (5, _('read')) )
 REJECT_REASON = ((1, _('unreadable')),
                 (2, _('bad orientation')), (3, _('bad framing')), (4, _('incomplete')),)
 
@@ -281,7 +281,10 @@ class Script(BaseResource):
     def submit(self):
         self.date_submitted = datetime.datetime.now()
         self.url = settings.MEDIA_URL + unicode(self.file)
-        self.box_uuid = crocodoc.document.upload(url=self.url)
+        try:
+            self.box_uuid = crocodoc.document.upload(url=self.url)
+        except:
+            pass
         if not self.corrector:
             self.auto_set_corrector()
 
index 33bfaf29b7d5c33abf098bf817c199b7265071a2..6d544bf829d4913c6eeffb19ebcd82aa49ac4ca0 100644 (file)
@@ -23,7 +23,7 @@
     </thead>
     <tbody id="spacing">
     {% for script in object_list %}
-    <tr>
+    <tr style="font-weight: bold;">
     <td><a href="{% url teleforma-exam-script-detail period.id script.id %}">{{ script.course.title }}</a></td>
      <td><a href="{% url teleforma-exam-script-detail period.id script.id %}">{{ script.session }}</a></td>
      <td><a href="{% url teleforma-exam-script-detail period.id script.id %}">{{ script.type }}</a></td>
index d907ff0dfd640847a4c168e926fbbfee1a491ad9..486743eceb9a8a6d8332ed151fe8ffa35ca6d97a 100644 (file)
@@ -39,6 +39,11 @@ class ScriptView(CourseAccessMixin, UpdateView):
         if not access:
             context['access_error'] = access_error
             context['message'] = contact_message
+
+        if script.status == 4 and self.request.user == script.author:
+            script.status = 5
+            script.save()
+
         return context
 
     @method_decorator(login_required)
@@ -66,7 +71,9 @@ class ScriptsPendingView(ScriptsView):
     def get_queryset(self):
         user = self.request.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))
+        Q1 = Q(status=3, author=user, period=period)
+        Q2 = Q(status=3, corrector=user, period=period)
+        scripts = Script.objects.filter(Q1 | Q2)
         return scripts
 
     def get_context_data(self, **kwargs):
@@ -79,7 +86,11 @@ class ScriptsTreatedView(ScriptsView):
 
     def get_queryset(self):
         user = self.request.user
-        scripts = Script.objects.filter(Q(status=4, author=user) | Q(status=4, corrector=user))
+        Q1 = Q(status=4, author=user)
+        Q2 = Q(status=5, author=user)
+        Q3 = Q(status=4, corrector=user)
+        Q4 = Q(status=5, corrector=user)
+        scripts = Script.objects.filter(Q1 | Q2 | Q3 | Q4)
         return scripts
 
     def get_context_data(self, **kwargs):
@@ -92,7 +103,9 @@ class ScriptsRejectedView(ScriptsView):
 
     def get_queryset(self):
         user = self.request.user
-        scripts = Script.objects.filter(Q(status=0, author=user) | Q(status=0, corrector=user))
+        Q1 = Q(status=0, author=user)
+        Q2 = Q(status=0, corrector=user)
+        scripts = Script.objects.filter(Q1 | Q2)
         return scripts
 
     def get_context_data(self, **kwargs):
index 8f27e366575724bfd4367c769a4c0e799cf64c68..89f8315f47bf13a40ebba8d45331df220ce70320 100644 (file)
@@ -113,13 +113,13 @@ alt="logo" />
 
   {% if exam_access %}
   {% if periods|length == 1 %}
-      <li><a href="{% url teleforma-exam-scripts-pending periods.0.id %}" class="green">&nbsp;{% trans "Scripts" %}&nbsp;
-      {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user periods.0.id %}
+      <li><a href="{% url teleforma-exam-scripts-pending periods.0.id %}" class="green">&nbsp;{% trans "Scripts" %}
+      {% if user.is_staff or user.quotas.all %}{% untreated_scripts_count user periods.0.id %}
      {% else %}{% treated_scripts_count user periods.0.id %}{% endif %}</a>
      </li>
   {% else %}
-    <li><a href="#scripts#" class="green">&nbsp;{% trans "Scripts" %}&nbsp;
-     {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user periods.0.id %}
+    <li><a href="#scripts#" class="green">&nbsp;{% trans "Scripts" %}
+     {% if user.is_staff or user.quotas.all %}{% untreated_scripts_count user periods.0.id %}
      {% else %}{% treated_scripts_count user periods.0.id %}{% endif %}</a>
       <ul>
        {% for period in periods %}
index bd1a596ff2d9e3b67b6ca90e9108500236d92b90..3bb89748159116d4f05b8003cfc1d4be81f9924c 100644 (file)
@@ -210,7 +210,9 @@ def published(doc):
 
 @register.simple_tag
 def untreated_scripts_count(user, period):
-    scripts = Script.objects.filter(Q(status=3, author=user, period=period) | Q(status=3, corrector=user, period=period))
+    Q1 = Q(status=3, author=user, period=period)
+    Q2 = Q(status=3, corrector=user, period=period)
+    scripts = Script.objects.filter(Q1 | Q2)
     if scripts:
         return ' (' + str(len(scripts)) + ')'
     else:
@@ -218,7 +220,9 @@ def untreated_scripts_count(user, period):
 
 @register.simple_tag
 def treated_scripts_count(user, period):
-    scripts = Script.objects.filter(Q(status=4, author=user, period=period) | Q(status=4, corrector=user, period=period))
+    Q1 = Q(status=4, author=user, period=period)
+    Q2 = Q(status=4, corrector=user, period=period)
+    scripts = Script.objects.filter(Q1 | Q2)
     if scripts:
         return ' (' + str(len(scripts)) + ')'
     else: