Skip to content

Commit

Permalink
Merge pull request #126 from forza-mor-rotterdam/django-4.2
Browse files Browse the repository at this point in the history
Django 4.2 upgrade.
  • Loading branch information
remcohoff authored Sep 25, 2024
2 parents 0595103 + 4230034 commit 9d0b170
Show file tree
Hide file tree
Showing 20 changed files with 521 additions and 144 deletions.
6 changes: 5 additions & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ ENV PYTHONUNBUFFERED 1

WORKDIR /app/

RUN apt-get update && apt-get install -y \
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get autoremove -y \
&& apt-get install --no-install-recommends -y \
build-essential \
python-dev \
curl \
Expand All @@ -34,6 +37,7 @@ RUN apt-get update && apt-get install -y \
libgeotiff-dev \
libwebp6 \
proj-bin \
libmagic1 \
libpq-dev \
git \
locales \
Expand Down
2 changes: 1 addition & 1 deletion app/apps/authenticatie/managers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.hashers import make_password
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class GebruikerManager(BaseUserManager):
Expand Down
31 changes: 25 additions & 6 deletions app/apps/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
from django.utils import timezone


class MultipleFileInput(forms.ClearableFileInput):
allow_multiple_selected = True


class MultipleFileField(forms.FileField):
def __init__(self, *args, **kwargs):
kwargs.setdefault("widget", MultipleFileInput())
super().__init__(*args, **kwargs)

def clean(self, data, initial=None):
single_file_clean = super().clean
if isinstance(data, (list, tuple)):
result = [single_file_clean(d, initial) for d in data]
else:
result = [single_file_clean(data, initial)]
return result


