Code

Opened 7 years ago

Closed 6 years ago

#5520 closed (fixed)

[newforms-admin] - support for save_as

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: brosner
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: UI/UX:

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@…> 7 years ago.
01-admin-saveas.diff (5.8 KB) - added by Petr Marhoun <petr.marhoun@…> 7 years ago.
01-admin-saveas.2.diff (5.8 KB) - added by Petr Marhoun <petr.marhoun@…> 7 years ago.
new version - after autoescape merge
00-admin-saveas.diff (5.7 KB) - added by Petr Marhoun <petr.marhoun@…> 7 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)

Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

comment:1 Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

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 Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

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

Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

new version - after autoescape merge

Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

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

comment:4 Changed 7 years ago by jkocherhans

  • Keywords save_as, nfa-blocker added; save_as removed
  • Needs tests set
  • Triage 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.

comment:5 Changed 6 years ago 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.

comment:6 Changed 6 years ago by brosner

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.