Ejemplo n.º 1
0
    class Meta:
        model = Gig
        fields = '__all__'

        widgets={
        'gig_date': DateTimePicker(
            options={"format": "YYYY-MM-DD", "pickTime": False},
            attrs={'placeholder': 'Use the button to the right to enter a date.'}),
        'gig_time': DateTimePicker(
            options={"format":"HH:mm", "pickDate":False},
            attrs={'placeholder': 'Use the button to the right to enter a time.'})
        }
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     self.user = kwargs.pop('current_user', None)
     super(CreateEventForm, self).__init__(*args, **kwargs)
     self.fields['group'].queryset = self.user.tavern_groups.all()
     self.fields['starts_at'].widget = DateTimePicker(
         options={
             "format": "YYYY-MM-DD HH:mm",
         })
     self.fields['ends_at'].widget = DateTimePicker(
         options={
             "format": "YYYY-MM-DD HH:mm",
         })
Ejemplo n.º 3
0
class EventForm(forms.ModelForm):

    description = forms.CharField(widget=SummernoteInplaceWidget())

    start_at = forms.DateTimeField(
        required=True,
        input_formats=['%d/%m/%Y %H:%M:%S'],
        label=_('Comienza'),
        widget=DateTimePicker(options={"format": "DD/MM/YYYY HH:ss:mm"}))

    end_at = forms.DateTimeField(
        required=True,
        input_formats=['%d/%m/%Y %H:%M:%S'],
        label=_('Finaliza'),
        widget=DateTimePicker(options={"format": "DD/MM/YYYY HH:ss:mm"}))

    class Meta:
        model = Event
        fields = ('name', 'description', 'place', 'address', 'url', 'start_at',
                  'end_at')

    def __init__(self, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.form_method = "post"
        self.helper.add_input(Submit('job_submit', _('Guardar')))
        self.helper.add_input(
            Reset('job_reset', _('Limpiar'), css_class='btn-default'))
        self.helper.layout = Layout(
            Div(
                'name',
                'description',
                'place',
                'address',
                'url',
                'start_at',
                'end_at',
            ))

    def clean(self):
        cleaned_data = super(EventForm, self).clean()
        start_at = cleaned_data.get('start_at')
        end_at = cleaned_data.get('end_at')
        if start_at is not None and end_at is not None:
            if start_at > end_at:
                msg = 'La fecha de inicio es menor a la fecha de finalizacion'
                self._errors['start_at'] = [_(msg)]
                self._errors['end_at'] = [_(msg)]
        return cleaned_data

    def save(self, *args, **kwargs):
        super(EventForm, self).save(*args, **kwargs)
        self.instance.save()
Ejemplo n.º 4
0
    def __init__(self, now_datetime, *args, **kwargs):
        initial_exam = kwargs.pop("initial_exam", None)

        super(IssueTicketForm, self).__init__(*args, **kwargs)

        from course.auth import UserSearchWidget

        self.fields["user"] = forms.ModelChoiceField(
            queryset=(get_user_model().objects.filter(
                is_active=True).order_by("last_name")),
            widget=UserSearchWidget(),
            required=True,
            help_text=_("Select participant for whom ticket is to "
                        "be issued."),
            label=_("Participant"))
        self.fields["exam"] = forms.ModelChoiceField(
            queryset=(Exam.objects.filter(
                Q(active=True)
                & (Q(no_exams_after__isnull=True)
                   | Q(no_exams_after__gt=now_datetime))).order_by(
                       "no_exams_before")),
            required=True,
            initial=initial_exam,
            label=_("Exam"))

        self.fields["valid_start_time"] = forms.DateTimeField(
            label=_("Start validity"),
            widget=DateTimePicker(options={
                "format": "YYYY-MM-DD HH:mm",
                "sideBySide": True
            }),
            required=False)
        self.fields["valid_end_time"] = forms.DateTimeField(
            label=_("End validity"),
            widget=DateTimePicker(options={
                "format": "YYYY-MM-DD HH:mm",
                "sideBySide": True
            }),
            required=False)
        self.fields["restrict_to_facility"] = forms.CharField(
            label=_("Restrict to facility"),
            help_text=_(
                "If not blank, the exam ticket may only be used in the "
                "given facility"),
            required=False)

        self.fields["revoke_prior"] = forms.BooleanField(
            label=_("Revoke prior exam tickets for this user"),
            required=False,
            initial=True)

        self.helper.add_input(Submit("issue", _("Issue ticket")))
Ejemplo n.º 5
0
class BarbershopForm(forms.ModelForm):
    service_type = forms.MultipleChoiceField(choices=SERVICE_CHOICES)
    start_date = forms.DateField(
        widget=DateTimePicker(options={"format": "YYYY-MM-DD",
                                       "pickTime": False}))
    end_date = forms.DateField(
        widget=DateTimePicker(options={"format": "YYYY-MM-DD",
                                       "pickTime": False}))
    operation_start_time = forms.ChoiceField(choices=TIME_CHOICE_START)
    operation_end_time = forms.ChoiceField(choices=TIME_CHOICES_END)

    class Meta:
        model = Barbershop
        fields = ('name', 'phone', 'website', 'rating', 'description')
        exclude = (
            'picture_url',
            'rating'
        )
        widgets = {
            'phone': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Phone'}),
            'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Barbaershop name'}),
            'website': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Barbaershop website'}),
            'description': forms.Textarea(
                attrs={'rows': '4', 'column': '6', 'class': 'form-control', 'placeholder': 'Barbaershop description'}),
        }

    picture = forms.FileField(required=False)

    # the last to operate
    def clean(self):
        cleaned_data = super(BarbershopForm, self).clean()
        print self.cleaned_data
        return cleaned_data

    def clean_end_date(self):
        print self.cleaned_data
        start_date = self.cleaned_data.get('start_date')
        end_date = self.cleaned_data.get('end_date')  # would be none if use clean_start_date
        print start_date
        print end_date
        if start_date > end_date:
            raise forms.ValidationError('Start date is larger than end date.')
        return start_date

    def clean_operation_end_time(self):
        operation_start_time = self.cleaned_data.get('operation_start_time')
        print operation_start_time
        operation_end_time = self.cleaned_data.get('operation_end_time')
        print operation_end_time
        if operation_start_time > operation_end_time:
            raise forms.ValidationError('Operation start time is larger than operation end time.')
        return operation_start_time
