Skip to content

Commit

Permalink
Merge pull request #1214 from scieloorg/beta
Browse files Browse the repository at this point in the history
Incorporação de códigos estáveis
  • Loading branch information
gustavofonseca committed Sep 3, 2015
2 parents d1d6004 + ad02611 commit f792b29
Show file tree
Hide file tree
Showing 78 changed files with 9,764 additions and 3,988 deletions.
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ South
psycopg2==2.4.1
wsgiref==0.1.2
scielo-django-extensions==0.4
python-memcached==1.48
ordereddict==1.1
pillow==2.3.0
django-widget-tweaks==1.1.1
Expand All @@ -14,7 +13,6 @@ yuicompressor
jsonfield
django-tastypie==0.9.16
django-htmlmin==0.7.0
-e git+git://github.com/scieloorg/django-cache-machine.git#egg=django-cache-machine
packtools
Celery
django-celery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h4>{% trans "You are not authorized to access the requested page." %}</h4>
{% trans " Maybe you want to " %}
<a href="{% url journalmanager.user_login %}{% if next %}?next={{ next }}{% endif %}">
{% trans "login <strong>with a more previleged account</strong></a> or contact support." %}
{% trans "login <strong>with a more privileged account</strong></a> or contact support." %}
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</td>
</tr>
<tr>
<td class="table-journal-detail-td"><b>{% trans 'Lanaguages' %}:</b></td>
<td class="table-journal-detail-td"><b>{% trans 'Languages' %}:</b></td>
<td>
<ul>
{% for lang in journal.languages.all %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<i class="icon-pencil"></i> {% trans 'Edit Journal' %}
</a>
<a href="{% url editorial.board journal.pk %}" class="btn btn-mini">
<i class="icon-list-alt"></i> {% trans 'Corpo editorial' %}
<i class="icon-list-alt"></i> {% trans 'Editorial Board' %}
</a>
</div>
</td>
Expand Down
2 changes: 1 addition & 1 deletion scielomanager/export/templates/export/markup_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="controls">
{{ form.issue }}
<span id="loading" style="display: none; margin: 5px;">
<img src="/static/images/loading.gif" width="20px" heigth="20px" />
<img src="{% static 'img/loading.gif' %}" width="20px" heigth="20px" />
{% trans 'Retrieving its issues' %}
</span>
</div>
Expand Down
18 changes: 2 additions & 16 deletions scielomanager/health/checks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#coding: utf-8
# coding: utf-8
import logging
import uuid

import psycopg2
from django.db import connections, DatabaseError
from django.core.cache import cache
from celery import current_app
from kombu import Connection

Expand All @@ -24,6 +23,7 @@ class PGConnection(CheckItem):
psycopg2.extensions.STATUS_IN_TRANSACTION,
psycopg2.extensions.STATUS_PREPARED,
)

def __init__(self):
self.must_fail = False

Expand Down Expand Up @@ -55,20 +55,6 @@ def __call__(self):
return True


class CachingBackend(CheckItem):
"""
Connection with the caching backend
"""
def __call__(self):
key = uuid.uuid4().hex

try:
ret_code = cache.add(key, '\x01', timeout=1)
return bool(ret_code)
finally:
cache.delete(key)


class CeleryConnection(CheckItem):
"""
Connection with celery backend.
Expand Down
2 changes: 0 additions & 2 deletions scielomanager/health/management/commands/healthd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
def get_checklist():
checklist = health.CheckList()
checklist.add_check(checks.PGConnection())
checklist.add_check(checks.CachingBackend())
checklist.add_check(checks.CeleryConnection())
checklist.add_check(checks.RabbitConnection())

Expand Down Expand Up @@ -58,4 +57,3 @@ def handle(self, *args, **kwargs):
server.run()
except KeyboardInterrupt:
logger.info('healthd is shutting down')

80 changes: 9 additions & 71 deletions scielomanager/journalmanager/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,20 @@ class SectionTitleInline(admin.StackedInline):
model = SectionTitle


class StudyAreaAdmin(admin.ModelAdmin):

def queryset(self, request):
return StudyArea.nocacheobjects

admin.site.register(StudyArea, StudyAreaAdmin)
admin.site.register(StudyArea)


class CollectionAdmin(admin.ModelAdmin):

def queryset(self, request):
return Collection.nocacheobjects

list_display = ('name',)
search_fields = ('name',)

admin.site.register(Collection, CollectionAdmin)


class SectionAdmin(admin.ModelAdmin):

def queryset(self, request):
return Section.nocacheobjects

admin.site.register(Section, SectionAdmin)
admin.site.register(Section)


class JournalAdmin(admin.ModelAdmin):

def queryset(self, request):
return Journal.nocacheobjects

list_display = ('title',)
search_fields = ('title',)
filter_horizontal = ('languages',)
Expand All @@ -62,31 +44,19 @@ def queryset(self, request):


class InstitutionAdmin(admin.ModelAdmin):

def queryset(self, request):
return Institution.nocacheobjects

list_display = ('name',)
search_fields = ('name',)

admin.site.register(Institution, InstitutionAdmin)


class UserCollectionsInline(admin.TabularInline):

def queryset(self, request):
return UserCollections.nocacheobjects

model = UserCollections
extra = 1
can_delete = True


class UserProfileInline(admin.StackedInline):

def queryset(self, request):
return UserProfile.nocacheobjects

model = UserProfile
max_num = 1
can_delete = True
Expand Down Expand Up @@ -127,83 +97,51 @@ def profile_email_notifications(self, user):


class IssueAdmin(admin.ModelAdmin):

def queryset(self, request):
return Issue.nocacheobjects

search_fields = ('publication_year', 'volume', 'number', 'journal__title')
list_display = ('journal', 'volume', 'number', 'is_trashed', 'is_marked_up', '__unicode__',)

admin.site.register(Issue, IssueAdmin)


class SponsorAdmin(admin.ModelAdmin):

def queryset(self, request):
return Sponsor.nocacheobjects

filter_horizontal = ('collections',)

admin.site.register(Sponsor, SponsorAdmin)


class UseLicenseAdmin(admin.ModelAdmin):
list_display = ('license_code', 'is_default', )
def queryset(self, request):
return UseLicense.nocacheobjects

admin.site.register(UseLicense, UseLicenseAdmin)


class LanguageAdmin(admin.ModelAdmin):

def queryset(self, request):
return Language.nocacheobjects

admin.site.register(Language, LanguageAdmin)


class TranslatedDataAdmin(admin.ModelAdmin):

def queryset(self, request):
return TranslatedData.nocacheobjects

admin.site.register(Language)
admin.site.register(TranslatedData)
admin.site.register(PressRelease)


class PressReleaseAdmin(admin.ModelAdmin):

def queryset(self, request):
return PressRelease.nocacheobjects

admin.site.register(PressRelease, PressReleaseAdmin)


#--------
# --------
# Article
#--------
# --------

def is_linked_to_issue(article):
return bool(article.issue)
is_linked_to_issue.boolean = True


def is_linked_to_journal(article):
return bool(article.journal)
is_linked_to_issue.boolean = True


class ArticleAdmin(admin.ModelAdmin):
list_display = (
'aid', 'xml_version', 'domain_key','updated_at',
'aid', 'xml_version', 'domain_key', 'updated_at',
is_linked_to_issue, is_linked_to_journal,
)
list_filter = ('issue__journal',)
date_hierarchy = 'updated_at'
actions = ['link_to_issue', 'link_to_journal']
readonly_fields = ('domain_key', 'xml', 'is_aop', 'xml_version', )

def queryset(self, request):
return Article.nocacheobjects

def link_to_issue(self, request, queryset):
for article in queryset:
tasks.link_article_to_issue.delay(article.pk)
Expand Down
25 changes: 19 additions & 6 deletions scielomanager/journalmanager/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,26 @@ def clean_cover(self):
if cover:
if not cover.name:
if cover.content_type not in settings.IMAGE_CONTENT_TYPE:
raise forms.ValidationError(_(u"Journal cover image extension is not allowed! Please select another file."))
raise forms.ValidationError(
_(u"Journal cover image extension is not allowed! Please select another file."))

if cover.size > settings.JOURNAL_COVER_MAX_SIZE:
raise forms.ValidationError(_(u"Journal cover image file size is too large! Please select another file."))
raise forms.ValidationError(
_(u"Journal cover image file size is too large! Please select another file."))

w, h = get_image_dimensions(cover)

if w != settings.IMAGE_DIMENSIONS['width_cover']:
raise forms.ValidationError(_(u"The image is %ipx pixel wide. It's supposed to be %spx") % (w, settings.IMAGE_DIMENSIONS['width_cover']))
raise forms.ValidationError(
_(u"The image is {image_size}px pixel wide. It's supposed to be {expected_size}px".format(
image_size=w,
expected_size=settings.IMAGE_DIMENSIONS['width_cover'])))

if h != settings.IMAGE_DIMENSIONS['height_cover']:
raise forms.ValidationError("The image is %ipx pixel high. It's supposed to be %spx" % (h, settings.IMAGE_DIMENSIONS['height_cover']))
raise forms.ValidationError(
_("The image is {image_size}px pixel high. It's supposed to be {expected_size}px".format(
image_size=h,
expected_size=settings.IMAGE_DIMENSIONS['height_cover'])))

return cover

Expand All @@ -211,9 +220,13 @@ def clean_logo(self):
w, h = get_image_dimensions(logo)

if w != settings.IMAGE_DIMENSIONS['width_logo']:
raise forms.ValidationError(_("The image is %ipx pixel wide. It's supposed to be %spx") % (w, settings.IMAGE_DIMENSIONS['width_logo']))
raise forms.ValidationError(_("The image is {logo_size}px pixel wide. It's supposed to be {expected_size}px".format(
logo_size=w,
expected_size=settings.IMAGE_DIMENSIONS['width_logo'])))
if h != settings.IMAGE_DIMENSIONS['height_logo']:
raise forms.ValidationError(_("The image is %ipx pixel high. It's supposed to be %spx") % (h, settings.IMAGE_DIMENSIONS['height_logo']))
raise forms.ValidationError(_("The image is {logo_size}px pixel high. It's supposed to be {expected_size}px".format(
logo_size=h,
expected_size=settings.IMAGE_DIMENSIONS['height_logo'])))

return logo

Expand Down
1 change: 0 additions & 1 deletion scielomanager/journalmanager/modelmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* ``unavailable`` returns all objects marked as trash.
"""
import caching.base
import models
from scielomanager.utils import usercontext
from scielomanager.utils.modelmanagers import UserObjectQuerySet, UserObjectManager
Expand Down
Loading

0 comments on commit f792b29

Please sign in to comment.