class CreateRouteForm(forms.Form): route = forms.CharField(widget=forms.HiddenInput()) date = forms.DateField() time = forms.TimeField() arrivalTime = forms.CharField(max_length=10) vehicle = forms.CharField(widget=Select(choices=[("Car", "Car"), ("Truck", "Truck")])) capacity = forms.IntegerField(widget=Select( choices=[(x, str(x)) for x in range(1, 10)])) baggage = forms.BooleanField(required=False) pet = forms.BooleanField(required=False)
class Meta: model = Course fields = [ 'title', 'sub_title', 'category', 'description', 'start_date', 'finish_date', 'image' ] labels = { 'sub_title': 'Sub Title', 'image': 'Upload Image', 'start_date': 'Start Date', 'finish_date': 'Finish Date', } widgets = { 'title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Title' }), 'sub_title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Sub-Title' }), 'description': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter Description' }), 'category': Select(attrs={'class': u'form-control'}), 'start_date': SelectDateWidget(), 'finish_date': SelectDateWidget(), }
class Meta: model = Exam fields = [ 'exam_num', 'title', 'description', 'start_date', 'due_date', 'worth', 'is_final' ] labels = { 'exam_num': 'Exam #', 'worth': 'Worth % of Final Mark', 'is_final': 'Is Final Exam', } widgets = { 'exam_num': NumberInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Exam Number' }), 'title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Title' }), 'description': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter Description' }), 'start_date': SelectDateWidget(), 'due_date': SelectDateWidget(), 'worth': Select(attrs={'class': u'form-control'}), }
class Meta: model = Quiz fields = [ 'quiz_num', 'title', 'description', 'start_date', 'due_date', 'worth' ] labels = { 'quiz_num': 'Quiz #', 'worth': 'Worth % of Final Mark', } widgets = { 'quiz_num': NumberInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Quiz Number' }), 'title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Title' }), 'description': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter Description' }), 'start_date': SelectDateWidget(), 'due_date': SelectDateWidget(), 'worth': Select(attrs={'class': u'form-control'}), }
class Meta: model = Student fields = {'profile_pic', 'country', 'age', 'bio', 'interests'} labels = { 'country': 'Country :', 'age': 'Age :', 'bio': 'Bio :', 'interests': 'Interests :', } widgets = { 'interests': TextInput( attrs={ 'class': u'form-control', 'placeholder': u'Enter your interests interests' }), 'bio': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter your Bio here' }), 'country': Select(attrs={'class': u'form-control'}), 'age': NumberInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter your age here' }), }
class RatingForm(forms.Form): ice_surface = forms.ChoiceField( widget=Select(attrs={'class': 'form-control'}), choices=((1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'))) referees = forms.ChoiceField( widget=Select(attrs={'class': 'form-control'}), choices=((1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'))) lockers = forms.ChoiceField(widget=Select(attrs={'class': 'form-control'}), choices=((1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'))) league = forms.ChoiceField(widget=Select(attrs={'class': 'form-control'}), choices=((1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'))) teams = forms.ChoiceField(widget=Select(attrs={'class': 'form-control'}), choices=((1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'))) comment = forms.CharField(widget=forms.Textarea( attrs={'class': 'form-control'}))
class SearchForm(forms.Form): zip = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control'})) within = forms.ChoiceField(widget=Select(attrs={'class': 'form-control'}), choices=((5, '5 miles'), (10, '10 miles'), (25, '25 miles'), (100, '100 miles'))) lng = forms.CharField(widget=forms.HiddenInput()) lat = forms.CharField(widget=forms.HiddenInput())
class SelectAccessLevelForm(forms.Form): # Dropdown list to select from one of the current access levels for a project. user_role = forms.ChoiceField( choices=( (user_association.ROLE_CLIENT, "Client"), (user_association.ROLE_DEVELOPER, "Developer"), (user_association.ROLE_OWNER, "Owner"), ), widget=Select(attrs={'class': 'form-control'}))
def __init__(self, *args, **kwargs): super(UserChangeForm, self).__init__(*args, **kwargs) self.fields['username'].label = "Usuario" self.fields['first_name'].required = True self.fields['last_name'].required = True self.fields['email'].required = True if kwargs.get('initial'): self.fields['company'].value = 'HANABI S.A.S.' self.fields['company'].widget = TextInput(attrs={'readonly':'readonly'}) CHOICES = Role.objects.all() choices = [(x.name, x.name) for x in CHOICES ] self.fields['role'].widget = Select(choices=[('---------','---------')]+choices)
class ParamForm(forms.ModelForm): objectid = forms.IntegerField(widget=forms.HiddenInput()) sciname = forms.CharField(max_length=100) commonname = forms.CharField() casnumber = forms.IntegerField() epanumber = forms.IntegerField() category = forms.CharField(widget=Select(choices=(('Chemical', 'Chemical'), ('Physical', 'Physical'), ('Spatial', 'Spatial'), ('Temporal', 'Temporal'), ('General', 'General')))) class Meta: model = Parameter
class Meta: model = Lecture fields = [ 'lecture_id', 'lecture_num', 'week_num', 'title', 'description', 'youtube_url', 'vimeo_url', 'preferred_service' ] labels = { 'lecture_num': 'Lecture Number', 'week_num': 'Week Number', 'youtube_url': 'YouTube URL', 'vimeo_url': 'Vimeo URL', } widgets = { 'lecture_num': NumberInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Lecture Number' }), 'week_num': NumberInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Week Number' }), 'title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Title' }), 'description': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter Description' }), 'youtube_url': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter YouTube URL' }), 'vimeo_url': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Vimeo URL' }), 'preferred_service': Select(attrs={'class': u'form-control'}), }
class OrganismForm(forms.ModelForm): objectid = forms.IntegerField(widget=forms.HiddenInput()) organismname = forms.CharField() family = forms.CharField( widget=Select(attrs={'disabled': 'True'})) #last added line!!!! order_field = forms.CharField(widget=Select(attrs={'disabled': 'True'})) class_field = forms.CharField(widget=Select( attrs={'disabled': 'True' })) # Field renamed because it was a Python reserved word. phylum = forms.CharField(widget=Select(attrs={'disabled': 'True'})) kingdom = forms.CharField(widget=Select( choices=(('', ''), ('Bacteria', 'Bacteria'), ('Archaea', 'Archaea'), ('Protista', 'Protista'), ('Plantae', 'Plantae'), ('Fungi', 'Fungi'), ('Animalia', 'Animalia')))) genus = forms.CharField(widget=Select(attrs={'disabled': 'True'})) species = forms.CharField(max_length=255) wetland_designation = forms.CharField(max_length=10, required=False) cvalue = forms.IntegerField(required=False) introduced = forms.IntegerField( widget=forms.RadioSelect(choices=((1, 'Yes'), (0, 'No'))), required=False) class Meta: model = Organism
def __init__(self, *args, **kwargs): instance = kwargs['instance'] #print instance super(EditOrganismForm, self).__init__(*args, **kwargs) self.fields['objectid'] = forms.IntegerField( widget=forms.HiddenInput(), initial=instance.objectid) self.fields['organismname'] = forms.CharField( initial=instance.organismname) self.fields['kingdom'] = forms.CharField( initial=instance.kingdom, widget=Select(choices=(('', ''), ('Bacteria', 'Bacteria'), ('Archaea', 'Archaea'), ('Protista', 'Protista'), ('Plantae', 'Plantae'), ('Fungi', 'Fungi'), ('Animalia', 'Animalia')))) phylae = Organism.objects.filter( kingdom=instance.kingdom).values('phylum').distinct() choices = [] for ph in phylae: choices.append((ph['phylum'], ph['phylum'])) tuple(choices) self.fields['phylum'] = forms.CharField(initial=instance.phylum, widget=Select(choices=choices)) class_fields = Organism.objects.filter( phylum=instance.phylum).values('class_field').distinct() choices = [] for cl in class_fields: choices.append((cl['class_field'], cl['class_field'])) tuple(choices) self.fields['class_field'] = forms.CharField( initial=instance.class_field, widget=Select(choices=choices)) order_fields = Organism.objects.filter( class_field=instance.class_field).values('order_field').distinct() choices = [] for order in order_fields: choices.append((order['order_field'], order['order_field'])) tuple(choices) self.fields['order_field'] = forms.CharField( initial=instance.order_field, widget=Select(choices=choices)) families = Organism.objects.filter( class_field=instance.class_field).values('family').distinct() choices = [] for fam in families: choices.append((fam['family'], fam['family'])) tuple(choices) self.fields['family'] = forms.CharField(initial=instance.family, widget=Select(choices=choices)) genera = Organism.objects.filter( family=instance.family).values('genus').distinct() choices = [] for g in genera: choices.append((g['genus'], g['genus'])) tuple(choices) self.fields['genus'] = forms.CharField(initial=instance.genus, widget=Select(choices=choices)) self.fields['species'] = forms.CharField(initial=instance.species, max_length=255) self.fields['wetland_designation'] = forms.CharField( initial=instance.wetland_designation, max_length=10, required=False) self.fields['cvalue'] = cvalue = forms.IntegerField( initial=instance.cvalue, required=False) self.fields['introduced'] = forms.IntegerField( initial=instance.introduced, widget=forms.RadioSelect(choices=((1, 'Yes'), (0, 'No'))), required=False)