-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3399 controlled access fra data files page #3430
base: develop
Are you sure you want to change the base?
3399 controlled access fra data files page #3430
Conversation
…led-access-FRA-Data-Files-page-3
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3430 +/- ##
===========================================
- Coverage 91.43% 91.26% -0.17%
===========================================
Files 300 302 +2
Lines 8647 8720 +73
Branches 640 650 +10
===========================================
+ Hits 7906 7958 +52
- Misses 621 642 +21
Partials 120 120
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
Hey Mo, can you update testing steps here? Functionally it's looking good |
tdrs-backend/tdpservice/users/migrations/0042_user_feature_flags.py
Outdated
Show resolved
Hide resolved
…gs.py Co-authored-by: Andrew <[email protected]>
def test_create_data_file_fra(self, api_client, data_file_data, user): | ||
"""Test ability to create data file metadata registry.""" | ||
response = self.post_data_file_fra(api_client, data_file_data) | ||
from rest_framework.exceptions import ErrorDetail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this lives in the function instead of at the module level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, corrected it
@@ -19,6 +21,9 @@ class Meta: | |||
exclude = ['password', 'user_permissions'] | |||
readonly_fields = ['last_login', 'date_joined', 'login_gov_uuid', 'hhs_id', 'access_request'] | |||
|
|||
def __init__(self, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this stylistic/for completeness, or was this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byproduct of an approach I was taking, can be removed
client = Client() | ||
client.force_login(user) | ||
|
||
# Need a datafile, with a section that is not in the FRA_SECTION_LIST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is confusing since the test is using an FRA section immediately below it even though the comment says not to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments and questions
default=dict, | ||
help_text="Feature flags for this data file.", | ||
null=True, | ||
blank=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep null
and blank
set to True
, the property has_fra_access
should do a null check on self.feature_flags
before checking for the key. I was able to leave the form field blank in the admin and cause an exception to be raised when navigating to the data files page. Could we instead make them both false since we do have the default set as dict
to avoid worrying about checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there is an internal check for {} in JSONField. The only way to bypass is to override JSONField, but I decided to check for null or empty dict during cleaning which is simple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also moved null out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout my comment
@raftmsohani this PR is also generating another migration on top of the two existing ones when I start it locally.\ |
fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working for the most part. I do have one suggestion i think would be worth exploring
filtered_for_fra = qs.exclude(section__in=FRA_SECTION_LIST) | ||
return filtered_for_fra | ||
else: | ||
return qs.filter(section__in=FRA_SECTION_LIST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is intended, but setting fra_access=True
means that the data files page filters down to only FRA files. you have to set fra_access=False
to see other file types. maybe we should have a "both" option for admins and other users so that they don't have to switch the feature flag to find files in the admin
@@ -37,6 +37,16 @@ class Media: | |||
|
|||
actions = ['reparse'] | |||
|
|||
def get_queryset(self, request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if user doesn't have FRA access or is Admin, then FRA files will be filtered
@@ -135,6 +145,28 @@ def queryset(self, request, queryset): | |||
else: | |||
return queryset | |||
|
|||
class FRA_AccessFilter(admin.SimpleListFilter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filter will appear if user has FRA access and is Admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Summary of Changes
Provide a brief summary of changes
Pull request closes #3399 _
How to Test
List the steps to test the PR
{"fra_access": true}
Deliverables
More details on how deliverables herein are assessed included here.
Deliverable 1: Accepted Features
Checklist of ACs:
lfrohlich
and/oradpennington
confirmed that ACs are met.Deliverable 2: Tested Code
CodeCov Report
comment in PR)CodeCov Report
comment in PR)Deliverable 3: Properly Styled Code
Deliverable 4: Accessible
iamjolly
andttran-hub
using Accessibility Insights reveal any errors introduced in this PR?Deliverable 5: Deployed
Deliverable 6: Documented
Deliverable 7: Secure
Deliverable 8: User Research
Research product(s) clearly articulate(s):