Ejemplo n.º 6
0
class AnimalForm(forms.ModelForm):
    sex = Select2ChoiceField(
        choices=Animal.SEX_CHOICES,
        widget=Select2Widget(select2_options={'minimumInputLength': 0}))
    color = ColorField(required=False,
                       widget=AutoHeavySelect2Widget(
                           select2_options={'minimumInputLength': 0}))
    sire = BullField(
        required=False,
        widget=AutoHeavySelect2Widget(select2_options={
            'minimumInputLength': 0,
            'width': '40px'
        }),
        attrs={
            'add_button':
            mark_safe(
                '<button id="comment-button" class="btn btn-primary" type="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Category</button>'
            )
        })
    dam = CowField(required=False,
                   widget=AutoHeavySelect2Widget(
                       select2_options={'minimumInputLength': 0}),
                   help_text='')
    breeder = BreederField(required=False,
                           widget=AutoHeavySelect2Widget(
                               select2_options={'minimumInputLength': 0}))
    birth_date = forms.DateField(widget=DateTimePicker(options={
        'format': 'YYYY-MM-DD',
        'pickTime': False
    }))
    weaning_date = forms.DateField(widget=DateTimePicker(options={
        'format': 'YYYY-MM-DD',
        'pickTime': False
    }),
                                   required=False)
    yearling_date = forms.DateField(widget=DateTimePicker(options={
        'format': 'YYYY-MM-DD',
        'pickTime': False
    }),
                                    required=False)

    def __init__(self, *args, **kwargs):
        super(AnimalForm, self).__init__(*args, **kwargs)
        for field_name, field in self.fields.items():
            if field_name not in ('group', 'sire', 'dam'):
                field.widget.attrs['class'] = 'form-control'

    class Meta:
        model = Animal
        fields = ('ear_tag', 'name', 'color', 'sex', 'breed', 'sire', 'dam',
                  'breeder', 'birth_date', 'birth_weight', 'weaning_date',
                  'weaning_weight', 'yearling_date', 'yearling_weight')
