Commit e9db2e65 by Dudás Ádám

vm: implement check_auth method of operations

parent 57fc676a
...@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals ...@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
from logging import getLogger from logging import getLogger
from string import ascii_lowercase from string import ascii_lowercase
from django.core.exceptions import PermissionDenied
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
...@@ -43,7 +44,7 @@ class Operation: ...@@ -43,7 +44,7 @@ class Operation:
"""This method contains the shared prelude of __call__ and async. """This method contains the shared prelude of __call__ and async.
""" """
user = kwargs.setdefault('user', None) user = kwargs.setdefault('user', None)
self.check_auth(user) # TODO what's check_auth's specification? self.check_auth(user)
self.check_precond() self.check_precond()
return self.create_activity(user=user) return self.create_activity(user=user)
...@@ -76,7 +77,13 @@ class Operation: ...@@ -76,7 +77,13 @@ class Operation:
pass pass
def check_auth(self, user): def check_auth(self, user):
pass if not self.instance.has_level(user, self.acl_level):
raise PermissionDenied("%s doesn't have the required ACL level." %
user)
if not user.has_perms(self.required_perms):
raise PermissionDenied("%s doesn't have the required permissions."
% user)
def create_activity(self, user=None): def create_activity(self, user=None):
return InstanceActivity.create(code_suffix=self.activity_code_suffix, return InstanceActivity.create(code_suffix=self.activity_code_suffix,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment