|
4 | 4 | ApplicationActivePermission) |
5 | 5 | from apps.authorization.permissions import DataAccessGrantPermission |
6 | 6 | from apps.capabilities.permissions import TokenHasProtectedCapability |
| 7 | +from django.http import JsonResponse |
7 | 8 |
|
8 | 9 | from rest_framework import permissions # pyright: ignore[reportMissingImports] |
9 | 10 |
|
@@ -79,18 +80,38 @@ def get(self, request, *args, **kwargs): |
79 | 80 | print("GET OF INSURANCE CARD") |
80 | 81 | print("request: ", request.__dict__) |
81 | 82 | print("self.resource_type: ", self.resource_type) |
82 | | - return super().get(request, self.resource_type, *args, **kwargs) |
83 | | - # return JsonResponse(status=200, data={"ok": "go"}) |
| 83 | + # return super().get(request, self.resource_type, *args, **kwargs) |
| 84 | + return JsonResponse(status=200, data={"ok": "go"}) |
84 | 85 |
|
85 | 86 | # How do the has_permission herre and the has_permission in the permission classes |
86 | 87 | # play together? If they pass, can this fail? Visa-versa? |
| 88 | + # def has_permission(self, request, view) -> bool: # type: ignore |
| 89 | + # required_scopes = getattr(view, 'required_scopes', None) |
| 90 | + # if required_scopes is None: |
| 91 | + # return True |
| 92 | + |
| 93 | + # if hasattr(request, 'auth') and request.auth is not None: |
| 94 | + # token_scopes = request.auth.scope |
| 95 | + # return any(scope in token_scopes for scope in required_scopes) |
| 96 | + # return False |
| 97 | + |
| 98 | + def has_permission(self, request, view): |
| 99 | + # TODO: Why is this not being called? |
| 100 | + # A print statement where this comment is does not appear when unit tests are run. |
| 101 | + # But, the permission classes run. Where/when does has_permission get called? |
| 102 | + # required_scopes = getattr(view, 'required_scopes', None) |
| 103 | + # if required_scopes is None: |
| 104 | + # return False |
| 105 | + # return request.user.is_authenticated and hasattr(request.user, 'crosswalk') |
| 106 | + return True |
87 | 107 |
|
88 | 108 | def build_parameters(self, request): |
89 | 109 | return { |
90 | 110 | '_format': 'application/json' |
91 | 111 | } |
92 | 112 |
|
93 | 113 | def build_url(self, fhir_settings, resource_type, resource_id=None, *args, **kwargs): |
| 114 | + print("BUILD_URL IN DIGITALINSURANCECARD") |
94 | 115 | if fhir_settings.fhir_url.endswith('v1/fhir/'): |
95 | 116 | # only if called by tests |
96 | 117 | return f"{fhir_settings.fhir_url}{resource_type}/" |
|
0 commit comments