-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from opensafely-core/update-upstream-assets
Update upstream assets from jobserver
- Loading branch information
Showing
77 changed files
with
736 additions
and
2,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from datetime import UTC, datetime | ||
|
||
from django import forms | ||
from django.template.response import TemplateResponse | ||
|
||
|
||
class ExampleForm(forms.Form): | ||
|
||
example_select = forms.ChoiceField( | ||
choices=[ | ||
["", "Please select a language"], | ||
["english", "English"], | ||
["french", "French"], | ||
["german", "German"], | ||
["spanish", "Spanish"], | ||
], | ||
label="Language select", | ||
initial="french", | ||
) | ||
|
||
example_email = forms.EmailField() | ||
|
||
example_textarea = forms.Textarea() | ||
|
||
example_radios = forms.ChoiceField( | ||
choices=[ | ||
["english", "English"], | ||
["french", "French"], | ||
["german", "German"], | ||
["spanish", "Spanish"], | ||
], | ||
label="Language select", | ||
initial="french", | ||
widget=forms.RadioSelect, | ||
) | ||
|
||
def clean_example_email(self): | ||
self.add_error( | ||
"example_email", "This email is registered to a different account" | ||
) | ||
|
||
|
||
def components(request): | ||
example_date = datetime.fromtimestamp(1667317153, tz=UTC) | ||
form = ExampleForm({"example_select": "french", "example_email": "[email protected]"}) | ||
form.is_valid() | ||
return TemplateResponse( | ||
request, | ||
"_components/index.html", | ||
context={ | ||
"example_date": example_date, | ||
"example_form": form, | ||
}, | ||
) |
Oops, something went wrong.