Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions apps/dot_ext/views/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,25 @@ def post(self, request, *args, **kwargs):
app_authorized.send(
sender=self, request=request,
token=token)

if app.data_access_type == "THIRTEEN_MONTH":
try:
dag = DataAccessGrant.objects.get(
beneficiary=token.user,
application=app
)
if dag.expiration_date is not None:
dag_expiry = strftime('%Y-%m-%d %H:%M:%SZ', dag.expiration_date.timetuple())
except DataAccessGrant.DoesNotExist:
flag = get_waffle_flag_model().get("limit_data_access")
if flag.rollout or (flag.id is not None and flag.is_active_for_user(app.user)):
if app.data_access_type == "THIRTEEN_MONTH":
try:
dag = DataAccessGrant.objects.get(
beneficiary=token.user,
application=app
)
if dag.expiration_date is not None:
dag_expiry = strftime('%Y-%m-%d %H:%M:%SZ', dag.expiration_date.timetuple())
except DataAccessGrant.DoesNotExist:
dag_expiry = ""

elif app.data_access_type == "ONE_TIME":
expires_at = datetime.utcnow() + timedelta(seconds=body['expires_in'])
dag_expiry = expires_at.strftime('%Y-%m-%d %H:%M:%SZ')
elif app.data_access_type == "RESEARCH_STUDY":
dag_expiry = ""

elif app.data_access_type == "ONE_TIME":
expires_at = datetime.utcnow() + timedelta(seconds=body['expires_in'])
dag_expiry = expires_at.strftime('%Y-%m-%d %H:%M:%SZ')
elif app.data_access_type == "RESEARCH_STUDY":
dag_expiry = ""

body['access_grant_expiration'] = dag_expiry
body = json.dumps(body)

Expand Down
Loading