setting offerAccepted to only superAdmins
This commit is contained in:
parent
8d6976fb81
commit
c7304cb814
|
@ -104,22 +104,29 @@ def updateDeadline(request, id, email, user_type):
|
|||
|
||||
|
||||
@api_view(['POST'])
|
||||
@isAuthorized([ADMIN])
|
||||
@isAuthorized([SUPER_ADMIN])
|
||||
@precheck([OPENING_ID, OFFER_ACCEPTED])
|
||||
def updateOfferAccepted(request, id, email, user_type):
|
||||
try:
|
||||
data = request.data
|
||||
offer_accepted = data[OFFER_ACCEPTED]
|
||||
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
||||
if not opening.offer_accepted:
|
||||
opening.offer_accepted = True
|
||||
if opening.offer_accepted is None:
|
||||
opening.offer_accepted = offer_accepted == "true"
|
||||
opening.changed_by = get_object_or_404(User, id=id)
|
||||
opening.save()
|
||||
send_opening_notifications(opening.id)
|
||||
else:
|
||||
raise ValueError("Offer Status already updated")
|
||||
|
||||
return Response({'action': "Update Offer Accepted", 'message': "Offer Accepted Updated"},
|
||||
status=status.HTTP_200_OK)
|
||||
except Http404:
|
||||
return Response({'action': "Update Offer Accepted", 'message': 'Opening Not Found'},
|
||||
status=status.HTTP_404_NOT_FOUND)
|
||||
except ValueError as e:
|
||||
return Response({'action': "Update Offer Accepted", 'message': str(e)},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
except:
|
||||
logger.warning("Update Offer Accepted: " + str(sys.exc_info()))
|
||||
return Response({'action': "Update Offer Accepted", 'message': "Something went wrong"},
|
||||
|
|
|
@ -62,7 +62,8 @@ EMAIL = "email"
|
|||
|
||||
STUDENT = 'student'
|
||||
ADMIN = 'admin'
|
||||
COMPANY = ''
|
||||
SUPER_ADMIN = 'super_admin'
|
||||
COMPANY = 'company'
|
||||
TIER = 'tier'
|
||||
# To be Configured Properly
|
||||
FOURTH_YEAR = '2019'
|
||||
|
|
Loading…
Reference in New Issue