diff --git a/admin/nodes/urls.py b/admin/nodes/urls.py index 087a1d57e94..e350adb90fa 100644 --- a/admin/nodes/urls.py +++ b/admin/nodes/urls.py @@ -8,6 +8,7 @@ re_path(r'^flagged_spam$', views.NodeFlaggedSpamList.as_view(), name='flagged-spam'), re_path(r'^known_spam$', views.NodeKnownSpamList.as_view(), name='known-spam'), re_path(r'^known_ham$', views.NodeKnownHamList.as_view(), name='known-ham'), + re_path(r'^embargo_report/$', views.EmbargoReportView.as_view(), name='embargo-report'), re_path(r'^doi_backlog_list/$', views.DoiBacklogListView.as_view(), name='doi-backlog-list'), re_path(r'^approval_backlog_list/$', views.ApprovalBacklogListView.as_view(), name='approval-backlog-list'), re_path(r'^confirm_approve_backlog_list/$', views.ConfirmApproveBacklogView.as_view(), name='confirm-approve-backlog-list'), diff --git a/admin/nodes/views.py b/admin/nodes/views.py index 01ebad686ce..9a403131547 100644 --- a/admin/nodes/views.py +++ b/admin/nodes/views.py @@ -16,7 +16,9 @@ View, FormView, ListView, + TemplateView ) +from django.core.paginator import Paginator, InvalidPage from admin.base.forms import GuidForm from admin.base.utils import change_embargo_date @@ -39,6 +41,7 @@ SpamStatus, TrashedFile ) +from osf.models.sanctions import Embargo from osf.models.admin_log_entry import ( update_admin_log, NODE_REMOVED, @@ -474,6 +477,54 @@ def get_context_data(self, **kwargs): } +class EmbargoReportView(PermissionRequiredMixin, TemplateView): + """Report view for inspecting current and overdue embargoed registrations. + + Shows: + - pending embargoes that should have been activated + - active embargoes that are past their end date + - upcoming active embargoes + """ + template_name = 'nodes/embargo_report.html' + permission_required = 'osf.view_registration' + raise_exception = True + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + pending_embargoes = Embargo.objects.pending_embargoes().select_related('initiated_by') + active_embargoes = Embargo.objects.active_embargoes().select_related('initiated_by') + + pending_overdue_embargoes = [ + embargo for embargo in pending_embargoes + if embargo.should_be_embargoed + ] + + overdue_embargoes = [ + embargo for embargo in active_embargoes + if embargo.should_be_completed + ] + + upcoming_queryset = active_embargoes.filter( + end_date__gte=timezone.now(), + ).order_by('end_date') + + page_number = self.request.GET.get('page') or 1 + paginator = Paginator(upcoming_queryset, 10) + try: + upcoming_page = paginator.page(page_number) + except InvalidPage: + upcoming_page = paginator.page(1) + + context.update({ + 'now': timezone.now(), + 'pending_overdue_embargoes': pending_overdue_embargoes, + 'overdue_embargoes': overdue_embargoes, + 'upcoming_embargoes': upcoming_page.object_list, + 'upcoming_page': upcoming_page, + }) + return context + + class ConfirmApproveBacklogView(RegistrationListView): template_name = 'nodes/registration_approval_list.html' permission_required = 'osf.view_registrationapproval' diff --git a/admin/templates/base.html b/admin/templates/base.html index e6f10794c29..92a0541ef34 100644 --- a/admin/templates/base.html +++ b/admin/templates/base.html @@ -169,6 +169,7 @@
| Registration | +Embargo ID | +State | +Embargo Start | +Embargo End | +Initiated By | +
|---|---|---|---|---|---|
| + + {{ registration.title | truncatechars:30 }} + + | +{{ embargo.id }} | +{{ embargo.state }} | +{{ embargo.initiation_date|date:"F j, Y P" }} | +{{ embargo.end_date|date:"F j, Y P" }} | ++ {% if embargo.initiated_by %} + + {{ embargo.initiated_by.fullname }} + + {% else %} + — + {% endif %} + | +
| No active embargoes found. | +|||||
These embargoes are still awaiting approval but have passed the automatic activation window.
+| Registration | +Embargo ID | +State | +Embargo Initiation | +Embargo End | +Initiated By | +
|---|---|---|---|---|---|
| + + {{ registration.title | truncatechars:30 }} + + | +{{ embargo.id }} | +{{ embargo.state }} | +{{ embargo.initiation_date|date:"F j, Y P" }} | +{{ embargo.end_date|date:"F j, Y P" }} | ++ {% if embargo.initiated_by %} + + {{ embargo.initiated_by.fullname }} + + {% else %} + — + {% endif %} + | +
| No pending embargoes past the pending window. | +|||||
These embargoes have an end date in the past but the embargo is still marked as active.
+| Registration | +Embargo ID | +State | +Embargo End | +Is Registration Public? | +Initiated By | +
|---|---|---|---|---|---|
| + + {{ registration.title | truncatechars:30 }} + + | +{{ embargo.id }} | +{{ embargo.state }} | +{{ embargo.end_date|date:"F j, Y P" }} | ++ {% if registration.is_public %} + Yes + {% else %} + No + {% endif %} + | ++ {% if embargo.initiated_by %} + + {{ embargo.initiated_by.fullname }} + + {% else %} + — + {% endif %} + | +
| No overdue active embargoes found. | +|||||