Ejemplo n.º 1
0
class ExcursionForm(forms.ModelForm):

    name = forms.CharField(label='Nome da Excursão',
                           help_text='Em até 50 caracteres')
    details = forms.CharField(label='Detalhes da Excursão',
                              help_text='Em até 100 caracteres')
    origin = forms.CharField(label='Partida')
    destiny = forms.ModelMultipleChoiceField(queryset=Destiny.objects.all())
    start_time = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget(
        date_attrs={'type': 'date'},
        time_attrs={'type': 'time'},
    ))
    end_time = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget(
        date_attrs={'type': 'date'},
        time_attrs={'type': 'time'},
    ))

    class Meta:
        model = Excursion
        fields = [
            'name',
            'details',
            'excursion_situation',
            'excursion_type',
            'origin',
            'destiny',
            'start_time',
            'end_time',
        ]
Ejemplo n.º 2
0
class EventForm(forms.ModelForm):
    start_day = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(date_attrs={
            'type': 'date',
            'class': 'form-control'
        },
                                         time_attrs={
                                             'type': 'time',
                                             'class': 'form-control'
                                         }))
    end_day = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(date_attrs={
            'type': 'date',
            'class': 'form-control'
        },
                                         time_attrs={
                                             'type': 'time',
                                             'class': 'form-control'
                                         }))

    class Meta:
        model = Event
        fields = EVENT_FIELDS
        labels = {
            "image": "Poster",
            "start_day": "Start Date and Time",
            "end_day": "End Date and Time"
        }
Ejemplo n.º 3
0
class EstimateForm(forms.ModelForm):
    name = forms.CharField(label='Nome do orçamento')
    excursion = forms.ModelChoiceField(queryset=Excursion.objects.all(),
                                       label='Excursão')
    service_provider_type = forms.ModelChoiceField(
        queryset=ServiceProviderType.objects.all(),
        label='Categoria Prestação de Serviço')
    service_provider = forms.ModelChoiceField(
        queryset=ServiceProvider.objects.all(), label='Prestador de Serviço')
    cost = forms.IntegerField(label='Custo')
    start_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={'type': 'date'},
            time_attrs={'type': 'time'},
        ),
        label='Horário Partida',
        help_text='Data e hora que o transporte ficará disponível para agência'
    )
    end_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={'type': 'date'},
            time_attrs={'type': 'time'},
        ),
        label='Horário Chegada',
        help_text='Data e hora que o transporte deverá ser devolvido')
    selected = forms.BooleanField(label='Selecionado', required=False)
    details = forms.CharField()

    class Meta:
        model = Estimate
        fields = [
            'name', 'excursion', 'service_provider_type', 'service_provider',
            'cost', 'start_time', 'end_time', 'selected', 'details'
        ]
Ejemplo n.º 4
0
class TravelItineraryForm(forms.ModelForm):
    excursion = forms.ModelChoiceField(queryset=Excursion.objects.all(),
                                       label='Excursão')
    start_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={'type': 'date'},
            time_attrs={'type': 'time'},
        ),
        label='Horário Início',
        help_text='Horário de início da atividade')
    end_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={'type': 'date'},
            time_attrs={'type': 'time'},
        ),
        label='Horário Fim',
        help_text='Horário do fim da atividade')
    paid = forms.BooleanField(label='Pago', required=False)
    inclusive = forms.BooleanField(label='Incluso', required=False)
    cost = forms.IntegerField(label='Custo')
    details = forms.CharField(label='Detalhes')

    class Meta:
        model = TravelItinerary
        fields = [
            'excursion', 'start_time', 'end_time', 'paid', 'inclusive', 'cost',
            'details'
        ]
Ejemplo n.º 5
0
class EssayForm(forms.ModelForm):
    #	content = forms.CharField(widget=forms.Textarea(attrs={"rows":20, "cols":120}))
    essay_description = forms.CharField(widget=forms.Textarea(attrs={
        "rows": 10,
        "cols": 50
    }))
    words = forms.CharField(widget=forms.Textarea(attrs={
        "rows": 3,
        "cols": 50
    }))
    start_date_time = forms.SplitDateTimeField(
        label='What is the essay start date and time?',
        widget=forms.SplitDateTimeWidget(date_attrs={'type': 'date'},
                                         time_attrs={'type': 'time'}))
    end_date_time = forms.SplitDateTimeField(
        label='What is the essay end date and time?',
        widget=forms.SplitDateTimeWidget(date_attrs={'type': 'date'},
                                         time_attrs={'type': 'time'}))

    class Meta:
        model = Essay
        fields = '__all__'

    def __init__(self, user_id, *args, **kwargs):
        print(user_id)
        super(EssayForm, self).__init__(*args, **kwargs)
        self.fields['course'].queryset = Course.objects.filter(
            teacher__id=user_id)
