Permalink
Browse files

Merge branch 'master' into tk62

  • Loading branch information...
2 parents 9d67735 + 2886d67 commit c8e94b3bb3580e714861d13aa50a507e8b9151fb @gustavofonseca committed Mar 4, 2013
View
@@ -34,3 +34,13 @@ _template
#OPAC
settings_local.include
settings_opac.include
+
+
+#DJANGO-ASSETS
+bundle.min.js
+bundle.min.css
+.webassets-cache
+
+#DEV Database
+data.sqlite
+
View
@@ -0,0 +1,22 @@
+#
+# DEVE SER MANTIDA A ORDEM DOS ARQUIVOS JS e CSS
+#
+
+from django_assets import Bundle, register
+
+base_bundle = Bundle('../static/js/jquery-1.9.1.js')
+
+app_bundle = Bundle('../static/js/languages.js',
+ '../static/js/ratchet.js',
+ '../static/js/bootstrap.js')
+
+js = Bundle(base_bundle, app_bundle, filters='yui_js', output='bundle.min.js')
+
+register('js', js)
+
+css = Bundle('../static/css/bootstrap.css',
+ '../static/css/style.css',
+ filters='yui_css',
+ output='bundle.min.css')
+
+register('css', css)
@@ -0,0 +1,6 @@
+# coding: utf-8
+from django.conf import settings
+
+
+def access_to_settings(request):
+ return {'SETTINGS': settings}
@@ -282,22 +282,28 @@ def list_journals_by_study_areas(mongomanager_lib=MongoManager):
class Journal(Document):
objects = ManagerFactory(collection='journals', indexes=[
- 'issue_ref', 'title', 'study_areas', 'id',
+ 'issue_ref', 'title', 'study_areas', 'id', 'previous_title',
{'attr': 'acronym', 'unique': True}
])
_twitter_api = twitter.Api()
@classmethod
- def get_journal(cls, journal_id):
+ def get_journal(cls, criteria=None):
"""
- Return a specific journal
+ Return a specific journal by acronym or by any valid criteria
+ IMPORTANT: Try using indexed fields in the parameter criteria
"""
- journal = cls.objects.find_one({'acronym': journal_id})
+ criteria = {} if criteria is None else criteria
+
+ if not isinstance(criteria, dict):
+ raise ValueError('criteria must be dict')
+
+ journal = cls.objects.find_one(criteria)
if not journal:
- raise ValueError('no journal found for id:'.format(journal_id))
+ raise ValueError('no journal found for this citeria')
return cls(**journal)
@@ -331,6 +337,10 @@ def list_issues_as_grid(self):
return grid
+ def get_resource_id(self, resource):
+ cleaned = [seg for seg in resource.split('/') if seg]
+ return cleaned[-1]
+
@property
def issues_count(self):
try:
@@ -429,12 +439,56 @@ def history(self):
history_list = []
for history in self.pub_status_history:
- history_date = datetime.strptime(history['date'], '%Y-%m-%dT%H:%M:%S')
+ history_date = datetime.strptime(history['date'][:19], '%Y-%m-%dT%H:%M:%S')
history_list.append({'history_date': history_date,
'reason': history['status']})
return history_list
+ @property
+ def last_date_history(self):
+ """
+ This property get the last date status from journal
+ """
+
+ date_list = []
+
+ for history in self.pub_status_history:
+ date = datetime.strptime(history['date'][:19], '%Y-%m-%dT%H:%M:%S')
+ date_list.append(date)
+
+ if date_list:
+ return max(date_list)
+
+ @property
+ def former_journal(self):
+ """
+ This property get the former journal by the api path ```/api/v1/journals/2/```
+ """
+
+ if self.previous_title:
+ journal = Journal.get_journal(
+ criteria={
+ 'id': int(self.get_resource_id(self.previous_title))
+ })
+
+ return journal
+
+ @property
+ def latter_journal(self):
+ """
+ This property get the new journal by api ```/api/v1/journals/2/``` using
+ the mongo regex operator
+ """
+ try:
+ journal = Journal.get_journal(
+ criteria={
+ 'previous_title': {'$regex': '/*/*/*/' + str(self.id) + '/'}
+ })
+ return journal
+ except:
+ return None
+
class Issue(Document):
objects = ManagerFactory(collection='journals', indexes=['issues.id'])
@@ -461,7 +515,7 @@ def journal(self):
This method retrieves the journal related to issue instance.
"""
- journal = Journal.get_journal(journal_id=self._data['acronym'])
+ journal = Journal.get_journal({'acronym': self._data['acronym']})
return journal
@@ -1,11 +1,13 @@
{% load i18n %}
+{% load assets %}
<!DOCTYPE html>
<html>
<head>
<title>SciELO Brasil</title>
- <link rel="stylesheet" type="text/css" href="/static/css/bootstrap/css/bootstrap.css" />
- <link rel="stylesheet" type="text/css" href="/static/css/style.css" />
+ {% assets "css" %}
+ <link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}"/>
+ {% endassets %}
<meta charset="UTF-8" />
</head>
<body>
@@ -63,9 +65,9 @@
</div>
</div>
{% block main_js %}
- <script type="text/javascript" src="/static/js/jquery-1.9.0.min.js"></script>
- <script type="text/javascript" src="/static/css/bootstrap/js/bootstrap.js"></script>
- <script type="text/javascript" src="/static/js/languages.js"></script>
+ {% assets "js" %}
+ <script type="text/javascript" src="{{ ASSET_URL }}"></script>
+ {% endassets %}
<script type="text/javascript">
$(document).ready(function(){
options = {placement:'bottom'}
@@ -84,12 +84,28 @@ <h3 style="text-align: center;">{% trans 'Library Collection' %}</h3>
{% for journal in journals_list %}
<dl>
- <dt>{{ journal.grouper|capfirst }} {% trans 'titles' %} - {{journal.list|length}} {% trans 'serial(s) listed' %}</dt>
+ <dt>{{ journal.grouper|capfirst }} {% trans 'titles' %} - {{ journal.list|length }} {% trans 'serial(s) listed' %}</dt>
<dd>
<ul class="unstyled">
{% for item in journal.list %}
{% ifchanged item.title.0 %} <li>&nbsp;</li> {% endifchanged %}
- <li><a href="{{item.get_absolute_url}}">{{ item.title }}</a> - {{ item.issues_count }} {% trans 'issues' %}</li>
+ <li><a href="{{item.get_absolute_url}}">{{ item.title }}</a>
+ - {{ item.issues_count }} {% trans 'issues' %}
+ {% if item.latter_journal and item.pub_status = 'deceased' %}
+ - <small>
+ <em>{% trans 'Continued as' %}</em>
+ </small>
+ <a href={% url 'catalog.journal' item.latter_journal.acronym %}>{{ item.latter_journal.title }}</a>
+ {% elif item.pub_status = 'deceased' %}
+ - <small>
+ <em>{% trans 'Deceased in ' %} - {{ item.last_date_history|date:"F d, Y" }}</em>
+ </small>
+ {% elif item.pub_status = 'suspended' %}
+ - <small>
+ <em>{% trans 'Indexing interrupted by committee in ' %} {{ item.last_date_history|date:"F d, Y" }}</em>
+ </small>
+ {% endif %}
+ </li>
{% endfor %}
</ul>
</dd>
@@ -12,7 +12,7 @@
<h4>{% trans 'Table of Contents' %}</h4>
<h4>{{ journal.short_title }} vol.{{ issue.volume }} n.{{ issue.number }} {{ journal.publication_city }} {{ issue.publication_start_month }} {{ issue.publication_end_month }} {{ issue.publication_year }}</h4>
- {% list_articles_by_section sections LANGUAGE_CODE %}
+ list_articles_by_section sections LANGUAGE_CODE
</div>
{% endblock %}
@@ -54,4 +54,12 @@
<li><i class="icon-play"></i> <a href="#" target="_blank">{% trans 'statistics' %}</a></li>
</ul>
</blockquote>
+{% endblock %}
+
+{% block extra_js %}
+<script type="text/javascript">
+ $(document).ready(function() {
+ {% ratchet_caller resource='issue' code=issue.id journal=journal.id %}
+ });
+</script>
{% endblock %}
@@ -1,4 +1,5 @@
{% extends "base_lv1.html" %}
+{% load catalogtags %}
{% load i18n %}
{% block body %}
@@ -65,6 +66,16 @@
<strong>{% trans 'e-mail' %}: </strong> <a href="mailto: {{ journal.editor_email }}">{{ journal.editor_email }}</a>
{% endif %}
</dd>
+ <dd>
+ {% if journal.former_journal %}
+ <strong>{% trans 'Former Title:' %}</strong>
+ <a href={% url 'catalog.journal' journal.former_journal.acronym %}> {{ journal.former_journal.title }}</a>
+ {% endif %}
+ {% if journal.latter_journal %}
+ <strong>{% trans 'New Title:' %}</strong>
+ <a href={% url 'catalog.journal' journal.latter_journal.acronym %}> {{ journal.latter_journal.title }}</a>
+ {% endif %}
+ </dd>
</dl>
</div>
<div class="span3">
@@ -117,9 +128,9 @@
}
});
}
-
$(document).ready(function() {
qry_tweets();
+ {% ratchet_caller resource='journal' code=journal.id %}
});
</script>
{% endblock %}
@@ -102,10 +102,24 @@ <h3 style="text-align: center;">{% trans 'Library Collection' %}</h3>
<dd>
<ul class="unstyled">
{% for item in journal.list %}
- <li><a href="{{ item.get_absolute_url }}">{{ item.title }}</a> - {{ item.issues_count }} {% trans 'issues' %}</li>
- {% if not forloop.last %}
- {% ifchanged item.title.0 %} <li>&nbsp;</li> {% endifchanged %}
+ {% ifchanged item.title.0 %} <li>&nbsp;</li> {% endifchanged %}
+ <li><a href="{{ item.get_absolute_url }}">{{ item.title }}</a>
+ - {{ item.issues_count }} {% trans 'issues' %}
+ {% if item.latter_journal and item.pub_status = 'deceased' %}
+ - <small>
+ <em>{% trans 'Continued as' %}</em>
+ </small>
+ <a href={% url 'catalog.journal' item.latter_journal.acronym %}>{{ item.latter_journal.title }}</a>
+ {% elif item.pub_status = 'deceased' %}
+ - <small>
+ <em>{% trans 'Deceased in ' %} - {{ item.last_date_history|date:"F d, Y" }}</em>
+ </small>
+ {% elif item.pub_status = 'suspended' %}
+ - <small>
+ <em>{% trans 'Indexing interrupted by committee in ' %} {{ item.last_date_history|date:"F d, Y" }}</em>
+ </small>
{% endif %}
+ </li>
{% endfor %}
</ul>
</dd>
@@ -1,10 +1,28 @@
+import json
+
from django import template
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
+from django.conf import settings
+
register = template.Library()
+@register.simple_tag
+def ratchet_caller(**attributes):
+
+ if settings.DEBUG:
+ return ''
+
+ attributes['ratchet_uri'] = settings.RATCHET_URI
+ js = json.dumps(attributes)
+ snippet = u'ratchet_obj = {0}; send_access(ratchet_obj);'.format(js)
+
+ return snippet
+
+
+@register.simple_tag
def list_articles_by_section(sections, language):
snippet = u'<dl class="issue_toc">'
@@ -36,5 +54,3 @@ def list_articles_by_section(sections, language):
snippet += u'</dl>'
return snippet
-
-register.simple_tag(list_articles_by_section)
Oops, something went wrong.

0 comments on commit c8e94b3

Please sign in to comment.