##// END OF EJS Templates
Task #487: Vista de Operacion...
Task #487: Vista de Operacion git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@77 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r53:5104723250fd
r56:89f0d8586d56
Show More
forms.py
79 lines | 2.9 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):
Miguel Urco
Models changed:...
r53
Miguel Urco
Campaign has been added to RadarSys Model...
r13 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')))
Fiorella Quino
Task #487: Vista de Operacion...
r50
Miguel Urco
Models changed:...
r53
class UploadFileForm(forms.Form):
file = forms.FileField()
class DownloadFileForm(forms.Form):
format = forms.ComboField()
Fiorella Quino
Task #487: Vista de Operacion...
r50 class OperationForm(forms.Form):
Miguel Urco
Models changed:...
r53 # today = datetime.today()
Fiorella Quino
Task #487: Vista de Operacion...
r50 # -----Campaigns from this month------
Miguel Urco
Models changed:...
r53 campaign = forms.ChoiceField(choices=Campaign.objects.all().order_by('-start_date').values_list('id', 'name')[:5], label="Campaign")
Fiorella Quino
Task #487: Vista de Operacion...
r50