Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LessonCheckMixin(object):
- def __init__(self):
- # List of method names on mixin
- #
- self._LESSON_CHECK_METHODS = ['expected_failure', 'companies_check']
- def can_see_lessons(self, *args, **kwargs):
- """
- """
- for AUTHORIZATION_CHECK in self._LESSON_CHECK_METHODS:
- # Go thru all possible methods
- # If any return True success, else return False
- try:
- getattr(self, AUTHORIZATION_CHECK)()
- return True
- except:
- pass
- return False
- def companies_check(self, *args, **kwargs):
- """
- Some check to go see if a user is in a company or something
- """
- company = 'company' in kwargs
- return True
- def expected_failure():
- """
- Simulated failure, would be something like a UserLesson
- """
- raise
- class PermissionsMixin(LessonCheckMixin):
- """
- Not a million percent sure on this extra collating
- Feels ugly to have User inherit directly from a bunch of xCheckMixins
- but also having an empty object feesl a bit gross
- """
- pass
- class User(PermissionsMixin):
- """
- """
- username = '123'
- user = User()
- user.companies_check(1, b=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement