/usr/lib/python2.7/dist-packages/guardian/testapp/models.py is in python-django-guardian 1.2.4+git20141127-0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | from __future__ import unicode_literals
from datetime import datetime
import django
from django.db import models
from django.contrib.admin.models import LogEntry
from guardian.mixins import GuardianUserMixin
from guardian.models import UserObjectPermissionBase
from guardian.models import GroupObjectPermissionBase
class DynamicAccessor(object):
def __init__(self):
pass
def __getattr__(self, key):
return DynamicAccessor()
class ProjectUserObjectPermission(UserObjectPermissionBase):
content_object = models.ForeignKey('Project')
class ProjectGroupObjectPermission(GroupObjectPermissionBase):
content_object = models.ForeignKey('Project')
class Project(models.Model):
name = models.CharField(max_length=128, unique=True)
created_at = models.DateTimeField(default=datetime.now)
class Meta:
get_latest_by = 'created_at'
def __unicode__(self):
return self.name
Project.not_a_relation_descriptor = DynamicAccessor()
class MixedGroupObjectPermission(GroupObjectPermissionBase):
content_object = models.ForeignKey('Mixed')
class Mixed(models.Model):
"""
Model for tests obj perms checks with generic user object permissions model
and direct group object permissions model.
"""
name = models.CharField(max_length=128, unique=True)
def __unicode__(self):
return self.name
class LogEntryWithGroup(LogEntry):
group = models.ForeignKey('auth.Group', null=True, blank=True)
class NonIntPKModel(models.Model):
"""
Model for testing whether get_objects_for_user will work when the objects to
be returned have non-integer primary keys.
"""
char_pk = models.CharField(primary_key=True, max_length=128)
if django.VERSION > (1, 5):
from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser, GuardianUserMixin):
custom_id = models.AutoField(primary_key=True)
|