Skip to content

Commit

Permalink
1855: Add Page.updated_url to 12-week retest
Browse files Browse the repository at this point in the history
  • Loading branch information
ahernp committed Feb 12, 2025
1 parent 022f4a4 commit 33f6e58
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 36 deletions.
19 changes: 19 additions & 0 deletions accessibility_monitoring_platform/apps/audits/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,25 @@ class Meta:
]


class AuditRetestPageUpdateForm(forms.ModelForm):
"""Form for updating a page at 12-week retest"""

updated_url = AMPURLField(label="New URL (if applicable)")
updated_location = AMPCharFieldWide(label="New page location (if applicable)")

class Meta:
model = Page
fields = [
"updated_url",
"updated_location",
]


AuditRetestPageFormset: forms.formsets.BaseFormSet = forms.modelformset_factory(
Page, AuditRetestPageUpdateForm, extra=0
)


class AuditRetestPageChecksForm(forms.Form):
"""
Form for retesting checks for a page
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.4 on 2024-12-31 08:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("audits", "0011_remove_audit_accessibility_statement_backup_url_and_more"),
]

operations = [
migrations.AddField(
model_name="page",
name="updated_url",
field=models.TextField(blank=True, default=""),
),
migrations.AddField(
model_name="page",
name="updated_location",
field=models.TextField(blank=True, default=""),
),
]
4 changes: 3 additions & 1 deletion accessibility_monitoring_platform/apps/audits/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DisproportionateBurden(models.TextChoices):
audit_retest_metadata_notes = models.TextField(default="", blank=True)
audit_retest_metadata_complete_date = models.DateField(null=True, blank=True)

# Retest pages
# Update page links
audit_retest_pages_complete_date = models.DateField(null=True, blank=True)

# Retest website compliance
Expand Down Expand Up @@ -550,7 +550,9 @@ class Type(models.TextChoices):
)
name = models.TextField(default="", blank=True)
url = models.TextField(default="", blank=True)
updated_url = models.TextField(default="", blank=True)
location = models.TextField(default="", blank=True)
updated_location = models.TextField(default="", blank=True)
complete_date = models.DateField(null=True, blank=True)
no_errors_date = models.DateField(null=True, blank=True)
not_found = models.CharField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
{% load static %}

{% block preform %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{% include 'audits/helpers/psb_page_links.html' %}
</div>
</div>
{% include 'audits/helpers/page_check_filters.html' with page='test' %}
{% endblock %}

Expand Down Expand Up @@ -33,14 +38,6 @@
class="govuk-button govuk-button--secondary"
data-module="govuk-button"
/>
{% if page %}
<a href="{{ page.url }}" class="govuk-link" target="_blank">
Link to {% if page.page_type == 'pdf' %}{{ page }}{% else %}{{ page|lower }}{% endif %}
</a>
{% endif %}
{% if page.location %}
<p class="govuk-body">{{ page.location }}</p>
{% endif %}
</div>
</div>
{% include 'common/next_platform_page.html' %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
{% extends 'common/case_form.html' %}

{% block preform %}
{% for page in case.audit.testable_pages %}
{% if page.failed_check_results.count > 0 %}
<h2 class="govuk-heading-m">{{ page }}</h2>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="govuk-form-group">
<label class="govuk-label"><b>URL</b></label>
<div class="govuk-hint">{{ page.url }}</div>
</div>
<div class="govuk-form-group">
<label class="govuk-label"><b>Page location description if single page app</b></label>
<div class="govuk-hint">{% if page.location %}{{ page.location }}{% else %}None{% endif %}</div>
</div>
</div>
{% if audit_retest_pages_formset.errors %}
{% for form in audit_retest_pages_formset.forms %}
{% if form.errors %}
{% include 'common/error_summary.html' %}
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}

{% block form %}
<form method="post" action="{% url sitemap.current_platform_page.url_name object.id %}">
{% csrf_token %}
{{ audit_retest_pages_formset.management_form }}

<table class="govuk-table">
<tbody class="govuk-table__body">
{% for page_form in audit_retest_pages_formset %}
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h2 class="govuk-heading-m">{{ page_form.instance }}</h2>
<div class="govuk-form-group">
<label class="govuk-label"><b>URL</b></label>
<div class="govuk-hint">{{ page_form.instance.url }}</div>
</div>
<div class="govuk-form-group">
<label class="govuk-label"><b>Page location description if single page app</b></label>
<div class="govuk-hint">{% if page_form.instance.location %}{{ page_form.instance.location }}{% else %}None{% endif %}</div>
</div>
{% include 'common/form_errors.html' with errors=page_form.non_field_errors %}
{% include 'common/form_hidden_fields.html' with hidden_fields=page_form.hidden_fields %}
{% for field in page_form.visible_fields %}
{% include 'common/amp_field.html' %}
{% endfor %}
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{% include 'common/amp_form_snippet.html' %}
</div>
<div class="govuk-grid-column-full">
{% include 'cases/helpers/save_continue_cancel.html' %}
</div>
{% endif %}
{% endfor %}
</div>
</form>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
{% load static %}

{% block preform %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{% include 'audits/helpers/psb_page_links.html' %}
</div>
</div>
{% include 'audits/helpers/page_check_filters.html' with page='retest' %}
{% endblock %}

Expand Down Expand Up @@ -70,14 +75,6 @@
class="govuk-button govuk-button--secondary"
data-module="govuk-button"
/>
{% if page %}
<a href="{{ page.url }}" class="govuk-link" target="_blank">
Link to {% if page.page_type == 'pdf' %}{{ page }}{% else %}{{ page|lower }}{% endif %}
</a>
{% endif %}
{% if page.location %}
<p class="govuk-body">{{ page.location }}</p>
{% endif %}
</div>
</div>
{% include 'common/next_platform_page.html' %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<details class="govuk-details" data-module="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
Website links
</span>
</summary>
<div class="govuk-details__text">
{% if page %}
{% if page.url %}
<p class="govuk-body-m">
<a href="{{ page.url }}" rel="noreferrer noopener" target="_blank" class="govuk-link">
Link to {{ page }} (initial test)</a>
</p>
{% endif %}
{% if page.updated_url %}
<p class="govuk-body-m">
<a href="{{ page.updated_url }}" rel="noreferrer noopener" target="_blank" class="govuk-link">
Link to {{ page }} (12-week test)</a>
</p>
{% endif %}
<p class="govuk-body-m amp-label amp-margin-bottom-0">Page location description if single page app</p>
<p class="govuk-body-m">{% if page.location %}{{ page.location }}{% else %}N/A{% endif %}</p>
<p class="govuk-body-m amp-label amp-margin-bottom-0">New page location</p>
<p class="govuk-body-m">{% if page.updated_location %}{{ page.updated_location }}{% else %}N/A{% endif %}</p>
{% else %}
<p class="govuk-body">No page added.</p>
{% endif %}
</div>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def test_audit_edit_redirects_based_on_button_pressed(
"version": audit.version,
button_name: "Button value",
"case-compliance-version": audit.case.compliance.version,
"form-TOTAL_FORMS": "0",
"form-INITIAL_FORMS": "0",
"form-MIN_NUM_FORMS": "0",
"form-MAX_NUM_FORMS": "1000",
},
)

Expand Down Expand Up @@ -3386,7 +3390,7 @@ def test_tall_results_page_has_back_to_top_link(path_name, admin_client):
("edit-audit-pages", "Initial WCAG test | Compliance decision"),
("edit-statement-overview", "Initial statement | Statement information"),
("edit-statement-overview", "Initial statement | Disproportionate burden"),
("edit-audit-retest-metadata", "12-week WCAG test | Retest pages"),
("edit-audit-retest-metadata", "12-week WCAG test | Update page links"),
("edit-audit-retest-pages", "12-week WCAG test | Compliance decision"),
("edit-retest-statement-overview", "12-week statement | Statement information"),
(
Expand Down
33 changes: 33 additions & 0 deletions accessibility_monitoring_platform/apps/audits/views/twelve_week.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
AuditRetestCheckResultFormset,
AuditRetestMetadataUpdateForm,
AuditRetestPageChecksForm,
AuditRetestPageFormset,
AuditRetestPagesUpdateForm,
AuditRetestStatementCheckResultFormset,
AuditRetestStatementComplianceUpdateForm,
Expand Down Expand Up @@ -87,6 +88,38 @@ def get_next_platform_page(self):
audit: Audit = self.object
return get_next_platform_page_twelve_week(audit=audit)

def get_context_data(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
"""Get context data for template rendering"""
context: dict[str, Any] = super().get_context_data(**kwargs)
audit: Audit = self.object
if self.request.POST:
audit_retest_pages_formset: AuditRetestPageFormset = AuditRetestPageFormset(
self.request.POST
)
else:
audit_retest_pages_formset: AuditRetestPageFormset = AuditRetestPageFormset(
queryset=audit.testable_pages
)
context["audit_retest_pages_formset"] = audit_retest_pages_formset
return context

def form_valid(self, form: ModelForm):
"""Process contents of valid form"""
context: dict[str, Any] = self.get_context_data()
audit_retest_pages_formset: AuditRetestPageFormset = context[
"audit_retest_pages_formset"
]

if audit_retest_pages_formset.is_valid():
pages: list[Page] = audit_retest_pages_formset.save(commit=False)
for page in pages:
record_model_update_event(user=self.request.user, model_object=page)
page.save()
else:
return super().form_invalid(form)

return super().form_valid(form)


class AuditRetestPageChecksFormView(AuditPageChecksFormView):
"""
Expand Down
2 changes: 1 addition & 1 deletion accessibility_monitoring_platform/apps/common/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def populate_from_case(self, case: Case):
case_details_template_name="cases/details/details.html",
),
AuditRetestPagesPlatformPage(
name="Retest pages",
name="Update page links",
url_name="audits:edit-audit-retest-pages",
complete_flag_name="audit_retest_pages_complete_date",
subpages=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('Create case, tests and report', () => {
cy.title().should('eq', `${newOrganisationName} | 12-week retest metadata`)
cy.contains('Save and continue').click()

cy.title().should('eq', `${newOrganisationName} | Retest pages`)
cy.title().should('eq', `${newOrganisationName} | Update page links`)
cy.contains('Save and continue').click()

cy.title().should('eq', `${newOrganisationName} | Home page retest`)
Expand Down

0 comments on commit 33f6e58

Please sign in to comment.