Skip to content

Commit

Permalink
abstracted detail and list views
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebader committed Sep 26, 2018
1 parent 263c3d4 commit 0ae3fcd
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 247 deletions.
6 changes: 4 additions & 2 deletions cv/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ def clean(self, *args, **kwargs):
super(VitaePublicationModel, self).clean(*args, **kwargs)

def get_absolute_url(self):
url_name = 'cv:%s_object_detail' % self._meta.model_name
return reverse(url_name, kwargs={'slug': self.slug})
return reverse(
'cv:item_detail',
kwargs={'model_name': self._meta.model_name, 'slug': self.slug}
)

def get_next_previous_by_status(self, direc):
if direc not in ["previous", "next"]:
Expand Down
3 changes: 2 additions & 1 deletion cv/templates/cv/citations/article.bib
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load cvtags %}
@article{bader,
author = { {{ article.articleauthorship_set.all|print_authors_bib_format }} },
author = { {{ article.authorship.all|print_authors_bib_format }} },
year = { {{article.pub_date.year}} },
month = {{article.pub_date|date:"b"}},
title = { {{article.title}} },
Expand Down
4 changes: 2 additions & 2 deletions cv/templates/cv/citations/article.ris
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TY - JOUR
TI - {{article.title}}
{% spaceless %}{% for author in article.articleauthorship_set.all %}
{% spaceless %}{% for author in article.authorship.all %}
AU - {{author}}{% endfor %}{% endspaceless %}
PY - {{article.pub_date|date:"Y/m/d"}}
SP - {{article.start_page}}
Expand All @@ -14,4 +14,4 @@ N2 - {{article.abstract|safe}}
UR - {{article.url}}
SN - {{article.journal.issn}}
DO - {{article.doi}}
ER -
ER -
2 changes: 1 addition & 1 deletion cv/templates/cv/citations/book.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@book{bader_{{book.slug}}_{{book.pub_date.year}},
author = { {{ book.authorship.all|print_authors_bib_format }} },
title = { {{book.title}} },
abstract = { {{book.summary}} },
abstract = { {{book.abstract}} },
{% if book.editions %}{% with book.editions.all|first as edition %}{% if edition.publisher %}publisher = { {{edition.publisher}} },{% endif %}
{% if edition.edition %}edition = { {{edition.edition}} },{% endif %}
{% if edition.edition_date %}year = {{edition.edition_date.year}},{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion cv/templates/cv/citations/book.ris
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TI - {{book.title}}
{% spaceless %}{% for author in book.authorship.all %}
AU - {{author}}{% endfor %}{% endspaceless %}
ST - {{book.short_title}}
AB - {{book.summary}}
AB - {{book.abstract}}
{% if book.editions %}{% with book.editions.all|first as edition %}PB - {{edition.publisher}}
PP - {{edition.place}}
PY - {{edition.edition_date|date:"Y/m/d"}}
Expand Down
2 changes: 1 addition & 1 deletion cv/templates/cv/citations/report.bib
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load cvtags %}
@techreport{bader-{{report.slug}},
author = { {{ report.reportauthorship_set.all|print_authors_bib_format }} },
author = { {{ report.authorship.all|print_authors_bib_format }} },
year = { {{report.pub_date.year}} },
month = {{report.pub_date|date:"b"}},
title = { {{report.title}} },
Expand Down
2 changes: 1 addition & 1 deletion cv/templates/cv/citations/report.ris
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TY - RPRT
T1 - {{report.title}}
{% spaceless %}{% for author in report.articleauthorship_set.all %}
{% spaceless %}{% for author in report.authorship.all %}
AU - {{author}}{% endfor %}{% endspaceless %}
PY - {{report.pub_date|date:"Y/m/d"}}
SP - {{report.start_page}}
Expand Down
19 changes: 14 additions & 5 deletions cv/templates/cv/details/_cv_detail_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@



{% block maintitle %}{{object.title}}{% endblock %}


{% block centerbar-content %}
<div id="abstract" class="col-xs-12 col-sm-10 push-sm-1 abstract">
<h1 class="col-12 col-sm-10">{% block maintitle %}{{object.title}}{% endblock %}</h1>
{% block abstract %}
<h2 class="col-12 col-sm-10 abstract-name">{% block abstract_name %}Abstract{% endblock abstract_name %}</h2>
<div id="abstract" class="col-xs-12 col-sm-10 abstract">
{{object.abstract_html|safe}}
</div>
{% endblock abstract %}
{% endblock %}

{% block next-previous %}
Expand All @@ -19,8 +23,10 @@

{% block details %}
{% block citation %}
<h2>Citation</h2>
{% block formatted-citation %}{% endblock %}
<h2 class="col-12 col-sm-10">Citation</h2>
<div class="col-12 col-sm-10 citation">
{% block formatted-citation %}{% endblock %}
</div>

{% block url %}
{% if object.url %}
Expand All @@ -29,13 +35,15 @@ <h2>Citation</h2>
</p>
{% endif %}
{% endblock %}

<div class="col-12 col-sm-10 citation-links">
<a class="btn btn-secondary btn-sm" role="button" href="{% block object-citation-url-ris %}{% endblock %}" title="Download {{object.short_title}} in Reference Manager format"><span class='fa fa-paperclip ' aria-hidden="true"></span> Cite with Reference Manager</a>
<a class="btn btn-secondary btn-sm" role="button" href="{% block object-citation-url-bib %}{% endblock %}" title="Download {{object.short_title}} in BibTeX format"><span class='fa fa-paperclip' aria-hidden="true"></span> Cite with BibTeX</a>
</div>
{% endblock citation %}


{% block files %}
<div class="col-12 col-sm-10 files">
<h2>Files</h2>
{% with object.files.all as files %}
<ul>
Expand All @@ -50,6 +58,7 @@ <h2>Files</h2>
{% endif %}
</ul>
{% endwith %}
</div>
{% endblock files %}

{% block type-specific-info %}{% endblock %}
Expand Down
8 changes: 4 additions & 4 deletions cv/templates/cv/details/article_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% with article as object %}

{% block object-list-url %}{% url 'cv:article_object_list' %}{% endblock %}
{% block object-list-url %}{% url 'cv:section_list' model_name='article' %}{% endblock %}

{% block next-previous %}
{% with "article" as section_name %}
Expand All @@ -12,15 +12,15 @@
{% endblock next-previous %}

{% block formatted-citation %}
<p>{{article.articleauthorship_set.all|print_authors}}. ({{article.pub_date.year}}). {% if article.journal %} <cite>{{article.journal}}</cite>{% endif %} {% if article.volume %}<span class="volume-issue">{{article.volume}}{% if article.issue %}({{article.issue}}){% endif %}</span>{% endif %}{%if article.start_page %}:<span class='page-numbers'>{{article.start_page}}{%if article.end_page %}-{{article.end_page}}{% endif %}</span>{% endif %}.</p>
<p>{{article.authorship.all|print_authors}} ({{article.pub_date.year}}). &#8220;{{ article.title}}.&#8221; {% if article.journal %} <cite>{{article.journal}}</cite>{% endif %} {% if article.volume %}<span class="volume-issue">{{article.volume}}{% if article.issue %}({{article.issue}}){% endif %}</span>{% endif %}{%if article.start_page %}:<span class='page-numbers'>{{article.start_page}}{%if article.end_page %}-{{article.end_page}}{% endif %}</span>{% endif %}.</p>
{% endblock formatted-citation %}

{% block object-citation-url-ris %}
{% url 'cv:article_citation' article.slug 'ris' %}
{% url 'cv:citation' 'article' article.slug 'ris' %}
{% endblock %}

{% block object-citation-url-bib %}
{% url 'cv:article_citation' article.slug 'bib' %}
{% url 'cv:citation' 'article' article.slug 'bib' %}
{% endblock %}

{% block object_type_and_location %}article on journal website{% endblock %}
Expand Down
13 changes: 4 additions & 9 deletions cv/templates/cv/details/book_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@

{% with book as object %}

{% block object-list-url %}{% url 'cv:book_object_list' %}{% endblock %}
{% block object-list-url %}{% url 'cv:section_list' 'book' %}{% endblock %}

{% block next-previous %}
{% with "book" as section_name %}
{{block.super}}
{% endwith %}
{% endblock next-previous %}

{% block centerbar-content %}
<h2>Summary</h2>
<div id="abstract" class="col-xs-12 col-sm-10 push-sm-1 abstract">
{{object.abstract_html|safe}}
</div>
{% endblock centerbar-content %}
{% block abstract_name %}Summary{% endblock %}

{% block formatted-citation %}
<p>{{book.authorship.all|print_authors}}. {{book.pub_date.year}}. <cite>{{book.title}}</cite>.{% if book.editions %} {% with book.editions.all|first as edition %}{{edition.edition}} ed.,{% if edition.publisher %} {% if edition.place %}{{edition.place}}: {% endif %}{{edition.publisher}}.{% endif %}{% if edition.isbn %} ISBN: {{edition.isbn}}{% endif %}{% endwith %}{% else %}{% if book.publisher %}{% if book.place %} {{book.place}}: {{book.publisher}}.{% endif %}{% endif %}{% if book.ISBN %} ISBN: {{book.isbn}}{% endif %}{% endif %}</p>
Expand All @@ -32,11 +27,11 @@ <h3>Other editions</h3>
{% endblock formatted-citation %}

{% block object-citation-url-ris %}
{% url 'cv:book_citation' book.slug 'ris' %}
{% url 'cv:citation' 'book' book.slug 'ris' %}
{% endblock %}

{% block object-citation-url-bib %}
{% url 'cv:book_citation' book.slug 'bib' %}
{% url 'cv:citation' 'book' book.slug 'bib' %}
{% endblock %}

{% block object_type_and_location %}article on book website{% endblock %}
Expand Down
6 changes: 3 additions & 3 deletions cv/templates/cv/details/report_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% with report as object %}

{% block object-list-url %}{% url 'cv:report_object_list' %}{% endblock %}
{% block object-list-url %}{% url 'cv:section_list' 'report' %}{% endblock %}

{% block next-previous %}
{% with "report" as section_name %}
Expand All @@ -16,11 +16,11 @@
{% endblock formatted-citation %}

{% block object-citation-url-ris %}
{% url 'cv:report_citation' report.slug 'ris' %}
{% url 'cv:citation' 'report' report.slug 'ris' %}
{% endblock %}

{% block object-citation-url-bib %}
{% url 'cv:report_citation' report.slug 'bib' %}
{% url 'cv:citation' 'report' report.slug 'bib' %}
{% endblock %}

{% block object_type_and_location %}{% endblock %}
Expand Down
6 changes: 3 additions & 3 deletions cv/templates/cv/details/talk_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% with talk as object %}

