@@ -85,7 +85,6 @@ class EditPositionForm(forms.Form):
8585 position = forms .ModelChoiceField (queryset = BallotPositionName .objects .all (), widget = forms .RadioSelect , initial = "norecord" , required = True )
8686 discuss = forms .CharField (required = False , widget = forms .Textarea )
8787 comment = forms .CharField (required = False , widget = forms .Textarea )
88- return_to_url = forms .CharField (required = False , widget = forms .HiddenInput )
8988
9089 def __init__ (self , * args , ** kwargs ):
9190 ballot_type = kwargs .pop ("ballot_type" )
@@ -107,8 +106,8 @@ def edit_position(request, name, ballot_id):
107106
108107 ad = login = request .user .person
109108
110- if 'HTTP_REFERER ' in request .META :
111- return_to_url = request .META [ 'HTTP_REFERER ' ]
109+ if 'ballot_edit_return_point ' in request .session :
110+ return_to_url = request .session [ 'ballot_edit_return_point ' ]
112111 else :
113112 return_to_url = urlreverse ("doc_ballot" , kwargs = dict (name = doc .name , ballot_id = ballot_id ))
114113
@@ -131,9 +130,6 @@ def edit_position(request, name, ballot_id):
131130 # save the vote
132131 clean = form .cleaned_data
133132
134- if clean ['return_to_url' ]:
135- return_to_url = clean ['return_to_url' ]
136-
137133 pos = BallotPositionDocEvent (doc = doc , by = login )
138134 pos .type = "changed_ballot_position"
139135 pos .ballot = ballot
@@ -195,9 +191,9 @@ def edit_position(request, name, ballot_id):
195191 e .save () # save them after the position is saved to get later id for sorting order
196192
197193 if request .POST .get ("send_mail" ):
198- qstr = "?return_to_url=%s" % return_to_url
194+ qstr = ""
199195 if request .GET .get ('ad' ):
200- qstr += "& ad=%s" % request .GET .get ('ad' )
196+ qstr += "? ad=%s" % request .GET .get ('ad' )
201197 return HttpResponseRedirect (urlreverse ("doc_send_ballot_comment" , kwargs = dict (name = doc .name , ballot_id = ballot_id )) + qstr )
202198 elif request .POST .get ("Defer" ):
203199 return redirect ("doc_defer_ballot" , name = doc )
@@ -212,9 +208,6 @@ def edit_position(request, name, ballot_id):
212208 initial ['discuss' ] = old_pos .discuss
213209 initial ['comment' ] = old_pos .comment
214210
215- if return_to_url :
216- initial ['return_to_url' ] = return_to_url
217-
218211 form = EditPositionForm (initial = initial , ballot_type = ballot .ballot_type )
219212
220213 blocking_positions = dict ((p .pk , p .name ) for p in form .fields ["position" ].queryset .all () if p .blocking )
@@ -243,8 +236,9 @@ def send_ballot_comment(request, name, ballot_id):
243236
244237 ad = request .user .person
245238
246- return_to_url = request .GET .get ('return_to_url' )
247- if not return_to_url :
239+ if 'ballot_edit_return_point' in request .session :
240+ return_to_url = request .session ['ballot_edit_return_point' ]
241+ else :
248242 return_to_url = urlreverse ("doc_ballot" , kwargs = dict (name = doc .name , ballot_id = ballot_id ))
249243
250244 if 'HTTP_REFERER' in request .META :
0 commit comments