class AgreementDetailForm(ModelForm):
    evidence = forms.FileField(required=False)

    date_start = forms.Field(widget=DateInputWidget, label=_('start date'))
    date_until = forms.Field(widget=DateInputWidget, label=_('end date'))

    class Meta:
        model = AgreementDetail
        fields = [
            'description', 'date_start', 'date_until', 'state', 'evidence',
            'owner'
        ]
        # widgets = {
        #     'date_start': DateInputWidget
        # 'date_start': DateInput(attrs={'type': 'date'}, format='%m-%d-%Y')
        # }

    def __init__(self, *args, **kwargs):
        super(AgreementDetailForm, self).__init__(*args, **kwargs)
        # _instance = kwargs.pop('instance', None)
        # self.fields['description'].widget.attrs['class'] = 'form-control'
        # self.fields['date_until'].widget.attrs['class'] = 'form-control input-datepicker'
        # self.fields['date_start'].widget.attrs['class'] = 'form-control input-datepicker'
        # self.fields['state'].widget.attrs['class'] = 'form-control'
        # self.fields['evidence'].widget.attrs['class'] = 'form-control'
        add_form_control_class(self.fields)
Exemple #2
0
class CustomUserCreationForm(UserCreationForm):
    email = forms.Field(required=True)

    class Meta(UserCreationForm):
        model = User
        fields = (
            'email',
            'username',
            'password1',
            'password2',
        )

    def clean_password2(self):
        # Check that the two password entries match
        password1 = self.cleaned_data.get("password1")
        password2 = self.cleaned_data.get("password2")
        if password1 and password2 and password1 != password2:
            raise forms.ValidationError("Passwords don't match")
        return password2

    def save(self, commit=True):
        user = super().save(commit=False)
        user.set_password(self.cleaned_data["password1"])
        user.email = self.cleaned_data['email']
        if commit:
            user.save()
        return user
Exemple #3
0
class DriveUrlForm(forms.Form):
    document_url = forms.Field(required=True,
                               label='URL',
                               help_text='Enter the drive shareable URL')
    quality = ChoiceField(choices=DriveJob.QUALITY_CHOICES,
                          required=True,
                          initial='360p')
    recipient = EmailField()
    file_name_suffix = forms.Field(required=True,
                                   label='File Name',
                                   help_text='File Name to be added')

    def save(self):
        return DriveJob.initialize_job(self.cleaned_data['document_url'],
                                       self.cleaned_data['quality'],
                                       self.cleaned_data['recipient'],
                                       self.cleaned_data['file_name_suffix'])
Exemple #4
0
class SignUpForm(UserCreationForm):
    email = forms.Field(help_text='What is your email')

    #need to add email validator

    class Meta:
        model = User
        fields = ('username', 'email', 'password1', 'password2',)
class UrlForm(forms.Form):
    url = forms.Field(widget=URLInput(), required=True, label='Paste your URL here')

    def clean_url(self):
        url = self.cleaned_data.get('url')
        try:
            validator = URLValidator()
            validator(url)
        except forms.ValidationError:
            raise forms.ValidationError('Please enter a valid URL.')
        return url
class MettingForm(ModelForm):
    date = forms.Field(widget=DateInputWidget, label=_('date'))

    class Meta:
        model = Metting
        fields = ['title', 'date']

    def __init__(self, *args, **kwargs):
        super(MettingForm, self).__init__(*args, **kwargs)
        _instance = kwargs.pop('instance', None)
        add_form_control_class(self.fields)
Exemple #7
0
class StaffForm(ModelForm):

    link = forms.Field(required=False)

    class Meta:
        model = Staff
        fields = {'firstname', 'secondname', 'academic_rank', 'link'}
        labels = {
            'firstname': 'Imie',
            'secondname': 'Nazwisko',
            'academic_rank': 'tytuł',
            'link': 'link do jego strony'
        }
class AgreementForm(ModelForm):
    date = forms.Field(widget=DateInputWidget, label=_('date'))

    class Meta:
        model = Agreement
        fields = [
            'number', 'title', 'content', 'date', 'owner', 'observations'
        ]

    def __init__(self, *args, **kwargs):
        super(AgreementForm, self).__init__(*args, **kwargs)
        _instance = kwargs.pop('instance', None)
        add_form_control_class(self.fields)
Exemple #9
0
class PresentationForm(ModelForm):
    class Meta:
        model = Presentation
        fields = (
            'contact_email',
            'speaker_email',
            'speaker_code',
            'categories',
            'audiences',
            'title',
            'description',
            'short_abstract',
            'long_abstract',
            'file',
            'msg',
        )

    additional_speakers = forms.Field(required=False)
Exemple #10
0
class CommentCreateForm(forms.Form):
    content = forms.Field()
Exemple #11
0
class UserForm(forms.Form):
    userName = forms.Field()
    headImg = forms.FileField()