Skip to content

Commit 2188589

Browse files
committed
Added an experimental screen where you can export any article
1 parent edcf27b commit 2188589

4 files changed

Lines changed: 94 additions & 10 deletions

File tree

templates/export/articles_all.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{% extends "admin/core/base.html" %}
2+
3+
{% block title %}Article Export{% endblock %}
4+
5+
{% block body %}
6+
<div class="large-12 columns">
7+
<div class="box">
8+
<div class="title-area">
9+
<h2>Article Export</h2>
10+
</div>
11+
<div class="content">
12+
<table class="small scroll" id="unassigned">
13+
<thead>
14+
<tr>
15+
<th>ID</th>
16+
<th style="width: 25%">Title</th>
17+
<th>Submitted</th>
18+
<th>Main Author</th>
19+
<th>Editors</th>
20+
<th>Section</th>
21+
<th>Archive</th>
22+
<th>Export CSV</th>
23+
<th>Export HTML</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
{% for article in articles_in_stage %}
28+
<tr>
29+
<td>{{ article.pk }}</td>
30+
<td>{{ article.title|safe }}</td>
31+
<td>{{ article.date_submitted }}</td>
32+
<td>{{ article.correspondence_author.full_name }}</td>
33+
<td>{% for editor in article.editors %}{{ editor.editor.full_name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
34+
<td>{{ article.section.name }}</td>
35+
<td><a target="_blank" class="small secondary button" href="{% url 'manage_archive_article' article.pk %}"><span class="fa fa-sticky-note"></span></a></td>
36+
<td>
37+
<a class="small secondary button" href="{% url 'export_article' article.pk 'csv' %}?in_stage=false"><span class="fa fa-download"></span> </a>
38+
</td>
39+
<td>
40+
<a class="small secondary button" href="{% url 'export_article' article.pk 'html' %}?in_stage=false"><span class="fa fa-download"></span> </a>
41+
</td>
42+
</tr>
43+
{% empty %}
44+
<tr>
45+
<td colspan="10">No articles in this stage</td>
46+
</tr>
47+
{% endfor %}
48+
</tbody>
49+
</table>
50+
</div>
51+
</div>
52+
</div>
53+
54+
{% endblock body %}
55+
56+
{% block js %}
57+
{% include "elements/datatables.html" with target="#unassigned" %}
58+
{% endblock js %}

templates/export/manager.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<h2>Management Form</h2>
1010
</div>
1111
<div class="content">
12-
{{ form|foundation }}
12+
<a href="{% url 'export_articles_all' %}">View Mass Exporter</a>
1313
</div>
1414
</div>
1515
{% endblock body %}

urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
views.export_article,
1414
name='export_article',
1515
),
16+
url(r'^articles/all/$', views.export_articles_all, name='export_articles_all'),
1617
]

views.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ def manager(request):
1515
:param request: HttpRequest object
1616
:return: HttpReponse or HttpRedirect
1717
"""
18-
form = forms.DummyManagerForm()
19-
2018
template = 'export/manager.html'
2119
context = {
22-
'form': form,
2320
}
2421

2522
return render(request, template, context)
@@ -56,12 +53,20 @@ def export_article(request, article_id, format='csv'):
5653
:param format: string, csv or html
5754
:return: HttpResponse or Http404
5855
"""
59-
article = get_object_or_404(
60-
models.Article,
61-
pk=article_id,
62-
journal=request.journal,
63-
stage=plugin_settings.STAGE,
64-
)
56+
in_stage = request.GET.get('in_stage', 'true')
57+
if in_stage == 'true':
58+
article = get_object_or_404(
59+
models.Article,
60+
pk=article_id,
61+
journal=request.journal,
62+
stage=plugin_settings.STAGE,
63+
)
64+
else:
65+
article = get_object_or_404(
66+
models.Article,
67+
pk=article_id,
68+
journal=request.journal,
69+
)
6570
files = core_models.File.objects.filter(
6671
article_id=article.pk,
6772
)
@@ -85,3 +90,23 @@ def export_article(request, article_id, format='csv'):
8590
return logic.export_html(request, article, files)
8691

8792
raise Http404
93+
94+
95+
@decorators.has_journal
96+
@decorators.editor_user_required
97+
def export_articles_all(request):
98+
"""
99+
A view that displays all articles in a journal and allows export.
100+
"""
101+
articles = models.Article.objects.filter(
102+
journal=request.journal,
103+
).select_related(
104+
'correspondence_author',
105+
)
106+
107+
template = 'export/articles_all.html'
108+
context = {
109+
'articles_in_stage': articles,
110+
}
111+
112+
return render(request, template, context)

0 commit comments

Comments
 (0)