##// 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@73 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r50:28cae6c7c559
r52:ea2186d4be47
Show More
forms.py
73 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
Fiorella Quino
Task #487: Vista de Operacion...
r50 from datetime import datetime
from apps.main.widgets import Filtering_ComboBox_Widget, Datepicker, HTMLrender,Filtering_ComboBox_Widget2
Juan C. Espinoza
Updating base models and views ...
r6
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')))
Fiorella Quino
Task #487: Vista de Operacion...
r50
class OperationForm(forms.Form):
today = datetime.today()
# -----Campaigns from this month------
campaign = forms.ChoiceField(choices=Campaign.objects.filter(start_date__month=today.month).filter(start_date__year=today.year).order_by('-start_date').values_list('id', 'name'), label="Campaign")