Opened 19 years ago

Closed 18 years ago

Last modified 18 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: no UI/UX: no

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

Download all attachments as: .zip

Change History (26)

by robert@…, 19 years ago

Attachment: django-admin-refactor.patch added

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

comment:1 by Adrian Holovaty, 19 years ago

Summary: Admin refactoring Refactor admin code to clean it up

comment:2 by anonymous, 19 years ago

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 by anonymous, 19 years ago

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

comment:4 by robert@…, 19 years ago

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

comment:5 by robert@…, 19 years ago

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

comment:6 by robert@…, 19 years ago

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

comment:7 by anonymous, 19 years ago

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

comment:8 by Jacob, 19 years ago

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

comment:9 by Jacob, 19 years ago

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

comment:10 by Jacob, 19 years ago

Heh -- neither can I :)

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

by robert@…, 19 years ago

updated patch

by robert@…, 19 years ago

patch that refactors data flattening

comment:11 by robert@…, 19 years ago

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.

by robert@…, 19 years ago

Makes inline editing a piece of cake outside the admin

comment:12 by robert@…, 19 years ago

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

by robert@…, 19 years ago

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

comment:13 by anonymous, 19 years ago

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 by robert@…, 19 years ago

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

by robert@…, 19 years ago

Updated patch

comment:15 by robert@…, 19 years ago

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 by rjwittams, 19 years ago

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

This patch is now on the new-admin branch.

comment:17 by anonymous, 19 years ago

Owner: changed from anonymous to rjwittams
Status: assignednew

comment:18 by pylorca, 19 years ago

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 by anonymous, 19 years ago

Cc: jforcier@… added

comment:20 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

Fixed in [1434].

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