diff options
author | Christopher Long <indirecthit@gmail.com> | 2006-08-20 18:00:07 +0000 |
---|---|---|
committer | Christopher Long <indirecthit@gmail.com> | 2006-08-20 18:00:07 +0000 |
commit | 722d0dbf4281d06d51d85cfbe82e74e669e843c6 (patch) | |
tree | cf928cde5319a09c0b40a280019ae4bff38ddff0 | |
parent | 6bed9e0b2c5e2152df454bc5f1a865eb46c427da (diff) | |
download | django-722d0dbf4281d06d51d85cfbe82e74e669e843c6.tar.gz |
[per-object-permissions] Added some more comments
[per-object-permissions] Added "hidden" option to admin options, this is to allow an object to have admin options but not be shown on the admin interface. Might not be wanted, and can be removed if that is the case.
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@3622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | django/contrib/auth/models.py | 9 | ||||
-rw-r--r-- | django/db/models/options.py | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 2fc889ec79..5856840ddd 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -73,9 +73,11 @@ class RowLevelPermissionManager(models.Manager): return ret_dict class RowLevelPermission(models.Model): - """ Similiar to permissions but works on instances of objects instead of types. + """ + Similiar to permissions but works on instances of objects instead of types. This uses generic relations to minimize the number of tables, and connects to the permissions table using a many to one relation. + """ model_id = models.PositiveIntegerField("'Model' ID") model_ct = models.ForeignKey(ContentType, verbose_name="'Model' content type", related_name="model_ct") @@ -93,7 +95,9 @@ class RowLevelPermission(models.Model): verbose_name = _('row level permission') verbose_name_plural = _('row level permissions') unique_together = (('model_ct', 'model_id', 'owner_id', 'owner_ct', 'permission'),) - + + class Admin: + hidden = True def __str__(self): return "%s | %s:%s | %s:%s" % (self.permission, self.owner_ct, self.owner, self.model_ct, self.model) @@ -319,6 +323,7 @@ class User(models.Model): if self.is_superuser: return True if object and object._meta.row_level_permissions: + #Since we use the content type for row level perms, we don't need the application name permission_str = perm[perm.index('.')+1:] row_level_permission = self.check_row_level_permission(permission_str, object) if row_level_permission is not None: diff --git a/django/db/models/options.py b/django/db/models/options.py index a574623c86..4faf14a0ea 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -203,7 +203,7 @@ class AdminOptions(object): def __init__(self, fields=None, js=None, list_display=None, list_display_links=None, list_filter=None, date_hierarchy=None, save_as=False, ordering=None, search_fields=None, save_on_top=False, list_select_related=False, manager=None, list_per_page=100, - grant_change_row_level_perm=False, grant_delete_row_level_perm=False): + grant_change_row_level_perm=False, grant_delete_row_level_perm=False, hidden=False): self.fields = fields self.js = js or [] self.list_display = list_display or ['__str__'] @@ -218,6 +218,7 @@ class AdminOptions(object): self.manager = manager or Manager() self.grant_change_row_level_perm=grant_change_row_level_perm self.grant_delete_row_level_perm=grant_delete_row_level_perm + self.hidden = hidden def get_field_sets(self, opts): "Returns a list of AdminFieldSet objects for this AdminOptions object." |