Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions admin/nodes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
View,
FormView,
ListView,
TemplateView,
)
from django.shortcuts import redirect, reverse, get_object_or_404
from django.urls import reverse_lazy
Expand Down Expand Up @@ -102,12 +101,16 @@ def get_context_data(self, **kwargs):
node = self.get_object()

detailed_duplicates = detect_duplicate_notifications(node_id=node.id)

children = node.get_nodes(is_node_link=False)
# Annotate guid because django templates prohibit accessing attributes that start with underscores
children = AbstractNode.objects.filter(
id__in=[child.id for child in children]
).prefetch_related('guids').annotate(guid=F('guids___id'))
context.update({
'SPAM_STATUS': SpamStatus,
'STORAGE_LIMITS': settings.StorageLimits,
'node': node,
'children': node.get_nodes(is_node_link=False),
'children': children,
'duplicates': detailed_duplicates
})

Expand Down Expand Up @@ -194,10 +197,9 @@ def add_contributor_removed_log(self, node, user):
).save()


class NodeDeleteView(NodeMixin, TemplateView):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove the template_name and other TemplateView specific stuff if you do this.

class NodeDeleteView(NodeMixin, View):
""" Allows authorized users to mark nodes as deleted.
"""
template_name = 'nodes/remove_node.html'
permission_required = ('osf.view_node', 'osf.delete_node')
raise_exception = True

Expand Down
25 changes: 8 additions & 17 deletions admin/templates/nodes/children.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
{% for child in children %}
<tr>
<td>
<a href="{{ child | reverse_node }}">
{{ child.id }}
</a>
<a href="{{ child | reverse_node }}">{{ child.guid }}</a>
</td>
<td>{{ child.title }}</td>
<td>{{ child.is_public }}</td>
Expand All @@ -29,26 +27,19 @@
<td>
{% if not child.is_registration %}
{% if child.deleted %}
<form method="post"
action="{% url 'nodes:restore' guid=child.id %}">
<form method="post" action="{% url 'nodes:restore' guid=child.guid %}">
{% csrf_token %}
<input class="btn btn-success"
type="submit"
value="Restore Node" />
</form>
{% else %}
<a href="{% url 'nodes:remove' guid=child.id %}"
data-toggle="modal"
data-target="#deleteModal{{ child.id }}"
class="btn btn-danger">
Delete Node
</a>
<div class="modal" id="deleteModal{{ child.id }}">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
<form method="post" action="{% url 'nodes:remove' guid=child.guid %}">
{% csrf_token %}
<input class="btn btn-danger"
type="submit"
value="Delete Node" />
</form>
{% endif %}
{% endif %}
</td>
Expand Down
Loading