From 08636d2fd7d28b30db5fde6682b5a843a860522d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 20 Jul 2014 16:30:17 +0200 Subject: [PATCH] add JS timers --- teleforma/models/pro.py | 2 +- .../templates/teleforma/answer_form.html | 2 -- .../templates/teleforma/seminar_detail.html | 25 ++++++++++++++++--- teleforma/views/pro.py | 1 + 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/teleforma/models/pro.py b/teleforma/models/pro.py index e7fad46f..f571534c 100755 --- a/teleforma/models/pro.py +++ b/teleforma/models/pro.py @@ -315,7 +315,7 @@ class SeminarRevision(models.Model): date_modified = models.DateTimeField(_('date modified'), blank=True, null=True) def __unicode__(self): - return ' - '.join([self.seminar.title, self.user.username, str(self.date)]) + return ' - '.join([self.seminar.title, self.user.username, str(self.date), str(self.date_modified)]) class Meta(MetaCore): db_table = app_label + '_' + 'seminar_revisions' diff --git a/teleforma/templates/teleforma/answer_form.html b/teleforma/templates/teleforma/answer_form.html index d6c2d021..83d474e4 100644 --- a/teleforma/templates/teleforma/answer_form.html +++ b/teleforma/templates/teleforma/answer_form.html @@ -32,7 +32,6 @@ $(document).ready(function(){ new Messi(gettext('You must reach the required number of characters.'), {buttons: [{id: 0, label: gettext('OK'), val: 'X'}], modal: true}); } if (c.hasClass('exceed')){ - b1.unbind('click'); $('#id_status').val("3"); $('#_AnswerForm').submit(); } @@ -41,7 +40,6 @@ $(document).ready(function(){ var b2 = $('#save_button'); b2.unbind('click').click(function() { $(window).unbind('beforeunload'); - b2.unbind('click'); $('#_AnswerForm').submit(); }); diff --git a/teleforma/templates/teleforma/seminar_detail.html b/teleforma/templates/teleforma/seminar_detail.html index bddca01f..ab94a785 100644 --- a/teleforma/templates/teleforma/seminar_detail.html +++ b/teleforma/templates/teleforma/seminar_detail.html @@ -52,11 +52,25 @@ var seminarUtils = { p.html('{% trans " rejected" %}') }); } + load : function(id, username){ + json([id, username],'teleforma.seminar_load',function(){ + return false + }); + }, + + unload : function(id, username){ + json([id, username],'teleforma.seminar_unload',function(){ + return false + }); + }, + } $(window).ready(function(){ - var p = $('#publish'); var f = seminarUtils; + f.load('{{seminar.id}}','{{user.username}}'); + + var p = $('#publish'); p.unbind('click').click(function() { if (p.hasClass('icon_ok')){ f.unpublish('{{seminar.id}}'); @@ -71,6 +85,11 @@ $(window).ready(function(){ }); +$(window).unload(function(){ + var f = seminarUtils; + f.unload('{{seminar.id}}','{{user.username}}'); + }); + {% endif %} @@ -84,12 +103,12 @@ $(window).ready(function(){
- +
{% if seminar_progress == 100 and not user.is_staff %} {% trans {% endif %} - + {% if user.is_staff %} {% if seminar.status == 2 %}{% trans " published" %}{% else %}{% trans " rejected" %}{% endif %} {% endif %} diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 896a76b1..6f95c07a 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -102,6 +102,7 @@ def set_revision(user, seminar): r = revisions[0] if not r.date_modified: r.date_modified = datetime.datetime.now() + r.save() else: SeminarRevision.objects.create(seminar=seminar, user=user) else: -- 2.39.5