Skip to content

Commit

Permalink
Incorporação de códigos estáveis
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fonseca committed Dec 8, 2015
2 parents a0c8225 + b057cba commit 64894bc
Show file tree
Hide file tree
Showing 25 changed files with 6,960 additions and 60 deletions.
6 changes: 6 additions & 0 deletions scielomanager/api/resources_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class JournalResource(ModelResource):
study_areas = fields.ListField(readonly=True)
pub_status = fields.CharField(readonly=True)
pub_status_reason = fields.CharField(readonly=True)
national_code = fields.CharField(attribute='ccn_code', readonly=True)

#recursive field
previous_title = fields.ForeignKey('self', 'previous_title', null=True)
Expand Down Expand Up @@ -311,6 +312,11 @@ def dehydrate_pub_status_reason(self, bundle):

return bundle.obj.membership_info(col, 'reason')

def dehydrate(self, bundle):
# garantia de compatibilidade
bundle.data.pop('ccn_code', False)
return bundle


class PressReleaseTranslationResource(ModelResource):
language = fields.CharField(readonly=True)
Expand Down
6 changes: 6 additions & 0 deletions scielomanager/api/resources_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class JournalResource(ModelResource):
study_areas = fields.ListField(readonly=True)
pub_status = fields.CharField(readonly=True)
pub_status_reason = fields.CharField(readonly=True)
national_code = fields.CharField(attribute='ccn_code', readonly=True)

# Relation fields
creator = fields.ForeignKey(UserResource, 'creator')
Expand Down Expand Up @@ -303,6 +304,11 @@ def dehydrate_subject_categories(self, bundle):
return [subject_category.term
for subject_category in bundle.obj.subject_categories.all()]

def dehydrate(self, bundle):
# garantia de compatibilidade
bundle.data.pop('ccn_code', False)
return bundle


class PressReleaseTranslationResource(ModelResource):
language = fields.CharField(readonly=True)
Expand Down
11 changes: 2 additions & 9 deletions scielomanager/audit_log/tests/tests_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ def test_POST_valid_formdata_do_log(self):
'abstract_keyword_languages',
'subject_categories',
'study_areas',
'current_ahead_documents',
'previous_ahead_documents',
'title',
'title_iso',
'short_title',
Expand Down Expand Up @@ -203,10 +201,5 @@ def test_POST_valid_formdata_do_log(self):

# compare form data and stored new_values data
for k,v in log_entry.new_values['form_data'].iteritems():
if k in ['previous_ahead_documents', 'current_ahead_documents']:
# when created, are set by default to None,
# and when saved to db are transformed to jsonfield, is saved as u'None'
self.assertEqual(log_entry.new_values['form_data'][k], u'None')
else:
form_value = form['journal-%s' % k].value
self.assertEqual(log_entry.new_values['form_data'][k], force_unicode(v))
form_value = form['journal-%s' % k].value
self.assertEqual(log_entry.new_values['form_data'][k], force_unicode(v))
2 changes: 1 addition & 1 deletion scielomanager/journalmanager/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def clean_logo(self):
class Meta:

model = models.Journal
exclude = ('collections')
exclude = ('collections', 'previous_ahead_documents', 'current_ahead_documents')
# Overriding the default field types or widgets
widgets = {
'title': forms.TextInput(attrs={'class': 'span9'}),
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions scielomanager/journalmanager/migrations/0015_fix_nulls_in_init_vol.py

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions scielomanager/journalmanager/migrations/0016_fix_nulls_in_init_num.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions scielomanager/journalmanager/migrations/0022_fix_nulls_in_notes.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

141 changes: 96 additions & 45 deletions scielomanager/journalmanager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,78 +512,129 @@ class Journal(models.Model):
userobjects = modelmanagers.JournalManager()

# Relation fields
editor = models.ForeignKey(User, verbose_name=_('Editor'), related_name='editor_journal', null=True, blank=True)
creator = models.ForeignKey(User, related_name='enjoy_creator', editable=False)
sponsor = models.ManyToManyField('Sponsor', verbose_name=_('Sponsor'), related_name='journal_sponsor', null=True, blank=True)
previous_title = models.ForeignKey('Journal', verbose_name=_('Previous title'), related_name='prev_title', null=True, blank=True)
use_license = models.ForeignKey('UseLicense', verbose_name=_('Use license'), default=get_journals_default_use_license)
editor = models.ForeignKey(User, verbose_name=_('Editor'),
related_name='editor_journal', null=True, blank=True)
creator = models.ForeignKey(User, related_name='enjoy_creator',
editable=False)
sponsor = models.ManyToManyField('Sponsor', verbose_name=_('Sponsor'),
related_name='journal_sponsor', null=True, blank=True)
previous_title = models.ForeignKey('Journal', verbose_name=_('Previous title'),
related_name='prev_title', null=True, blank=True)
# licença de uso padrão definida pelo editor da revista
use_license = models.ForeignKey('UseLicense', verbose_name=_('Use license'),
default=get_journals_default_use_license)
collections = models.ManyToManyField('Collection', through='Membership')
languages = models.ManyToManyField('Language',)
national_code = models.CharField(_('National Code'), max_length=64, null=True, blank=True)
abstract_keyword_languages = models.ManyToManyField('Language', related_name="abstract_keyword_languages", )
subject_categories = models.ManyToManyField(SubjectCategory, verbose_name=_("Subject Categories"), related_name="journals", null=True)
study_areas = models.ManyToManyField(StudyArea, verbose_name=_("Study Area"), related_name="journals_migration_tmp", null=True)
# os idiomas que a revista publica conteúdo
languages = models.ManyToManyField('Language')
ccn_code = models.CharField(_("CCN Code"), max_length=64, default='',
blank=True, help_text=_("The code of the journal at the CCN database."))
# os idiomas que os artigos da revista apresentam as palavras-chave
abstract_keyword_languages = models.ManyToManyField('Language',
related_name="abstract_keyword_languages")
subject_categories = models.ManyToManyField(SubjectCategory,
verbose_name=_("Subject Categories"), related_name="journals",
null=True)
study_areas = models.ManyToManyField(StudyArea, verbose_name=_("Study Area"),
related_name="journals_migration_tmp", null=True)

# Fields
current_ahead_documents = models.IntegerField(_('Total of ahead of print documents for the current year'), max_length=3, default=0, blank=True, null=True)
previous_ahead_documents = models.IntegerField(_('Total of ahead of print documents for the previous year'), max_length=3, default=0, blank=True, null=True)
twitter_user = models.CharField(_('Twitter User'), max_length=128, null=True, blank=True)
current_ahead_documents = models.IntegerField(
_('Total of ahead of print documents for the current year'),
max_length=3, default=0, blank=True)
previous_ahead_documents = models.IntegerField(
_('Total of ahead of print documents for the previous year'),
max_length=3, default=0, blank=True)
twitter_user = models.CharField(_('Twitter User'), max_length=128,
default='', blank=True)
title = models.CharField(_('Journal Title'), max_length=256, db_index=True)
title_iso = models.CharField(_('ISO abbreviated title'), max_length=256, db_index=True)
short_title = models.CharField(_('Short Title'), max_length=256, db_index=True, null=True)
title_iso = models.CharField(_('ISO abbreviated title'), max_length=256,
db_index=True)
short_title = models.CharField(_('Short Title'), max_length=256,
db_index=True, default='')
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
acronym = models.CharField(_('Acronym'), max_length=16, blank=False)
scielo_issn = models.CharField(_('The ISSN used to build the Journal PID.'), max_length=16,
choices=sorted(choices.SCIELO_ISSN, key=lambda SCIELO_ISSN: SCIELO_ISSN[1]))
scielo_issn = models.CharField(_('The ISSN used to build the Journal PID.'),
max_length=16, choices=sorted(
choices.SCIELO_ISSN, key=lambda SCIELO_ISSN: SCIELO_ISSN[1]))
print_issn = models.CharField(_('Print ISSN'), max_length=9, db_index=True)
eletronic_issn = models.CharField(_('Electronic ISSN'), max_length=9, db_index=True)
subject_descriptors = models.CharField(_('Subject / Descriptors'), max_length=1024)
eletronic_issn = models.CharField(_('Electronic ISSN'), max_length=9,
db_index=True)
subject_descriptors = models.CharField(_('Subject / Descriptors'),
max_length=1024)
init_year = models.CharField(_('Initial Year'), max_length=4)
init_vol = models.CharField(_('Initial Volume'), max_length=16, null=True, blank=True)
init_num = models.CharField(_('Initial Number'), max_length=16, null=True, blank=True)
final_year = models.CharField(_('Final Year'), max_length=4, null=True, blank=True)
final_vol = models.CharField(_('Final Volume'), max_length=16, null=False, blank=True)
final_num = models.CharField(_('Final Number'), max_length=16, null=False, blank=True)
medline_title = models.CharField(_('Medline Title'), max_length=256, null=True, blank=True)
medline_code = models.CharField(_('Medline Code'), max_length=64, null=True, blank=True)
init_vol = models.CharField(_('Initial Volume'), max_length=16, default='',
blank=True)
init_num = models.CharField(_('Initial Number'), max_length=16, default='',
blank=True)
final_year = models.CharField(_('Final Year'), max_length=4, default='',
blank=True)
final_vol = models.CharField(_('Final Volume'), max_length=16, default='',
blank=True)
final_num = models.CharField(_('Final Number'), max_length=16, default='',
blank=True)
medline_title = models.CharField(_('Medline Title'), max_length=256,
default='', blank=True)
medline_code = models.CharField(_('Medline Code'), max_length=64,
default='', blank=True)
frequency = models.CharField(_('Frequency'), max_length=16,
choices=sorted(choices.FREQUENCY, key=lambda FREQUENCY: FREQUENCY[1]))
choices=sorted(
choices.FREQUENCY, key=lambda FREQUENCY: FREQUENCY[1]))
editorial_standard = models.CharField(_('Editorial Standard'), max_length=64,
choices=sorted(choices.STANDARD, key=lambda STANDARD: STANDARD[1]))
choices=sorted(choices.STANDARD, key=lambda STANDARD: STANDARD[1]))
ctrl_vocabulary = models.CharField(_('Controlled Vocabulary'), max_length=64,
choices=choices.CTRL_VOCABULARY)
choices=choices.CTRL_VOCABULARY)
pub_level = models.CharField(_('Publication Level'), max_length=64,
choices=sorted(choices.PUBLICATION_LEVEL, key=lambda PUBLICATION_LEVEL: PUBLICATION_LEVEL[1]))
secs_code = models.CharField(_('SECS Code'), max_length=64, null=False, blank=True)
choices=sorted(
choices.PUBLICATION_LEVEL, key=lambda PUBLICATION_LEVEL: PUBLICATION_LEVEL[1]))
secs_code = models.CharField(_('SECS Code'), max_length=64, default='',
blank=True)
# detentor dos direitos de uso
copyrighter = models.CharField(_('Copyrighter'), max_length=254)
url_online_submission = models.CharField(_('URL of online submission'), max_length=128, null=True, blank=True)
url_journal = models.CharField(_('URL of the journal'), max_length=128, null=True, blank=True)
notes = models.TextField(_('Notes'), max_length=254, null=True, blank=True)
index_coverage = models.TextField(_('Index Coverage'), null=True, blank=True)
cover = ContentTypeRestrictedFileField(_('Journal Cover'), upload_to='img/journal_cover/', null=True, blank=True,
content_types=settings.IMAGE_CONTENT_TYPE, max_upload_size=settings.JOURNAL_COVER_MAX_SIZE)
logo = ContentTypeRestrictedFileField(_('Journal Logo'), upload_to='img/journals_logos', null=True, blank=True,
content_types=settings.IMAGE_CONTENT_TYPE, max_upload_size=settings.JOURNAL_LOGO_MAX_SIZE)
is_trashed = models.BooleanField(_('Is trashed?'), default=False, db_index=True)
other_previous_title = models.CharField(_('Other Previous Title'), max_length=255, blank=True)
url_online_submission = models.CharField(_('URL of online submission'),
max_length=128, default='', blank=True)
url_journal = models.CharField(_('URL of the journal'), max_length=128,
default='', blank=True)
notes = models.TextField(_('Notes'), max_length=254, default='', blank=True)
index_coverage = models.TextField(_('Index Coverage'), default='',
blank=True)
cover = ContentTypeRestrictedFileField(_('Journal Cover'),
upload_to='img/journal_cover/', null=True, blank=True,
content_types=settings.IMAGE_CONTENT_TYPE,
max_upload_size=settings.JOURNAL_COVER_MAX_SIZE)
logo = ContentTypeRestrictedFileField(_('Journal Logo'),
upload_to='img/journals_logos', null=True, blank=True,
content_types=settings.IMAGE_CONTENT_TYPE,
max_upload_size=settings.JOURNAL_LOGO_MAX_SIZE)
is_trashed = models.BooleanField(_('Is trashed?'), default=False,
db_index=True)
other_previous_title = models.CharField(_('Other Previous Title'),
max_length=255, default='', blank=True)
editor_name = models.CharField(_('Editor Names'), max_length=512)
editor_address = models.CharField(_('Editor Address'), max_length=512)
editor_address_city = models.CharField(_('Editor City'), max_length=256)
editor_address_state = models.CharField(_('Editor State/Province/Region'), max_length=128)
editor_address_zip = models.CharField(_('Editor Zip/Postal Code'), max_length=64)
editor_address_state = models.CharField(_('Editor State/Province/Region'),
max_length=128)
editor_address_zip = models.CharField(_('Editor Zip/Postal Code'),
max_length=64)
editor_address_country = modelfields.CountryField(_('Editor Country'))
editor_phone1 = models.CharField(_('Editor Phone 1'), max_length=32)
editor_phone2 = models.CharField(_('Editor Phone 2'), null=True, blank=True, max_length=32)
editor_phone2 = models.CharField(_('Editor Phone 2'), null=True, blank=True,
max_length=32)
editor_email = models.EmailField(_('Editor E-mail'))
publisher_name = models.CharField(_('Publisher Name'), max_length=256)
publisher_country = modelfields.CountryField(_('Publisher Country'))
publisher_state = models.CharField(_('Publisher State/Province/Region'), max_length=64)
publisher_state = models.CharField(_('Publisher State/Province/Region'),
max_length=64)
publication_city = models.CharField(_('Publication City'), max_length=64)
is_indexed_scie = models.BooleanField(_('SCIE'), default=False)
is_indexed_ssci = models.BooleanField(_('SSCI'), default=False)
is_indexed_aehci = models.BooleanField(_('A&HCI'), default=False)

def __repr__(self):
return u'<%s pk="%s" acronym="%s">' % (self.__class__.__name__, self.pk,
self.acronym)

def __unicode__(self):
return self.title

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h2><a name="languages"></a>{% trans "Languages" %}:</h2>
<h2><a name="system_information"></a>{% trans "System Information" %}:</h2>
<div class="well">

{% with add_form.national_code as field %}
{% with add_form.ccn_code as field %}
{% include "journalmanager/includes/form_field_row.html" %}
{% endwith %}

Expand Down
5 changes: 1 addition & 4 deletions scielomanager/tools/import_data/journalimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def load_journal(self, collection, user, loaded_sponsor, record):

# National Code
if '20' in record:
journal.national_code = record['20'][0]
journal.ccn_code = record['20'][0]

# Publication Frequency
if '380' in record:
Expand All @@ -392,9 +392,6 @@ def load_journal(self, collection, user, loaded_sponsor, record):
if '340' in record:
journal.alphabet = record['340'][0]

if '20' in record:
journal.national_code = record['20'][0]

if '117' in record:
journal.editorial_standard = record['117'][0]

Expand Down

0 comments on commit 64894bc

Please sign in to comment.