Skip to content

Instantly share code, notes, and snippets.

@0atman
Created February 25, 2013 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0atman/5030476 to your computer and use it in GitHub Desktop.
Save 0atman/5030476 to your computer and use it in GitHub Desktop.
AccessLevel model
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')
@0atman
Copy link
Author

0atman commented Feb 25, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment