]> git.parisson.com Git - teleforma.git/commitdiff
add rpc publish methods for seminars
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 7 Jan 2014 22:51:00 +0000 (23:51 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 7 Jan 2014 22:51:00 +0000 (23:51 +0100)
teleforma/models/pro.py
teleforma/templates/teleforma/seminar_detail.html
teleforma/views/pro.py

index 5bbbe5ec90f6c7bd8b34b26a5fada034a01ba874..7cc62f1f7ef09c261c1c11159909578103735458 100755 (executable)
@@ -58,7 +58,8 @@ class SeminarType(models.Model):
 
 class Seminar(ClonableMixin, Displayable):
 
-    # title, description, keywords and dates are given by Displayable
+    # title, description, keywords, dates and status are given by Displayable
+    # status values : 1: draft, 2: published
 
     type            = models.ForeignKey(SeminarType, related_name='seminar', verbose_name=_('type'),
                                         blank=True, null=True)
index ac5e223703e9147eb0019fd942cf341b46f39feb..d0fa4a79ff5ac760385b0e39aad4293308e3feee 100644 (file)
@@ -33,6 +33,47 @@ $(function () {
 });
 
 </script>
+
+{% if user.is_staff %}
+<script type="text/javascript">
+
+var seminarUtils = {
+        publish : function(id){
+            var p = $('#publish');
+            json([id],'teleforma.publish_seminar',function(){
+                p.removeClass('icon_delete').addClass('icon_ok')
+                p.html('{% trans " published" %}')
+                });
+         },
+        unpublish : function(id){
+            var p = $('#publish');
+            json([id],'teleforma.unpublish_seminar',function(){
+                p.removeClass('icon_ok').addClass('icon_delete')
+                p.html('{% trans " rejected" %}')
+                });
+         }
+        }
+
+$(window).ready(function(){
+    var p = $('#publish');
+    var f = seminarUtils;
+    p.unbind('click').click(function() {
+        if (p.hasClass('icon_ok')){
+            f.unpublish('{{media.id}}');
+            return false;
+            }
+        if (p.hasClass('icon_delete')) {
+            f.publish('{{media.id}}');
+            return false;
+            }
+        }
+        );
+
+    });
+
+</script>
+{% endif %}
+
 {% endblock infra_javascript %}
 
 
@@ -43,14 +84,25 @@ $(function () {
     <div class="course">
 
         <div class="course_title">
-         <a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a>
+          <div style="text-align: left;">
+            <a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a>
+          </div>
 
           <div style="float: right; font-size: 0.9em;">
-          {% if seminar_progress == 100 %}
-          <img src="{{ STATIC_URL }}telemeta/images/ok.png" title="{% trans "validated" %}" alt="{% trans "validated" %}"/>
-          {% endif %}
+            {% if seminar_progress == 100 %}
+            <img src="{{ STATIC_URL }}telemeta/images/ok.png" title="{% trans "validated" %}" alt="{% trans "validated" %}"/>
+            {% endif %}
+            
+            {% if user.is_staff %}
+            <a id="publish" href="#" class="{% if seminar.status == 2 %}component_icon button icon_ok{% else %}component_icon button icon_delete{% endif %}">{% if seminar.status == 2 %}{% trans " published" %}{% else %}{% trans " rejected" %}{% endif %}</a>
+            {% endif %}
           </div>
 
+          <div style="float: right; font-size: 0.9em;">
+            {% if seminar_progress == 100 %}
+            <img src="{{ STATIC_URL }}telemeta/images/ok.png" title="{% trans "validated" %}" alt="{% trans "validated" %}"/>
+            {% endif %}
+          </div>
         </div>
 
         {% block course_content %}
index 9a73544e8b7a428c75d96daa7e26d667f331fc11..5c3c6427427e91f2fb87ca36537ea710752fca5f 100644 (file)
@@ -141,6 +141,18 @@ class SeminarView(SeminarAccessMixin, DetailView):
         set_revision(user, seminar)
         return context
 
+    @jsonrpc_method('teleforma.publish_seminar')
+    def publish(request, id):
+        seminar = Seminar.objects.get(id=id)
+        seminar.status = 2
+        seminar.save()
+
+    @jsonrpc_method('teleforma.unpublish_seminar')
+    def unpublish(request, id):
+        seminar = Seminar.objects.get(id=id)
+        seminar.status = 1
+        seminar.save()
+
 
 class SeminarsView(ListView):