diff --git a/journals/models.py b/journals/models.py index 19f91696369b9c352752288f5461df2e77da734c..17d9ce34ff6bd49d873bafa0e863fff7ef8f89e5 100644 --- a/journals/models.py +++ b/journals/models.py @@ -125,6 +125,12 @@ class Journal(models.Model): def has_issues(self): return self.structure in (ISSUES_AND_VOLUMES, ISSUES_ONLY) + @property + def get_latest_issue(self): + if not self.has_issues: + return None + return Issue.obejcts.... + @property def has_volumes(self): return self.structure in (ISSUES_AND_VOLUMES) diff --git a/journals/templates/journals/issue_list.html b/journals/templates/journals/issue_list.html new file mode 100644 index 0000000000000000000000000000000000000000..169d2838e4296122887ab6cd620772f5f21d0bfb --- /dev/null +++ b/journals/templates/journals/issue_list.html @@ -0,0 +1,42 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block pagetitle %}{{block.super}}: Issues Admin{% endblock pagetitle %} + +{% block breadcrumb_items %} + {{block.super}} + <span class="breadcrumb-item active">Issues Admin</span> +{% endblock %} + +{% block content %} + + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Issues Admin</h1> + <a href="javascript:;">Create a new Issue</a> + <br><br> + + <h3>Journals with their latest Issue</h3> + <table class="table"> + <thead> + <tr> + <th>Journal</th> + <th>Latest Issue</th> + <th>Has active Issue?</th> + </tr> + </thead> + {% for journal in journals %} + {% if journal.has_issues %} + <tr> + <td>{{ journal.get_name_display }}</td> + <td></td> + <td><i class="fa fa-exclamation-triangle text-warning"></i> No.</td> + </tr> + {% endif %} + {% endfor %} + </table> + </div> +</div> + + +{% endblock %} diff --git a/journals/urls/general.py b/journals/urls/general.py index 87b194828631fee4b013c9d7ea506e169727254f..e8082bd4a7687f86a60a017b227c0b64b66bb610 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -103,6 +103,17 @@ urlpatterns = [ journals_views.add_associated_grant, name='add_associated_grant'), + url(r'^admin/issues/$', + journals_views.IssuesAdminListView.as_view(), + name='admin_issue_list'), + url(r'^admin/issues/add$', + journals_views.IssuesAdminAddView.as_view(), + name='add_issue'), + url(r'^admin/issues/(?P<id>[0-9]+)/$', + journals_views.IssuesAdminUpdateView.as_view(), + name='update_issue'), + + # Metadata handling url(r'^admin/(?P<doi_label>{regex})/metadata/crossref/create$'.format( regex=PUBLICATION_DOI_REGEX), diff --git a/journals/views.py b/journals/views.py index 436a1ec1d9fdb43ee418d63cfda5251a8d8b11fe..528695ede2f53479a9ce517bbe1098174548f6fb 100644 --- a/journals/views.py +++ b/journals/views.py @@ -24,7 +24,7 @@ from django.http import Http404, HttpResponse from django.utils import timezone from django.utils.decorators import method_decorator from django.views.generic.detail import DetailView -from django.views.generic.edit import UpdateView +from django.views.generic.edit import CreateView, UpdateView from django.views.generic.list import ListView from django.shortcuts import get_object_or_404, get_list_or_404, render, redirect @@ -177,6 +177,30 @@ class IssuesView(DetailView): template_name = 'journals/journal_issues.html' +class IssuesAdminListView(PermissionsMixin, ListView): + """ + List all Issues in the database for the admin. + """ + model = Issue + permission_required = 'scipost.can_manage_issues' + + +class IssuesAdminAddView(PermissionsMixin, CreateView): + """ + List all Issues in the database for the admin. + """ + model = Issue + permission_required = 'scipost.can_manage_issues' + + +class IssuesAdminUpdateView(PermissionsMixin, UpdateView): + """ + List all Issues in the database for the admin. + """ + model = Issue + permission_required = 'scipost.can_manage_issues' + + def redirect_to_about(request, doi_label): journal = get_object_or_404(Journal, doi_label=doi_label) return redirect(