##// END OF EJS Templates
Se agrego tabla "Radar" y Estados del Radar...
Se agrego tabla "Radar" y Estados del Radar git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@70 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r47:f6d4e6a94b9f
r49:95059da329ea
Show More
forms.py
64 lines | 2.5 KiB | text/x-python | PythonLexer
Juan C. Espinoza
Actualizacion de templates y modelos base #263...
r2 from django import forms
Juan C. Espinoza
Updating base models and views ...
r6 from django.utils.safestring import mark_safe
Miguel Urco
Location model added to RadarSys...
r41 from .models import DeviceType, Device, Experiment, Campaign, Configuration, Location
Juan C. Espinoza
Actualizacion de templates y modelos base #263...
r2
def add_empty_choice(choices, pos=0, label='-----'):
if len(choices)>0:
choices = list(choices)
choices.insert(0, (0, label))
return choices
else:
return [(0, label)]
Juan C. Espinoza
Updating base models and views ...
r6 class DatepickerWidget(forms.widgets.TextInput):
def render(self, name, value, attrs=None):
input_html = super(DatepickerWidget, self).render(name, value, attrs)
html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>'
return mark_safe(html)
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class TimepickerWidget(forms.widgets.TextInput):
def render(self, name, value, attrs=None):
input_html = super(TimepickerWidget, self).render(name, value, attrs)
html = '<div class="input-group time">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span></div>'
return mark_safe(html)
class CampaignForm(forms.ModelForm):
Juan C. Espinoza
Updating base models and views ...
r6 def __init__(self, *args, **kwargs):
Miguel Urco
Campaign has been added to RadarSys Model...
r13 super(CampaignForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Updating base models and views ...
r6 self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs)
self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs)
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class Meta:
model = Campaign
Miguel Urco
template attribute added to RadarSys Models...
r47 exclude = ['']
Miguel Urco
Campaign has been added to RadarSys Model...
r13
class ExperimentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ExperimentForm, self).__init__(*args, **kwargs)
self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs)
self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs)
self.fields['campaign'].widget.attrs['readonly'] = True
Juan C. Espinoza
Actualizacion de templates y modelos base #263...
r2 class Meta:
model = Experiment
Miguel Urco
template attribute added to RadarSys Models...
r47 exclude = ['']
Juan C. Espinoza
Actualizacion de templates y modelos base #263...
r2
Miguel Urco
Location model added to RadarSys...
r41 class LocationForm(forms.ModelForm):
class Meta:
model = Location
exclude = ['']
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class DeviceForm(forms.ModelForm):
Juan C. Espinoza
Updating base models and views ...
r6 class Meta:
model = Device
exclude = ['status']
Juan C. Espinoza
Actualizacion de templates y modelos base #263...
r2
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class ConfigurationForm(forms.ModelForm):
class Meta:
model = Configuration
Miguel Urco
template attribute added to RadarSys Models...
r47 exclude = ['type', 'created_date', 'programmed_date', 'parameters']
Miguel Urco
Campaign has been added to RadarSys Model...
r13
Juan C. Espinoza
Updating base models and views ...
r6 class DeviceTypeForm(forms.Form):
device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name')))