Esempio n. 1
0
class UserProfileForm(forms.ModelForm):
    nr_selfphone = forms.CharField(validators=[number_selphone])
    postal_code = PLPostalCodeField()

    class Meta:
        model = ProfileUser
        exclude = ['user']
Esempio n. 2
0
 class Meta:
     model = Order
     code = PLPostalCodeField()
     nip = PLNIPField()
     fields = [
         'name', 'surname', 'email', 'street', 'street_number', 'city',
         'code', 'nip'
     ]
Esempio n. 3
0
class OrderCreateForm(forms.ModelForm):
    postal_code = PLPostalCodeField()

    class Meta:
        model = Order
        fields = [
            'first_name', 'last_name', 'email', 'address', 'postal_code',
            'city'
        ]
Esempio n. 4
0
class PLPostalAddressForm(PostalAddressForm):    
    line1 = forms.CharField(label=_(u"Street"), max_length=100)
    city = forms.CharField(label=_(u"City"), max_length=100)
    code = PLPostalCodeField(label=_(u"Zip code"))

    def __init__(self, *args, **kwargs):
        super(PLPostalAddressForm, self).__init__(*args, **kwargs)
        self.fields.pop('line2')
        self.fields.pop('state')
        self.fields['country'].initial = "PL"
Esempio n. 5
0
class AddressForm(forms.ModelForm):
    zip_code = PLPostalCodeField()

    class Meta:
        model = Address
        exclude = ["user"]
        widgets = {"address_type": forms.HiddenInput()}
        labels = {"is_default": _("Set as default")}

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user", None)
        super().__init__(*args, **kwargs)
        if not self.user.is_authenticated:
            del self.fields["is_default"]
        else:
            del self.fields["email"]
Esempio n. 6
0
class OrganizationForm(forms.ModelForm):
    description = forms.CharField(
        widget=CKEditorWidget(
            attrs={
                'placeholder': _("Some information about the institution"),
            }
        ),
        label=_("Description"),
        required=False

    )

    slug = forms.SlugField(required=False)

    users = forms.ModelMultipleChoiceField(
        queryset=User.objects.all(),
        required=False,
        widget=FilteredSelectMultiple(
            verbose_name=_('Users'),
            is_stacked=False
        ),
        label=_("Users")

    )
    postal_code = PLPostalCodeField(label=_("Postal code"))
    regon = PLREGONField()
    website = forms.URLField(label=_("Website"))
    # institution_type = forms.ChoiceField(choices=(
    #     ('local', _('Local goverment')),
    #     ('state', _('Public goverment')),
    #     ('other', _('Other'))),
    #     initial='state',
    #     label=_("Institution type"))

    email = forms.EmailField()

    def __init__(self, *args, **kwargs):
        super(OrganizationForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['users'].initial = self.instance.users.all()

    def clean_slug(self):
        slug = self.cleaned_data['slug']
        obj = Organization.raw.filter(slug=slug)
        if obj and 'slug' in self.changed_data:
            raise forms.ValidationError(_("That value is already taken"))
        return slug

    def save(self, commit=True):
        super(OrganizationForm, self).save(commit=False)
        if commit:
            self.instance.save()
        if self.instance.pk:
            self.instance.users.set(self.cleaned_data['users'])
            self.save_m2m()
        return self.instance

    class Meta:
        model = Organization
        fields = [
            'slug',
            'title',
            'institution_type',
            'postal_code',
            'city',
            'street',
            'street_number',
            'flat_number',
            'street_type',
            'email',
            'fax',
            'tel',
            'epuap',
            'regon',
            'website',
            'users'
        ]
Esempio n. 7
0
    'ID': IDPostalCodeField(),
    'IL': ILPostalCodeField(),
    'IN': INPostalCodeField(),
    'IS': ISPostalCodeField(),
    'IT': ITPostalCodeField(),
    'JP': JPPostalCodeField(),
    'LT': LTPostalCodeField(),
    'LV': LVPostalCodeField(),
    'MA': MAPostalCodeField(),
    'MT': MTPostalCodeField(),
    'MX': MXPostalCodeField(),
    'NL': NLPostalCodeField(),
    'NO': NOPostalCodeField(),
    'NZ': NZPostalCodeField(),
    'PK': PKPostalCodeField(),
    'PL': PLPostalCodeField(),
    'PT': PTPostalCodeField(),
    'RO': ROPostalCodeField(),
    'RU': RUPostalCodeField(),
    'SE': SEPostalCodeField(),
    'SG': SGPostalCodeField(),
    'SI': SIPostalCodeField(),
    'SK': SKPostalCodeField(),
    'TR': TRPostalCodeField(),
    'UA': UAPostalCodeField(),
    'US': USZipCodeField(),
    'ZA': ZAPostalCodeField(),
}