Ejemplo n.º 7
0
 class Meta:
     model = Activity
     fields = [
         'id', 'name', 'description', 'requirements', 'start_time',
         'end_time', 'participants_limit', 'activity_category',
         'activity_type'
     ]
     error_messages = {'required': 'This field is required'}
     widgets = {
         'start_time':
         DateTimePicker(options={"format": "YYYY-MM-DD HH:mm"}),
         'end_time': DateTimePicker(options={"format": "YYYY-MM-DD HH:mm"})
     }
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        super(ClaimForm, self).__init__(*args, **kwargs)

        self.fields['claim_date'].label = "Claim Date"
        self.fields['claim_date'].widget = DateTimePicker(
            options=DATEPICKER_OPTIONS)

        self.fields['delivery_date'].label = "Delivery Date"
        self.fields['delivery_date'].widget = DateTimePicker(
            options=DATEPICKER_OPTIONS)

        self.fields['order_invoice_num'].label = "Vendor Order/invoice #"
        self.fields['order_ref'].label = "FurniCloud Order"
Ejemplo n.º 9
0
class ObservationLogForm(forms.Form):
    start_time = forms.DateField(required=False, widget=DateTimePicker(
            options={"format": "YYYY-MM-DD"}
        ))
    end_time = forms.DateField(required=False, widget=DateTimePicker(
            options={"format": "YYYY-MM-DD"}
        ))

    def clean_start_time(self):
        start_time = self.cleaned_data['start_time']
        if start_time > timezone.now().date():
            raise forms.ValidationError("You can't have observed anything in the future")
        return start_time
Ejemplo n.º 10
0
class ToDoForm(forms.Form):
    todo = forms.CharField(widget=forms.TextInput(
        attrs={"class": "form-control"}))
    date = forms.DateField(widget=DateTimePicker(options={
        "format": "YYYY-MM-DD",
        "pickTime": False
    }))
    reminder = forms.DateTimeField(
        required=False,
        widget=DateTimePicker(options={
            "format": "YYYY-MM-DD HH:mm",
            "pickSeconds": False
        }))
Ejemplo n.º 11
0
class DataRangeForm(forms.Form):
    dtinicio = forms.DateTimeField(label='Data Inicial',
                                   required=False,
                                   widget=DateTimePicker(options={
                                       "format": "YYYY-MM-DD",
                                       "pickTime": True
                                   }))
    dtfim = forms.DateTimeField(label='Data Final',
                                required=False,
                                widget=DateTimePicker(options={
                                    "format": "YYYY-MM-DD",
                                    "pickTime": True
                                }))
Ejemplo n.º 12
0
class DateCotizationForm(forms.Form):
    start_date = forms.DateField(label='Fecha inicial',
                                 required=True,
                                 widget=DateTimePicker(options={
                                     "format": "YYYY-MM-DD",
                                     "pickTime": False
                                 }))
    end_date = forms.DateField(label='Fecha final',
                               required=True,
                               widget=DateTimePicker(options={
                                   "format": "YYYY-MM-DD",
                                   "pickTime": False
                               }))
