Exemple #1
0
 def has_permission(self, request, view):
     records = MaintenanceRecord.active()\
                                .filter(provider__isnull=True)
     if records:
         if not request.user.is_staff:
             raise ServiceUnavailable(
                 detail=get_maintenance_messages(records))
     return True
 def has_permission(self, request, view):
     records = MaintenanceRecord.active()\
                                .filter(provider__isnull=True)
     if records:
         request_username = request.user.username
         #TODO: Optional logic related to session_username -- the one who is 'Authenticated'..
         atmo_user = AtmosphereUser.objects.filter(
             username=request_username).first()
         if atmo_user and request_username in settings.MAINTENANCE_EXEMPT_USERNAMES:
             return True
         else:
             raise ServiceUnavailable(
                 detail=get_maintenance_messages(records))
     return True