# Dictionary of ISO country code to IBAN length.
#
Esempio n. 8
0
class UserRegistrationCourseFormBase(ModelForm):
    pesel = PLPESELField(max_length=11,
                         label=_("PESEL"),
                         widget=TextInput(attrs={'type': 'number'}))
    postal_code = PLPostalCodeField(label=_("Postal code"))
    email = EmailField(label=_("E-mail address"))
    country = CharField(required=True)

    statement1 = BooleanField(required=True)
    statement2 = BooleanField(required=True)

    def __init__(self, *args, **kwargs):
        super(UserRegistrationCourseFormBase, self).__init__(*args, **kwargs)

        self.fields['statement1'].label = _(
            "I agree with the project participant's declaration. <a href='{url}'>PDF</a>"
        ).format(url=static(settings.STATEMENT1_PDF))

        self.fields['statement2'].label = _(
            "I consent to the processing of my personal data to participate in the project. <a href='{url}'>PDF</a>"
        ).format(url=static(settings.STATEMENT2_PDF))

        self.helper = FormHelper(self)

        self.helper.layout = Layout(
            Fieldset(
                '',
                HTML('<p class="h4 mt-5">{}</p><hr/>'.format(
                    _("Participant details"))),
                Div(Div(Div('first_name', css_class="col-md-6 mb-3"),
                        Div('last_name', css_class="col-md-6 mb-3"),
                        css_class="row"),
                    Div(Div('gender', css_class="col-md-4 mb-4"),
                        Div('pesel', css_class="col-md-6 mb-4"),
                        Div('age', css_class="col-md-2 mb-2"),
                        css_class="row"),
                    Div(Div('education', css_class="col-md mb-3"),
                        css_class="row"),
                    css_class="group p-3 mb-4"),
                HTML('<p class="h4 mt-5">{}</p><hr/>'.format(
                    _("Contact details"))),
                Div(Div(Div('street', css_class="col-md-4 mb-4"),
                        Div('street_no', css_class="col-md-2 mb-2"),
                        Div('street_building_no', css_class="col-md-2 mb-2"),
                        Div('postal_code', css_class="col-md-2 mb-2"),
                        Div('city', css_class="col-md-2 mb-2"),
                        css_class="row"),
                    Div(Div('voivodeship', css_class="col-md-3 mb-3"),
                        Div('county', css_class="col-md-3 mb-3"),
                        Div('commune', css_class="col-md-3 mb-3"),
                        Div('country', css_class="col-md-3 mb-3"),
                        css_class="row"),
                    Div(Div('phone', css_class="col-md-6 mb-3"),
                        Div('email', css_class="col-md-6 mb-3"),
                        css_class="row"),
                    css_class="group p-3 mb-4"),
                HTML('<p class="h4 mt-5">{}</p><hr/>'.format(
                    _("Details and type of support"))),
                Div(Div(Div('start_project_date', css_class="col-md-4 mb-4"),
                        Div('end_project_date', css_class="col-md-4 mb-4"),
                        Div('start_support_date', css_class="col-md-4 mb-4"),
                        css_class="row"),
                    Div(Div('status', css_class="col-md-4 mb-4"),
                        Div('profession', css_class="col-md-4 mb-4"),
                        Div('work_name', css_class="col-md-4 mb-4"),
                        css_class="row align-items-end"),
                    Div(Div('origin', css_class="col-md-3 mb-3"),
                        Div('homeless', css_class="col-md-3 mb-3"),
                        Div('disabled_person', css_class="col-md-3 mb-3"),
                        Div('social_disadvantage', css_class="col-md-3 mb-3"),
                        css_class="row align-items-end"),
                    css_class="group p-3 mb-4"),
            ),
            'statement1',
            'statement2',
            ButtonHolder(
                Submit('submit',
                       _("Send the form and register me for the course"),
                       css_class='button white w-100 rounded-0')),
        )

    class Meta:
        model = UserRegistrationCourse
        exclude = ('user', 'course_id', 'language_code')
