Ticket #1035: add_popup.diff
File add_popup.diff, 3.2 KB (added by , 19 years ago) |
---|
-
django/contrib/admin/templatetags/admin_modify.py
246 246 247 247 return { 248 248 'add': context['add'], 249 'app_permission': context['app_permission'], 249 250 'change': context['change'], 250 251 'bound_fields': bound_fields, 251 252 'class_names': " ".join(class_names), … … 257 258 return bound_manip.get_ordered_object_pk(ordered_obj) 258 259 259 260 object_pk = register.simple_tag(object_pk) 261 262 #@register.filter 263 def has_perm(perm_obj, perm): 264 if perm_obj: 265 return perm_obj[perm] 266 return False 267 268 has_perm = register.filter(has_perm) -
django/contrib/admin/views/main.py
286 286 self.is_date_time = isinstance(field, meta.DateTimeField) 287 287 self.is_file_field = isinstance(field, meta.FileField) 288 288 self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToMany) and field.rel.to.admin 289 self.add_permission = self.needs_add_label and "can_add_%s" % (field.rel.to.verbose_name) 289 290 self.hidden = isinstance(self.field, meta.AutoField) 290 291 self.first = False 291 292 … … 375 376 return "" 376 377 377 378 def render_change_form(opts, manipulator, app_label, context, add=False, change=False, show_delete=False, form_url=''): 379 app_permission = context['perms'][app_label] 378 380 extra_context = { 379 381 'add': add, 380 382 'change': change, 381 383 'bound_manipulator': AdminBoundManipulator(opts, manipulator, context['form']), 382 'has_delete_permission': context['perms'][app_label][opts.get_delete_permission()], 384 'has_delete_permission': app_permission[opts.get_delete_permission()], 385 'app_permission': app_permission, 383 386 'form_url': form_url, 384 387 'app_label': app_label, 385 388 } -
django/contrib/admin/templates/widget/foreign.html
4 4 <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a> 5 5 {% else %} 6 6 {% if bound_field.needs_add_label %} 7 {% if app_permission|has_perm:bound_field.add_permission %} 7 8 <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 8 {% endif %}{% endif %} 9 {% endif %}{% endif %}{% endif %}