Ejemplo n.º 13
0
class EventForm(forms.ModelForm):

    start_at = forms.DateTimeField(widget=DateTimePicker(
        options={
            "format": "DD/MM/YYYY HH:mm",
            "pickTime": True,
        }))

    end_at = forms.DateTimeField(widget=DateTimePicker(
        options={
            "format": "DD/MM/YYYY HH:mm",
            "pickTime": True
        }))

    lat = forms.CharField(max_length=20,
                          required=True,
                          widget=forms.HiddenInput())
    lng = forms.CharField(max_length=20,
                          required=True,
                          widget=forms.HiddenInput())

    class Meta:
        model = Event
        fields = ('name', 'description', 'place', 'address', 'url', 'start_at',
                  'end_at')

    def __init__(self, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.form_method = "post"
        self.helper.add_input(Submit('job_submit', _('Guardar')))
        self.helper.add_input(
            Reset('job_reset', _('Limpiar'), css_class='btn-default'))
        self.helper.layout = Layout(
            Div(
                'name',
                'description',
                'place',
                'address',
                'url',
                'start_at',
                'end_at',
                'lat',
                'lng',
            ), Div(css_id="map-canvas", ))

    def save(self, *args, **kwargs):
        super(EventForm, self).save(*args, **kwargs)
        self.instance.lat = self.cleaned_data.get('lat')
        self.instance.lng = self.cleaned_data.get('lng')
        self.instance.save()
Ejemplo n.º 14
0
class ScheduleFollowUpModalForm(forms.Form):

	def __init__(self,*args,**kwargs):
	
		self.user = kwargs.pop('user',User)
		
		super (ScheduleFollowUpModalForm,self).__init__(*args,**kwargs)
		
		self.fields['contact'] = forms.TypedChoiceField(
		choices = get_contact_list(self.user)
		)
	
	date = forms.DateField(
	input_formats=['%m/%d/%y'],
	required = False,
	initial = datetime.date.today(),
	label="Date of follow up",
	widget=DateTimePicker(
		options = {
		'format':'MM/DD/YY',
		'pickTime':False,
		}
	)
	)
	
	time = forms.TimeField(
	input_formats=['%I:%M %p'],
	required = False,
	initial = datetime.time(),
	label = 'Time of follow up',
	widget = DateTimePicker(
		options={
		'format': 'hh:mm a',
		'pickDate':False,
		'pickSeconds':False,
		}
	)
	)
	
	method = forms.CharField(
	required = False,
	max_length = 50,
	label = 'Method of contact',
	)
	
	note = forms.CharField(
	required = False,
	max_length = 250,
	label = 'Note about this follow up',
	widget = forms.Textarea
	)
Ejemplo n.º 15
0
 class Meta:
     model = Project
     fields = (
         'startDate',
         'endDate',
         'plannedEffort',
         'totalValue',
         'po',
         'salesForceNumber'
     )
     widgets = {
         'startDate': DateTimePicker(options=dateTimeOption),
         'endDate': DateTimePicker(options=dateTimeOption),
     }
Ejemplo n.º 16
0
class DocumentForm(forms.Form):
    # docfile = forms.FileField(label='Select a file',widget=forms.ClearableFileInput(attrs={'class' : 'btn btn-info btn-lg'}))
    podId = forms.CharField(label='Pod ID', max_length=30,widget=forms.TextInput(attrs={'class': 'form-control'}))
    projectName = forms.CharField(label='Project Name', max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
    school = forms.CharField(label='Name of your School', max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
    mentorName = forms.CharField(label='Name of your CU Mentor', max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
    location = forms.CharField(label='Location', max_length=30,widget=forms.TextInput(attrs={'class': 'form-control'}))
    startDate = forms.DateField(label='Start Date',widget=DateTimePicker(options={"format": "YYYY-MM-DD"}))
    endDate = forms.DateField(label='End Date',widget=DateTimePicker(options={"format": "YYYY-MM-DD"}))
    podUseType = forms.MultipleChoiceField(label='POD Usage type', choices=USETYPE,widget=forms.CheckboxSelectMultiple())
    pollutantOfInterest = forms.MultipleChoiceField(label='Pollutants of Interest', choices=POLLUTANTOFINTEREST,widget=forms.CheckboxSelectMultiple())
    podUseReason = forms.CharField(label='POD Usage Reason',widget=forms.Textarea(attrs={'class': 'form-control'}))

    docfile = forms.FileField(label='Select a file',label_suffix="") 
Ejemplo n.º 17
0
class OrderFilterForm(forms.Form):
    production_date_start = forms.DateField(
        label="Production date start", required=False,
        widget=DateTimePicker(options={"format": "YYYY-MM-DD", "pickTime": False})
    )
    production_date_end = forms.DateField(
        label='End', required=False,
        widget=DateTimePicker(options={"format": "YYYY-MM-DD", "pickTime": False})
    )
    customers = forms.ModelMultipleChoiceField(queryset=Customer.objects.all(), required=False)

    def clean(self):
        if self.cleaned_data.get('production_date_start', 0) > self.cleaned_data.get('production_date_end', 1):
            raise ValidationError("Start date should earlier than end date!")
        return super(OrderFilterForm, self).clean()
Ejemplo n.º 18
0
class FilterForm(forms.Form):
    start_date = forms.DateField(widget=DateTimePicker(
        format=date_format, options={'pickTime': False}),
                                 label=_('Start Date'))
    end_date = forms.DateField(widget=DateTimePicker(
        format=date_format, options={'pickTime': False}),
                               label=_('End Date'))
    minimum_magnitude = forms.IntegerField(min_value=0,
                                           max_value=10,
                                           label=_('Minimum Magnitude'))
    maximum_magnitude = forms.IntegerField(min_value=0,
                                           max_value=10,
                                           label=_('Maximum Magnitude'))
    # hidden field for felt shakes
    felt = forms.BooleanField()
Ejemplo n.º 19
0
 class Meta:
     model = ProjectTeamMember
     fields = (
         'member',
         'datapoint',
         'startDate',
         'endDate',
         'rate',
         'plannedEffort',
     )
     widgets = {
         'startDate': DateTimePicker(options=dateTimeOption),
         'endDate': DateTimePicker(options=dateTimeOption),
         'project': forms.HiddenInput(),
     }
Ejemplo n.º 20
0
    class Meta:
        model = Event
        fields = ('name', 'description', 'start', 'end', 'location')
        widgets = {
        	'name': forms.TextInput(attrs={'class': 'form-control'}),
        	'description': forms.TextInput(attrs={'class': 'form-control'}),
        	'start': DateTimePicker(attrs={'class': 'form-control'},options={
        		'format': "MM/DD/YYYY HH:mm",
        		}),
        	'end': DateTimePicker(attrs={'class': 'form-control'},options={
        		'format': "MM/DD/YYYY HH:mm",
        		}),
        	'location': forms.TextInput(attrs={'class': 'form-control'}),

        }
Ejemplo n.º 21
0
	def __init__(self,*args,**kwargs):
		self.user = kwargs.pop('user',User)
		self.contact = kwargs.pop('contact',False)
		
		super (RecordMeetingModalForm, self).__init__(*args,**kwargs)

		if self.contact:
		
			self.fields['contact_id'] = forms.IntegerField(
				widget=forms.HiddenInput(),
				initial=self.contact
			)
			
		else:
		
			self.fields['contact_id'] = forms.TypedChoiceField(
				choices = get_contact_list(self.user),
				label = 'Contact',
			)
				
			self.fields['date'] = forms.DateField(
			input_formats=['%m/%d/%y'],
			initial = datetime.date.today,
			widget=DateTimePicker(
			attrs={'class':'form-control'},
			options={
			'format':'MM/DD/YY',
			'pickTime':False,
			},
			),
			)
			
			self.fields['time'] = forms.TimeField(
			input_formats=['%I:%M %p'],
			widget=DateTimePicker(
			attrs={'class':'form-control'},
			options={
			'format':'HH:mm a',
			'pickDate':False,
			'pickSeconds':False,
			},
			),
			)
			
			self.fields['location'] = forms.CharField(
			max_length=255,
			required=False
			)
Ejemplo n.º 22
0
class AbsenceForm(forms.Form):
    name = forms.CharField(label='Nom et prénom :',
                           max_length=300,
                           required=True)

    motif = forms.ChoiceField(
        label='Motifs',
        choices=tuple(motifs),
        required=False,
    )

    datetime_absence_start = forms.DateTimeField(
        label="Date du début de l'absence",
        widget=DateTimePicker(),
        required=False,
    )

    datetime_absence_end = forms.DateTimeField(
        label="Date de la fin de l'absence",
        widget=DateTimePicker(),
        required=False,
    )

    comment = forms.CharField(
        label='Commentaire(s)',
        widget=forms.Textarea(),
        max_length=10000,
        required=False,
    )

    def __init__(self, *args, **kwargs):
        self.abs_id = kwargs.pop('abs_id', -1)
        self.id_person = kwargs.pop('person_id', -1)
        self.type = 'new'
        if self.abs_id >= 0:
            self.type = 'change'
        super(AbsenceForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.include_media = False
        self.helper.html5_required = True
        self.helper.form_class = 'col-sm-8'
        self.helper.layout = Layout(
            Field('name', id="nomForm", autocomplete='off'),
            Field('motif', autocomplete='off'),
            Field('datetime_absence_start'), Field('datetime_absence_end'),
            Field('comment'), Hidden('id_person', self.id_person),
            Hidden('abs_id', self.abs_id), Hidden('type', self.type),
            Submit('submit', 'Soumettre'))
Ejemplo n.º 23
0
 class Meta:
     model = Campaign
     exclude = [
         'user', 'status', 'content_type', 'object_id', 'has_been_started',
         'has_been_duplicated', 'created_date', 'totalcontact',
         'imported_phonebook', 'completed'
     ]
     # fields = ['campaign_code', 'name',
     #           'callerid', 'caller_name', 'aleg_gateway', 'sms_gateway',
     #           'content_object',  # 'content_type', 'object_id'
     #           'extra_data', 'dnc', 'description', 'phonebook',
     #           'frequency', 'callmaxduration', 'maxretry',
     #           'intervalretry', 'calltimeout',
     #           'completion_maxretry', 'completion_intervalretry',
     #           'startingdate', 'expirationdate',
     #           'daily_start_time', 'daily_stop_time',
     #           'monday', 'tuesday', 'wednesday', 'thursday', 'friday',
     #           'saturday', 'sunday',
     #           'selected_phonebook', 'selected_content_object',
     #           'voicemail', 'amd_behavior', 'voicemail_audiofile',
     #           #'agent_script', 'lead_disposition', 'external_link'
     #           ]
     widgets = {
         'description':
         Textarea(attrs={
             'cols': 23,
             'rows': 3
         }),
         'agent_script':
         Textarea(attrs={
             'cols': 23,
             'rows': 3
         }),
         'lead_disposition':
         Textarea(attrs={
             'cols': 23,
             'rows': 3
         }),
         'external_link':
         Textarea(attrs={
             'cols': 23,
             'rows': 3
         }),
         'startingdate':
         DateTimePicker(options={"format": "YYYY-MM-DD HH:mm:ss"}),
         'expirationdate':
         DateTimePicker(options={"format": "YYYY-MM-DD HH:mm:ss"}),
     }
Ejemplo n.º 24
0
class JobForm(forms.ModelForm):
    description = forms.CharField(widget=CKEditorWidget())
    website = forms.URLField(
        initial='http://',
        help_text='Remember to start with http:// or https://'
    )
    cities = forms.CharField(
        help_text="List the cities where this opportunity is available. \
            If you have opportunities in cities in more than one country, \
            please submit a separate job opportunity per country."
    )
    state_province = forms.CharField(
        required=False,
        help_text="If relevant, add the name of the state or province where the meetup/event is happening."
    )
    expiration_date = forms.DateField(
        required=False,
        help_text="Enter the date until which the post should be published. "
                  "By default, it is set to 60 days from posting.",
        widget=DateTimePicker(options={"format": "YYYY-MM-DD",
                                       "pickTime": False}))

    class Meta:
        model = Job
        fields = ('company', 'website', 'contact_email', 'title',
                  'description', 'cities', 'state_province', 'country', 'remote_work', 'relocation')
        # custom labels
        labels = {
            'title': 'Job title'
        }
Ejemplo n.º 25
0
class UpdateArticleForm(ModelForm):
    """
    Form to update information about articles
    """
    title = forms.CharField(
        required=True,
        label='Title',
        widget=forms.TextInput(attrs={'placeholder': 'Title of the article'}))

    area = forms.CharField(
        required=True,
        label='Area',
        widget=forms.TextInput(attrs={'placeholder': 'Area of the article'}))

    magazine_name = forms.CharField(
        required=True,
        label='Magazine',
        widget=forms.TextInput(attrs={'placeholder': 'Magazine Name'}))

    publication_date = forms.DateField(
        required=True,
        widget=DateTimePicker(
            options={
                "pickTime": False,
                "format": "YYYY-MM-DD"
            },
            attrs={'placeholder': 'Published Date (YYYY-MM-DD)'}))

    class Meta:
        model = Article
        exclude = [
            'username',
            'achievement_id',
        ]
Ejemplo n.º 26
0
class EditUserSettingsForm(forms.ModelForm):
    birth_date = forms.DateField(
        label=_("Syntymäaika"),
        widget=DateTimePicker(options={
            "format": "DD.MM.YYYY",
            'startDate': '01/01/1900'
        }),
        required=False)
    municipality = forms.ModelChoiceField(label=_("Kotikunta"),
                                          queryset=Municipality.objects.all(),
                                          widget=Select2,
                                          required=True,
                                          empty_label=_("Valitse"))
    phone_number = CustomPhoneNumberField(required=False)
    """
    def clean_email(self):
        username = self.cleaned_data.get('email', None)
        if username:
            if bool(self._meta.model._default_manager.filter(email=username)):
                raise forms.ValidationError(_("Sähköpostiosoite on jo käytössä."))
        return username
    """
    class Meta:
        model = UserSettings
        fields = ("first_name", "last_name", "birth_date", "municipality",
                  "email", "phone_number", "message_notification")
Ejemplo n.º 27
0
class UpdateAppointmentForm(forms.ModelForm):

    doctor = forms.ModelChoiceField(queryset=Doctor.objects.all(),
                                    empty_label=None)
    time = forms.DateTimeField(
        widget=DateTimePicker(options={
            'format': 'YYYY-MM-DD HH:mm',
            'pickSeconds': False
        }),
        help_text='Choose a time on the quarters of an hour')

    class Meta:
        model = Appointment
        exclude = ['location', 'patient']

    def clean_time(self):
        time = self.cleaned_data['time']
        if int(time.minute) % 15 != 0:
            raise ValidationError(
                "Appointment must be on the quarter of the hour!")
        elif Appointment.objects.filter(time=time).exists():
            raise ValidationError(
                "The doctor already has an appointment at this time!")
        elif time.hour < 9 or time.hour >= 17:
            raise ValidationError("Hospital is not open at this time!")
        elif time < datetime.now():
            raise ValidationError("Can't pick a date in the past")

        return time
Ejemplo n.º 28
0
Archivo: forms.py Proyecto: tobast/care
    def __init__(self, transaction_id, *args, **kwargs):
        super().__init__(*args, **kwargs)

        transaction = TransactionReal.objects.get(id=transaction_id)

        self.fields['amount'].label = '€'
        self.fields['sender'] = forms.ModelChoiceField(
            queryset=UserProfile.objects.filter(group_accounts=transaction.group_account.id),
            empty_label=None, label='From',
            widget=forms.HiddenInput)

        self.fields['receiver'] = forms.ModelChoiceField(
            queryset=GroupAccount.shown_members_queryset(transaction.group_account.id),
            empty_label=None, label='To')

        self.fields['group_account'] = forms.ModelChoiceField(
            queryset=GroupAccount.objects.filter(id=transaction.group_account.id),
            empty_label=None,
            label='Group')

        self.fields['group_account'].widget.attrs['readonly'] = True
        self.fields['modifications'] = forms.ModelMultipleChoiceField(queryset=Modification.objects.all(),
                                                                      required=False,
                                                                      widget=forms.MultipleHiddenInput())

        self.fields['date'] = forms.DateTimeField(widget=DateTimePicker(options={"format": "YYYY-MM-DD"}))
Ejemplo n.º 29
0
Archivo: forms.py Proyecto: tobast/care
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        transaction = self.instance

        self.fields['consumers'] = ShareConsumersField(
            queryset=GroupAccount.shown_members_queryset(transaction.group_account),
            label='Shared by some',
            required=False
        )

        self.fields['buyer'] = forms.ModelChoiceField(
            queryset=GroupAccount.shown_members_queryset(transaction.group_account),
            empty_label=None
        )

        self.fields['group_account'] = forms.ModelChoiceField(
            queryset=GroupAccount.objects.filter(id=transaction.group_account.id),
            empty_label=None,
            label='Group'
        )

        self.fields['date'] = forms.DateTimeField(widget=DateTimePicker(options={"format": "YYYY-MM-DD", "pickTime": False}))
        # self.fields['modifications'] = forms.ModelMultipleChoiceField(queryset=Modification.objects.all(),
        #                                                               required=False,
        #                                                               widget=forms.MultipleHiddenInput())
        self.fields['group_account'].widget.attrs['readonly'] = True
Ejemplo n.º 30
0
class TicketForm(forms.ModelForm):

    datesolved = forms.DateField(
        widget=DateTimePicker(options={"format": "DD/MM/YYYY"}),
        required=False,
        label='Solucionado')
    name = forms.CharField(max_length=100, label='Nombre')
    description = forms.CharField(widget=forms.Textarea(attrs={'rows': 7}),
                                  label='Descripción')
    priority = forms.ModelChoiceField(queryset=Priority.objects.all(),
                                      label='Prioridad')
    categories = forms.ModelMultipleChoiceField(
        queryset=Category.objects.all(), label='Categorias')
    user = forms.ModelChoiceField(queryset=User.objects.all(),
                                  label='Asignado')
    escalated = forms.BooleanField(label='Escalar',
                                   initial=False,
                                   required=False)
    hidden = forms.BooleanField(label='Archivar',
                                initial=False,
                                required=False)
    state = forms.ModelChoiceField(queryset=State.objects.all(),
                                   label='Estado',
                                   required=True)

    class Meta:
        model = Ticket
        fields = [
            'datesolved', 'name', 'description', 'priority', 'categories',
            'user', 'escalated', 'hidden', 'state'
        ]