- November 16, 2016
- Not specified
- admin mixin permissions
- 1 (after 1 ratings)
Implements necessary permission checks on a user model to be compatible with django admin, but just return true on all permissions without actually checking it against anything. Useful when you have a user model that should always be allowed to use django admin, and you don't care about using django's own PermissionsMixin and don't want to have those models added to your database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
class FakeAdminPermissionsMixin(object): """ Implements necessary parts of a User to work with the django admin. Simply returns true on all permission and superuser questions. Not intended to be a fully compatible PermissionsMixin, that would implement all parts of the API, only implements just enough to make django admin happy. Don't use this if you actually want to use permissions. """ def has_perm(self, *args, **kwargs): return True def has_module_perms(self, *args, **kwargs): return True @property def is_staff(self): return True @is_staff.setter def is_staff(self, value): pass @property def is_superuser(self): return True @is_superuser.setter def is_superuser(self, value): pass