google-code-export / django-grappelli

Automatically exported from code.google.com/p/django-grappelli
0 stars 0 forks source link

Inlines with max_num=1 to not have the + for adding another inline. #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The summary is probably explained badly.. but basically I have some admin
Inline models that are only supposed to have 1 entry.  Your Inlines have
that handy little '+' to the right of the Inline name which allows the
end-user to add a new entry to the Inline without having to reload the
page, which is great, but not when I only want to display 1 entry in the
Inline in question.

If you could have your code detect if the AdminModel has 'max_num=1' and
remove the '+' button that would be great.  Also if it could go a step
further and detect if the fk_name related model field has 'unique=True'
declared and have it do the same thing (remove the '+') that would be
super-great.

Cheers again,
  Gontro.

Original issue reported on code.google.com by Gontro@gmail.com on 16 Aug 2009 at 9:01

GoogleCodeExporter commented 9 years ago
I can think of another usecase here: what if I want exactly 3 items within my
inlines. there, max_num is not 1 but 3. and the initial number should also be 3.

so, what if we add an attribute to the admin-definition? something like
"allow_add=True/False". with this attribute, one could decide if the plus-button
should be shown or not.

Original comment by sehmaschine on 16 Aug 2009 at 9:10

GoogleCodeExporter commented 9 years ago

Original comment by sehmaschine on 16 Aug 2009 at 9:21

GoogleCodeExporter commented 9 years ago
that would be the perfect solution to the problem I've been having.. very true, 
I
hadn't thought of the usecase you described there.  If this functionality could 
be
implemented I would be eternally greatful :)

Original comment by Gontro@gmail.com on 16 Aug 2009 at 9:25

GoogleCodeExporter commented 9 years ago
will do. I´m just not sure about the naming of the option ... 

Original comment by sehmaschine on 16 Aug 2009 at 9:39

GoogleCodeExporter commented 9 years ago
'grappelli_allow_add' seems the most logical to me.  your call though ;)

Original comment by Gontro@gmail.com on 16 Aug 2009 at 9:40

GoogleCodeExporter commented 9 years ago
the grappelli-prefix is usually "grp_" (with templatetags and other stuff). if 
we use
something like "grp_allow_add" or "grappelli_allow_add" here we should also use
"grp_collapse_closed" and "grp_collapse_open" for coherence. not sure we need 
the
prefix here ...

Original comment by sehmaschine on 16 Aug 2009 at 9:54

GoogleCodeExporter commented 9 years ago
true.. in that case 'allow_add' seems the most logical choice imo

Original comment by Gontro@gmail.com on 16 Aug 2009 at 10:22

GoogleCodeExporter commented 9 years ago

Original comment by sehmaschine on 16 Aug 2009 at 11:40