Django

Code

Ticket #5520 (closed: fixed)

Opened 1 year ago

Last modified 3 months ago

[newforms-admin] - support for save_as

Reported by: Petr Marhoun <petr.marhoun@gmail.com> Assigned to: brosner
Milestone: Component: Admin interface
Version: newforms-admin Keywords: admin, save_as, nfa-blocker
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

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

admin-save-as.diff (1.1 kB) - added by Petr Marhoun <petr.marhoun@gmail.com> on 09/16/07 20:51:42.
01-admin-saveas.diff (5.8 kB) - added by Petr Marhoun <petr.marhoun@gmail.com> on 11/21/07 00:02:00.
01-admin-saveas.2.diff (5.8 kB) - added by Petr Marhoun <petr.marhoun@gmail.com> on 11/30/07 09:35:58.
new version - after autoescape merge
00-admin-saveas.diff (5.7 kB) - added by Petr Marhoun <petr.marhoun@gmail.com> on 12/08/07 14:43:33.
This version fixes permission for save as and remove context parameter show_delete which is not necessary for this functionality

Change History

09/16/07 20:51:42 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • attachment admin-save-as.diff added.

11/21/07 00:02:00 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • attachment 01-admin-saveas.diff added.

11/21/07 00:15:00 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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.

11/21/07 00:21:11 changed by Petr Marhoun <petr.marhoun@gmail.com>

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.

11/21/07 00:24:41 changed by Petr Marhoun <petr.marhoun@gmail.com>

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

11/30/07 09:35:58 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • attachment 01-admin-saveas.2.diff added.

new version - after autoescape merge

12/08/07 14:43:33 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • 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

12/10/07 12:39:21 changed by jkocherhans

  • keywords changed from admin, save_as to admin, save_as, nfa-blocker.
  • needs_tests set to 1.
  • stage changed from Unreviewed to Accepted.

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.

04/21/08 19:02:00 changed by brosner

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

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

06/09/08 22:54:05 changed by brosner

  • status changed from assigned to closed.
  • resolution set to fixed.

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


Add/Change #5520 ([newforms-admin] - support for save_as)




Change Properties
Action