Ejemplo n.º 6
0
class AssessmentCreationForm(forms.ModelForm):
    DURATION_HOURS_CHOICES = [
        (i,i) for i in range(0,24)
        ]
    
    DURATION_MINUTES_CHOICES = [
        (i,i) for i in range(0,60)
        ]
    
    duration_hours = forms.ChoiceField(choices=DURATION_HOURS_CHOICES, required=True)
    duration_minutes = forms.ChoiceField(choices=DURATION_MINUTES_CHOICES, required=True)
    
    expired_on = forms.SplitDateTimeField(input_date_formats=['%Y-%m-%d'],
                               input_time_formats=['%H:%M:%S'], 
                               widget=forms.SplitDateTimeWidget(date_format='%Y-%m-%d',
                                                          time_format='%H:%M:%S',
                                                          attrs={'class':'form-control'}),
                                                          
                               )
    exam_start_date_time = forms.SplitDateTimeField(input_date_formats=['%Y-%m-%d'],
                               input_time_formats=['%H:%M:%S'], 
                               widget=forms.SplitDateTimeWidget(date_format='%Y-%m-%d',
                                                          time_format='%H:%M:%S',
                                                          attrs={'class':'form-control'}),
                                                          
                               )

    subscriber_users = CustomOptionsForAssesment(queryset = Student.objects.filter(id=1),
                                                      widget=forms.CheckboxSelectMultiple())
    
    class Meta:
        model = Assesment
        fields = ('__all__')
        exclude= ['deleted_by','deleted_at', 'created_by', 'updated_by', 'exam_start_type','total_exam_duration', 'is_exam_active']
        
        labels = {
        "header": "Short Heading",
        "privilege": "Visibility",
        }
        widgets = {
            'header': forms.TextInput(
                                       attrs={'class':'form-control'}
                                    ),
            'brief': forms.Textarea(
                                       attrs={'class':'form-control'}
                                    ),
            
            'passing_marks'         : forms.NumberInput(attrs={'class':'form-control',}),
            'privilege'             : forms.Select(attrs={'class':'custom-select custom-select-md mb-3', 'data-toggle':"tooltip", 'data-placement':"right", 'title':"Public: Assessment Visible to Students. \n\n Private and Protected: Assessment Visible Only To Staff"}),
            
                   
            
        }    
       
    
    
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request")
        super(AssessmentCreationForm, self).__init__(*args, **kwargs)
        self.fields["subscriber_users"].queryset = Student.active.filter(staffuser__institute = self.request.user.staff.institute)    
Ejemplo n.º 7
0
    class Meta:
        model = Carpool

        fields = [
            'departure_latitude',
            'departure_longitude',
            'arrival_latitude',
            'arrival_longitude',
            'frequency',
            'occ_departure_datetime',
            'occ_arrival_datetime',
            'reg_departure_time',
            'reg_arrival_time',
            'seats_number',
            'free',
            'comment',
        ]

        exclude = (
            'organizer',
        )

        widgets = {
            'frequency': forms.RadioSelect(),
            'departure_latitude': forms.HiddenInput(),
            'departure_longitude': forms.HiddenInput(),
            'arrival_latitude': forms.HiddenInput(),
            'arrival_longitude': forms.HiddenInput(),
            'occ_departure_datetime': forms.SplitDateTimeWidget(),
            'occ_arrival_datetime': forms.SplitDateTimeWidget(),
        }
Ejemplo n.º 8
0
class ShiftForm(forms.ModelForm):

    start_time = forms.SplitDateTimeField(
        required=True,
        widget=forms.SplitDateTimeWidget(date_attrs={'type': 'date'},
                                         time_attrs={'type': 'time'}),
    )
    end_time = forms.SplitDateTimeField(
        required=True,
        widget=forms.SplitDateTimeWidget(date_attrs={'type': 'date'},
                                         time_attrs={'type': 'time'}),
    )

    class Meta:
        model = Shift
        fields = ('start_time', 'end_time', 'job_type', 'required_employees')

    def clean(self):
        start_time = self.cleaned_data.get('start_time')
        end_time = self.cleaned_data.get('end_time')
        if start_time is None:
            raise forms.ValidationError('Start time is invalid.')
        elif start_time < timezone.now():
            raise forms.ValidationError(
                'The shift can only be created for the future.')
        elif end_time is None:
            raise forms.ValidationError('End time is invalid.')
        elif end_time < start_time:
            raise forms.ValidationError(
                'Check your input. Start and End time do not match')
Ejemplo n.º 9
0
class AdmCalendarEventForm(forms.ModelForm):
    id = forms.ModelChoiceField(queryset=CalendarEvent.objects.all(), widget=forms.HiddenInput())
    date =  forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
    date.widget.widgets = (forms.TextInput({'class':'vDateField'}),forms.TextInput({'class':'vTimeField'}))
    startdate =  forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
    startdate.widget.widgets = (forms.TextInput({'class':'vDateField'}),forms.TextInput({'class':'vTimeField'}))
    enddate =  forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
    enddate.widget.widgets = (forms.TextInput({'class':'vDateField'}),forms.TextInput({'class':'vTimeField'}))
    type = forms.ModelChoiceField(queryset=CalendarEventType.objects.all())
    calendar = forms.ModelChoiceField(queryset=Calendar.objects.all())
    class Meta:
        model = CalendarEvent
        fields = ('id', 'date', 'calendar', 'type', 'startdate', 'enddate', 'sw', 'state', 'town', 'image', 'www', 'email', 'price', 'permissions')

    def __init__(self, *args, **kwargs):
        super(AdmCalendarEventForm, self).__init__(*args, **kwargs)
        try:
            root_pgroup = PermisionGroup.objects.filter(model='CalendarEvent')
        except Exception, e:
            print 'form/calendarium.py: ', e
            root_pgroup = None

        self.fields['permissions'].label = u'Uprawnienia - pozostaw puste jeśli mają być domyślne'

        if root_pgroup is not None:
            pgroups = []
            for rg in root_pgroup:
                pg = PermisionGroup.objects.filter(parent=rg)
                for group in pg:
                    pgroups.append((group.id,mark_safe(group.name)))
            self.fields['permissions'].choices = pgroups
Ejemplo n.º 10
0
class CreateEventForm(FormWithLocationMixin, forms.ModelForm):
    phone = forms.fields.CharField(widget=forms.TextInput,
                                   label="Contact phone")
    dtstart = forms.fields.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(time_format="%H:%M",
                                         date_attrs=DATE_INPUT_ARGS),
        initial=datetime.datetime.now,
        label="From",
    )
    dtend = forms.fields.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(time_format="%H:%M",
                                         date_attrs=DATE_INPUT_ARGS),
        initial=lambda: datetime.datetime.now() + datetime.timedelta(hours=1),
        label="To",
    )
    until = forms.DateField(
        label="Last occurrence",
        widget=forms.DateInput(attrs=DATE_INPUT_ARGS),
        required=False,
    )
    summary = forms.fields.CharField(widget=forms.TextInput, label="Name")
    email = CaseInsensitiveEmail(widget=forms.TextInput, label="Contact email")
    tags = TagFormField(required=False)

    class Meta:
        model = Event
        exclude = ("location", "rso", "university")
        widgets = {
            "freq": forms.widgets.Select(attrs=RRULE_TYPE_CHOICE_INPUT_ATTRS)
        }

    # Am I breaking Liskov substitution principle? HELL YEAH.
    def __init__(self, university_id, rso_id, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.university_id = university_id
        self.rso_id = rso_id

    def clean(self):
        if self.cleaned_data["freq"] == "WEEKLY":
            if not (self.cleaned_data["until"] and self.cleaned_data["byday"]):
                raise forms.ValidationError(
                    '"Last occurrence" and "Repeat on" must be speficied for weekly events.'
                )
        return self.cleaned_data

    def save(self, commit=True):
        instance = super().save(commit=False)

        instance.university_id = self.university_id
        instance.rso_id = self.rso_id
        if commit:
            instance.save()
            for t in self.cleaned_data["tags"]:
                tag = Tag.objects.filter(text=t).first() or Tag.objects.create(
                    text=t)
                tag.events.add(instance)
        return instance
Ejemplo n.º 11
0
class CreateEventForm(forms.Form):

    error_css_class = 'error'
    required_css_class = 'required'
    isUserEvent = forms.BooleanField(widget=forms.CheckboxInput(
        attrs={'onclick': 'javascript:viewGroup()'}),
                                     label='User Event',
                                     required=False,
                                     initial=False)
    title = forms.CharField(max_length=150,
                            required=True,
                            validators=[standard_validator])

    startTime = forms.SplitDateTimeField(input_time_formats=['%H:%M'],
                                         input_date_formats=['%m/%d/%Y'],
                                         label='Start Time',
                                         widget=forms.SplitDateTimeWidget(
                                             date_format='%m/%d/%Y',
                                             time_format='%H:%M',
                                         ))
    endTime = forms.SplitDateTimeField(input_time_formats=['%H:%M'],
                                       input_date_formats=['%m/%d/%Y'],
                                       label='End Time',
                                       widget=forms.SplitDateTimeWidget(
                                           date_format='%m/%d/%Y',
                                           time_format='%H:%M',
                                       ))
    description = forms.CharField(label='Description',
                                  max_length=1000,
                                  widget=forms.Textarea)
    group = forms.ModelChoiceField(
        queryset=Group.objects.all(),
        label='Group',
        required=False,
    )
    friends = forms.ModelMultipleChoiceField(
        queryset=Squirl.objects.all(),
        widget=forms.CheckboxSelectMultiple,
        required=False)

    def is_valid(self):

        # run the parent validation first
        valid = super(CreateEventForm, self).is_valid()

        # we're done now if not valid
        if not valid:
            return valid
        if self.cleaned_data['startTime'] > self.cleaned_data['endTime']:
            self.errors[
                'start_end_time'] = 'The start time cannot be after the end time'
            return False
        return True

    class Media:
        js = ('QED/addEventValidation.js')
Ejemplo n.º 12
0
class HuntForm(forms.Form):
    name = forms.CharField(
        max_length=128,
        widget=forms.TextInput(attrs={
            "class": "form-control",
            "placeholder": "Name of Hunt"
        }),
    )
    url = forms.URLField(widget=forms.TextInput(attrs={
        "class": "form-control",
        "placeholder": "URL"
    }))
    start_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={
                "class": "form-control",
                "placeholder": "Start Date"
            },
            time_attrs={
                "class": "form-control",
                "placeholder": "Start Time (ET, HH:MM, 24 hr)",
            },
        ),
        required=False,
    )
    end_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs={
                "class": "form-control",
                "placeholder": "End Date"
            },
            time_attrs={
                "class": "form-control",
                "placeholder": "End Time (ET, HH:MM, 24 hr)",
            },
        ),
        required=False,
    )

    def clean(self):
        data = super().clean()

        if "start_time" in data and "end_time" in data:

            if data["end_time"] and not data["start_time"]:
                raise forms.ValidationError(
                    "Start time must be provided with end time.",
                    code="missing_start")

            if (data["start_time"] and data["end_time"]
                    and data["end_time"] <= data["start_time"]):
                raise forms.ValidationError(
                    "End time must be after start time.",
                    code="end_before_start")

        return data
Ejemplo n.º 13
0
 class Meta:
     model = Competition
     fields = '__all__'
     exclude = ['categories', 'owner', 'files']
     widgets = {
         'data_start_inscription': forms.SplitDateTimeWidget(),
         'data_finish_inscription': forms.SplitDateTimeWidget(),
         'data_start_competition': forms.SplitDateTimeWidget(),
         'data_finish_competition': forms.SplitDateTimeWidget(),
     }
Ejemplo n.º 14
0
class AssessmentForm(forms.ModelForm):
    expired_on = forms.SplitDateTimeField(
        input_date_formats=['%Y-%m-%d'],
        input_time_formats=['%H:%M:%S'],
        widget=forms.SplitDateTimeWidget(date_format='%Y-%m-%d',
                                         time_format='%H:%M:%S',
                                         attrs={'class': 'form-control'}),
    )

    exam_start_date_time = forms.SplitDateTimeField(
        input_date_formats=['%Y-%m-%d'],
        input_time_formats=['%H:%M:%S'],
        widget=forms.SplitDateTimeWidget(date_format='%Y-%m-%d',
                                         time_format='%H:%M:%S',
                                         attrs={'class': 'form-control'}),
    )

    subscriber_users = forms.ModelMultipleChoiceField(
        queryset=Student.objects.filter(id=1),
        widget=forms.CheckboxSelectMultiple())

    class Meta:
        model = Assesment
        fields = ('__all__')
        exclude = [
            'deleted_by', 'deleted_at', 'created_by', 'updated_by',
            'exam_start_type'
        ]
        labels = {
            "header": "Short Heading",
            "privilege": "Visibility",
        }
        widgets = {
            'header':
            forms.TextInput(attrs={'class': 'form-control'}),
            'brief':
            forms.Textarea(attrs={'class': 'form-control'}),
            'passing_marks':
            forms.NumberInput(attrs={
                'class': 'form-control',
            }),
            'privilege':
            forms.Select(
                attrs={'class': 'custom-select custom-select-md mb-3'}),
        }

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request")
        super(AssessmentForm, self).__init__(*args, **kwargs)

        # If you pass FormHelper constructor a form instance
        # It builds a default layout with all its fields
        #self.helper = FormHelper(self)
        self.fields["subscriber_users"].queryset = Student.active.filter(
            staffuser__institute=self.request.user.staff.institute)
