Django

Code

Ticket #494 (new)

Opened 3 years ago

Last modified 1 month ago

Collapse in admin interface for inline related objects

Reported by: jcstover@nilling.nl Assigned to: xian
Component: Admin interface Version: newforms-admin
Keywords: edit_inline, nfa-someday Cc: eric@aa.usno.navy.mil
Triage Stage: Design decision needed Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 1

Description

It would be nice if there is a property to tell the admin interface to collapse the related object.

eg: organisatie = meta.ForeignKey?(Organisatie, edit_inline=meta.STACKED, edit_inline_style='collapse')

I changed line 610 in the django/views/admin/main.py to t.append('<fieldset class="module%s">\n' % ((rel_field.rel.edit_inline != meta.TABULAR) and ' aligned collapse' or ' collapse')) and it works. But using a property would be better.

Thanks

Attachments

494.patch (4.2 kB) - added by Antonis Christofides <anthony@itia.ntua.gr> on 11/22/07 09:36:22.
Patch with alternative approach
494.2.patch (4.2 kB) - added by Antonis Christofides <anthony@itia.ntua.gr> on 11/22/07 11:05:35.
Updated patch, fixing a documentation problem

Change History

09/12/05 14:29:05 changed by jctover@nilling.nl

Since I changed already a few things in the admin view for translation and I'm not experienced with svn yet here are my changes I made to create an inline_style property to make it collapse

in django/core/meta/fields.py line nr 585

  • raw_id_admin=kwargs.pop('raw_id_admin', False)) + raw_id_admin=kwargs.pop('raw_id_admin', False), inline_style=kwargs.pop('inline_style', None))

in django/core/meta/fields.py line nr 654

  • related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False): + related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False, inline_style=None):

in django/views/admin/main.py line 610

  • t.append('<fieldset class="module%s %s">\n' % ((rel_field.rel.edit_inline != meta.TABULAR) and ' aligned' or )) + t.append('<fieldset class="module%s %s">\n' % ((rel_field.rel.edit_inline != meta.TABULAR) and ' aligned' or , rel_field.rel.inline_style or ))

For using it just include inline_style='collapse' and the related objects are collapsed. Hope you include a better solution to this problem

Johan

09/25/05 17:31:39 changed by jacob

  • owner changed from adrian to jacob.
  • status changed from new to assigned.
  • milestone set to Version 1.0.

10/04/05 17:48:48 changed by jforcier@strozllc.com

  • cc set to jforcier@strozllc.com.

05/03/06 07:55:28 changed by mdt@emdete.de

even the collapse in the related object has no effect. is that a bug?

05/03/06 08:50:28 changed by anonymous

  • cc deleted.

Removed myself from the Cc list (no longer that interested =))

06/12/06 06:45:00 changed by URL

  • type deleted.

09/05/06 10:11:20 changed by eric@aa.usno.navy.mil

  • cc set to eric@aa.usno.navy.mil.
  • type set to defect.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

01/23/07 08:48:15 changed by Marc Fargas <telenieko@telenieko.com>

Wy don't you use the method provied by http://www.djangoproject.com/documentation/model_api/#id3? It provides almost this, I think.

If it's enought for the reporter, please close the ticket as "worksforme" ;)

01/23/07 13:04:49 changed by jcstover@nilling.nl

I didn't use django for a while, but from what I remember. For a tablular view of related objects you can collapse that view, but not when it is stacked. That was it about. If it is working for stacked objects now its okay.

01/23/07 17:06:26 changed by SmileyChris

  • summary changed from Collapse in admin interface for related objects to Collapse in admin interface for related objects using meta.STACKED.

Can someone confirm this?

01/23/07 17:49:22 changed by Marc Fargas <telenieko@telenieko.com>

  • summary changed from Collapse in admin interface for related objects using meta.STACKED to Collapse in admin interface for related objects using models.STACKED.
  • stage changed from Unreviewed to Design decision needed.

Confirmed, it has to do with the way django/trunk/django/contrib/admin/templates/admin/change_form.html works, it can handle the "classes" attribute for fields (line 36), but not for "edit_inline" relations (stacked or inline) on line 57. And I could not find any easy way to get it working. Maybe django/trunk/django/contrib/admin/templates/admin/edit_inline_stacked.html should get the classes for the related objects but dunno how to pass it.

As a side note, it's models.STACKED not meta.STACKED right now, changing the summary to reflect this.

02/17/07 23:45:52 changed by Gary Wilson <gary.wilson@gmail.com>

  • keywords set to edit_inline.

09/04/07 18:05:21 changed by anonymous

  • summary changed from Collapse in admin interface for related objects using models.STACKED to Collapse in admin interface for inline related objects.

09/14/07 10:55:01 changed by jacob

  • version set to newforms-admin.

-> newforms-admin

09/14/07 14:04:45 changed by jkocherhans

  • owner changed from nobody to xian.
  • status changed from assigned to new.

11/22/07 09:36:22 changed by Antonis Christofides <anthony@itia.ntua.gr>

  • attachment 494.patch added.

Patch with alternative approach

11/22/07 09:38:35 changed by Antonis Christofides <anthony@itia.ntua.gr>

I just uploaded a patch. You append a string with classes to edit_inline, and it uses these classes. For example:

edit_inline = models.TABULAR + 'collapse extrapretty'

11/22/07 11:05:35 changed by Antonis Christofides <anthony@itia.ntua.gr>

  • attachment 494.2.patch added.

Updated patch, fixing a documentation problem

12/01/07 07:12:46 changed by yserrano

  • has_patch set to 1.

12/01/07 07:48:04 changed by yserrano

  • has_patch deleted.

The patch fails on the newforms-admin branch. The file structure has changed from django/contrib/admin/templates/admin/edit_inline_stacked.html to django/contrib/admin/templates/admin/edit_inline/stacked.html

12/07/07 17:07:55 changed by brosner

  • keywords changed from edit_inline to edit_inline, nfa-someday.

Tagging with nfa-someday as this is functionality that is not critical to the merge of the newforms-admin branch.

12/07/07 17:12:28 changed by brosner

  • needs_better_patch set to 1.

04/09/08 06:19:09 changed by Antonis Christofides <anthony@itia.ntua.gr>

Could you please point me to a description of how the newforms-admin branch is managed and what is the policy for patching admin/newforms-admin? Do I need to write two patches, one for old admin and one for new admin?

The second question is whether a better patch in the same spirit would be accepted.


Add/Change #494 (Collapse in admin interface for inline related objects)




Change Properties
Action