Skip to content

Commit

Permalink
fix recording bug, delete recording when delete meeting record
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji246 committed Jan 9, 2015
1 parent edbf858 commit d140b1c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bbb_django/bbb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)

0 comments on commit d140b1c

Please sign in to comment.