Opened 11 years ago

Closed 11 years ago

Last modified 10 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@… 11 years ago.
1st cut of the change and add views refactored to templates
django-admin-refactor-2.patch (53.5 KB) - added by robert@… 11 years ago.
updated patch
django-admin-refactor-3.patch (57.9 KB) - added by robert@… 11 years ago.
patch that refactors data flattening
django-admin-refactor-4.patch (64.5 KB) - added by robert@… 11 years ago.
Makes inline editing a piece of cake outside the admin
django-admin-refactor-5.patch (71.6 KB) - added by robert@… 11 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@… 11 years ago.
Updated patch

Download all attachments as: .zip

Change History (26)

Changed 11 years ago by robert@…

Attachment: django-admin-refactor.patch added

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

comment:1 Changed 11 years ago by Adrian Holovaty

Summary: Admin refactoring Refactor admin code to clean it up

comment:2 Changed 11 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 11 years ago by anonymous

Owner: changed from robert@… to anonymous
Status: newassigned

comment:4 Changed 11 years ago by robert@…

Owner: changed from anonymous to robert@…
Status: assignednew

comment:5 Changed 11 years ago by robert@…

Owner: changed from robert@… to anonymous
Status: newassigned

comment:6 Changed 11 years ago by robert@…

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

comment:7 Changed 11 years ago by anonymous

Owner: changed from anonymous to robert@…
Status: assignednew

comment:8 Changed 11 years ago by Jacob

Owner: changed from robert@… to Jacob
Status: newassigned

comment:9 Changed 11 years ago by Jacob

Owner: changed from Jacob to robert@…
Status: assignednew

comment:10 Changed 11 years ago by Jacob

Heh -- neither can I :)

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

Changed 11 years ago by robert@…

updated patch

Changed 11 years ago by robert@…

patch that refactors data flattening

comment:11 Changed 11 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 11 years ago by robert@…

Makes inline editing a piece of cake outside the admin

comment:12 Changed 11 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 11 years ago by robert@…

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

comment:13 Changed 11 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 11 years ago by robert@…

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

Changed 11 years ago by robert@…

Updated patch

comment:15 Changed 11 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 11 years ago by rjwittams

Owner: changed from robert@… to anonymous
Status: newassigned

This patch is now on the new-admin branch.

comment:17 Changed 11 years ago by anonymous

Owner: changed from anonymous to rjwittams
Status: assignednew

comment:18 Changed 11 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 11 years ago by anonymous

Cc: jforcier@… added

comment:20 Changed 11 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

Fixed in [1434].

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