Esempio n. 9
0
class OrganizationForm(forms.ModelForm):
    description = forms.CharField(widget=CKEditorWidget(
        attrs={
            'placeholder': _("Some information about the institution"),
        }),
                                  label=_("Description"),
                                  required=False)
    description_en = forms.CharField(widget=CKEditorWidget(
        attrs={
            'placeholder': _("Some information about the institution"),
        }),
                                     label=_("Description") + " (EN)",
                                     required=False)
    tel = PhoneNumberField(label=_("Phone number"), required=True)
    fax = PhoneNumberField(label=_("Fax number"), required=False)
    tel_internal = InternalPhoneNumberField(label=_("int."), required=False)
    fax_internal = InternalPhoneNumberField(label=_("int."), required=False)
    slug = forms.SlugField(required=False)

    users = forms.ModelMultipleChoiceField(queryset=User.objects.all(),
                                           required=False,
                                           widget=FilteredSelectMultiple(
                                               verbose_name=_('Users'),
                                               is_stacked=False),
                                           label=_("Users"))
    postal_code = PLPostalCodeField(label=_("Postal code"))
    regon = PLREGONField()
    website = forms.URLField(label=_("Website"))

    status = forms.ChoiceField(
        choices=STATUS_CHOICES,
        help_text=_(
            "If you select a draft, the status of all published datasets belonging "
            "to this institution will be changed to a draft."
            "Also all resources of those datasets will be change to a draft"))

    email = forms.EmailField()

    def __init__(self, *args, **kwargs):
        super(OrganizationForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['users'].initial = self.instance.users.all()

    def clean_slug(self):
        slug = self.cleaned_data['slug']
        obj = Organization.raw.filter(slug=slug)
        if obj and 'slug' in self.changed_data:
            raise forms.ValidationError(_("That value is already taken"))
        return slug

    def clean_fax_internal(self):
        if 'fax' not in self.cleaned_data:
            return
        if self.cleaned_data.get(
                'fax_internal') and not self.cleaned_data.get('fax'):
            raise InternalPhoneNumberField.NoMainNumberError
        return self.cleaned_data.get('fax_internal')

    def clean_tel_internal(self):
        if self.cleaned_data.get(
                'tel_internal') and not self.cleaned_data.get('tel'):
            raise InternalPhoneNumberField.NoMainNumberError
        return self.cleaned_data.get('tel_internal')

    def save(self, commit=True):
        super(OrganizationForm, self).save(commit=False)
        if commit:
            self.instance.save()
        if self.instance.pk:
            self.instance.users.set(self.cleaned_data['users'])
            self.save_m2m()
        return self.instance

    class Meta:
        model = Organization
        fields = [
            'slug', 'title', 'institution_type', 'postal_code', 'city',
            'street', 'street_number', 'flat_number', 'street_type', 'email',
            'fax', 'tel', 'epuap', 'regon', 'website', 'users'
        ]