From 8d385737f7920c76e5c745e5e6b9fae004b7b16f Mon Sep 17 00:00:00 2001 From: yomguy Date: Mon, 20 Feb 2012 14:36:03 +0100 Subject: [PATCH] fix forms --- telecaster/htdocs/js/application.js | 1 + telecaster/models.py | 15 ++++++++++----- telecaster/templates/telecaster/start.html | 2 +- telecaster/urls.py | 12 +++++------- telecaster/views.py | 17 +++++++---------- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/telecaster/htdocs/js/application.js b/telecaster/htdocs/js/application.js index 120b334..e116e01 100644 --- a/telecaster/htdocs/js/application.js +++ b/telecaster/htdocs/js/application.js @@ -159,6 +159,7 @@ function server_status_callback(){ } }, function(){ + var doc = document; var wrapper = doc.getElementById('server_status_table_wrapper'); s = 'NOT connected'; wrapper.innerHTML = s; diff --git a/telecaster/models.py b/telecaster/models.py index 6d20911..9412c7a 100644 --- a/telecaster/models.py +++ b/telecaster/models.py @@ -120,11 +120,16 @@ class Professor(Model): class Station(Model): - organization = ForeignKey(Organization, related_name='stations', verbose_name='organization') - department = ForeignKey(Department, related_name='stations', verbose_name='department') - conference = ForeignKey(Conference, related_name='stations', verbose_name='conference') - session = ForeignKey(Session, related_name='stations', verbose_name='session') - professor = ForeignKey(Professor, related_name='stations', verbose_name='professor') + organization = ForeignKey(Organization, related_name='stations', verbose_name='organization', + null=True, on_delete=models.SET_NULL) + department = ForeignKey(Department, related_name='stations', verbose_name='department', + null=True, on_delete=models.SET_NULL) + conference = ForeignKey(Conference, related_name='stations', verbose_name='conference', + null=True, on_delete=models.SET_NULL) + session = ForeignKey(Session, related_name='stations', verbose_name='session', + null=True, on_delete=models.SET_NULL) + professor = ForeignKey(Professor, related_name='stations', verbose_name='professor', + null=True, on_delete=models.SET_NULL) comment = TextField(_('comment'), blank=True) started = BooleanField(_('started')) datetime_start = DateTimeField(_('time_start'), blank=True, null=True) diff --git a/telecaster/templates/telecaster/start.html b/telecaster/templates/telecaster/start.html index 636ee96..58f6f07 100644 --- a/telecaster/templates/telecaster/start.html +++ b/telecaster/templates/telecaster/start.html @@ -20,7 +20,7 @@ jQuery(window).ready(function(){ {% for error in form.non_field_errors %}
  • {{ error }}
  • {% endfor %} {% for field in station %} - {% if field.errors %}{{ field.errors }}{% endif %} + {% if field.errors %}{{ field.errors }}{% endif %} {% if not field.html_name in hidden_fields %} {% trans field.label_tag %}:{{ field }} {% else %} diff --git a/telecaster/urls.py b/telecaster/urls.py index 93d235f..08ca71f 100644 --- a/telecaster/urls.py +++ b/telecaster/urls.py @@ -53,18 +53,16 @@ urlpatterns = patterns('', # CSS+Images (FIXME: for developement only) url(r'^css/(?P.*)$', 'django.views.static.serve', - {'document_root': htdocs+'/css'}, - name="telecaster-css"), + {'document_root': htdocs+'/css'}, name="telecaster-css"), url(r'images/(?P.*)$', 'django.views.static.serve', - {'document_root': htdocs+'/images'}, - name="telecaster-images"), + {'document_root': htdocs+'/images'}, name="telecaster-images"), url(r'^js/(?P.*)$', 'django.views.static.serve', - {'document_root': htdocs+'/js'}, - name="telecaster-js"), + {'document_root': htdocs+'/js'}, name="telecaster-js"), # JSON RPC url(r'json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'), +# url(r'^items/json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint2'), # for the graphical browser/web console only, omissible - url(r'json/browse/', 'jsonrpc.views.browse', name="jsonrpc_browser"), +# url(r'json/browse/', 'jsonrpc.views.browse', name="jsonrpc_browser"), ) diff --git a/telecaster/views.py b/telecaster/views.py index fb28394..1ecedeb 100644 --- a/telecaster/views.py +++ b/telecaster/views.py @@ -65,13 +65,12 @@ class WebView(object): station = stations[0] if request.method == 'POST': station.stop() - time.sleep(2) +# time.sleep(2) station.save() self.logger.write_info('stop') return HttpResponseRedirect('/telecaster/record') else: - return render(request, template, {'station': station, 'status': self.status.update(), - 'hidden_fields': self.hidden_fields, }) + return render(request, template, {'station': station, 'hidden_fields': self.hidden_fields, }) else: return HttpResponseRedirect('/telecaster/record') @@ -87,13 +86,12 @@ class WebView(object): station.start() station.save() self.logger.write_info('start') - time.sleep(2) - return HttpResponseRedirect('/telecaster/items/'+str(station.id)) +# time.sleep(2) + return HttpResponseRedirect('/telecaster/') else: form = StationForm() - return render(request, template, {'station': form, 'status': self.status.update(), - 'hidden_fields': self.hidden_fields, }) + return render(request, template, {'station': form, 'hidden_fields': self.hidden_fields, }) @jsonrpc_method('telecaster.get_server_status') @@ -103,9 +101,8 @@ class WebView(object): return status.to_dict() def get_server_status(self): - status = Status() - status.update() - return status + self.status.update() + return self.status @jsonrpc_method('telecaster.get_station_status') def get_station_status_json(request): -- 2.39.5