Skip to content

Commit

Permalink
1. use id as meeting_id
Browse files Browse the repository at this point in the history
2. unicode support
3. use south to do migration
  • Loading branch information
fuji246 committed Nov 11, 2012
1 parent 925119e commit 062c733
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bbb_django/bbb/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class MeetingAdmin(admin.ModelAdmin):
list_display = ('name','meeting_id')
list_display = ('name','id')
list_filter = ['name']
search_fields = ['name']

Expand Down
23 changes: 12 additions & 11 deletions bbb_django/bbb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def parse(response):

class Meeting(models.Model):

name = models.CharField(max_length=100, unique=True, verbose_name=_('meeting name'))
meeting_id = models.CharField(max_length=100, unique=True, verbose_name=_('meeting id'))
name = models.CharField(max_length=100, verbose_name=_('meeting name'))
attendee_password = models.CharField(max_length=50, verbose_name=_('attendee password'))
moderator_password = models.CharField(max_length=50, verbose_name=_('moderator password'))

Expand All @@ -38,7 +37,7 @@ def api_call(self, query, call):
def is_running(self):
call = 'isMeetingRunning'
query = urlencode((
('meetingID', self.meeting_id),
('meetingID', self.id),
))
hashed = self.api_call(query, call)
url = settings.BBB_API_URL + call + '?' + hashed
Expand Down Expand Up @@ -102,10 +101,12 @@ def get_meetings(self):
d = []
r = result[1].findall('meeting')
for m in r:
meeting_name = m.find('meetingName').text
meeting_id = m.find('meetingID').text
password = m.find('moderatorPW').text
d.append({
'name': meeting_id,
'name': meeting_name,
'meeting_id': meeting_id,
'running': m.find('running').text,
'moderator_pw': password,
'attendee_pw': m.find('attendeePW').text,
Expand All @@ -122,8 +123,8 @@ def start(self):
call = 'create'
voicebridge = 70000 + random.randint(0,9999)
query = urlencode((
('name', self.name),
('meetingID', self.meeting_id),
('name', self.name.encode('utf8')),
('meetingID', self.id),
('attendeePW', self.attendee_password),
('moderatorPW', self.moderator_password),
('voiceBridge', voicebridge),
Expand All @@ -142,7 +143,7 @@ def start(self):
def join_url(self, meeting_id, name, password):
call = 'join'
query = urlencode((
('fullName', name),
('fullName', name.encode('utf8')),
('meetingID', meeting_id),
('password', password),
))
Expand All @@ -151,7 +152,7 @@ def join_url(self, meeting_id, name, password):
return url

class CreateForm(forms.Form):
name = forms.SlugField(label=_('meeting name'))
name = forms.CharField(label=_('meeting name'))
attendee_password = forms.CharField(label=_('attendee password'),
widget=forms.PasswordInput(render_value=False))
moderator_password= forms.CharField(label=_('moderator password'),
Expand All @@ -161,10 +162,10 @@ def clean(self):
data = self.cleaned_data

# TODO: should check for errors before modifying
data['meeting_id'] = data.get('name')
#data['meeting_id'] = data.get('name')

if Meeting.objects.filter(name = data.get('name')):
raise forms.ValidationError("That meeting name is already in use")
#if Meeting.objects.filter(name = data.get('name')):
# raise forms.ValidationError("That meeting name is already in use")
return data

class JoinForm(forms.Form):
Expand Down
2 changes: 1 addition & 1 deletion bbb_django/bbb/templates/join.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<form action="" method="POST">
{% csrf_token %}
<h2>{% trans "Join meeting" %} '{{ meeting_name }}'</h2>
<p>{% blocktrans %} "Invite others to this meeting with <a href="/meeting/{{ meeting_name }}/join">this URL</a>{% endblocktrans %}</p>
<p>{% blocktrans %} "Invite others to this meeting with <a href="/meeting/{{ meeting_id }}/join">this URL</a>{% endblocktrans %}</p>
<table>
{{form}}
<tr>
Expand Down
2 changes: 1 addition & 1 deletion bbb_django/bbb/templates/meetings.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>{% trans "Meetings" %}</h2>
{% else %}
<span class="status notrunning">{% trans "Not running" %}</span>
{% endif %}
<form method="GET" action="{% url join meeting.name %}"><input type="submit" value="{% trans "Join" %}"></form> <form method="POST" action="{% url delete meeting.name meeting.moderator_pw %}">{% csrf_token %}<input type="submit" value="{% trans "End" %}"></form>
<form method="GET" action="{% url join meeting.meeting_id%}"><input type="submit" value="{% trans "Join" %}"></form> <form method="POST" action="{% url delete meeting.meeting_id meeting.moderator_pw %}">{% csrf_token %}<input type="submit" value="{% trans "End" %}"></form>
{% else %}
<span class="status notrunning">{% trans "Ended" %}</span>
{% endif %}
Expand Down
10 changes: 6 additions & 4 deletions bbb_django/bbb/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def join_meeting(request, meeting_id):
else:
form = form_class()

meeting = Meeting.objects.get(id=meeting_id)
context = RequestContext(request, {
'form': form,
'meeting_name': meeting_id,
'meeting_name': meeting.name,
'meeting_id': meeting_id
})

return render_to_response('join.html', context)
Expand Down Expand Up @@ -94,10 +96,10 @@ def create_meeting(request):
#password = hashlib.sha1(data.get('password')).hexdigest()
meeting.attendee_password = data.get('attendee_password')
meeting.moderator_password = data.get('moderator_password')
meeting.meeting_id = data.get('meeting_id')
url = meeting.start()
#meeting.meeting_id = data.get('meeting_id')
meeting.save()
msg = _('Successfully created meeting %s') % meeting.meeting_id
url = meeting.start()
msg = _('Successfully created meeting %s') % meeting.name
messages.success(request, msg)
return HttpResponseRedirect(reverse('meetings'))
'''
Expand Down
1 change: 1 addition & 0 deletions bbb_django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
'django.contrib.messages',
'django.contrib.admin',
'bbb',
'south',
#'gunicorn',

)
Expand Down

0 comments on commit 062c733

Please sign in to comment.