66from endorsement .dao .uwnetid_supported import get_supported_resources_for_netid
77from endorsement .dao .persistent_messages import get_persistent_messages
88from endorsement .dao .access import (
9- get_accessee_model , store_access , update_access , revoke_access )
9+ get_accessee_model , store_access , update_access ,
10+ revoke_access , renew_access )
1011from endorsement .dao .office import is_office_permitted , get_office_accessor
1112from endorsement .views .rest_dispatch import (
1213 RESTDispatch , invalid_session , invalid_endorser , data_error )
@@ -99,6 +100,7 @@ def patch(self, request, *args, **kwargs):
99100 except InvalidNetID :
100101 return invalid_endorser (logger )
101102
103+ action = request .data .get ('action' , None )
102104 mailbox = request .data .get ('mailbox' , None )
103105 delegate = request .data .get ('delegate' , None )
104106 access_type = request .data .get ('access_type' , None )
@@ -111,9 +113,17 @@ def patch(self, request, *args, **kwargs):
111113 accessor = get_office_accessor (delegate )
112114
113115 try :
114- access = update_access (
115- accessee , accessor , previous_access_type ,
116- access_type , acted_as )
116+ if action == 'renew' :
117+ access = renew_access (accessee , accessor , acted_as )
118+ return self .json_response (access .json_data ())
119+ elif previous_access_type and access_type :
120+ access = update_access (
121+ accessee , accessor , previous_access_type ,
122+ access_type , acted_as )
123+ else :
124+ return self .error_response (404 , message = "Insufficient Data" )
125+ except AccessRecord .DoesNotExist :
126+ return self .error_response (404 , message = "Unknown Access Record" )
117127 except DataFailureException as ex :
118128 return self .error_response (ex .status , message = ex .msg )
119129
0 commit comments