|
From: Mercurial C. <th...@in...> - 2026-05-17 06:27:56
|
# HG changeset patch
# User John Rouillard <ro...@ie...>
# Date 1778989957 14400
# Sat May 16 23:52:37 2026 -0400
# Node ID ede573cfbd7d0d4e7a5755aa3a3c679d3167ebd5
# Parent d681fce4c3789b28a31f109b47aa462c58acfe28
bug: don't clobber existing query with identically named new query
Fix SearchAction so we don't clobber a saved search when a new search
of the same name is created.
The issue.search.html template sets @old-queryname to the value of
@queryname. In new searches @old-queryname is "" so saving the new
query doesn't update an existing query identified by @old-queryname.
However, assume a search named "asearch" exists. Create a new search
(not editing the existing "asearch").
Set new query params and name it "asearch". Roundup will warn you that
"asearch" already exists and you need to choose a new name. It can
tell this because @old-queryname is empty and @queryname is looked up
and a conflicting identically named search is found.
Now a replacement search input form is generated with the warning that
the query name is in use. However in this replacement form
@old-queryname is set to "asearch". Then the user renames the query
to "bsearch" and saves/executes.
This used to overwrite "asearch" as it set "@old-queryname" of the
form to "asearch". So it looked like you were trying to edit
the existing query.
This fix modifies @queryname (and hence @old-queryname) before
generating the error form by appending " - duplicate'. Now when it is
submitted it doesn't overwrite "asearch".
diff -r d681fce4c378 -r ede573cfbd7d CHANGES.txt
--- a/CHANGES.txt Sat May 16 21:47:18 2026 -0400
+++ b/CHANGES.txt Sat May 16 23:52:37 2026 -0400
@@ -96,6 +96,17 @@
- Make queries selected from query edit screen include the query
name/display name. This makes it work the same as invoking a query
from the main "Your Queries" menu. (John Rouillard)
+- Fix SearchAction to not clobber a saved search when a new search of
+ the same name is created. Assume a search named "asearch"
+ exists. Create a new search (not editing the existing
+ "asearch"). Set new query params and name it "asearch". Roundup will
+ warn you that "asearch" already exists and you need to choose a new
+ name. In the warning form, you rename it to "bsearch" and
+ save/execute. Before this would overwrite "asearch" as it set the
+ "@old-queryname" of the warning form to "asearch". So it looked like
+ you were trying to edit the existing query. This fix modifies the
+ queryname before generating the error form. So when submitted it
+ doesn't overwrite "asearch". (John Rouillard)
Features:
diff -r d681fce4c378 -r ede573cfbd7d roundup/cgi/actions.py
--- a/roundup/cgi/actions.py Sat May 16 21:47:18 2026 -0400
+++ b/roundup/cgi/actions.py Sat May 16 23:52:37 2026 -0400
@@ -358,6 +358,23 @@
"Please choose another name.") % (queryname)
self.client.add_error_message(message)
+ # Assume we duplicate query "a". When the
+ # response is generated, @old-queryname is set
+ # to 'a' in the template. This causes the 'a'
+ # query to be changed to the new query name
+ # and values.
+
+ # So we change @queryname by appending ' -
+ # duplicate'. This way @old-queryname will be
+ # 'a - duplicate' and will not overwrite the
+ # query named 'a'. (but it will
+ # overwrite/change a query named "a -
+ # duplicate". Hopefully nobody uses that name
+ # 8-).
+ self.client.form['@queryname'].value = (
+ # .Hint suffix added to queryname when
+ # a new queryname is already used.
+ queryname + _(" - duplicate"))
return
# edit the new way, query name not a key any more
|