Created
February 25, 2013 15:14
-
-
Save 0atman/5030476 to your computer and use it in GitHub Desktop.
AccessLevel model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccessLevel(models.Model): | |
user = models.ForeignKey(User, related_name='access_levels') | |
access_level = models.CharField( | |
max_length=12, | |
choices=(("open", "open"), ("closed", "closed")), | |
default="open" | |
) | |
starts = models.DateTimeField(auto_now=True) | |
expires = models.DateTimeField(blank=True, null=True) | |
content_type = models.ForeignKey(ContentType, related_name='access_levels') | |
object_id = models.PositiveIntegerField() | |
content_object = generic.GenericForeignKey('content_type', 'object_id') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This model allows us to set any piece of content in our system to "open" or "closed" per user.
This would be the basis of an object-level permissions system.