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)
});
</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 %}
<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 %}
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):