class MeldingAanmakenForm(forms.Form):
specifiek_graf = forms.ChoiceField(
widget=forms.RadioSelect(
Expand Down Expand Up @@ -80,11 +98,12 @@ class MeldingAanmakenForm(forms.Form):
required=True,
)

fotos = forms.FileField(
widget=forms.widgets.FileInput(
fotos = MultipleFileField(
widget=MultipleFileInput(
attrs={
"accept": ".jpg, .jpeg, .png, .heic",
"data-action": "change->request#updateImageDisplay",
"class": "file-upload-input",
}
),
label="Foto's",
Expand Down Expand Up @@ -139,7 +158,7 @@ class MeldingAanmakenForm(forms.Form):
no_email = forms.BooleanField(
widget=forms.CheckboxInput(
attrs={
"class": "form-check-input",
"class": "form-check-input margin-bottom",
"data-action": "change->request#toggleInputNoEmail",
}
),
Expand Down Expand Up @@ -302,9 +321,9 @@ def signaal_data(self, files=[]):
labels = {
k: {
"label": v.label,
"choices": {c[0]: c[1] for c in v.choices}
if hasattr(v, "choices")
else None,
"choices": (
{c[0]: c[1] for c in v.choices} if hasattr(v, "choices") else None
),
}
for k, v in self.fields.items()
}
Expand Down
68 changes: 68 additions & 0 deletions app/apps/main/templates/django/forms/widgets/checkbox_select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{% load file_exists from main_tags %}
{% load l10n %}
{% with id=widget.attrs.id %}
<div class="form-row {{ classes.label }} {{ classes.value }} {{ classes.single_value }}">
{% if id and not widget.attrs.hideLabel %}
<h3 class="label {% if widget.attrs.hasMoreInfo and widget.help_text %}has-more-info{% endif %}">
{{ widget.label }}{{ widget.attrs.hideLabel }}
</h3>
{% endif %}
{% if widget.attrs.hasMoreInfo and widget.help_text %}
<div class="foldout--info" data-controller="utils">
<h4 class="summary"
data-action="click->utils#foldOut"
aria-label="Meer info">{% include "icons/info-filled.svg" %}</h4>
<p>{{ widget.help_text|safe }}</p>
</div>
{% endif %}
{% if widget.attrs.showSelectAll %}
<div class="container__buttons">
<button class="btn btn-textlink btn-inline"
data-action="selectAll#selectAll"
data-selectAll-filter-type-param="all">Selecteer alles</button>
|
<button class="btn btn-inline" data-action="selectAll#selectAll">Selecteer niets</button>
</div>
{% endif %}
<div id="{{ id }}">
<ul class="{% if widget.attrs.classList %}{{ widget.attrs.classList }}{% else %}list--form-check-input{% endif %}">
{% for group, options, index in widget.optgroups %}
{% if group %}
<li>
{{ group }}
<ul {% if id %}id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
<li class="{% if widget.required and form.required_css_class %}{{ form.required_css_class }}{% endif %}">
<div class="form-check">
{% include "django/forms/widgets/input.html" with widget=option %}
<label class="form-check-label"
for="{{ option.attrs.id }}"
{% if option.selected %}checked{% endif %}
{% if widget.required %}required{% endif %}
{% include "django/forms/widgets/attrs.html" %}>
{% if widget.attrs.hasIcon %}
{% with option.label|slugify as slugged_option_label %}
{% with "icons/afdelingen/"|add:slugged_option_label|add:".svg" as icon_path %}
{% if icon_path|file_exists %}
{% include icon_path %}
{% else %}
{% include "icons/noimage.svg" %}
{% endif %}
{% endwith %}
{% endwith %}
{% endif %}
{{ option.label }}
</label>
</div>
</li>
{% endfor %}
{% if group %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
{% endwith %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% with id=widget.attrs.id %}
<div {% if id %}id="{{ id }}"{% endif %}>
<ul {% if widget.attrs.classList %}class="{{ widget.attrs.classList }}"{% endif %}>
{% for group, options, index in widget.optgroups %}
{% if group %}
<li>
{{ group }}
<ul {% if id %}id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
<li>
<div class="form-check">
{% include "django/forms/widgets/input.html" with widget=option %}
<label {% if option.attrs.id %}for="{{ option.attrs.id }}"{% endif %}
class="form-check-label">{{ option.label }}</label>
</div>
</li>
{% endfor %}
{% if group %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endwith %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div data-controller="bijlagen">
<button type="button"
class="btn btn-secondary btn-files"
id="buttonFile_{{ field.auto_id }}"
data-action="request#showFileInput">
<svg width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 6H15V15H6V17H15V26H17V17H26V15H17V6Z" fill="#fff" />
</svg>
<span>
{% if field.field.widget.attrs.button_text %}
{{ field.field.widget.attrs.button_text }}
{% else %}
Foto toevoegen
{% endif %}
</span>
</button>
{% if field.help_text %}<p class="help-block">{{ field.help_text|safe }}</p>{% endif %}
{% for error in field.errors %}
<span class="help-block invalid-text {{ form.error_css_class }}">{{ error }}</span>
{% endfor %}
<div class="file-upload multiple hidden" tabindex="1">
<div class="file-upload-mask">Sleep één of meer bestanden hier naartoe, of klik hier om bestanden te uploaden</div>
{% include "django/forms/widgets/input.html" %}
<div id="imagesPreview" class="preview"></div>
</div>
</div>
30 changes: 30 additions & 0 deletions app/apps/main/templates/django/forms/widgets/file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div>
<button type="button"
class="btn btn-secondary btn-files"
id="buttonFile_{{ field.auto_id }}"
data-action="request#showFileInput">
<svg width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 6H15V15H6V17H15V26H17V17H26V15H17V6Z" fill="#fff" />
</svg>
<span>
{% if field.field.widget.attrs.button_text %}
{{ field.field.widget.attrs.button_text }}
{% else %}
Foto toevoegen
{% endif %}
</span>
</button>
{% if field.help_text %}<p class="help-block">{{ field.help_text|safe }}</p>{% endif %}
{% for error in field.errors %}
<span class="help-block invalid-text {{ form.error_css_class }}">{{ error }}</span>
{% endfor %}
<div class="file-upload multiple hidden" tabindex="1">
<div class="file-upload-mask">Sleep één of meer bestanden hier naartoe, of klik hier om bestanden te uploaden</div>
{% include "django/forms/widgets/input.html" %}
<div id="imagesPreview" class="preview"></div>
</div>
</div>
19 changes: 19 additions & 0 deletions app/apps/main/templates/django/forms/widgets/multiple_input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% with id=widget.attrs.id %}
<ul {% if id %}id="{{ id }}"{% endif %}
{% if widget.attrs.class %}class="{{ widget.attrs.class }}"{% endif %}>
{% for group, options, index in widget.optgroups %}
{% if group %}
<li>
{{ group }}
<ul {% if id %}id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
<li>{% include option.template_name with widget=option %}</li>
{% endfor %}
{% if group %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
{% endwith %}
11 changes: 6 additions & 5 deletions app/apps/main/templates/melding/aanmaken.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>Serviceverzoek</h1>
{% csrf_token %}
<fieldset>
{% include "snippets/legend.html" with title="Locatie" icon_name="pin_filled" only %}
{{ form.specifiek_graf|render_rotterdam_formulier }}
<div class="wrapper-horizontal">{{ form.specifiek_graf|render_rotterdam_formulier }}</div>
{{ form.begraafplaats|render_rotterdam_formulier }}
{{ form.vak|render_rotterdam_formulier }}
{{ form.grafnummer|render_rotterdam_formulier }}
Expand All @@ -34,11 +34,12 @@ <h1>Serviceverzoek</h1>
{% include "snippets/legend.html" with title="Melder" icon_name="person" only %}
{{ form.naam_melder|render_rotterdam_formulier }}
{{ form.email_melder|render_rotterdam_formulier }}
{{ form.no_email|render_rotterdam_formulier }}
<div class="margin-bottom-2">{{ form.no_email|render_rotterdam_formulier }}</div>
{{ form.telefoon_melder|render_rotterdam_formulier }}
{{ form.rechthebbende|render_rotterdam_formulier }}
{% comment %} {{ form.rechthebbende }} {% endcomment %}
{{ form.terugkoppeling_gewenst|render_rotterdam_formulier }}
<div class="wrapper-horizontal form-row">
<div id="id_rechthebbende">{{ form.rechthebbende|render_rotterdam_formulier }}</div>
</div>
<div class="wrapper-horizontal">{{ form.terugkoppeling_gewenst|render_rotterdam_formulier }}</div>
</fieldset>
<div class="form-row container__button">
<button class="btn btn-action" type="submit">
Expand Down
31 changes: 31 additions & 0 deletions app/apps/main/templates/widgets/checkbox_select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% with id=widget.attrs.id %}
<div {% if id %}id="{{ id }}"{% endif %} class="form-row">
{% if not widget.attrs.hideLabel %}
<h3 class="label{% if widget.attrs.hasMoreInfo and widget.help_text %}has-more-info{% endif %}">
{{ field.label }}{{ widget.attrs.hideLabel }}
</h3>
{% endif %}
<ul {% if widget.attrs.class %}class="list--{{ widget.attrs.class }}"{% endif %}>
{% for group, options, index in widget.optgroups %}
{% if group %}
<li>
{{ group }}
<ul {% if id %}id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
<li>
<div class="form-check">
{% include "django/forms/widgets/input.html" with widget=option %}
<label {% if option.attrs.id %}for="{{ option.attrs.id }}"{% endif %}
class="form-check-label">{{ option.label }}</label>
</div>
</li>
{% endfor %}
{% if group %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endwith %}
19 changes: 19 additions & 0 deletions app/apps/main/templates/widgets/multiple_input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% with id=widget.attrs.id %}
<ul {% if id %}id="{{ id }}"{% endif %}
{% if widget.attrs.class %}class="{{ widget.attrs.class }}"{% endif %}>
{% for group, options, index in widget.optgroups %}
{% if group %}
<li>
{{ group }}
<ul {% if id %}id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
<li>{% include option.template_name with widget=option %}</li>
{% endfor %}
{% if group %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
{% endwith %}
7 changes: 0 additions & 7 deletions app/apps/main/templates/widgets/radio_option.html

This file was deleted.

Loading

0 comments on commit 9d0b170

Please sign in to comment.