{% block object-list-url %}{% url 'cv:talk_object_list' %}{% endblock %}
{% block object-list-url %}{% url 'cv:section_list' 'talk' %}{% endblock %}

{% block next-previous %}
{% with "talk" as section_name %}
Expand All @@ -28,11 +28,11 @@


{% block object-citation-url-ris %}
{% url 'cv:talk_citation' talk.slug 'ris' %}
{% url 'cv:citation' 'talk' talk.slug 'ris' %}
{% endblock %}

{% block object-citation-url-bib %}
{% url 'cv:talk_citation' talk.slug 'bib' %}
{% url 'cv:citation' 'talk' talk.slug 'bib' %}
{% endblock %}

{% block type-specific-info %}
Expand Down
8 changes: 4 additions & 4 deletions cv/templates/cv/lists/article_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

{% block centerbar-content %}

{% with article_objects.total_articles as total_articles %}
{% with article_objects.article_published_list as article_published_list %}
{% with article_objects.article_revise_list as article_revise_list %}
{% with article_objects.article_inprep_list as article_inprep_list %}
{% with object_list.total_articles as total_articles %}
{% with object_list.article_published_list as article_published_list %}
{% with object_list.article_revise_list as article_revise_list %}
{% with object_list.article_inprep_list as article_inprep_list %}

