Django

Code

Ticket #9071 (new)

Opened 2 years ago

Last modified 8 months ago

Can't disable "add" popup links in the admin

Reported by: jacob Assigned to: kratorius
Milestone: Component: django.contrib.admin
Version: 1.0 Keywords: pyconuk
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

There's no way to prevent the little green "plus" icons from appearing on related fields in the admin (well, other than removing the related object from the admin). It should be possible to prevent those from appearing -- an admin option would make sense here.

Attachments

add-r9017.diff (2.6 kB) - added by kratorius on 09/13/08 09:23:53.
add-r9017-tests.diff (2.0 kB) - added by kratorius on 09/13/08 09:24:17.
add-r9050.diff (2.5 kB) - added by kratorius on 09/16/08 12:39:47.
add-r9751.diff (5.3 kB) - added by jackymac on 01/15/09 14:48:58.
updated patch to so it applies cleanly to SVN-9751, added docs

Change History

09/13/08 06:34:17 changed by kratorius

  • owner changed from nobody to kratorius.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

09/13/08 09:23:53 changed by kratorius

  • attachment add-r9017.diff added.

09/13/08 09:24:17 changed by kratorius

  • attachment add-r9017-tests.diff added.

09/13/08 09:33:05 changed by kratorius

  • has_patch set to 1.

Attached patch adds an exclude_add option (I'm not happy with the naming, any suggestion is welcome) that allows to specify which related fields shouldn't have the add image. Fields should be specified in a list, like exclude_add = [ 'rel_field1', 'rel_field2' ].

However, docs are missing since I'm not a native english-speaker, so it would be nice if someone else could do that.

09/16/08 00:54:11 changed by adrian

  • stage changed from Unreviewed to Accepted.

I like the idea but haven't tested the patch (note there's a print statement in the patch).

09/16/08 12:39:47 changed by kratorius

  • attachment add-r9050.diff added.

09/16/08 12:40:24 changed by kratorius

  • needs_docs set to 1.

Woops, removed the print statement.

(follow-up: ↓ 6 ) 09/16/08 20:45:49 changed by mtredinnick

What's the use-case here? If you have permission to add the object, it's giving you a way to add it. If you don't have permission to add objects of that type, it shouldn't be showing the plus-sign, but I believe that's already the case.

Saying that you can add it in one way, but not in another seems inconsistent.

(in reply to: ↑ 5 ) 10/22/08 12:12:13 changed by fabionatali

Replying to mtredinnick:

What's the use-case here? If you have permission to add the object, it's giving you a way to add it. If you don't have permission to add objects of that type, it shouldn't be showing the plus-sign, but I believe that's already the case. Saying that you can add it in one way, but not in another seems inconsistent.

If you have a foreign key with a limit_choices_to filter, then in your admin you get a drop down menu with a selection of items. However, if you add a new item through the green plus link, you can actually circumvent this limit_choices_to filter. You can create a new object which doesn't agree with the limit_choices_to filter and it will be used in the foreign key field despite the filter.

This could be a scenario where disabling the green plus link would make sense.

My 2 cents.

11/23/08 20:29:45 changed by vincent

It seems that if you don't have the permission to add objects of a particular type, the add popup link is still there, and there's an ugly Permission Denied page if you click on it.

I tried with Group or User Permissions, and the problem is still there.

There's an old (3 years old) ticket opened here : http://code.djangoproject.com/ticket/1035

Another patch a little less old here : http://code.djangoproject.com/ticket/2927

But I found no patch for the current version of django.

12/08/08 18:57:22 changed by milan612

Hi,

I tried it with latest version of trunk SVN-9218, but doesnt work for me

Any suggestion ?

Milan

01/15/09 14:48:58 changed by jackymac

  • attachment add-r9751.diff added.

updated patch to so it applies cleanly to SVN-9751, added docs

01/15/09 14:56:04 changed by jackymac

  • needs_docs deleted.

I've updated the patch so that it now applies to SVN-9751. Also added some docs. The option is still called "exclude_add." I couldn't think of a better name for it. *shrugs*

I'd be awesome if this could be committed in time for 1.1. Anything I can do to help make that happen?

07/14/09 19:29:17 changed by SmileyChris

  • owner changed from kratorius to SmileyChris.
  • status changed from new to assigned.

Slightly related, I just uploaded a new patch to #1035

07/14/09 19:29:53 changed by SmileyChris

  • owner changed from SmileyChris to kratorius.
  • status changed from assigned to new.

(Sorry, didn't mean to accept the ticket)

07/16/09 06:55:31 changed by floledermann

Btw. you can remove the plus sign by using css - this will not really disable the feature but hide it if you shoot for a more consistent user experience:

#add_id_<<fieldname>> {
    display: none;
}

Best is to look up the id of the element in the admin pages' html source.

If you dont't have an admin css already, you can put this snippet in a file - say css/admin.css - and add a Media class to your Admin class:

    class Media:
        css = {
            'all': [settings.MEDIA_URL + 'css/admin.css']
        }

Add/Change #9071 (Can't disable "add" popup links in the admin)




Change Properties
Action