Author: clong
Date: 2006-08-20 13:00:07 -0500 (Sun, 20 Aug 2006)
New Revision: 3622
Modified:
django/branches/per-object-permissions/django/contrib/auth/models.py
django/branches/per-object-permissions/django/db/models/options.py
Log:
[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.
Modified: django/branches/per-object-permissions/django/contrib/auth/models.py
===================================================================
--- django/branches/per-object-permissions/django/contrib/auth/models.py
2006-08-20 16:11:02 UTC (rev 3621)
+++ django/branches/per-object-permissions/django/contrib/auth/models.py
2006-08-20 18:00:07 UTC (rev 3622)
@@ -73,9 +73,11 @@
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,8 +95,10 @@
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 @@
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:
Modified: django/branches/per-object-permissions/django/db/models/options.py
===================================================================
--- django/branches/per-object-permissions/django/db/models/options.py
2006-08-20 16:11:02 UTC (rev 3621)
+++ django/branches/per-object-permissions/django/db/models/options.py
2006-08-20 18:00:07 UTC (rev 3622)
@@ -203,7 +203,7 @@
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 @@
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."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---