]> git.parisson.com Git - teleforma.git/commitdiff
WIP
authorYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 14 May 2020 09:51:56 +0000 (11:51 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 14 May 2020 09:51:56 +0000 (11:51 +0200)
teleforma/management/commands/teleforma-revisions-from-bbb.py
teleforma/models/core.py
teleforma/templates/teleforma/course_webclass.html
teleforma/views/core.py

index 994cc476576d83615681c4785485ca3918f81c79..c9f68fcd15651499fe2413132e55acdca65203c3 100644 (file)
@@ -72,3 +72,5 @@ class Command(BaseCommand):
                                          date = start,
                                          date_modified = end)
                     sr.save()
+                    sr.date = start
+                    sr.save()
index 30842d75eee17eeb7972aa9d783d1d4bcb553b5b..7c77262a0d1c0ad17b37c7b9c378d0963058f043 100755 (executable)
@@ -43,6 +43,7 @@ import string
 import datetime
 import mimetypes
 import copy
+from unidecode import unidecode
 
 from django.conf import settings
 from django.db.models import *
@@ -541,7 +542,8 @@ class WebclassMixin(Model):
         generate room id and moderator password 
         """
         if not self.webclass_id and self.webclass:
-            meeting_id = self.slug + "-" + self.period
+            # not sure why, but the slug contains accent
+            meeting_id = unidecode(self.slug) + "-" + str(self.period)
             password = User.objects.make_random_password()
             self.webclass_id = meeting_id
             self.webclass_password = password
@@ -558,7 +560,7 @@ class WebclassMixin(Model):
                     'moderatorPW':self.webclass_password,
                     'attendeePW':'pwattendee',
                     # 'maxParticipants':self.webclass_max_participants + 1,
-                    'welcome':"Bienvenue sur la conférence \"%s\"." % (str(self.title),),
+                    'welcome':"Bienvenue sur la conférence \"%s\"." % (self.title.encode('utf-8'),),
                     'record':True,
                     # 'autoStartRecording':True,
                     'muteOnStart':True,
@@ -574,7 +576,7 @@ class WebclassMixin(Model):
                     raise
             
     
-    def get_join_webclass_url(self, user):
+    def get_join_webclass_url(self, user, username=None):
         """ 
         Get url to BBB meeting.
         If user are professor or staff, provide the url with the moderator password
@@ -590,6 +592,17 @@ class WebclassMixin(Model):
         print(bbb.get_join_meeting_url(username, self.webclass_id, password, params))
         return bbb.get_join_meeting_url(username, self.webclass_id, password, params)
 
+    def get_fake_join_webclass_url(self, username):
+        """ 
+        Fake join url for testing purpose
+        Get url to BBB meeting.
+        If user are professor or staff, provide the url with the moderator password
+        """
+        self.create_webclass_room()
+        password = 'pwattendee'
+        params = {'userID': username}
+        return bbb.get_join_meeting_url(username, self.webclass_id, password, params)
+
     def is_webclass_running(self):
         """ Is webclass currently running ? """
         # print(self.get_webclass_info())
@@ -604,7 +617,11 @@ class WebclassMixin(Model):
     def get_record(self):
         """ get longest published record for the current conference """
         all_records = []
-        for recording in bbb.get_recordings(self.webclass_id).get_field('recordings')['recording']:
+        recordings = []
+        recordings_xml = bbb.get_recordings(self.webclass_id).get_field('recordings')
+        if hasattr(recordings_xml, 'get'):
+            recordings = recordings_xml['recording']
+        for recording in recordings:
             recording.prettyprint()
             url = recording.get('playback', {}).get('format', {}).get('url')
             if url:
@@ -623,6 +640,7 @@ class WebclassMixin(Model):
         if not all_records:
             return None
         all_records = sorted(all_records, key=lambda record:-record['duration'])
+
         longest_record = all_records[0]
         if not longest_record['url'] or longest_record['state'] != 'published':
             return None
@@ -638,7 +656,9 @@ class WebclassMixin(Model):
             return auditors < self.webclass_max_participants
         return True
     
