Skip to content

Commit

Permalink
hack to reuse django admin widget for datetime field
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji246 committed Nov 22, 2012
1 parent a74b7b0 commit 0633572
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bbb_django/bbb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.contrib.admin import widgets

from urllib2 import urlopen
from urllib import urlencode
Expand Down Expand Up @@ -182,7 +183,7 @@ class CreateForm(forms.Form):
welcome = forms.CharField(label=_('welcome message'), initial=_('Welcome!'))
record = forms.BooleanField(label=_('record'))
duration = forms.ChoiceField(label=_('duration'), choices=MEETING_DURATION)
start_time = forms.DateTimeField(label=_('start time'), initial=datetime.date.today())
start_time = forms.DateTimeField(label=_('start time'), widget=widgets.AdminSplitDateTime())

def clean(self):
data = self.cleaned_data
Expand Down
15 changes: 12 additions & 3 deletions bbb_django/bbb/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
<head>
<title>{% block title %}{% endblock %}</title>
{% block extrahead %}{% endblock%}
<link rel="stylesheet" type="text/css" href="/static/reset.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<!--<link rel="stylesheet" type="text/css" href="/static/reset.css">-->
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css" />

<!--<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>-->
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>

<script>
$(document).ready(function() {
$('.more-info').show();
$('.more-info').click(function() { $(this).parent().find('table').toggle() });
});
</script>

<style>
html {
background: #eee;
Expand Down Expand Up @@ -194,6 +200,8 @@
border-style: solid;
border-color: #ccc#ddd #eee#ddd;
}

/*
tr {
padding: 4px 0;
display: block;
Expand All @@ -205,7 +213,8 @@
vertical-align: top;
padding: 0.2em 0.4em 0.2em 0;
}
</style>
*/
</style>
</head>
<body>
<div class="container">
Expand Down
9 changes: 9 additions & 0 deletions bbb_django/bbb/templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@

{% block title %}{% trans "Create a meeting" %}{% endblock %}

{% block extrahead %}
<script type="text/javascript">window.__admin_media_prefix__ = "/static/admin/";</script>
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/calendar.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/DateTimeShortcuts.js"></script>
{% endblock%}

{% block content %}
<h2>{% trans "Create Meeting" %}</h2>
<form action="" method ="POST">
<table>
{% csrf_token %}
{{form}}
<!--<input name="date" value="{%now "Y-m-d"%}" class="vDateField" type="text" id="query_date" size="10" /> -->
<tr>
<th></th>
<td><input type="submit" value="{% trans "create" %}"></td>
Expand Down
5 changes: 5 additions & 0 deletions bbb_django/bbb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import settings

def i18n_javascript(request):
return admin.site.i18n_javascript(request)

urlpatterns = patterns('',
url('^$', home_page, name='home'),
url(r'^login/$', 'django.contrib.auth.views.login', {
Expand All @@ -26,6 +29,8 @@
'url': 'http://www.bigbluebutton.org/content/videos' ,
}, name='help'),

(r'^admin/jsi18n', i18n_javascript),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_ROOT}),
Expand Down

0 comments on commit 0633572

Please sign in to comment.