| 232 | def _has_permission(self, model, perm, *args): |
| 233 | if not isinstance(model, ModelBase): |
| 234 | from django.db.models import get_model |
| 235 | |
| 236 | app_label, model_name = model.split('.') |
| 237 | model = get_model(app_label, model_name) |
| 238 | |
| 239 | try: |
| 240 | admin = self._registry[model] |
| 241 | except KeyError: |
| 242 | return False |
| 243 | |
| 244 | return getattr(admin, 'has_%s_permission' % perm)(*args) |
| 245 | |
| 246 | def has_add_permission(self, request, model): |
| 247 | return self._has_permission(model, 'add', request) |
| 248 | |
| 249 | def has_change_permission(self, request, model, obj=None): |
| 250 | return self._has_permission(model, 'change', request, obj) |
| 251 | |
| 252 | def has_delete_permission(self, request, model, obj=None): |
| 253 | return self._has_permission(model, 'delete', request, obj) |
| 254 | |