Skip to content

Commit

Permalink
Merge pull request #1765 from UlrichB22/del_from_idx
Browse files Browse the repository at this point in the history
Fix delete/destroy from +index and ...
  • Loading branch information
RogerHaase authored Sep 20, 2024
2 parents 9c355e1 + f98f8f1 commit ed643d4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
15 changes: 10 additions & 5 deletions src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ def ajaxdestroy(item_name, req="destroy"):
# user probably checked a subitem and checked do subitems
response["messages"].append(_("Item '{bad_name}' does not exist.").format(bad_name=item.name))
continue
subitem_names = []
if req == "destroy":
subitem_names = []
if do_subitems:
subitems = item.get_subitem_revs()
# if subitem has alias of unselected sibling or ancester, it will be included
Expand All @@ -1094,7 +1094,6 @@ def ajaxdestroy(item_name, req="destroy"):
response["itemnames"] += subitem_names + itemnames
except AccessDenied:
response["messages"].append(_("Access denied processing '{bad_name}'.").format(bad_name=itemname))
response["itemnames"] = [url_for_item(x) for x in response["itemnames"]]
return jsonify(response)


Expand Down Expand Up @@ -1148,11 +1147,17 @@ def ajaxsubitems():
alias_names = []
subitems = list(item.get_subitem_revs())
# TODO: add check for delete/destroy auth, add to rejected names,
item_names = tuple(x + "/" for x in item.names)
# subitems may have alias names pointing to sibling or parent of user selected items
subitem_names = [y for x in subitems for y in x.meta[NAME]]

if fqname.namespace:
namespace_prefix = f"{fqname.namespace}/" # used to build fullname for aliases and subitems
else:
namespace_prefix = ""

subitem_names = [f"{namespace_prefix}{y}" for x in subitems for y in x.meta[NAME]]

if not [item.name] == item.names:
alias_names = [x for x in item.names if not x == item.name]
alias_names = [f"{namespace_prefix}{x}" for x in item.names if not x == item.name]
all_alias_names += alias_names
all_subitem_names += subitem_names
all_selected_names.append(item_name)
Expand Down
6 changes: 3 additions & 3 deletions src/moin/static/js/index_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $("document").ready(function () {
function get_checked() {
var checked_names = [];
$("input.moin-item:checked").each(function () {
var itemname = $(this).attr("value").slice(1);
var itemname = $(this).attr("value");
checked_names.push(itemname);
});
return checked_names;
Expand Down Expand Up @@ -106,7 +106,7 @@ $("document").ready(function () {
url;
// create an array of selected item names
$("input.moin-item:checked").each(function () {
var itemname = $(this).attr("value").slice(1);
var itemname = $(this).attr("value");
links.push(itemname);
});
// remove any flash messages, display "deleting..." or "destroying..." flash msg while process is in progress
Expand All @@ -125,7 +125,7 @@ $("document").ready(function () {
comment: comment,
do_subitems: $("#moin-do-subitems").is(":checked") ? "true" : "false"
}, function (data) {
// incoming itemnames is url-encoded list of item names (including alias names) successfully deleted/destroyed
// incoming itemnames is list of item names (including alias names) successfully deleted/destroyed
var itemnames = data.itemnames,
idx;
// display success/fail flash messages created by server for each selected item and subitem
Expand Down
2 changes: 1 addition & 1 deletion src/moin/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<tr>
<td class="moin-index-icons">
<span class="moin-select-item">
<input class="moin-item" type="checkbox" value="{{ url_for('.show_item', item_name=e.fullname) }}"/>
<input class="moin-item" type="checkbox" value="{{ e.fullname }}"/>
{% set mimetype = "application/x.moin.download" %}
{# invisible link below is used by js to download item #}
<a href="{{ url_for('.download_item', item_name=e.fullname, mimetype=mimetype) }}" class="moin-download-link">
Expand Down
8 changes: 4 additions & 4 deletions src/moin/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2443,23 +2443,23 @@ msgstr "Kommentar zum Änderungslog zufügen (optional)."

#: src/moin/templates/index.html:293
msgid "Selected names: "
msgstr "Auswahl"
msgstr "Auswahl: "

#: src/moin/templates/index.html:294
msgid "Alias names: "
msgstr "Alias Namen:"
msgstr "Alias Namen: "

#: src/moin/templates/index.html:297
msgid "Check to remove subitems"
msgstr "Auswählen um Subitems zu löschen"

#: src/moin/templates/index.html:299
msgid "Subitem names: "
msgstr "Subitem-Name"
msgstr "Subitem-Namen: "

#: src/moin/templates/index.html:300
msgid "Rejected names, permission denied: "
msgstr "Unzulässge Namen, keine Berechtigung: "
msgstr "Unzulässige Namen, keine Berechtigung: "

#: src/moin/templates/index.html:302
msgid "Enter your comment"
Expand Down

0 comments on commit ed643d4

Please sign in to comment.