Ejemplo n.º 15
0
class CreateQuestForm(forms.Form, forms.ModelForm):
    name = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control'}))
    password = forms.CharField(
        widget=forms.PasswordInput(attrs={'class': 'form-control'}),
        required=False)
    target = forms.CharField(widget=forms.Textarea(
        attrs={'class': 'md-textarea'}))
    cost = forms.IntegerField(
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'type': 'number',
            'min': '0',
            'value': '0'
        }),
        required=False)
    town = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control'}))
    description = forms.CharField(widget=forms.Textarea, required=False)
    meeting_point = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control'}))
    meeting_date_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(attrs={'class': 'form-control'}))
    begin_date_time = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(attrs={'class': 'form-control m-2'}))
    end_date_time = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget(
        attrs={'class': 'form-control m-2'}))
    avatar = forms.ImageField(widget=forms.FileInput(
        attrs={'onchange': 'QuestImageAvatar(this.files[0])'}),
                              required=False)
    category = forms.MultipleChoiceField(required=False,
                                         widget=forms.CheckboxSelectMultiple,
                                         choices=Categ())

    class Meta:
        model = Quest
        fields = ('id', 'avatar', 'name', 'have_password', 'password', 'town',
                  'target', 'description', 'begin_date_time', 'end_date_time',
                  'meeting_point', 'meeting_date_time', 'have_group', 'paid',
                  'cost', 'category', 'author_id')

    def save(self, commit=True):
        quest = super(CreateQuestForm, self).save(commit=False)
        quest.author_id = self.author_id
        categories = self.category
        if commit:
            quest.save()
        for item in list(categories):
            quest.category.add(item)
        if commit:
            quest.save()
        return quest.id
Ejemplo n.º 16
0
class statsForm(forms.Form):
    kw_admit = forms.CharField(
        widget=forms.TextInput(attrs={
            'class': "toolbar_item_kw",
            'placeholder': "Keywords..."
        }),
        required=False)
    kw_dis = forms.CharField(
        widget=forms.TextInput(attrs={
            'class': "toolbar_item_kw",
            'placeholder': "Keywords..."
        }),
        required=False)
    kw_pre = forms.CharField(
        widget=forms.TextInput(attrs={
            'class': "toolbar_item_kw",
            'placeholder': "Keywords..."
        }),
        required=False)
    kw_patient = forms.CharField(
        widget=forms.TextInput(attrs={
            'class': "toolbar_item_kw",
            'placeholder': "Keywords..."
        }),
        required=False)

    start = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(attrs={'id': "dateTimeIds"}),
        initial=timezone.now() - datetime.timedelta(days=-30),
        label="Start",
        input_time_formats=['%H:%M', '%I:%M%p', '%I:%M %p', '%H:%M:%S'])

    end = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(attrs={'id': "dateTimeIde"}),
        initial=timezone.now(),
        label="End",
        input_time_formats=['%H:%M', '%I:%M%p', '%I:%M %p', '%H:%M:%S'])

    filter_choices = (
        ('patients_visiting_per',
         "Average Number of patients visiting the hospital each day,week,month,year"
         ),
        ('ave_stay_length', "Average Length from admission to dishcharge"),
        ('comm_pres', "Most common prescriptions"),
    )

    filters = forms.MultipleChoiceField(
        required=False,
        choices=filter_choices,
        widget=forms.CheckboxSelectMultiple(
            attrs={'class': 'toolbar_item_checkbox'}))
Ejemplo n.º 17
0
class AttendForm(forms.ModelForm):
    leave_start = forms.DateTimeField(widget=forms.SplitDateTimeWidget(),
                                      label='Baslangic Tarixi ve Saati')
    leave_end = forms.DateTimeField(widget=forms.SplitDateTimeWidget(),
                                    label='Bitme Tarixi ve Saati')

    class Meta:
        model = Attend
        fields = [
            'leave_type',
            'leave_start',
            'leave_end',
            'leave_reason',
        ]
Ejemplo n.º 18
0
class UpdateForm(forms.ModelForm):
    # TODO - review this in detail https://docs.djangoproject.com/en/2.0/topics/forms/modelforms/
    type = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control'}))
    start = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
    finish = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget(),
                                      required=False)
    rating = forms.ChoiceField(widget=forms.RadioSelect(),
                               choices=((1, 1), (2, 2), (3, 3), (4, 4), (5,
                                                                         5)),
                               required=False)

    class Meta:
        model = PracticeSession
        fields = ['start', 'finish', 'type', 'rating', 'feel', 'attemptCount']
