diff --git a/bbb_django/bbb/models.py b/bbb_django/bbb/models.py index 7e8bddc..0bfd1e6 100755 --- a/bbb_django/bbb/models.py +++ b/bbb_django/bbb/models.py @@ -6,6 +6,7 @@ from django.contrib.admin import widgets from django.contrib.auth.models import User from django.core.urlresolvers import reverse +from django.db.models.signals import pre_delete from urllib2 import urlopen from urllib import urlencode @@ -150,6 +151,34 @@ def get_meetings(self): else: return 'error' + @classmethod + def delete_recordings(self, meeting_id=None): + """ + Delete one or more recordings for a given recordID (or set of record IDs). + + :param record_id: A record ID for specify the recordings to delete. It can be a set of meetingIDs separate by commas. + """ + record_info = Meeting.get_recordings(meeting_id) + record_id_list = [] + for item in record_info: + record_id_list.append(item['record_id']) + + call = 'deleteRecordings' + if record_id_list: + query = urlencode(( + ('recordID', ','.join(record_id_list)), + )) + else: + query = '' + hashed = self.api_call(query, call) + url = settings.BBB_API_URL + call + '?' + hashed + print 'delete recording url:%s'%url + r = parse(urlopen(url).read()) + # ToDO implement more keys + if r: + return r.find('deleted').text == 'true' + return False + @classmethod def get_recordings(self, meeting_id=None): """ @@ -254,3 +283,11 @@ class JoinForm(forms.Form): name = forms.CharField(label=_("Your name")) password = forms.CharField(label=_('password'), widget=forms.PasswordInput(render_value=False)) + + +def delete_record_cb(sender, **kwargs): + meeting = kwargs['instance'] + if meeting.record: + Meeting.delete_recordings(meeting.id) + +pre_delete.connect(delete_record_cb, sender=Meeting)