예제 #1
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column("new_password1")),
            Row(Column("new_password2")),
            Submit("submit", "Nastavit nové heslo"),
        )
예제 #2
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column("email")),
            Row(Column("password")),
            Submit("submit", "Přihlásit se"),
        )
예제 #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column("old_password")),
            Row(Column("new_password1")),
            Row(Column("new_password2")),
            FormActions(
                FormControl(Submit("submit", "Nastavit nové heslo"), ),
                FormControl(Link("core:home", "Zpět", "button is-text")),
            ),
        )
예제 #4
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields["email"].disabled = True

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column(Field("email", autocomplete="email"))),
            # Row(Column("password"), Column("password2")),
            Row(
                Column("first_name"),
                Column("last_name"),
                Column(Field("phone", autocomplete="phone")),
            ),
            Row(Column("street")),
            Row(
                Column("zip_code", css_class="is-2"),
                Column("city", css_class="is-4"),
                Column("country", css_class="is-4 is-offset-2"),
            ),
            Row(Column("school", css_class="is-10"), Column("school_year")),
            Row(Column("school_alt_name"), Column("school_alt_street")),
            Row(
                Column("school_alt_zip_code", css_class="is-2"),
                Column("school_alt_city", css_class="is-4"),
            ),
            FormActions(
                FormControl(Submit("submit", "Uložit změny")),
                FormControl(Link("core:home", "Zpět", "button is-text")),
            ),
        )
예제 #5
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column("email")),
            FormActions(
                FormControl(Submit("submit", "Pokračovat")),
                FormControl(Link("core:home", "Zpět", "button is-text")),
            ),
        )
예제 #6
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        email_field = User.get_email_field_name()
        self.fields[email_field].validators.append(
            reg_validators.CaseInsensitiveUnique(
                User, email_field, reg_validators.DUPLICATE_EMAIL
            )
        )
        self.fields[email_field].label = "Emailová adresa"
        self.fields[
            email_field
        ].help_text = "Slouží jako uživatelské jméno pro přihlášení."

        self.fields["tos"] = forms.BooleanField(
            widget=forms.CheckboxInput,
            label=f"Přečetl/a jsem si a souhlasím s <a href='{webpack_static('attachments/zpracovani-osobnich-udaju-pro-web.pdf')}' target='_blank' rel='noopener'>podmínkami použití a zpracováním osobních údajů</a>",
        )

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column(Field("email", autocomplete="email"))),
            Row(Column("password1"), Column("password2")),
            Row(
                Column("first_name"),
                Column("last_name"),
                Column(Field("phone", autocomplete="phone")),
            ),
            Row(Column("street")),
            Row(
                Column("zip_code", css_class="is-2"),
                Column("city", css_class="is-4"),
                Column("country", css_class="is-4 is-offset-2"),
            ),
            Row(Column("school", css_class="is-10"), Column("school_year")),
            Row(Column("school_alt_name"), Column("school_alt_street")),
            Row(
                Column("school_alt_zip_code", css_class="is-2"),
                Column("school_alt_city", css_class="is-4"),
            ),
            Row(Column("tos")),
            FormActions(
                FormControl(Submit("submit", "Pokračovat")),
                FormControl(Link("core:home", "Zpět", "button is-text")),
            ),
        )
예제 #7
0
파일: forms.py 프로젝트: adamprada/ksicht
    def __init__(self, *args, task, **kwargs):
        super().__init__(*args, **kwargs)

        def _clean_file(self, field_name):
            file = self.cleaned_data[field_name]

            if not file:
                return file

            if file.content_type not in self.SOLUTION_CONTENT_TYPES:
                raise forms.ValidationError("Vybere prosím soubor ve formátu PDF.")

            if file.size > self.SOLUTION_MAX_UPLOAD_SIZE:
                raise forms.ValidationError(
                    f"Maximální velikost souboru je {filesizeformat(self.SOLUTION_MAX_UPLOAD_SIZE)}. Vybraný soubor má velikost {filesizeformat(file.size)}."
                )

            return file

        self.fields[f"file_{task.pk}"] = FileField(
            label="Vyberte soubor s řešením",
            required=True,
            allow_empty_file=False,
        )

        setattr(
            self,
            f"clean_file_{task.pk}",
            partial(_clean_file, self=self, field_name=f"file_{task.pk}"),
        )

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column(
                    Field(f"file_{task.pk}"), css_class="is-12-mobile is-10-desktop"
                ),
                Column(
                    Submit("submit", "Odeslat", css_class="is-outlined"),
                    css_class="is-12-mobile is-2-desktop has-text-right-desktop",
                ),
                css_class="is-mobile is-multiline",
            )
        )
        self.helper.form_action = (
            reverse("core:solution_submit") + f"?task_id={task.pk}"
        )