Ejemplo n.º 19
0
class CatalogImageItemForm(forms.ModelForm):
    id = forms.ModelChoiceField(queryset=CatalogImage.objects.all(),
                                widget=forms.HiddenInput())
    temp = forms.BooleanField(widget=forms.HiddenInput(), required=False)
    date = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
    date.widget.widgets = (forms.TextInput({'class': 'vDateField'}),
                           forms.TextInput({'class': 'vTimeField'}))
    image = forms.ImageField(widget=AdmImageWidget(),
                             label=u'Zdjęcie',
                             required=False)
    tags = TagField(required=False)

    class Meta:
        model = CatalogImage
        fields = ('id', 'temp', 'date', 'image', 'sites', 'active', 'tags',
                  'permissions')

    def __init__(self, *args, **kwargs):
        super(CatalogImageItemForm, self).__init__(*args, **kwargs)
        try:
            root_pgroup = PermisionGroup.objects.filter(model='CatalogImage')
        except Exception, e:
            print 'form/catalog.py: ', e
            root_pgroup = None

        self.fields[
            'permissions'].label = u'Uprawnienia - pozostaw puste jeśli mają być domyślne'

        if root_pgroup is not None:
            pgroups = []
            for rg in root_pgroup:
                pg = PermisionGroup.objects.filter(parent=rg)
                for group in pg:
                    pgroups.append((group.id, mark_safe(group.name)))
            self.fields['permissions'].choices = pgroups
Ejemplo n.º 20
0
class WorkoutForm(forms.ModelForm):
    """How users log their runs/biking sessions/etc."""

    activity = forms.Select()
    calories = forms.IntegerField()

    # Will need to populate this with user's events, if any
    evt = forms.Select()

    date = forms.SplitDateTimeWidget()

    distance = forms.FloatField()

    duration = forms.TimeInput()

    class Meta:
        model = Workout

        fields = (
            "activity",
            "calories",
            "event",
            "date",
            "distance",
            "duration",
        )

        widgets = {
            "calories": forms.IntegerField(),
            "date": forms.DateTimeInput(format="%d/%m/%Y"),
            "distance": forms.FloatField(),
            "duration": forms.TimeInput(format="%H:%M:%S"),
        }
Ejemplo n.º 21
0
class AnnouncementForm(ModelForm):
    widget = forms.SplitDateTimeWidget(date_attrs={'type': 'date'},
                                       time_attrs={'type': 'time'})
    start_time = forms.SplitDateTimeField(widget=widget)
    end_time = forms.SplitDateTimeField(widget=widget)

    class Meta:
        model = AnnouncementModel
        fields = ['type', 'text', 'start_time', 'end_time']
        widgets = {
            'text':
            forms.Textarea(attrs={
                'class': 'form-control card-text',
                'rows': '3'
            })
        }

    def clean_start_time(self):
        data = self.cleaned_data['start_time']
        now = datetime.now()
        print(now)
        if data < now:
            raise forms.ValidationError(
                'Start datetime should be greater than now')
        return data

    def clean(self):
        cleaned_data = super().clean()
        start_time = cleaned_data.get("start_time")
        end_time = cleaned_data.get("end_time")
        print(cleaned_data)

        if start_time and start_time > end_time:
            raise forms.ValidationError(
                'End datetime should be greater than Start datetime')
Ejemplo n.º 22
0
    class Meta:

        model = Event

        fields = [
        'title',
        'description',
        'location',
        'date',
        'image_profile',
        'state',
        'categories',
        'arist',
        ]
        labels = {
        'title': 'Titulo',
        'description': 'Descripcion',
        'location': 'Ubicacion',
        'date': 'Fecha y Hora',
        'image_profile': 'Seleccionar imagen',
        'state': 'Estado Evento',
        'categories': 'Categoria',
        'arist': 'Artista',
        }
        widgets = {
        'title': forms.TextInput(attrs={'class':'form-control'}),
        'description': forms.Textarea(attrs={'class':'form-control'}),
        'location': forms.TextInput(attrs={'class':'form-control'}),
        'date': forms.SplitDateTimeWidget(),
        'image_profile': forms.FileInput(),
        'state': forms.RadioSelect(),
        'categories': forms.Select(),
        'arist': forms.Select(),
        }
