diff --git a/conntrackt/models.py b/conntrackt/models.py --- a/conntrackt/models.py +++ b/conntrackt/models.py @@ -3,25 +3,6 @@ from django.core.exceptions import Valid from django.db import models -class ViewPermissionModelMetaClass(models.base.ModelBase): - """ - Implements a meta class that can be used for automatically adding the view - permission for a model. - - Limitation is that syncdb must be called with --all if using South. - - Original source found at: - - http://stackoverflow.com/questions/725913/dynamic-meta-attributes-for-django-models - """ - - def __new__(cls, name, bases, attrs): - cl = super(ViewPermissionModelMetaClass, cls).__new__(cls, name, bases, attrs) - cl._meta.permissions.append(('view_' + cl._meta.module_name, u'Can view %s' % cl._meta.verbose_name)) - - return cl - - class Project(models.Model): """ Implements a model with information about a project. A project has some @@ -37,7 +18,8 @@ class Project(models.Model): name = models.CharField(max_length=100) description = models.TextField(blank=True) - __metaclass__ = ViewPermissionModelMetaClass + class Meta: + permissions = (("view", "Can view information"),) def __unicode__(self): """ @@ -75,8 +57,6 @@ class Location(models.Model): name = models.CharField(max_length=100) description = models.TextField(blank=True) - __metaclass__ = ViewPermissionModelMetaClass - def __unicode__(self): """ Returns: @@ -111,8 +91,6 @@ class Entity(models.Model): project = models.ForeignKey(Project) location = models.ForeignKey(Location) - __metaclass__ = ViewPermissionModelMetaClass - class Meta: """ Overrides some of the default parameters used by Django for this model.