Skip to content

Commit

Permalink
Merge pull request moinwiki#1774 from RogerHaase/1720-destroy
Browse files Browse the repository at this point in the history
eliminate traceback when destroying a deleted item; fixes moinwiki#1720
  • Loading branch information
UlrichB22 authored Oct 7, 2024
2 parents 11b9fa2 + d013745 commit e4e67a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ def destroy_item(item_name, rev):
ret = render_template(
"destroy.html",
item=item,
item_name=item_name,
item_name=item_name if item.meta[NAME] else item.meta[NAME_OLD][0],
subitem_names=subitem_names,
alias_names=alias_names,
fqname=fqname,
Expand Down
5 changes: 4 additions & 1 deletion src/moin/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,10 @@ def destroy(self, comment="", destroy_item=False, subitem_names=[], ajax=False):
action = DESTROY_ALL if destroy_item else DESTROY_REV
item_modified.send(app, fqname=self.fqname, action=action, data=self.rev.data, meta=self.meta)
close_file(self.rev.data)
old_name = self.names if len(self.names) > 1 else self.names[0]
if self.names:
old_name = self.names if len(self.names) > 1 else self.names[0]
else:
old_name = self.meta[NAME_OLD][0]
if destroy_item:
# destroy complete item with all revisions, metadata, etc.
self.rev.item.destroy_all_revisions()
Expand Down
4 changes: 2 additions & 2 deletions src/moin/templates/destroy.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{% extends theme("show.html") %}

{% if alias_names %}
{% set title = _("Destroy '{item_name}' with alias names {alias_names}").format(item_name=fqname|shorten_fqname, alias_names=alias_names) %}
{% set title = _("Destroy '{item_name}' with alias names {alias_names}").format(item_name=item_name, alias_names=alias_names) %}
{% else %}
{% set title = _("Destroy '{item_name}'").format(item_name=fqname|shorten_fqname) %}
{% set title = _("Destroy '{item_name}'").format(item_name=item_name) %}
{% endif %}

{% block content %}
Expand Down

0 comments on commit e4e67a5

Please sign in to comment.