Opened 17 years ago

Closed 17 years ago

#5520 closed (fixed)

[newforms-admin] - support for save_as

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: Brian Rosner
Component: contrib.admin Version: newforms-admin
Severity: Keywords: admin, save_as, nfa-blocker
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With the attached patch it is possible to use save_as in newforms-admin.

Related objects are not saved - this patch cares only about template.

Attachments (4)

admin-save-as.diff (1.1 KB ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.
01-admin-saveas.diff (5.8 KB ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.
01-admin-saveas.2.diff (5.8 KB ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.
new version - after autoescape merge
00-admin-saveas.diff (5.7 KB ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.
This version fixes permission for save as and remove context parameter show_delete which is not necessary for this functionality

Download all attachments as: .zip

Change History (10)

by Petr Marhoun <petr.marhoun@…>, 17 years ago

Attachment: admin-save-as.diff added

by Petr Marhoun <petr.marhoun@…>, 17 years ago

Attachment: 01-admin-saveas.diff added

comment:1 by Petr Marhoun <petr.marhoun@…>, 17 years ago

New version of patch - now save_as works without any problem. It is better than in oldforms admin.

The final version of submit row (with #5447):

def submit_row(context):
    # ... 
        'show_delete_link': change and context['has_delete_permission'] and not is_popup and not is_save_as,
        'show_save_as_new': save_as and (is_save_as or change) and context['has_add_permission'] and not is_popup,
        'show_save_and_add_another': (add or not save_as) and context['has_add_permission'] and not is_popup and not is_save_as,
        'show_save_and_continue': context['has_change_permission'] and not is_popup and not is_save_as,
        'show_save': not is_save_as, 
    }

As popup (is_popup is True) only save button is showed.

In saving as (is_save_as is True) only save_as_new button is showed.

Otherwise:

  • In add state - save_and_add_another (with add_permission), save_and_continue (with change_permission) and save buttons are showed.
  • In change state without save_as - delete (with delete permission), save_and_add_another (with add_permission), save_and_continue (with change_permission) and save buttons are showed.
  • In change state with save_as - delete (with delete permission), save_as (with add_permission), save_and_continue (with change_permission) and save buttons are showed.

I also removed form_url - it is not needed in this solution.

comment:2 by Petr Marhoun <petr.marhoun@…>, 17 years ago

I use this patch but I have two notes:

  • Button save_as_new can be showed in change stage so add_permission should be checked.
  • Context variable show_delete is not used anywhere so it can be removed.

Also my comment comment:ticket:5520:1 could be relevant.

comment:3 by Petr Marhoun <petr.marhoun@…>, 17 years ago

I made a mistake - the last comment should be on #5447.

by Petr Marhoun <petr.marhoun@…>, 17 years ago

Attachment: 01-admin-saveas.2.diff added

new version - after autoescape merge

by Petr Marhoun <petr.marhoun@…>, 17 years ago

Attachment: 00-admin-saveas.diff added

This version fixes permission for save as and remove context parameter show_delete which is not necessary for this functionality

comment:4 by jkocherhans, 17 years ago

Keywords: nfa-blocker added
Needs tests: set
Triage Stage: UnreviewedAccepted

The code just delegates to ModelAdmin.add_view() if someone clicks the "save as new" button, so fixing the templates should allow for saving copies of all the inline objects as well. However, I haven't tried this. There really ought to be some tests to make sure.

comment:5 by Brian Rosner, 17 years ago

Owner: changed from nobody to Brian Rosner
Status: newassigned

Taking this ticket as I need to implement this for work.

comment:6 by Brian Rosner, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [7603]) newforms-admin: Fixed #5520 -- Implemented save_as functionality. This also
properly makes inlines work as well.

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