def setUp(self): RoleManager.cleanup() RoleManager.register_role(Advisor) RoleManager.register_role(Coordenator) self.john = MyUser.objects.create(username='******') self.bob = MyUser.objects.create(username='******')
def setUp(self): RoleManager.cleanup() RoleManager.register_role(Advisor) RoleManager.register_role(Teacher) RoleManager.register_role(Secretary) RoleManager.register_role(SubCoordenator) RoleManager.register_role(Coordenator) RoleManager.register_role(UniqueOwner) self.john = MyUser.objects.create(username="******") self.bob = MyUser.objects.create(username="******") self.mike = MyUser.objects.create(username="******") self.julie = MyUser.objects.create(username="******") self.unique = UniqueTogether.objects.create(content='Some data')
def setUp(self): self.john = MyUser.objects.create(username='******') self.bob = MyUser.objects.create(username='******') self.mike = MyUser.objects.create(username='******') self.library = Library.objects.create(title='Cool Library') self.book = Book.objects.create(title='Very Nice Book 1', library=self.library) self.chapter = Chapter.objects.create(title='Very Nice Chapter 1', book=self.book) self.paragraph = Paragraph.objects.create(content='Such Text 1', chapter=self.chapter) self.another_book = Book.objects.create(title='Very Nice Book 2', library=self.library) RoleManager.cleanup() RoleManager.register_role(Author) RoleManager.register_role(Advisor) RoleManager.register_role(Coordenator) RoleManager.register_role(Reviewer) RoleManager.register_role(LibraryOwner)
def autodiscover(): """ Find for Role class implementations on all apps in order to auto-register. """ from importlib import import_module from django.conf import settings from improved_permissions.roles import RoleManager try: # Check if the Permission model # is ready to be used. from django.contrib.auth.models import Permission Permission.objects.count() except: # pragma: no cover return # Remove all references about previous # role classes and erase all cache. RoleManager.cleanup() dip_cache().clear() # Looking for Role classes in "roles.py". module = get_config('MODULE', 'roles') for app in settings.INSTALLED_APPS: try: mod = import_module('%s.%s' % (app, module)) rc_list = [obj[1] for obj in inspect.getmembers(mod, is_role)] for roleclass in rc_list: RoleManager.register_role(roleclass) except ImportError: pass # Clear the cache again after # all registrations. dip_cache().clear()
def setUp(self): RoleManager.cleanup() RoleManager.register_role(roles.Advisor) RoleManager.register_role(roles.Coordenator)
def setUp(self): RoleManager.cleanup()