Hi,
I've currently set up enabling row level permissions using the meta
class, e.g. to enable row level permissions for the Mineral model you
would have:
class Mineral(models.Model):
name = models.CharField(maxlength=150)
hardness = models.PositiveSmallIntegerField()
class Admin:
pass
class Meta:
unique_together = (('name', 'hardness'),)
row_lvl_perms = True
>From then on, you can access all row level permissions related to an
instance of Mineral by using the attribute row_lvl_perms (e.g.
mineral.row_lvl_perms.all() ).
The way I am adding the row_lvl_perms attribute is using the following
code in ModelBase (located in django.db.models.base):
if getattr(new_class._meta, 'row_lvl_perms', None):
from django.contrib.auth.models import RowLevelPermission
gen_rel =
django.db.models.GenericRelation(RowLevelPermission,
object_id_field="type_id", content_type_field="type_ct")
new_class.add_to_class("row_lvl_perms", gen_rel)
Wanted to get an opinion from the other developers, do you think this
is the best way of enabling row level permissions?
I thought about enabling them by default and having to specify if you
want them disabled, but I'm not sure if that would be the best route,
especially since general permissions have to be enabled to work. Any
thoughts?
Thanks,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---