permissions.py 492 B

12345678910111213141516
  1. from rest_framework.permissions import IsAdminUser
  2. class OrderUpsertPermission(IsAdminUser):
  3. def has_permission(self, request, view):
  4. if request.method == 'POST':
  5. try:
  6. _id = request.POST.get("_id",None)
  7. except:
  8. return super().has_permission(request, view)
  9. if _id :
  10. return super().has_permission(request, view)
  11. else:
  12. return True
  13. else:
  14. return False