Skip to content

Commit

Permalink
Merge pull request #1021 from maykinmedia/feedback-sprint-12-2024
Browse files Browse the repository at this point in the history
Feedback sprint 12 2024
  • Loading branch information
joeribekker authored Jan 8, 2025
2 parents 61b675b + 62e9c7b commit 24174dc
Show file tree
Hide file tree
Showing 44 changed files with 271 additions and 70 deletions.
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ lxml
glom
pydantic
email-validator
furl

# Framework libraries
django ~= 3.2
Expand Down
6 changes: 6 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ face==20.1.1
# via glom
faker==22.6.0
# via zgw-consumers
furl==2.1.3
# via -r requirements/base.in
gemma-zds-client==1.0.1
# via
# notifications-api-common
Expand Down Expand Up @@ -239,6 +241,8 @@ notifications-api-common==0.2.2
# via vng-api-common
oauthlib==3.2.2
# via requests-oauthlib
orderedmultidict==1.0.1
# via furl
oyaml==1.0
# via vng-api-common
phonenumbers==8.13.29
Expand Down Expand Up @@ -324,7 +328,9 @@ six==1.16.0
# via
# bleach
# django-compat
# furl
# isodate
# orderedmultidict
# python-dateutil
# qrcode
# requests-mock
Expand Down
11 changes: 11 additions & 0 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ flake8==7.0.0
# via -r requirements/test-tools.in
freezegun==1.4.0
# via -r requirements/test-tools.in
furl==2.1.3
# via
# -c requirements/base.txt
# -r requirements/base.txt
gemma-zds-client==1.0.1
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -465,6 +469,11 @@ oauthlib==3.2.2
# -c requirements/base.txt
# -r requirements/base.txt
# requests-oauthlib
orderedmultidict==1.0.1
# via
# -c requirements/base.txt
# -r requirements/base.txt
# furl
oyaml==1.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -636,7 +645,9 @@ six==1.16.0
# -r requirements/base.txt
# bleach
# django-compat
# furl
# isodate
# orderedmultidict
# python-dateutil
# qrcode
# requests-mock
Expand Down
11 changes: 11 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ freezegun==1.4.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
furl==2.1.3
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
gemma-zds-client==1.0.1
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -533,6 +537,11 @@ oauthlib==3.2.2
# -c requirements/ci.txt
# -r requirements/ci.txt
# requests-oauthlib
orderedmultidict==1.0.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# furl
oyaml==1.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -736,7 +745,9 @@ six==1.16.0
# -r requirements/ci.txt
# bleach
# django-compat
# furl
# isodate
# orderedmultidict
# python-dateutil
# qrcode
# requests-mock
Expand Down
8 changes: 6 additions & 2 deletions src/sdg/components/templates/components/fields/checkbox.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'components/fields/base.html' %}
{% load fields %}
{% load fields utils %}

{% block header %}
<label class="form__field-label">
Expand All @@ -11,7 +11,11 @@
{% block body %}
<div class="form__control">
<div class="form__control-body">
{{ field }}
{% if readonly %}
{{ field|add_readonly }}
{% else %}
{{ field }}
{% endif %}
{{ field.errors }}
</div>
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/sdg/components/templates/components/fields/localized.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@

