]> git.parisson.com Git - teleforma.git/commitdiff
fix answer validation, bugfix
authoryomguy <yomguy@parisson.com>
Mon, 21 Jan 2013 10:17:48 +0000 (11:17 +0100)
committeryomguy <yomguy@parisson.com>
Mon, 21 Jan 2013 10:17:48 +0000 (11:17 +0100)
teleforma/templates/teleforma/answer_detail.html
teleforma/templates/teleforma/answers.html
teleforma/views/pro.py

index 68a1b393ae6caff9cd2ce7dd78a113346a7c51f4..b018a220620334241047249800b9b875a9bba160 100644 (file)
@@ -3,12 +3,28 @@
 {% load i18n %}
 
 {% block extra_javascript %}
-<script src="{{ STATIC_URL }}teleforma/js/charCount.js" type="text/javascript"></script>
+{% endblock extra_javascript %}
+
+{% block infra_javascript %}
 <script type="text/javascript">
 
+$(document).ready(function(){
+
+$('#validate').unbind('click').click(function() {
+ json(['{{answer.id}}'],'teleforma.validate_answer');
+ setTimeout(function() {window.location.href = "{% url teleforma-answers %}";}, 1000);
+ });
+
+$('#reject').unbind('click').click(function() {
+ json(['{{answer.id}}'],'teleforma.reject_answer');
+ setTimeout(function() {window.location.href = "{% url teleforma-answers %}";}, 1000);
+});
+
+
+});
 </script>
-{% endblock extra_javascript %}
 
+{% endblock infra_javascript %}
 
 {% block course_content %}
 
@@ -27,7 +43,7 @@
 <div class="course_subtitle">
    <h3><img src="{{ STATIC_URL }}telemeta/images/item_title.png" width="10px" alt="" /> {% trans "Answer" %}</h3>
   </div>
-  <div style="text-align: justify;">
+  <div style="text-align: justify; padding: 1em;">
     {{ answer.answer|safe }}
   </div>
 </div>
@@ -35,8 +51,8 @@
 <br />
 
 {% if user.is_staff %}
-<a id="validate" href="#" class="component_icon button icon_ok" onclick="var f = answerUtils; f.validate('{{answer.id}}')">{% trans " validate" %}</a> 
-<a id="reject" href="#" class="component_icon button icon_delete" onclick="var f = answerUtils; f.reject('{{answer.id}}')">{% trans " reject" %}</a>
+<a id="validate" href="#" class="component_icon button icon_ok">{% trans " validate" %}</a> 
+<a id="reject" href="#" class="component_icon button icon_delete">{% trans " reject" %}</a>
 {% endif %}
 
 {% endblock course_content %}
index b9bd6e7aeb5f5955da68c2b3624f96bfe42590f0..92e34441a3439c0a1fff7aaeb72d8decf8d1de60 100644 (file)
 var answerUtils = {
         validate : function(id, a){
             json([id],'teleforma.validate_answer',function(){
-                a.removeClass('icon_delete').addClass('icon_ok')
-                a.html('{% trans " validated" %}')
+                a.removeClass('icon_delete').addClass('icon_ok');
+                a.html('{% trans " validated" %}');
                 });
          },
         reject : function(id, a){
             json([id],'teleforma.reject_answer',function(){
-                a.removeClass('icon_ok').addClass('icon_delete')
-                a.html('{% trans " rejected" %}')
+                a.removeClass('icon_ok').addClass('icon_delete');
+                a.html('{% trans " rejected" %}');
                 });
          }
         }
index 52cd07be9587d219287f437dac760b8058495c78..03442fc383bfe842ea2792415daf12e8dac03c78 100644 (file)
@@ -176,7 +176,7 @@ class AnswerView(FormView):
         context['status'] = self.status
         context['seminar'] = self.question.seminar
         context['seminar_progress'] = seminar_progress(user, self.question.seminar)
-        revision, c = SeminarRevision.objects.get_or_create(seminar=seminar, user=user)
+        revision, c = SeminarRevision.objects.get_or_create(seminar=self.question.seminar, user=user)
         revision.save()
         return context