-
+    # def clean(self):
+    #     if self.start_date > self.end_date::
+    #         raise ValidationError("Dates are incorrect")
 
 class Conference(Displayable, WebclassMixin):
 
index 8107b636427f7da18e4f66fd99bde9da82f14935..f3945aba7a546b18e581796cac35bf7172546440 100644 (file)
@@ -7,14 +7,13 @@
 {% block infra_javascript %}
 
 <script type="text/javascript">
-{% if show_record %}
+{% if webclass_status == 'past' %}
 $(document).ready(function(){
     onLoadSeminar('{{seminar.id}}','{{user.username}}')
 });
 
 $(window).ready(function(){
     $(window).bind('beforeunload', function(){
-        console.log('unload')
         onUnloadSeminar('{{seminar.id}}','{{user.username}}')        
     });
 });
@@ -25,29 +24,6 @@ $(window).ready(function(){
 
 
 {% block module-action %}
-{% get_telecaster as telecaster %}
-{%  if telecaster %}
-<script type="text/javascript">
-    var conferenceUtils = {
-        stop : function(id){
-            json([id],'teleforma.stop_conference',function(){
-                location.href = '{% url teleforma-conference-record %}';
-                }
-                );
-        }}
-
-    jQuery(window).ready(function(){
-        var a = jQuery('#action_red');
-        var f = conferenceUtils;
-        a.unbind('click').click(function(){
-            f.stop('{{conference.public_id}}');return false;});
-        });
-</script>
-
-<div class="module_action">
-<a href="#" class="component_icon button" id="action_red">{% trans "S T O P" %}</a>
-</div>
-{% endif %}
 {% endblock module-action %}
 
 {% block course %}
@@ -59,7 +35,9 @@ $(window).ready(function(){
     </a>{% if type.name != "None" %} - {{ type }}{% endif %}{% if conference.session %} - {% trans "Session" %} {{ conference.session }}{% endif %}
 </div>
 
-
+{% if not seminar %}
+<p class="warning">Attention, aucun séminaire n'est associé à cette conférence.</p>
+{% endif %}
 
 
 
@@ -83,8 +61,16 @@ $(window).ready(function(){
 {% endif %}
 
 
-<p>DEBUG : <a href="{% url teleforma-conference-join conference.id %}">Cliquez ici pour rejoindre la conférence</a></p>
 
+<h3>Liens de test</h3>
+<p>
+Utilisateur courant : <a href="{% url teleforma-conference-join conference.id %}">Cliquez ici pour rejoindre la conférence en tant que <strong>{{ request.user.username }}</strong></a>
+</p>
+<ul>
+{% for i in range %}
+<li>{{i}} : <a href="{% url teleforma-conference-join conference.id %}?username=test{{i}}">Cliquez ici pour rejoindre la conférence en tant que <strong>test{{i}}</strong></a></li>
+{% endfor %}
+</ul>
 
 {% block general_info %}
 <div class="course_content" id="media_infos">
index b5d2d571b2d8929eb58da5f250a3e2ab33b405a3..97b5e83ac0b336e63d6d5e68406eca185d52e949 100644 (file)
@@ -450,8 +450,13 @@ class ConferenceView(DetailView):
         if conference.webclass:
             context['is_webclass_running'] = conference.is_webclass_running() 
             context['show_record'] = True
-            context['seminar'] = conference.seminar.all()[0]
+            try:
+                context['seminar'] = conference.seminar.all()[0]
+            except IndexError :
+                context['seminar'] = None
             context['record'] = None
+            # debug -> test links
+            context['range'] = range(0,15)
             webclass_status = ""
 
             now = datetime.datetime.now()
@@ -518,6 +523,10 @@ class ConferenceView(DetailView):
 
 def join_webclass(request, pk):
     conference = Conference.objects.get(pk=int(pk))
+    # fake debug links
+    username = request.GET.get('username')
+    if username:
+        return redirect(conference.get_fake_join_webclass_url(username))
     user = request.user
     authorized = False