Ejemplo n.º 23
0
class PostEditForm(forms.ModelForm):
    """PostEditForm

    A form to edit a Post

    Args:
        forms ([type]): [description]
    """

    pub_date = forms.SplitDateTimeField(
        required=False,
        input_date_formats=["%Y-%m-%d"],
        input_time_formats=["%H:%M:%S", "%H:%M"],
        widget=forms.SplitDateTimeWidget(
            date_attrs={"type": "date"},
            date_format="%Y-%m-%d",
            time_attrs={"type": "time"},
            time_format="%H:%M:%S",
        ),
    )

    class Meta:
        """Meta class for PostEditForm ModelForm"""

        model = Post
        fields = (
            "title",
            "featured_title",
            "categories",
            "tags",
            "series",
            "order_in_series",
            "description",
            "body",
            "image",
            "slug",
            "withdrawn",
            "needs_reviewing",
            "featuring_state",
            "publication_state",
            "pub_date",
            "url_to_article",
            "url_to_article_title",
            "language",
            "is_outdated",
        )

        widgets = {
            "title": forms.TextInput(),
            "featured_title": forms.TextInput(),
            "categories": forms.SelectMultiple(),
            "description": forms.Textarea(),
            "tags": TagSelectize(),
            "body": forms.Textarea(),
            "slug": forms.TextInput(),
            "url_to_article": forms.URLInput(),
            "url_to_article_title": forms.TextInput(),
            "series": forms.Select(),
            "language": forms.Select(),
        }
Ejemplo n.º 24
0
    def __init__(self, *args, **kwargs):
        kwargs['initial'] = {'end_time': datetime.now()}
        super(ClockOutForm, self).__init__(*args, **kwargs)
        self.fields['start_time'] = forms.DateTimeField(
            widget=forms.SplitDateTimeWidget(
                attrs={'class': 'timepiece-time'},
                date_format='%m/%d/%Y',
            ))
        self.fields['end_time'] = forms.DateTimeField(
            widget=forms.SplitDateTimeWidget(
                attrs={'class': 'timepiece-time'},
                date_format='%m/%d/%Y',
            ), )

        self.fields.keyOrder = ('location', 'start_time', 'end_time',
                                'comments')
Ejemplo n.º 25
0
class GigModelForm(forms.ModelForm):
    dateTime = forms.SplitDateTimeField(
        label="",
        widget=forms.SplitDateTimeWidget(date_attrs={
            'type': 'date',
            'class': 'form-control col-4'
        },
                                         time_attrs={
                                             'type': 'time',
                                             'class': 'form-control col-4 mt-1'
                                         }),
        help_text="Date format: dd/mm/yyyy \nTime format: hh:MM")
    venue = forms.CharField(label="",
                            widget=forms.TextInput(attrs={
                                'class': 'col-6',
                                'placeholder': 'Venue'
                            }),
                            help_text="Provide a description for your venue")
    genre = forms.ModelChoiceField(
        label="",
        empty_label="--- Select a genre ---",
        queryset=Genre.objects.all(),
        widget=forms.Select(attrs={'class': 'col-6'}))

    # artist = forms.ModelChoiceField(
    #     queryset=User.objects.all(), widget=forms.Select(attrs={'class': 'col-6'}))

    class Meta:
        model = Gig
        fields = [
            'venue',
            'dateTime',
            'genre',
        ]
