mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 08:57:33 -02:30
Example of how to disassociate an object from a collection, to be generalized later!
This commit is contained in:
@@ -2,6 +2,7 @@ from django.db import models
|
||||
from django.db.models import CASCADE, SET_NULL, PROTECT
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
import exceptions
|
||||
|
||||
# TODO: jobs and events model TBD
|
||||
# TODO: reporting model TBD
|
||||
@@ -29,6 +30,9 @@ class CommonModel(models.Model):
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
|
||||
def can_user_administrate(self, user):
|
||||
raise exceptions.NotImplementedError()
|
||||
|
||||
class Tag(models.Model):
|
||||
'''
|
||||
@@ -173,6 +177,14 @@ class Project(CommonModel):
|
||||
import lib.urls
|
||||
return reverse(lib.urls.views_ProjectsDetail, args=(self.pk,))
|
||||
|
||||
def can_user_administrate(self, user):
|
||||
organizations = Organization.filter(admins__in = [ user ])
|
||||
organizations = self.organizations()
|
||||
for org in organizations:
|
||||
if org in project.organizations():
|
||||
return True
|
||||
return True
|
||||
|
||||
class Permission(CommonModel):
|
||||
'''
|
||||
A permission allows a user, project, or team to be able to use an inventory source.
|
||||
|
||||
Reference in New Issue
Block a user