22 | | def submit_row(context): |
23 | | opts = context['opts'] |
24 | | change = context['change'] |
25 | | is_popup = context['is_popup'] |
26 | | save_as = context['save_as'] |
27 | | return { |
28 | | 'onclick_attrib': (opts.get_ordered_objects() and change |
29 | | and 'onclick="submitOrderForm();"' or ''), |
30 | | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
31 | | and (change or context['show_delete'])), |
32 | | 'show_save_as_new': not is_popup and change and save_as, |
33 | | 'show_save_and_add_another': context['has_add_permission'] and |
34 | | not is_popup and (not save_as or context['add']), |
35 | | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
36 | | 'is_popup': is_popup, |
37 | | 'show_save': True |
38 | | } |
39 | | submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row) |
| 23 | class SubmitRowNode(template.Node): |
| 24 | def render(self, context): |
| 25 | app_label = context['app_label'] |
| 26 | opts = context['opts'] |
| 27 | change = context['change'] |
| 28 | is_popup = context['is_popup'] |
| 29 | save_as = context['save_as'] |
| 30 | context = { |
| 31 | 'onclick_attrib': (opts.get_ordered_objects() and change |
| 32 | and 'onclick="submitOrderForm();"' or ''), |
| 33 | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
| 34 | and (change or context['show_delete'])), |
| 35 | 'show_save_as_new': not is_popup and change and save_as, |
| 36 | 'show_save_and_add_another': context['has_add_permission'] and |
| 37 | not is_popup and (not save_as or context['add']), |
| 38 | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
| 39 | 'is_popup': is_popup, |
| 40 | 'show_save': True |
| 41 | } |
| 42 | return render_to_string([ |
| 43 | "admin/%s/%s/submit_line.html" % (app_label, opts.object_name.lower()), |
| 44 | "admin/%s/submit_line.html" % app_label, |
| 45 | "admin/submit_line.html" |
| 46 | ], context) |
| 47 | |
| 48 | def submit_row(parser, token): |
| 49 | return SubmitRowNode() |
| 50 | submit_row = register.tag(name="submit_row")(submit_row) |