-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add Consent management views and template - add JavaScript functionality to select/uncheck all checkboxes in consent forms - enhance the admin interface - add test - add migration to proxy_for symmetrical=False
- Loading branch information
Showing
30 changed files
with
785 additions
and
103 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
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 |
---|---|---|
@@ -1 +1,17 @@ | ||
"""Dashboard consent app.""" | ||
|
||
from typing import Literal | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
AWAITING: str = "AWAITING" | ||
VALIDATED: str = "VALIDATED" | ||
REVOKED: str = "REVOKED" | ||
CONSENT_STATUS_CHOICE = [ | ||
(AWAITING, _("Awaiting")), | ||
(VALIDATED, _("Validated")), | ||
(REVOKED, _("Revoked")), | ||
] | ||
|
||
# typing | ||
StatusChoices = Literal["AWAITING", "VALIDATED", "REVOKED"] |
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
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,20 @@ | ||
"""Dashboard consent app managers.""" | ||
|
||
from django.db import models | ||
from django.utils import timezone | ||
|
||
|
||
class ConsentManager(models.Manager): | ||
"""Custom consent manager.""" | ||
|
||
def get_queryset(self): | ||
"""Return consents with active delivery point, for the current period.""" | ||
return ( | ||
super() | ||
.get_queryset() | ||
.filter( | ||
delivery_point__is_active=True, | ||
start__lte=timezone.now(), | ||
end__gte=timezone.now(), | ||
) | ||
) |
34 changes: 34 additions & 0 deletions
34
...board/apps/consent/migrations/0002_alter_consent_managers_alter_consent_delivery_point.py
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,34 @@ | ||
# Generated by Django 5.1.3 on 2024-12-06 14:53 | ||
|
||
import django.db.models.deletion | ||
import django.db.models.manager | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("qcd_consent", "0001_initial"), | ||
( | ||
"qcd_core", | ||
"0003_alter_deliverypoint_managers_alter_entity_proxy_for_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name="consent", | ||
managers=[ | ||
("active_objects", django.db.models.manager.Manager()), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name="consent", | ||
name="delivery_point", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="consents", | ||
to="qcd_core.deliverypoint", | ||
), | ||
), | ||
] |
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,8 @@ | ||
/** | ||
* check/uncheck all checkbox in consent form | ||
*/ | ||
document.getElementById("toggle-all") | ||
.addEventListener("change", function() { | ||
const checkboxes = document.getElementsByName("status"); | ||
checkboxes.forEach(checkbox => checkbox.checked = this.checked); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
{% endblock content %} | ||
{% block dashboard_content %} | ||
{% endblock dashboard_content %} |
9 changes: 0 additions & 9 deletions
9
src/dashboard/apps/consent/templates/consent/consent-management.html
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/dashboard/apps/consent/templates/consent/includes/_resume_awaiting_consents.html
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,28 @@ | ||
{% load i18n %} | ||
|
||
<h2> | ||
{% trans "Consents summary" %} | ||
</h2> | ||
|
||
<p> | ||
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="{% url "consent:manage" %}"> | ||
<strong> | ||
{% trans "Validate content for all entities" %} | ||
</strong> | ||
</a> | ||
</p> | ||
|
||
<ul> | ||
{% for entity in entities %} | ||
|
||
<li> | ||
<strong>{{ entity.name }}</strong> | ||
<br /> | ||
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="{% url "consent:manage" entity.slug %}"> | ||
{% blocktranslate with entity_count=entity.count_awaiting_consents pluralize=entity.count_awaiting_consents|pluralize %} | ||
{{ entity_count }} consent{{ pluralize }} to validate for this entity | ||
{% endblocktranslate %} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> |
15 changes: 15 additions & 0 deletions
15
src/dashboard/apps/consent/templates/consent/includes/_resume_validated_consents.html
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,15 @@ | ||
{% load i18n %} | ||
|
||
<h2>{% trans "Validated entities" %}</h2> | ||
|
||
<ul> | ||
{% for entity in entities %} | ||
<li> | ||
<strong>{{ entity.name }}</strong> | ||
<br /> | ||
{% blocktranslate with entity_count=entity.count_validated_consents pluralize=entity.count_validated_consents|pluralize %} | ||
{{ entity_count }} consent{{ pluralize }} validated | ||
{% endblocktranslate %} | ||
</li> | ||
{% endfor %} | ||
</ul> |
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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
{% extends "home/base.html" %} | ||
{% extends "consent/base.html" %} | ||
|
||
{% load i18n %} | ||
|
||
{% block content %} | ||
<h2> | ||
{% trans "Consents summary" %} | ||
</h2> | ||
|
||
<p> | ||
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="{% url "consent:manage" %}"> | ||
{% trans "Manage consent" %} | ||
</a> | ||
</p> | ||
{% endblock content %} | ||
{% block dashboard_content %} | ||
{% include "consent/includes/_resume_awaiting_consents.html" %} | ||
{% include "consent/includes/_resume_validated_consents.html" %} | ||
{% endblock dashboard_content %} |
Oops, something went wrong.