-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
954 additions
and
137 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
77 changes: 77 additions & 0 deletions
77
...itoring_platform/apps/audits/migrations/0012_retestcheckresult_id_within_case_and_more.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,77 @@ | ||
# Generated by Django 5.1.4 on 2025-01-21 08:46 | ||
|
||
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="checkresult", | ||
name="issue_identifier", | ||
field=models.CharField(max_length=20, default=""), | ||
), | ||
migrations.AddField( | ||
model_name="retestcheckresult", | ||
name="id_within_case", | ||
field=models.IntegerField(blank=True, default=0), | ||
), | ||
migrations.AddField( | ||
model_name="retestcheckresult", | ||
name="issue_identifier", | ||
field=models.CharField(max_length=20, default=""), | ||
), | ||
migrations.AddField( | ||
model_name="reteststatementcheckresult", | ||
name="id_within_case", | ||
field=models.IntegerField(blank=True, default=0), | ||
), | ||
migrations.AddField( | ||
model_name="reteststatementcheckresult", | ||
name="issue_identifier", | ||
field=models.CharField(max_length=20, default=""), | ||
), | ||
migrations.AddField( | ||
model_name="statementcheck", | ||
name="issue_number", | ||
field=models.IntegerField(blank=True, default=0), | ||
), | ||
migrations.AddField( | ||
model_name="statementcheckresult", | ||
name="id_within_case", | ||
field=models.IntegerField(blank=True, default=0), | ||
), | ||
migrations.AddField( | ||
model_name="statementcheckresult", | ||
name="issue_identifier", | ||
field=models.CharField(max_length=20, default=""), | ||
), | ||
migrations.AddIndex( | ||
model_name="checkresult", | ||
index=models.Index( | ||
fields=["issue_identifier"], name="audits_chec_issue_i_a8fd9c_idx" | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="retestcheckresult", | ||
index=models.Index( | ||
fields=["issue_identifier"], name="audits_rete_issue_i_4df993_idx" | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="reteststatementcheckresult", | ||
index=models.Index( | ||
fields=["issue_identifier"], name="audits_rete_issue_i_a854a4_idx" | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="statementcheckresult", | ||
index=models.Index( | ||
fields=["issue_identifier"], name="audits_stat_issue_i_d20fe4_idx" | ||
), | ||
), | ||
] |
94 changes: 94 additions & 0 deletions
94
accessibility_monitoring_platform/apps/audits/migrations/0013_populate_ids_within_case.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,94 @@ | ||
# Generated by Django 5.1.4 on 2025-01-21 08:48 | ||
|
||
from django.db import migrations | ||
|
||
ISSUE_IDENTIFIER_WCAG: str = "A" | ||
ISSUE_IDENTIFIER_STATEMENT: str = "S" | ||
CUSTOM_ISSUE: str = "C" | ||
|
||
|
||
def build_issue_identifier(case, issue, issue_type): | ||
"""Format and return issue identifier""" | ||
return f"{case.case_number}-{issue_type}-{issue.id_within_case}" | ||
|
||
|
||
def populate_id_within_case(apps, schema_editor): # pylint: disable=unused-argument | ||
Audit = apps.get_model("audits", "Audit") | ||
CheckResult = apps.get_model("audits", "CheckResult") | ||
StatementCheck = apps.get_model("audits", "StatementCheck") | ||
StatementCheckResult = apps.get_model("audits", "StatementCheckResult") | ||
Retest = apps.get_model("audits", "Retest") | ||
RetestCheckResult = apps.get_model("audits", "RetestCheckResult") | ||
RetestStatementCheckResult = apps.get_model("audits", "RetestStatementCheckResult") | ||
|
||
issue_number = 0 | ||
for statement_check in StatementCheck.objects.all(): | ||
issue_number += 1 | ||
statement_check.issue_number = issue_number | ||
statement_check.save() | ||
|
||
for audit in Audit.objects.all(): | ||
for check_result in CheckResult.objects.filter(audit=audit): | ||
check_result.issue_identifier = build_issue_identifier( | ||
case=audit.case, | ||
issue=check_result, | ||
issue_type=ISSUE_IDENTIFIER_WCAG, | ||
) | ||
check_result.save() | ||
id_within_case = 0 | ||
|
||
for statement_check_result in StatementCheckResult.objects.filter(audit=audit): | ||
id_within_case += 1 | ||
statement_check_result.id_within_case = id_within_case | ||
issue_type = ISSUE_IDENTIFIER_STATEMENT | ||
if statement_check_result.statement_check is None: | ||
issue_type += CUSTOM_ISSUE | ||
statement_check_result.issue_identifier = build_issue_identifier( | ||
case=audit.case, | ||
issue=statement_check_result, | ||
issue_type=issue_type, | ||
) | ||
statement_check_result.save() | ||
|
||
for retest in Retest.objects.all(): | ||
for retest_check_result in RetestCheckResult.objects.filter(retest=retest): | ||
retest_check_result.id_within_case = ( | ||
retest_check_result.check_result.id_within_case | ||
) | ||
retest_check_result.issue_identifier = build_issue_identifier( | ||
case=audit.case, | ||
issue=retest_check_result, | ||
issue_type=ISSUE_IDENTIFIER_WCAG, | ||
) | ||
retest_check_result.save() | ||
|
||
id_within_case = 0 | ||
for retest_statement_check_result in RetestStatementCheckResult.objects.filter( | ||
retest=retest | ||
): | ||
id_within_case += 1 | ||
retest_statement_check_result.id_within_case = id_within_case | ||
issue_type = ISSUE_IDENTIFIER_STATEMENT | ||
if retest_statement_check_result.statement_check is None: | ||
issue_type += CUSTOM_ISSUE | ||
retest_statement_check_result.issue_identifier = build_issue_identifier( | ||
case=retest.case, | ||
issue=retest_statement_check_result, | ||
issue_type=issue_type, | ||
) | ||
retest_statement_check_result.save() | ||
|
||
|
||
def reverse_code(apps, schema_editor): # pylint: disable=unused-argument | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("audits", "0012_retestcheckresult_id_within_case_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(populate_id_within_case, reverse_code=reverse_code), | ||
] |
Oops, something went wrong.