Skip to content

Commit

Permalink
Merge pull request #120 from opensafely-core/update-upstream-assets
Browse files Browse the repository at this point in the history
Update upstream assets from jobserver
  • Loading branch information
rebkwok authored Mar 1, 2024
2 parents 0e60c36 + bb8e3f6 commit 0b201b9
Show file tree
Hide file tree
Showing 77 changed files with 736 additions and 2,145 deletions.
18 changes: 18 additions & 0 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ activating a virtual environment and running something like:
set -a; source .env; set +a
```

## Assets

The asset build tooling and component library is currently extracted
from job-server for use in airlock.

We also add the components browser view at the /ui-components. This acts
as a test to see everything works, and a helpful builtin reference for
using the slippers components.

To update the upstream assets, first remove any existing built assets:
```bash
just assets/clean
```
And then update with the latest upstream assets:
```bash
just assets/update
```

## Testing

### Test categories
Expand Down
54 changes: 54 additions & 0 deletions assets/base_views.py
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,
},
)
Loading

0 comments on commit 0b201b9

Please sign in to comment.