Skip to content

Commit

Permalink
Merge branch 'develop' into feature/uu-list
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/cdh/core/forms.py
  • Loading branch information
tymees committed Nov 20, 2023
2 parents d53b7d6 + 4cfb0fd commit 89d20a5
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 172 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# CDH Django libraries

A collection of Django apps for CDH/DH-IT Django projects. Developed by the
A collection of Django apps for CDH Django projects. Developed by the
[ILS Labs](https://github.com/UiL-OTS-labs) and the
[DH-IT Faculty Portal Development and Support Team](https://github.com/DH-IT-Portal-Development/django-shared-core)
[Humanities IT Portal Development and Support Team](https://github.com/orgs/CentreForDigitalHumanities/teams/portal-development)

Documentation provided here: https://dh-it-portal-development.github.io/django-shared-core/
Documentation provided here: https://centrefordigitalhumanities.github.io/django-shared-core/

## Currently targeting:
- Python 3.9
Expand All @@ -21,7 +21,7 @@ specifics.

Add the following line to your python requirements:

``cdh-django-core[all] @ git+https://github.com/DH-IT-Portal-Development/django-shared-core.git@<version>``
``cdh-django-core[all] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@<version>``

Replacing ``<version>`` with the latest DSC release tag. (e.g. ``v3.1.0``).

Expand All @@ -36,7 +36,7 @@ The library can be installed with a reduced dependency set for the apps your
project uses. To do this, replace the ``all`` with a comma-separated list of
the apps your project uses (sans ``cdh.``). For example:

``cdh-django-core[core,files,rest] @ git+https://github.com/DH-IT-Portal-Development/django-shared-core.git@[version]``
``cdh-django-core[core,files,rest] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@[version]``


## App collection
Expand Down
108 changes: 55 additions & 53 deletions dev/main/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import forms
from django.urls import reverse_lazy
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _

from cdh.core import fields as core_fields
from cdh.core.forms import SplitMonthInput, TemplatedForm, TemplatedModelForm
Expand All @@ -13,17 +14,11 @@
class FormStylesForm(forms.Form):
text = forms.CharField()

textarea = forms.CharField(
widget=forms.Textarea
)
textarea = forms.CharField(widget=forms.Textarea)

django_date = forms.DateField(
help_text="Using django's version of the field"
)
django_date = forms.DateField(help_text="Using django's version of the field")

django_time = forms.TimeField(
help_text="Using django's version of the field"
)
django_time = forms.TimeField(help_text="Using django's version of the field")

django_datetime = forms.DateTimeField(
help_text="Using django's version of the field"
Expand All @@ -33,13 +28,9 @@ class FormStylesForm(forms.Form):
help_text="Using django's version of the field"
)

core_date = core_fields.DateField(
help_text="Using core's version of the field"
)
core_date = core_fields.DateField(help_text="Using core's version of the field")

core_time = core_fields.TimeField(
help_text="Using core's version of the field"
)
core_time = core_fields.TimeField(help_text="Using core's version of the field")

core_datetime = core_fields.DateTimeField(
help_text="Using core's version of the field"
Expand All @@ -51,27 +42,31 @@ class FormStylesForm(forms.Form):

checkbox = forms.BooleanField()

choice = forms.ChoiceField(choices=[
(1, "Train"),
(2, "Bus"),
(3, "Aeroplane"),
(4, "Bike"),
(5, "Feet"),
(6, "Magical Unicorn"),
(6, "Broom"),
(6, "Thestrals"),
])

typed_choice = forms.TypedChoiceField(choices=[
(1, "Train"),
(2, "Bus"),
(3, "Aeroplane"),
(4, "Bike"),
(5, "Feet"),
(6, "Magical Unicorn"),
(6, "Broom"),
(6, "Thestrals"),
])
choice = forms.ChoiceField(
choices=[
(1, "Train"),
(2, "Bus"),
(3, "Aeroplane"),
(4, "Bike"),
(5, "Feet"),
(6, "Magical Unicorn"),
(6, "Broom"),
(6, "Thestrals"),
]
)

typed_choice = forms.TypedChoiceField(
choices=[
(1, "Train"),
(2, "Bus"),
(3, "Aeroplane"),
(4, "Bike"),
(5, "Feet"),
(6, "Magical Unicorn"),
(6, "Broom"),
(6, "Thestrals"),
]
)

radio = forms.TypedChoiceField(
choices=[
Expand All @@ -84,7 +79,7 @@ class FormStylesForm(forms.Form):
(6, "Broom"),
(6, "Thestrals"),
],
widget=forms.RadioSelect
widget=forms.RadioSelect,
)

integer = forms.IntegerField()
Expand Down Expand Up @@ -117,6 +112,9 @@ class FormStylesForm(forms.Form):


class CustomTemplateFormStylesForm(TemplatedForm):
info_header = core_fields.TemplatedFormTextField(
header=_("People involved"), classes=""
)

text = forms.CharField(
label="Onderzoeksprojectnaam",
Expand All @@ -127,33 +125,38 @@ class CustomTemplateFormStylesForm(TemplatedForm):
label="Eindverantwoordelijke",
)

date_header = core_fields.TemplatedFormTextField(
header=_("Project duration"), header_element="h4"
)

date_start = core_fields.DateField(
label="Begin Datum",
help_text="Op deze datum wordt de verwerking actief in het register "
"van verwerkingen"
"van verwerkingen",
)

date_end = core_fields.DateField(
label="Eind Datum",
help_text=mark_safe("Dit is de datum waarop de resultaten worden "
"gepubliceerd."
"<br/>"
"Op deze datum gaat de archiveringstermijn van de "
"onderzoeksdata in")
help_text=mark_safe(
"Dit is de datum waarop de resultaten worden "
"gepubliceerd."
"<br/>"
"Op deze datum gaat de archiveringstermijn van de "
"onderzoeksdata in"
),
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for visible in self.visible_fields():
visible.field.widget.attrs['class'] = 'form-control'
visible.field.widget.attrs["class"] = "form-control"


class JqueryUIFormStylesForm(forms.Form):
date = forms.DateField()


class CustomEmailForm(TemplatedForm):

sender = forms.CharField()

banner = forms.CharField()
Expand All @@ -162,10 +165,10 @@ class CustomEmailForm(TemplatedForm):
label="Mail content",
help_text=ExampleCustomTemplateEmail.help_text(),
widget=EmailContentEditWidget(
reverse_lazy('main:custom_email_form_preview'),
sender_field='sender',
banner_field='banner',
footer_field='footer',
reverse_lazy("main:custom_email_form_preview"),
sender_field="sender",
banner_field="banner",
footer_field="footer",
),
)

Expand All @@ -174,9 +177,8 @@ class CustomEmailForm(TemplatedForm):

class MonthFieldTestForm(TemplatedModelForm):
show_valid_fields = False

class Meta:
model = MonthFieldTest
fields = ['single_month_field', 'split_month_field']
widgets = {
'split_month_field': SplitMonthInput
}
fields = ["single_month_field", "split_month_field"]
widgets = {"split_month_field": SplitMonthInput}
2 changes: 1 addition & 1 deletion dev/main/templates/main/custom_styles_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h1>Custom form template</h1>
<p>Note: this required Django 4+</p>

<form method="post" class="uu-form" enctype="multipart/form-data">
<form method="post" class="uu-form uu-form-no-gap" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
<div class="uu-container">
Expand Down
Loading

0 comments on commit 89d20a5

Please sign in to comment.