-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1131 from GSA-TTS/main
2023-05-17 main -> prod
- Loading branch information
Showing
27 changed files
with
1,145 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Bug Report 🐞 | ||
description: Report a bug and help USWDS improve. | ||
title: "FAC - Bug: [YOUR TITLE]" | ||
labels: ['Type: Bug','Status: Triage','Needs: Confirmation'] | ||
body: | ||
- type: textarea | ||
id: problem | ||
attributes: | ||
label: Describe the bug | ||
description: Add a clear and concise description of the bug. Let us know if it impacts major or minor functionality and if you have workaround. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: Steps to reproduce the bug | ||
description: Describe how to reproduce this issue. | ||
placeholder: | | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error... | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expectation | ||
attributes: | ||
label: Expected Behavior | ||
description: Add a clear and concise description of what you expected to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: screenshots | ||
attributes: | ||
label: Screenshots | ||
description: Add screenshots to help provide context, if applicable. | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: system | ||
attributes: | ||
label: System setup | ||
description: Provide your system details. Be sure to include your device, operating system, and browser (with version). | ||
placeholder: | | ||
- Device: | ||
- Operating system: | ||
- Browser and version: | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: context | ||
attributes: | ||
label: Additional context | ||
description: Add any other context about the problem. | ||
validations: | ||
required: false | ||
- type: checkboxes | ||
id: terms | ||
attributes: | ||
label: Code of Conduct | ||
description: Please confirm the following | ||
options: | ||
- label: | ||
I agree to abide by the [Digital.gov Community Guidelines](https://digital.gov/communities/community-guidelines/) and the [TTS Code of Conduct](https://handbook.tts.gsa.gov/code-of-conduct/). Respect your peers, use plain language, and be patient. | ||
required: true | ||
- label: | ||
I checked the [current | ||
issues](https://github.com/GSA-TTS/FAC/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug%22) for | ||
duplicate bug reports. | ||
required: true |
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,51 @@ | ||
name: Feature Request 💡 | ||
description: | ||
Suggest a new idea for the design system. | ||
title: 'FAC - Feature: [YOUR TITLE]' | ||
labels: ['Type: Feature Request','Status: Triage'] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: '## Feature Request 💡' | ||
- type: textarea | ||
id: problem | ||
attributes: | ||
label: Is your feature request related to a problem? Please describe. | ||
description: "Provide a clear and concise description of what the problem is. Ex. I'm always frustrated when [...]" | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: solution | ||
attributes: | ||
label: "Describe the solution you'd like" | ||
description: "Provide a clear and concise description of what you want to happen." | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: alternatives | ||
attributes: | ||
label: "Describe alternatives you've considered" | ||
description: "Provide a clear and concise description of any alternative solutions or features you've considered." | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: context | ||
attributes: | ||
label: Additional context | ||
description: "Add any other context or screenshots about the feature request." | ||
validations: | ||
required: false | ||
- type: checkboxes | ||
id: terms | ||
attributes: | ||
label: Code of Conduct | ||
description: Please confirm the following | ||
options: | ||
- label: | ||
I agree to abide by the [Digital.gov Community Guidelines](https://digital.gov/communities/community-guidelines/) and the [TTS Code of Conduct](https://handbook.tts.gsa.gov/code-of-conduct/). Respect your peers, use plain language, and be patient. | ||
required: true | ||
- label: | ||
I checked the [current | ||
issues](https://github.com/GSA-TTS/FAC/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Feature+Request%22) for | ||
duplicate feature requests. | ||
required: true |
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,25 @@ | ||
# Generated by Django 4.1.7 on 2023-05-11 16:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("audit", "0022_remove_access_audit_single_creator_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="access", | ||
name="role", | ||
field=models.CharField( | ||
choices=[ | ||
("certifying_auditee_contact", "Auditee Certifying Official"), | ||
("certifying_auditor_contact", "Auditor Certifying Official"), | ||
("editor", "Audit Editor"), | ||
], | ||
help_text="Access type granted to this user", | ||
max_length=50, | ||
), | ||
), | ||
] |
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,101 @@ | ||
from typing import Any | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.http.request import HttpRequest | ||
from django.http.response import HttpResponse | ||
from django.core.exceptions import PermissionDenied | ||
|
||
from .models import Access, SingleAuditChecklist | ||
|
||
User = get_user_model() | ||
|
||
|
||
class CertificationPermissionDenied(PermissionDenied): | ||
def __init__(self, message, eligible_users): | ||
super().__init__(message) | ||
|
||
self.eligible_users = eligible_users | ||
|
||
|
||
def has_access(sac, user): | ||
"""Does a user have permission to access a submission?""" | ||
return bool(Access.objects.filter(sac=sac, user=user)) | ||
|
||
|
||
def has_role(sac, user, role): | ||
"""Does a user have a specific role on a submission?""" | ||
return bool(Access.objects.filter(sac=sac, user=user, role=role)) | ||
|
||
|
||
class SingleAuditChecklistAccessRequiredMixin(LoginRequiredMixin): | ||
""" | ||
View mixin to require that a user is logged in and has access to the submission. | ||
""" | ||
|
||
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: | ||
try: | ||
sac = SingleAuditChecklist.objects.get(report_id=kwargs["report_id"]) | ||
|
||
if not has_access(sac, request.user): | ||
raise PermissionDenied("You do not have access to this audit.") | ||
except SingleAuditChecklist.DoesNotExist: | ||
raise PermissionDenied("You do not have access to this audit.") | ||
|
||
return super().dispatch(request, *args, **kwargs) | ||
|
||
|
||
class CertifyingAuditeeRequiredMixin(LoginRequiredMixin): | ||
""" | ||
View mixin to require that a user is logged in, has access to the submission, and has | ||
the ``certifying_auditee_contact`` role. | ||
""" | ||
|
||
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: | ||
role = "certifying_auditee_contact" | ||
try: | ||
sac = SingleAuditChecklist.objects.get(report_id=kwargs["report_id"]) | ||
|
||
if not has_access(sac, request.user): | ||
raise PermissionDenied("You do not have access to this audit") | ||
|
||
if not has_role(sac, request.user, role): | ||
eligible_accesses = Access.objects.select_related("user").filter( | ||
sac=sac, role=role | ||
) | ||
eligible_users = [acc.user for acc in eligible_accesses] | ||
|
||
raise CertificationPermissionDenied( | ||
"bad role", eligible_users=eligible_users | ||
) | ||
except SingleAuditChecklist.DoesNotExist: | ||
raise PermissionDenied("You do not have access to this audit.") | ||
|
||
return super().dispatch(request, *args, **kwargs) | ||
|
||
|
||
class CertifyingAuditorRequiredMixin(LoginRequiredMixin): | ||
""" | ||
View mixin to require that a user is logged in, has access to the submission, and has | ||
the ``certifying_auditor_contact`` role. | ||
""" | ||
|
||
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: | ||
role = "certifying_auditor_contact" | ||
try: | ||
sac = SingleAuditChecklist.objects.get(report_id=kwargs["report_id"]) | ||
|
||
if not has_access(sac, request.user): | ||
raise PermissionDenied("You do not have access to this audit") | ||
|
||
if not has_role(sac, request.user, role): | ||
eligible_accesses = Access.objects.select_related("user").filter( | ||
sac=sac, role=role | ||
) | ||
eligible_users = [acc.user for acc in eligible_accesses] | ||
raise CertificationPermissionDenied( | ||
"bad role", eligible_users=eligible_users | ||
) | ||
except SingleAuditChecklist.DoesNotExist: | ||
raise PermissionDenied("You do not have access to this audit.") | ||
|
||
return super().dispatch(request, *args, **kwargs) |
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
Oops, something went wrong.