Ticket #10686: permission_inheritance.diff
File permission_inheritance.diff, 2.7 KB (added by , 16 years ago) |
---|
-
django/db/models/base.py
43 43 meta = getattr(new_class, 'Meta', None) 44 44 else: 45 45 meta = attr_meta 46 # Append any inherited permissions to any explicitly declared ones. 47 if hasattr(meta, 'permissions') and getattr(meta, 'inherit_permissions', True): 48 if hasattr(new_class, 'Meta') and hasattr(new_class.Meta, 'permissions'): 49 meta.permissions += new_class.Meta.permissions 46 50 base_meta = getattr(new_class, '_meta', None) 47 51 48 52 if getattr(meta, 'app_label', None) is None: -
django/db/models/options.py
21 21 DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering', 22 22 'unique_together', 'permissions', 'get_latest_by', 23 23 'order_with_respect_to', 'app_label', 'db_tablespace', 24 'abstract', 'managed', 'proxy' )24 'abstract', 'managed', 'proxy', 'inherit_permissions') 25 25 26 26 class Options(object): 27 27 def __init__(self, meta, app_label=None): … … 86 86 if ut and not isinstance(ut[0], (tuple, list)): 87 87 ut = (ut,) 88 88 setattr(self, 'unique_together', ut) 89 90 # check for the %(class)s escape used for inherited permissions. 91 # If present, replace it with the appropriate text based off of 92 # the class name for both the name and codename of the permission. 93 perms = meta_attrs.pop('permissions', getattr(self, 'permissions')) 94 translated_perms = () 95 if perms: 96 for codename, name in perms: 97 codename = codename % {'class': cls.__name__.lower()} 98 name = name % {'class': getattr(self, 'verbose_name')} 99 translated_perms += ((codename, name),) 100 setattr(self, 'permissions', translated_perms) 89 101 90 102 # verbose_name_plural is a special case because it uses a 's' 91 103 # by default. -
AUTHORS
26 26 ajs <adi@sieker.info> 27 27 alang@bright-green.com 28 28 Marty Alchin <gulopine@gamemusic.org> 29 Forrest Aldridge <forrest.aldridge@gmail.com> 29 30 Ahmad Alhashemi <trans@ahmadh.com> 30 31 Daniel Alves Barbosa de Oliveira Vaz <danielvaz@gmail.com> 31 32 AgarFu <heaven@croasanaso.sytes.net>