Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#535 closed task (fixed)

Refactor admin code to clean it up

Reported by: robert@… Owned by: rjwittams
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: jforcier@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Following the mail thread http://groups.google.com/group/django-developers/browse_thread/thread/0e0ee390664ba078/65e6dffff7699a22#65e6dffff7699a22

I have started to refactor the admin code to
a) Make it easier to work on
b) Make it clearer what the deficiencies in the meta system are for interfaces like the admin

I will attach patches here.
The patches do include some additional changes, eg ones I have applied from other tickets.

Attachments (6)

django-admin-refactor.patch (53.9 KB) - added by robert@… 10 years ago.
1st cut of the change and add views refactored to templates
django-admin-refactor-2.patch (53.5 KB) - added by robert@… 10 years ago.
updated patch
django-admin-refactor-3.patch (57.9 KB) - added by robert@… 10 years ago.
patch that refactors data flattening
django-admin-refactor-4.patch (64.5 KB) - added by robert@… 10 years ago.
Makes inline editing a piece of cake outside the admin
django-admin-refactor-5.patch (71.6 KB) - added by robert@… 10 years ago.
Clean up templates a bit, allow overriding edit_inline behaviour with custom templates.
django-admin-refactor-6.patch (75.8 KB) - added by robert@… 10 years ago.
Updated patch

Download all attachments as: .zip

Change History (26)

Changed 10 years ago by robert@…

1st cut of the change and add views refactored to templates

comment:1 Changed 10 years ago by adrian

  • Summary changed from Admin refactoring to Refactor admin code to clean it up

comment:2 Changed 10 years ago by anonymous

The first cut patch includes the following changes:

  • I have duplicated the add and change stages, so they can be compared with the old ones, rather than replacing them. Just add /new/ on to the end of a url to see the new pages. They should look very similar.
  • The template concatenation part of these stages has been replaced by a combination of templates, template tags, and helper objects. As the helper objects evolve, it should expose where it would be useful to push methods or whole classes into the meta system.
  • I am currently trying to preserve the output that is produced by the old views. Nevertheless, there are sure to be bits I have changed. One particular point is whitespace : templates preserve a lot of whitespace, which is duplicated (eg in for loops). This is maybe something to tackle in the template system at some point. I will eventually start to make modifications to the output ( which imo is a lot easier with the new scheme).

This is all at a very early stage, so take it as a given that the code is in a lot of flux.

comment:3 Changed 10 years ago by anonymous

  • Owner changed from robert@… to anonymous
  • Status changed from new to assigned

comment:4 Changed 10 years ago by robert@…

  • Owner changed from anonymous to robert@…
  • Status changed from assigned to new

comment:5 Changed 10 years ago by robert@…

  • Owner changed from robert@… to anonymous
  • Status changed from new to assigned

comment:6 Changed 10 years ago by robert@…

I can't work out how to have this assigned to me. Boo hoo.

comment:7 Changed 10 years ago by anonymous

  • Owner changed from anonymous to robert@…
  • Status changed from assigned to new

comment:8 Changed 10 years ago by jacob

  • Owner changed from robert@… to jacob
  • Status changed from new to assigned

comment:9 Changed 10 years ago by jacob

  • Owner changed from jacob to robert@…
  • Status changed from assigned to new

comment:10 Changed 10 years ago by jacob

Heh -- neither can I :)

Go ahead and leave this as "new"; we'll know it's assigned to you.

Changed 10 years ago by robert@…

updated patch

Changed 10 years ago by robert@…

patch that refactors data flattening

comment:11 Changed 10 years ago by robert@…

I am having to call the patch different names, and thereby take up space, as trac gives an error when I upload with the same name.

This version of the patch (3), among other things, refactors the data flattening. I just need to a few more things to make it easy to do edit_inline type stuff from any random view. ( Sort out form field wrapper, and add a few new methods to the manipulators.)

Again, sure to be bugs in here - I know there is something wrong with 0 value integer fields in edit_inline for example. Also, I have not tested every option. One thing that I plan to make is an example model that tries out as many options as possible, so it is easy to spot regressions.

Changed 10 years ago by robert@…

Makes inline editing a piece of cake outside the admin

comment:12 Changed 10 years ago by robert@…

The latest patch makes inline editing work with no hacking about in view functions.
Will post to django-devel about this.

Changed 10 years ago by robert@…

Clean up templates a bit, allow overriding edit_inline behaviour with custom templates.

comment:13 Changed 10 years ago by anonymous

So this latest patch lets you do stuff like

class Set(meta.Model):

workout = meta.ForeignKey(Workout, edit_inline='edit_inline_horizontal')

This means that the template 'edit_inline_horizontal' is loaded to handle the inline stuff in the admin.

Also fixes rezrovs issues with selects. But I'm not yet convinced in the right way...
And makes the many-to-many funky js stuff work again.

comment:14 Changed 10 years ago by robert@…

this thing needs cookies or something. Or give out accounts.

Changed 10 years ago by robert@…

Updated patch

comment:15 Changed 10 years ago by robert@…

Fixes select fields, adding with inline related objects, sorting descending on a 'select' keyword arg. The last one is a bug fix which would work on its own.

comment:16 Changed 10 years ago by rjwittams

  • Owner changed from robert@… to anonymous
  • Status changed from new to assigned

This patch is now on the new-admin branch.

comment:17 Changed 10 years ago by anonymous

  • Owner changed from anonymous to rjwittams
  • Status changed from assigned to new

comment:18 Changed 10 years ago by pylorca

when I edit the saved data (ChangeManipulator), it only shows the values for the parent table, and empty values for the child tables, but the data exists

comment:19 Changed 10 years ago by anonymous

  • Cc jforcier@… added

comment:20 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [1434].

Note: See TracTickets for help on using tickets.
Back to Top