Update by natay on Wed Sep 26 12:26:26 EDT 2018 from Admins-MacBook-Air.local
@@ -72,26 +72,6 @@ class write_access:
Controls WRITE level access to urls.
"""
- def __init__(self, type):
- self.type = type
- self.fallback_url = reverse("project_list")
-
- def __call__(self, function, *args, **kwargs):
- """
- Decorator used to test if a user has rights to access an instance
- """
-
- # Pass function attributes to the wrapper
- @wraps(function, assigned=available_attrs(function))
- def _wrapped_view(request, *args, **kwargs):
-
- pass
-
-
-class owner_only:
- """
- Controls privileges left to owner
- """
def __init__(self, type):
self.type = type
self.fallback_url = reverse("project_list")
@@ -112,15 +92,30 @@ class owner_only:
# Fetches the object that will be checked for permissions.
instance = self.type.objects.filter(uid=uid).first()
+ project = instance.project
+ access = models.Access.objects.filter(user=user, project=project, access=models.Access.WRITE_ACCESS).first()
- # Project owners may read their project.
- if instance.owner == user or instance.project.owner == user:
+ # Project owners may write their project.
+ if access or instance.project.owner == user:
return function(request, *args, **kwargs)
messages.error(request, "You have to be the owner to preform this action.")
return redirect(self.fallback_url)
- return _wrapped_view
+ pass
+
+
+class owner_only:
+ """
+ Controls privileges left to owner
+ """
+ def __init__(self, type):
+ self.type = type
+ self.fallback_url = reverse("project_list")
+
+ def __call__(self, function, *args, **kwargs):
+
+ return
class object_access:
