diff --git a/eruditorg/apps/public/search/serializers.py b/eruditorg/apps/public/search/serializers.py index 29640acfb..77ba2bbf9 100644 --- a/eruditorg/apps/public/search/serializers.py +++ b/eruditorg/apps/public/search/serializers.py @@ -2,7 +2,9 @@ from django.conf import settings from django.core.cache import cache +from django.core.urlresolvers import reverse from django.utils import translation +from django.utils.translation import ugettext as _ from eulfedora.util import RequestFailed from requests.exceptions import ConnectionError from rest_framework import serializers @@ -43,24 +45,32 @@ def get_real_object(self, obj): class ArticleSerializer(serializers.ModelSerializer): authors = serializers.SerializerMethodField() abstract = serializers.SerializerMethodField() + type = serializers.SerializerMethodField() collection_name = serializers.SerializerMethodField() + bibliographic_reference = serializers.SerializerMethodField() + paral_titles = serializers.SerializerMethodField() journal_code = serializers.SerializerMethodField() journal_name = serializers.SerializerMethodField() + journal_type = serializers.SerializerMethodField() + journal_url = serializers.SerializerMethodField() issue_localidentifier = serializers.SerializerMethodField() issue_title = serializers.SerializerMethodField() issue_number = serializers.SerializerMethodField() issue_volume = serializers.SerializerMethodField() issue_published = serializers.SerializerMethodField() issue_volume_slug = serializers.SerializerMethodField() + issue_publication_date = serializers.SerializerMethodField() has_pdf = serializers.SerializerMethodField() class Meta: model = erudit_models.Article fields = [ - 'journal_code', 'journal_name', 'issue_localidentifier', 'issue_title', 'issue_number', - 'issue_volume', 'issue_published', 'issue_volume_slug', 'title', 'surtitle', 'subtitle', - 'processing', 'authors', 'abstract', 'first_page', 'last_page', 'has_pdf', - 'external_url', 'external_pdf_url', 'collection_name', + 'journal_code', 'journal_name', 'journal_type', 'journal_url', 'issue_localidentifier', + 'issue_title', 'issue_number', 'paral_titles', + 'issue_volume', 'issue_published', 'issue_volume_slug', 'issue_publication_date', + 'title', 'surtitle', 'subtitle', + 'processing', 'authors', 'abstract', 'type', 'first_page', 'last_page', 'has_pdf', + 'external_url', 'external_pdf_url', 'collection_name', 'bibliographic_reference', ] def get_authors(self, obj): @@ -73,23 +83,49 @@ def get_authors(self, obj): }) return authors + def get_type(self, obj): + if obj.type: + return obj.get_type_display() + return _('Article') + + def get_paral_titles(self, obj): + paral_titles = obj.titles.filter(paral=True) + return list(t.title for t in paral_titles) + def get_abstract(self, obj): return obj.abstract def get_collection_name(self, obj): return obj.issue.journal.collection.name + def get_bibliographic_reference(self, obj): + return obj.bibliographic_reference + def get_journal_code(self, obj): return obj.issue.journal.code def get_journal_name(self, obj): return obj.issue.journal.name + def get_journal_type(self, obj): + if obj.issue.journal.type: + return obj.issue.journal.type.get_code_display().lower() + return '' + + def get_issue_publication_date(self, obj): + return obj.issue.volume_title + + def get_journal_url(self, obj): + journal = obj.issue.journal + if journal.external_url: + return journal.external_url + return reverse('public:journal:journal_detail', args=(journal.code, )) + def get_issue_localidentifier(self, obj): return obj.issue.localidentifier def get_issue_title(self, obj): - return obj.issue.title + return obj.issue.name_with_themes def get_issue_number(self, obj): return obj.issue.number_for_display diff --git a/eruditorg/templates/public/search/results.html b/eruditorg/templates/public/search/results.html index 73bf645d0..9684aaf45 100644 --- a/eruditorg/templates/public/search/results.html +++ b/eruditorg/templates/public/search/results.html @@ -165,7 +165,7 @@

{% trans "Documents repérés" %}

{% if document.real_object.authors %} {% for author in document.real_object.authors %} - {% if author.firstname and author.lastname %}{{ author.firstname }} {{ author.lastname }}{% elif author.othername %}{{ author.othername }}{% endif %}{% if not forloop.last %}, {% endif %} + {% if author.firstname and author.lastname %}{{ author.lastname }}, {{ author.firstname }}{% elif author.othername %}{{ author.othername }}{% endif %}{% if not forloop.last %}; {% endif %} {% endfor %} {% elif document.real_object.author %} {% with author=document.real_object.author %} @@ -193,19 +193,37 @@

{% if document.real_object.subtitle %}
{{ document.real_object.subtitle }}
{% endif %} + {% if document.real_object.paral_titles %} + {% for paral_title in document.real_object.paral_titles %} +
{{ paral_title }}
+ {% endfor %} + {% endif %} + {% if document.real_object.bibliographic_reference %} +
{{ document.real_object.bibliographic_reference }}
+ {% endif %}

{# article metadata #}
- {% if document.real_object.issue_title %}

{{ document.real_object.issue_title }}

{% endif %}

{% if document.document_type == 'article' %} - {% trans "Article" %}, + {% with article=document.real_object %} + {{ article.type }} + {% if article.type == 'note' or article.type == 'Note' %}publiée{% else %}publié{% endif %} + {% trans "dans la revue" %} + {% if article.journal_type == 'culturel' %}{% trans "culturelle" %}{% elif article.journal_type == 'savant' %}{% trans "savante" %}{% endif %} + {{ article.journal_name }} ({{ article.collection_name }}) + {% if document.real_object.issue_title %}

{{ document.real_object.issue_title|safe }}

{% endif %} +

+

+ {{ article.issue_publication_date }} +

+ {% endwith %} {% elif document.document_type == 'thesis' %} - {% trans "Thèse" %}, - {% endif %} + {% trans "Thèse" %} {% trans "déposée à" %} {{ document.real_object.collection_name }} + {% endif %}

{# abstract #} diff --git a/requirements.txt b/requirements.txt index 5d0f04b58..c69bd613c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ Django==1.9.9 -git+https://github.com/erudit/erudit-core.git@0.2.19#egg=erudit-core +git+https://github.com/erudit/erudit-core.git@0.2.21#egg=erudit-core +git+https://github.com/erudit/liberuditarticle.git@0.1.17#egg=liberuditarticle git+https://github.com/erudit/django-resumable-uploads.git@master#egg=django-resumable-uploads git+https://github.com/erudit/django-account-actions.git@master#egg=django-account-actions eulxml==1.0.1 eulfedora==1.5.0 -git+https://github.com/erudit/liberuditarticle.git@0.1.16#egg=liberuditarticle django-post-office==2.0.5 jsonfield==1.0.3 lxml==3.5.0 diff --git a/tests/functional/apps/public/citations/test_views.py b/tests/functional/apps/public/citations/test_views.py index 80d323801..f24ff5ee2 100644 --- a/tests/functional/apps/public/citations/test_views.py +++ b/tests/functional/apps/public/citations/test_views.py @@ -15,6 +15,7 @@ from erudit.models import JournalType from erudit.test.factories import ArticleFactory +from erudit.test.factories import ArticleTitleFactory from erudit.test.factories import AuthorFactory from erudit.test.factories import CollectionFactory from erudit.test.factories import IssueFactory @@ -47,9 +48,12 @@ def setup(self): collection=self.collection, type=JournalType.objects.get(code='C')) self.issue_1 = IssueFactory.create(journal=self.journal_1, year=2012) self.issue_2 = IssueFactory.create(journal=self.journal_2, year=2013) - self.article_1 = ArticleFactory.create(title='Title A', issue=self.issue_1) - self.article_2 = ArticleFactory.create(title='Title B', issue=self.issue_1) - self.article_3 = ArticleFactory.create(title='Title C', issue=self.issue_2) + self.article_1 = ArticleFactory.create(issue=self.issue_1) + self.article_2 = ArticleFactory.create(issue=self.issue_1) + self.article_3 = ArticleFactory.create(issue=self.issue_2) + ArticleTitleFactory(title='Title A', article=self.article_1) + ArticleTitleFactory(title='Title B', article=self.article_2) + ArticleTitleFactory(title='Title C', article=self.article_3) self.article_1.authors.add(author_3) self.article_2.authors.add(author_4) self.article_3.authors.add(author_3) @@ -229,9 +233,9 @@ def setup(self): collection=self.collection, type=JournalType.objects.get(code='C')) self.issue_1 = IssueFactory.create(journal=self.journal_1, year=2012) self.issue_2 = IssueFactory.create(journal=self.journal_2, year=2013) - self.article_1 = ArticleFactory.create(title='Title A', issue=self.issue_1) - self.article_2 = ArticleFactory.create(title='Title B', issue=self.issue_1) - self.article_3 = ArticleFactory.create(title='Title C', issue=self.issue_2) + self.article_1 = ArticleFactory.create(issue=self.issue_1) + self.article_2 = ArticleFactory.create(issue=self.issue_1) + self.article_3 = ArticleFactory.create(issue=self.issue_2) self.article_1.authors.add(author_3) self.article_2.authors.add(author_4) self.article_3.authors.add(author_3) @@ -295,9 +299,9 @@ def setup(self): collection=self.collection, type=JournalType.objects.get(code='C')) self.issue_1 = IssueFactory.create(journal=self.journal_1, year=2012) self.issue_2 = IssueFactory.create(journal=self.journal_2, year=2013) - self.article_1 = ArticleFactory.create(title='Title A', issue=self.issue_1) - self.article_2 = ArticleFactory.create(title='Title B', issue=self.issue_1) - self.article_3 = ArticleFactory.create(title='Title C', issue=self.issue_2) + self.article_1 = ArticleFactory.create(issue=self.issue_1) + self.article_2 = ArticleFactory.create(issue=self.issue_1) + self.article_3 = ArticleFactory.create(issue=self.issue_2) self.article_1.authors.add(author_3) self.article_2.authors.add(author_4) self.article_3.authors.add(author_3) diff --git a/tests/functional/apps/public/journal/test_views.py b/tests/functional/apps/public/journal/test_views.py index e1b3d50b7..5a721b772 100644 --- a/tests/functional/apps/public/journal/test_views.py +++ b/tests/functional/apps/public/journal/test_views.py @@ -253,7 +253,7 @@ def test_provides_only_authors_for_the_first_available_letter_by_default(self): def test_only_provides_authors_for_the_given_letter(self): # Seetup issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now()) - article_1 = ArticleFactory.create(title="lorem ipsum", issue=issue_1) + article_1 = ArticleFactory.create( issue=issue_1) author_1 = AuthorFactory.create(lastname='btest') author_2 = AuthorFactory.create(lastname='ctest1') @@ -274,7 +274,7 @@ def test_only_provides_authors_for_the_given_letter(self): def test_can_provide_contributors_of_article(self): issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now()) - article_1 = ArticleFactory.create(title="lorem ipsum", issue=issue_1) + article_1 = ArticleFactory.create( issue=issue_1) author_1 = AuthorFactory.create(lastname='btest') author_2 = AuthorFactory.create(lastname='ctest1') @@ -299,8 +299,8 @@ def test_can_provide_contributors_of_article(self): def test_can_filter_by_article_type(self): # Setup issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now()) - article_1 = ArticleFactory.create(title="lorem ipsum", issue=issue_1, type='article') - article_2 = ArticleFactory.create(title="lorem ipsum 2", issue=issue_1, type='compterendu') # noqa + article_1 = ArticleFactory.create( issue=issue_1, type='article') + article_2 = ArticleFactory.create( issue=issue_1, type='compterendu') # noqa author_1 = AuthorFactory.create(lastname='btest') article_1.authors.add(author_1) @@ -318,7 +318,7 @@ def test_can_filter_by_article_type(self): def test_can_filter_by_article_type_when_no_article_of_type(self): issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now()) - article_1 = ArticleFactory.create(title="lorem ipsum", issue=issue_1, type='article') + article_1 = ArticleFactory.create( issue=issue_1, type='article') author_1 = AuthorFactory.create(lastname='atest') article_1.authors.add(author_1) url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code}) @@ -333,7 +333,7 @@ def test_only_letters_with_results_are_active(self): """ Test that for a given selection in the authors list view, only the letters for which results are present are shown """ issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now()) - article_1 = ArticleFactory.create(title="lorem ipsum", issue=issue_1, type='article') + article_1 = ArticleFactory.create( issue=issue_1, type='article') author_1 = AuthorFactory.create(lastname='atest') article_1.authors.add(author_1) url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})