From: yomguy Date: Sun, 29 May 2011 01:34:56 +0000 (+0200) Subject: hide some fields X-Git-Tag: 1.0~82 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=fa75dca397b987ce202edfc857a0f227c34c8b3b;p=telecaster-server.git hide some fields --- diff --git a/models.py b/models.py index cf1fd41..966b49c 100644 --- a/models.py +++ b/models.py @@ -125,12 +125,19 @@ class Station(Model): professor = ForeignKey('Professor', related_name='stations', verbose_name='professor') comment = TextField(_('comment')) started = BooleanField(_('started')) - datetime_start = DateTimeField(_('datetime_start'), auto_now_add=True) - datetime_stop = DateTimeField(_('datetime_stop')) + datetime_start = DateTimeField(_('time_start')) + datetime_stop = DateTimeField(_('time_stop')) class Meta: db_table = app_label + '_' + 'station' + def __str__(self): + return ' - '.join(self.description) + ' - ' + str(self.datetime_start) + ' > ' + str(self.datetime_stop) + + @property + def description(self): + return [self.organization.name, self.conference.department.name, self.conference.title, self.session.name, self.professor.name, self.comment] + def set_conf(self, conf): self.conf = conf @@ -150,7 +157,6 @@ class Station(Model): self.ogg_quality = self.conf['media']['ogg_quality'] self.format = self.conf['media']['format'] self.channels = int(self.conf['media']['channels']) - self.description = [self.organization.name, self.conference.department.name, self.conference.title, self.session.name, self.professor.name, self.comment] self.server_name = [self.organization.name, self.conference.department.name, self.conference.title] self.ServerDescription = clean_string('-'.join(self.description)) self.ServerName = clean_string('_-_'.join(self.server_name)) diff --git a/templates/telecaster/start.html b/templates/telecaster/start.html index ee2ea47..befd942 100644 --- a/templates/telecaster/start.html +++ b/templates/telecaster/start.html @@ -1,22 +1,26 @@ {% extends "telecaster/base.html" %} +{% load telecaster_utils %} +{% load i18n %} {% block content %} -
{% csrf_token %} +{% csrf_token %}
{% for field in station %} - - - + {% if field.errors %}{% endif %} + {% if not field.html_name in hidden_fields %} + + {% else %} + + {% endif %} {% endfor %}
{% for error in form.non_field_errors %}
  • {{ error }}
  • {% endfor %}
    {{ field.errors }}
    {{ field.label_tag }}:{{ field }}
    {{ field.errors }}
    {% trans field.label_tag %}:{{ field }}{{ field.label_tag.as_hidden }}{{ field.as_hidden }}
    -
    diff --git a/templates/telecaster/stop.html b/templates/telecaster/stop.html index 352200d..a3f81ab 100644 --- a/templates/telecaster/stop.html +++ b/templates/telecaster/stop.html @@ -1,17 +1,19 @@ {% extends "telecaster/base.html" %} +{% load telecaster_utils %} +{% load i18n %} {% block content %} -
    {% csrf_token %} +{% csrf_token %}
    - - - - - - + + + + + +
    Organization : {{ station.organization }}
    Département : {{ station.conference.department }}
    Conference : {{ station.conference }}
    Session : {{ station.session }}
    Professeur : {{ station.professor }}
    Commentaire : {{ station.comment }}
    {% trans "Organization" %} : {{ station.organization }}
    {% trans "Department" %} : {{ station.conference.department }}
    {% trans "Conference" %} : {{ station.conference }}
    {% trans "Session" %} : {{ station.session }}
    {% trans "Professor" %} : {{ station.professor }}
    {% trans "Comment" %} : {{ station.comment }}
    diff --git a/views.py b/views.py index 434a723..963f163 100644 --- a/views.py +++ b/views.py @@ -41,6 +41,7 @@ class WebView(object): interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2','eth3'] acpi_states = {0: 'battery', 1: 'AC', 2: 'AC'} acpi = acpi.Acpi() + hidden_fields = ['started', 'datetime_start', 'datetime_stop'] def __init__(self, conf_file): self.uid = os.getuid() @@ -89,7 +90,8 @@ class WebView(object): else: station = StationForm() - return render(request, template, {'station': station, 'status': status}) + return render(request, template, {'station': station, 'status': status, + 'hidden_fields': self.hidden_fields}) def get_hosts(self): ip = ''