Skip to content

Commit 84ddcd4

Browse files
authored
Tie the clone form back to the action it posts to
Review follow-ups: the action name the page posts is taken from the function again, so renaming it cannot leave the form posting an action that no longer exists (nothing renders this template in tests, so a wrong name would go unnoticed); the steps keep their qualified name, so a traceback names the step it came from rather than the decorator; and the `copied` keys say why they are spelled out instead of derived.
1 parent a9f45e0 commit 84ddcd4

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎backend/conferences/admin/actions.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def clone_conference(modeladmin, request, queryset):
140140
form = CloneConferenceForm(request.POST)
141141

142142
if form.is_valid():
143-
return start_clone_conference(request, source, form.cleaned_data)
143+
start_clone_conference(request, source, form.cleaned_data)
144+
return None
144145
else:
145146
form = CloneConferenceForm(initial=next_edition_defaults(source))
146147

@@ -154,6 +155,9 @@ def clone_conference(modeladmin, request, queryset):
154155
"media": modeladmin.media + form.media,
155156
"source": source,
156157
"form": form,
158+
# The page posts back to the changelist, so it has to name the
159+
# action; taken from the function so a rename cannot break it.
160+
"action_name": clone_conference.__name__,
157161
},
158162
)
159163

‎backend/conferences/models/conference.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ class Conference(GeoLocalizedModel, TimeFramedModel, TimeStampedModel):
124124
_("max proposals per user"),
125125
null=True,
126126
blank=True,
127-
help_text=_("Maximum number of proposals a user can submit. Leave empty for no limit."),
127+
help_text=_(
128+
"Maximum number of proposals a user can submit. Leave empty for no limit."
129+
),
128130
)
129131

130132
def get_slack_oauth_token(self):

‎backend/conferences/templates/admin/conferences/clone_conference.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{% csrf_token %}
2828

2929
<input type="hidden" name="_selected_action" value="{{ source.pk }}">
30-
<input type="hidden" name="action" value="clone_conference">
30+
<input type="hidden" name="action" value="{{ action_name }}">
3131
<input type="hidden" name="apply" value="1">
3232

3333
<fieldset class="module aligned">

‎backend/conferences/workflows/clone_conference.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def step(ctx: Context, source_code: str, conference_id: int) -> int:
115115
return fn(source, conference)
116116

117117
step.__name__ = fn.__name__
118+
step.__qualname__ = fn.__qualname__
118119
step.__doc__ = fn.__doc__
119120

120121
return database_step(step)
@@ -461,7 +462,9 @@ def copy_voting_included_events(source: Conference, conference: Conference) -> i
461462

462463
# Everything that only needs the source and the freshly created conference,
463464
# in the order it is copied. Sponsor levels read the benefits copied just
464-
# before them, so the order matters.
465+
# before them, so the order matters. The names are what the workflow reports
466+
# back as its `copied` counts, so they are spelled out rather than derived from
467+
# the functions: renaming one should not change what callers read.
465468
COPY_STEPS = (
466469
("deadlines", copy_deadlines),
467470
("durations", copy_durations),

0 commit comments

Comments
 (0)