{% include "cv/sections/articles.html" %}

Expand Down
24 changes: 1 addition & 23 deletions cv/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,10 @@
app_name = 'cv'
urlpatterns = [
path('', views.cv_list, name='cv_list'),
path('articles/', views.ArticleListView.as_view(), name='article_object_list'),
path('articles/<slug:slug>/', views.ArticleDetailView.as_view(), name='article_object_detail'),
path('articles/<slug:slug>/citation/<str:format>/', views.article_citation_view, name='article_citation'),

path('books/', views.BookListView.as_view(), name='book_object_list'),
path('books/<slug:slug>/', views.BookDetailView.as_view(), name='book_object_detail'),
path('books/<slug:slug>/citation/<str:format>/', views.book_citation_view, name='book_citation'),

path('reports/', views.ReportListView.as_view(), name='report_object_list'),
path('reports/<slug:slug>/', views.ReportDetailView.as_view(), name='report_object_detail'),
path('reports/<slug:slug>/citation/<str:format>/', views.report_citation_view, name='report_citation'),

path('chapters/', views.ChapterListView.as_view(), name='chapter_object_list'),
path('chapters/<slug:slug>/', views.ChapterDetailView.as_view(), name='chapter_object_detail'),
path('chapters/<slug:slug>/citation/<str:format>/', views.chapter_citation_view, name='chapter_citation'),

path('talks/', views.TalkListView.as_view(), name='talk_object_list'),
path('talks/<slug:slug>/', views.TalkDetailView.as_view(), name='talk_object_detail'),
path('talks/<slug:slug>/citation/<str:format>/', views.talk_citation_view, name='talk_citation'),

# path('forms/article/add/', views.ArticleCreate.as_view(),name='article_new'),
# path('forms/article/<int:pk>/edit/',views.ArticleUpdate.as_view(),name='article_edit'),

path('<str:model_name>s/', views.CVListView.as_view(), name='section_list'),
path('<str:model_name>s/<slug:slug>', views.CVDetailView.as_view(), name='item_detail'),
# path('<str:model_name>s/<slug:slug>/<str:format>', name='citation'),
path('<str:model_name>s/<slug:slug>/<str:format>', views.citation_view, name='citation'),

path('forms/<str:model_name>/add/', views.CVCreateView.as_view(),name='cv_add'),
path('forms/<str:model_name>/<int:pk>/edit/', views.CVUpdateView.as_view(),name='cv_edit'),
Expand Down

0 comments on commit 0ae3fcd

Please sign in to comment.