Ejemplo n.º 26
0
class OrderCreateForm(BaseForm, forms.ModelForm):
    # date_pickup = forms.DateTimeField(initial=timezone.now())#forms.DateInput(attrs={'type':'date'}, format='%d.%m.%Y')format="%d %b %Y %H:%M:%S %Z")
    date_pickup = forms.SplitDateTimeField(initial=timezone.now(),
                                           widget=forms.SplitDateTimeWidget(
                                               date_attrs={'type': 'date'},
                                               date_format='%Y-%m-%d',
                                               time_attrs={'type': 'time'},
                                               time_format='%H:%M'))
    customer = forms.ModelChoiceField(queryset=Customer.objects.all(),
                                      empty_label="-----",
                                      required=False)

    class Meta:
        model = Order
        fields = [
            'title', 'content', 'customer', 'date_pickup', 'duration', 'state'
        ]

    def __init__(self, *args, **kwargs):
        super(OrderCreateForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        # self.helper.form_class = 'form-horizontal'
        # self.helper.label_class = 'col-md-3 create-label'
        self.helper.label_class = 'ml-5'
        self.helper.field_class = 'ml-5'
        self.helper.layout = Layout(
            Field('title', css_class="form-group col-md-9 mb-0 "),
            Field('content', css_class="form-group col-md-9 mb-0 "),
            Row(Column('customer', css_class='form-group col-md-3 mb-0 '),
                Column('date_pickup', css_class='form-group col-md-3 mb-0'),
                Column('duration', css_class='form-group col-md-3 mb-0'),
                css_class='form-row'),
            Field('state', css_class="form-group col-md-1 mb-0 "),
            Submit('submit', 'Speichern', css_class="ml-5 mb-5 form-group"))
Ejemplo n.º 27
0
class ExampleForm(forms.Form):
    submit_label = 'Send'

    char = forms.CharField(help_text='Non required example text input', )
    email = forms.EmailField(help_text='Valid email required', )
    boolean = forms.BooleanField(help_text='Required boolean!', )
    checkboxes = forms.MultipleChoiceField(
        choices=(('a', 'a'), ('b', 'b')),
        widget=forms.CheckboxSelectMultiple,
        help_text='Required checkbox multiple',
    )
    datetime = forms.SplitDateTimeField(
        widget=forms.SplitDateTimeWidget(
            date_attrs=dict(type='date'),
            time_attrs=dict(type='time'),
        ),
        help_text='Required help text',
    )
    textarea = forms.CharField(widget=forms.Textarea,
                               help_text='This is the help text')

    document = forms.FileField(widget=forms.FileInput,
                               help_text='Choose a file')

    select = forms.ChoiceField(widget=forms.Select,
                               choices=(
                                   ('Test',
                                    ((1, 'the first one'), (2, 'the second'),
                                     (3, 'the thirf'))),
                                   ('Re', ((4, '444'), (5, '555'))),
                               ),
                               initial=5)
Ejemplo n.º 28
0
 def __init__(self, *args, **kwargs):
     super(ParameterForm, self).__init__(*args, **kwargs)
     for i, p in enumerate(unique_parameters):
         kwargs2 = {}
         if p.label:
             kwargs2['label'] = p.label.title()
         else:
             kwargs2['label'] = p.name.replace('_', ' ').title()
         if p.comment:
             kwargs2['help_text'] = p.comment
         if p.data_type == 'CharField':
             kwargs2['max_length'] = 255
         kwargs2['required'] = p.required
         default = p.create_default()
         if default:
             kwargs2['initial'] = default
             #use default if a field with a default was left blank (useful for subscriptions)
         #Specify special widgets
         if p.data_type.lower() == 'datefield':
             kwargs2['widget'] = forms.DateInput(
                 attrs={'class': 'date'})  #SelectDateWidget
         elif p.data_type.lower() == 'datetimefield':
             kwargs2['widget'] = forms.SplitDateTimeWidget(
                 attrs={'class': 'datetime'})  #forms.DateTimeInput
         elif p.data_type.lower() == 'timefield':
             kwargs2['widget'] = forms.TimeInput(
                 attrs={'class': 'time'})
         self.fields[p.name] = getattr(django.forms.fields,
                                       p.data_type)(**kwargs2)
         #preserse order of parameters in form display (possibly unnecessary)
         self.fields[p.name].creation_counter = i
Ejemplo n.º 29
0
class ReportTagForm(forms.Form):
    player_code = forms.CharField(
        label="Other Player's Code",
        min_length=6,
        max_length=6,
        widget=forms.TextInput(attrs={
            'class': 'ui-input',
            'placeholder': "e.g. A1B2C3"
        }))
    datetime = forms.SplitDateTimeField(label="Date/Time",
                                        widget=forms.SplitDateTimeWidget(
                                            date_attrs={
                                                'class': 'ui-input',
                                                'type': 'date'
                                            },
                                            time_attrs={
                                                'class': 'ui-input',
                                                'type': 'time'
                                            }))
    location = forms.CharField(
        label="Location (optional)",
        required=False,
        widget=forms.TextInput(attrs={
            'class': 'ui-input',
            'placeholder': "e.g. RCH, DC Green"
        }))
    description = forms.CharField(
        label="Description (optional)",
        required=False,
        widget=forms.Textarea(
            attrs={
                'class': 'ui-input',
                'rows': '5',
                'placeholder': "Tell us how you tagged the player!"
            }))
Ejemplo n.º 30
0
class DateForm(ModelForm):
    date_format = '%m/%d/%Y'
    time_format = '%I:%M %p'
    start = forms.SplitDateTimeField(label=_("Start"),
                                     input_date_formats=[date_format],
                                     input_time_formats=[time_format],
                                     widget=forms.SplitDateTimeWidget(
                                         time_format=time_format,
                                         date_format=date_format))
    end = forms.SplitDateTimeField(label=_("End"),
                                   required=False,
                                   input_date_formats=[date_format],
                                   input_time_formats=[time_format],
                                   widget=forms.SplitDateTimeWidget(
                                       time_format=time_format,
                                       date_format=date_format))

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(DateForm, self).__init__(*args, **kwargs)

    def clean(self):
        # allows for equal start and end dates
        # when dates are equal end datetime is not shown in forms and templates
        start = self.cleaned_data.get('start')
        end = self.cleaned_data.get('end')
        if end and end < start:
            raise forms.ValidationError(
                _(u"The end time must be later than start time."))
        return self.cleaned_data

    def save(self):
        date = super(DateForm, self).save(commit=False)
        if not date.end:
            date.end = date.start
        if date.start and date.end:
            date.save()
        else:
            date = None
        return date

    class Meta:
        model = DateRange
        fields = (
            'start',
            'end',
        )