{# Field. #}
<div class="form__input form__input--wrapper">
{{ field|addclass:"form__input" }}
{% if readonly %}
{{ field|add_class_and_readonly:"form__input" }}
{% else %}
{{ field|addclass:"form__input" }}
{% endif %}

{{ field.errors }}
</div>
</div>
Expand Down Expand Up @@ -68,7 +73,7 @@

{% block footer %}
{% for field in object.bound_fields %}
{% if forloop.counter == 1 and inline != True and 'dynamic_array' not in field.field.widget.template_name %}
{% if forloop.counter == 1 and inline != True and 'dynamic_array' not in field.field.widget.template_name and not readonly %}
<footer class="form__field-footer button-group">
<button class="button button--light button--small form__display-btn" type="button">
<i class="fa fa-chevron-right"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
data-initialized="true"
>
<div class="url_label_field__container-item">
{{ field.label|addlabelclass:"form__input form__input--left" }}
{{ field.link|addlinkclass:"form__input form__input--right" }}
{% if readonly %}
{{ field.label|add_class_and_readonly_for_label:"form__input form__input--left" }}
{{ field.link|add_class_and_readonly_for_link:"form__input form__input--right" }}
{% else %}
{{ field.label|add_class_for_label:"form__input form__input--left" }}
{{ field.link|add_class_for_link:"form__input form__input--right" }}
{% endif %}
</div>
{% if field.label.errors or field.link.errors %}
<div class="url_label_field__container-item url_label_field__container-item--errorlist">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
{# Field. #}
<div class="form__control">
<div class="form__control-body">
{{ field|addclass:"form__input" }}
{% if readonly %}
{{ field|add_class_and_readonly:"form__input" }}
{% else %}
{{ field|addclass:"form__input" }}
{% endif %}
{{ field.errors }}
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/sdg/components/templates/components/fields/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
<div class="form__control-body">
<fieldset class="form__group--nopad">
<div class="select">
{{ field }}
{% if readonly %}
{{ field|add_readonly }}
{% else %}
{{ field }}
{% endif %}
</div>
</fieldset>
{{ field.errors }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
{% core inline=True label=_("Doelgroep")|capfirst tooltip=doelgroep.help_text value=doelgroep.value %}
{% endif %}

{% select inline=True field=product_form.product_aanwezig %}
{% localized inline=True object=localized_object_dict.product_aanwezig_toelichting render_hidden=product_form.product_aanwezig.value %}
{% select inline=True field=product_form.product_aanwezig readonly=readonly %}
{% localized inline=True object=localized_object_dict.product_aanwezig_toelichting render_hidden=product_form.product_aanwezig.value readonly=readonly %}

{% if not product.is_referentie_product %}
{% select inline=True field=product_form.product_valt_onder %}
{% localized inline=True object=localized_object_dict.product_valt_onder_toelichting render_hidden=product_form.product_valt_onder.value %}
{% select inline=True field=product_form.product_valt_onder readonly=readonly %}
{% localized inline=True object=localized_object_dict.product_valt_onder_toelichting render_hidden=product_form.product_valt_onder.value readonly=readonly %}

{% checkbox inline=True field=product_form.locaties %}

{% checkbox inline=True field=product_form.locaties readonly=readonly %}
{% endif %}

{% select hide_element=product.is_referentie_product|yesno:',True' inline=True field=product_form.automatisch_doordrukken %}
{% select hide_element=product.is_referentie_product|yesno:',True' inline=True field=product_form.automatisch_doordrukken readonly=readonly %}

{% if product.is_referentie_product %}
{# Render as core with value #}
Expand All @@ -35,19 +34,19 @@
{% endif %}

{# DISABLED PER REQUEST VNG #}
{% select hide_element=True inline=True field=product_form.api_verborgen %}
{% select hide_element=True inline=True field=product_form.api_verborgen readonly=readonly %}

{% select inline=True field=product_form.bevoegde_organisatie %}
{% select inline=True field=product_form.bevoegde_organisatie readonly=readonly %}

{% with publication_date=product.active_version|get_field:"publicatie_datum" %}
{% with configuration=publication_date.configuration.label %}
{% core inline=True label=configuration.label|default:_("Publicatie datum")|capfirst tooltip=configuration.tooltip|default:_('Publicatiedatum van de productversie') value=publication_date.value|default:"Concept" %}
{% endwith %}
{% endwith %}

{% select inline=True field=product_form.heeft_kosten %}
{% select inline=True field=product_form.heeft_kosten readonly=readonly %}

{% core inline=True label=_("Informatiegebied") tooltip=_("Informatiegebied in verband met dit product.") value=areas|join:", " %}

{% nonlocalized inline=True object=nonlocalized_object_dict.interne_opmerkingen %}
{% nonlocalized inline=True object=nonlocalized_object_dict.interne_opmerkingen readonly=readonly %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block title %}
<span>
2. {% trans "Generieke gegevens" %}
2. {% trans "Tekst Nationaal portaal" %}
</span>
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block title %}
<span>
3. {% trans "Specifieke gegevens" %}
3. {{org_type_name}} {% trans "Tekst" %}
</span>
{% endblock %}

Expand All @@ -16,8 +16,8 @@
{% endfor %}

{% for object in object_list %}
{% localized object=object %}
{% localized object=object readonly=readonly %}
{% endfor %}
{% localized_url form=form %}

{% localized_url form=form readonly=readonly %}
{% endblock %}
9 changes: 9 additions & 0 deletions src/sdg/components/templatetags/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ def checkbox(context, field, **kwargs):
Kwargs:
- as_row, define if the checkbox field is placed inside a tr and td.
- inline, define if the checkbox field is rendered inline.
- readonly, define if the field is readonly.
"""

as_row = kwargs.get("as_row", True)
inline = kwargs.get("inline", False)
readonly = kwargs.get("readonly", False)

return {
**kwargs,
"context": context,
"field": field,
"as_row": as_row,
"inline": inline,
"readonly": readonly,
}


Expand Down Expand Up @@ -76,11 +79,13 @@ def localized(context, object, **kwargs):
Kwargs:
- as_row, define if the localized field is placed inside a tr and td.
- inline, define if the localized field is rendered inline.
- readonly, define if the field is readonly.
"""

inline = kwargs.get("inline", False)
as_row = kwargs.get("as_row", True)
render_hidden = kwargs.get("render_hidden", False) in [True, None]
readonly = kwargs.get("readonly", False)

return {
**kwargs,
Expand All @@ -89,6 +94,7 @@ def localized(context, object, **kwargs):
"inline": inline,
"render_hidden": render_hidden,
"object": object,
"readonly": readonly,
}


Expand All @@ -103,9 +109,11 @@ def localized_url(context, form, **kwargs):
Kwargs:
- as_row, define if the localized url field is placed inside a tr and td.
- readonly, define if the field is readonly.
"""

as_row = kwargs.get("as_row", True)
readonly = kwargs.get("readonly", False)

def object_format(form):
return {
Expand All @@ -123,6 +131,7 @@ def get_object_list(forms):
"bound_fields": get_object_list(form.forms),
"form": form,
"as_row": as_row,
"readonly": readonly,
}


Expand Down
13 changes: 11 additions & 2 deletions src/sdg/components/templatetags/update_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import template
from django.forms import BaseForm, BaseFormSet

from sdg.conf.utils import org_type_cfg
from sdg.producten.utils import get_fields, get_languages

register = template.Library()
Expand All @@ -24,6 +25,8 @@ def update_form_generic(context) -> dict:
generic_products = context.get("generic_products")
formset = context.get("formset")

readonly = not context["user_can_edit"]

def get_object_list():
obj_list = []

Expand Down Expand Up @@ -51,6 +54,7 @@ def get_object_list():
"context": context,
"form_name": form_name,
"object_list": get_object_list(),
"readonly": readonly,
}


Expand All @@ -70,12 +74,13 @@ def update_form_specific(context) -> dict:
# Get some properties from the context
localized_form_fields = context.get("localized_form_fields")
formset: BaseFormSet = context.get("formset")
form = context.get("formset")

# Get languages and fields form utils functions.
languages = get_languages(formset)
fields = get_fields(formset.forms[0], localized_form_fields)

readonly = not context["user_can_edit"]

def get_object_list(formset: BaseFormSet, fields: list) -> list:
object_list = []
for field in fields:
Expand All @@ -90,9 +95,11 @@ def get_object_list(formset: BaseFormSet, fields: list) -> list:

return {
"context": context,
"form": form,
"form": formset,
"form_name": form_name,
"object_list": get_object_list(formset, fields),
"readonly": readonly,
"org_type_name": org_type_cfg().name,
}


Expand Down Expand Up @@ -130,6 +137,7 @@ def update_form_general(context) -> dict:
# Nonlocalized fields in the general update form
nonlocalized_field_names = ["interne_opmerkingen"]
nonlocalized_fields = get_fields(version_form, nonlocalized_field_names)
readonly = not context["user_can_edit"]

def get_localized_object_dict(formset: BaseFormSet, fields: list) -> dict:
object_list = {}
Expand Down Expand Up @@ -164,4 +172,5 @@ def get_nonlocalized_object_dict(form: BaseForm, fields: list) -> dict:
),
"product_form": product_form,
"product": product,
"readonly": readonly,
}
Loading

0 comments on commit 24174dc

Please sign in to comment.