Exemplo n.º 1
0
    def connect(self):
        user = self.scope['user']
        if not user.is_authenticated or not InstanceReference.can_manage(user):
            self.close()

        async_to_sync(self.channel_layer.group_add)(self.channel_group_name,
                                                    self.channel_name)
        self.accept()
Exemplo n.º 2
0
 def check_perm(user):
     """Checks if the user is an instance manager"""
     if InstanceReference.can_manage(user):
         return True
     # In case the 403 handler should be called raise the exception
     if raise_exception:
         raise PermissionDenied
     # Or, show login form.
     return False
Exemplo n.º 3
0
 def check_perm(user):
     """Checks if the user is an instance manager"""
     if InstanceReference.can_manage(user):
         return True
     # In case the 403 handler should be called raise the exception
     if raise_exception:
         raise PermissionDenied
     # Or, show login form.
     return False
Exemplo n.º 4
0
 def get_redirect_url(self, *args, **kwargs):
     """
     Redirect instance manager users to the instance list, and anyone else to the registration form
     """
     user = self.request.user
     if InstanceReference.can_manage(user):
         return reverse('instance:index')
     else:
         return reverse('registration:register')
Exemplo n.º 5
0
 def get_redirect_url(self, *args, **kwargs):
     """
     Redirect instance manager users to the instance list, and anyone else to the registration form
     """
     user = self.request.user
     if InstanceReference.can_manage(user):
         return reverse('instance:index')
     else:
         return reverse('registration:register')
Exemplo n.º 6
0
 def get_redirect_url(self, *args, **kwargs):
     """
     Redirect instance manager users to the instance list, and anyone else to the registration form
     """
     user = self.request.user
     if InstanceReference.can_manage(user):
         return reverse('instance:index')
     elif user.is_authenticated is False:
         return reverse('login')
     else:
         return settings.USER_CONSOLE_FRONTEND_URL
Exemplo n.º 7
0
 def has_permission(self, request, view):
     """Return True if user is an instance manager"""
     return InstanceReference.can_manage(request.user)
Exemplo n.º 8
0
 def has_permission(self, request, view):
     """Return True if user is an instance manager"""
     return InstanceReference.can_manage(request.user)