diff --git a/journals/constants.py b/journals/constants.py index 529c204ef05a223473c915cee4cca47717b6fc6f..477f07a6b23b2a3279cef58b3d1a31910c614e50 100644 --- a/journals/constants.py +++ b/journals/constants.py @@ -33,7 +33,7 @@ REGEX_CHOICES = '|'.join([ # Regex used for URLs of specific Publications and for # doi validation during the publication process. PUBLICATION_DOI_REGEX = '({})'.format(REGEX_CHOICES) -PUBLICATION_DOI_REGEX += '.[0-9]+(.[0-9]+.[0-9]{3,})?' +PUBLICATION_DOI_REGEX += '.[0-9]+((.[0-9]+)?.[0-9]{3,})?' PUBLICATION_DOI_VALIDATION_REGEX = PUBLICATION_DOI_REGEX SCIPOST_JOURNALS_DOMAINS = ( @@ -93,6 +93,6 @@ ISSUES_ONLY = 'IO' INDIVIDUAL_PUBLCATIONS = 'IP' JOURNAL_STRUCTURE = ( (ISSUES_AND_VOLUMES, 'Issues and Volumes'), - # (ISSUES_ONLY, 'Issues only'), # This option complies with Crossref's rules, but is not implemented (yet). + (ISSUES_ONLY, 'Issues only'), (INDIVIDUAL_PUBLCATIONS, 'Individual Publications'), ) diff --git a/journals/migrations/0042_auto_20180923_2130.py b/journals/migrations/0042_auto_20180923_2130.py new file mode 100644 index 0000000000000000000000000000000000000000..70e6f49568399481e69c1b15c9dd0fab5addaa31 --- /dev/null +++ b/journals/migrations/0042_auto_20180923_2130.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-23 19:30 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0041_auto_20180922_1609'), + ] + + operations = [ + migrations.AlterField( + model_name='journal', + name='structure', + field=models.CharField(choices=[('IV', 'Issues and Volumes'), ('IO', 'Issues only'), ('IP', 'Individual Publications')], default='IV', max_length=2), + ), + migrations.AlterField( + model_name='publication', + name='doi_label', + field=models.CharField(db_index=True, max_length=200, unique=True, validators=[django.core.validators.RegexValidator('^(SciPostPhysProc|SciPostPhysSel|SciPostPhysLectNotes|SciPostPhys).[0-9]+((.[0-9]+)?.[0-9]{3,})?$', 'Only valid DOI expressions are allowed (`[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,}` or `[a-zA-Z]+.[0-9]+`)')]), + ), + ] diff --git a/journals/models.py b/journals/models.py index 6858d5d598aefe03a53924e268b81df915afad02..6f2cd352eb0690069008f865f12b0c10c21b6b0a 100644 --- a/journals/models.py +++ b/journals/models.py @@ -308,11 +308,15 @@ class Issue(models.Model): @property def issue_number(self): - return '%s issue %s' % (self.in_volume, self.number) + if self.in_volume: + return '%s issue %s' % (self.in_volume, self.number) + return self.short_str @property def short_str(self): - return 'Vol. %s issue %s' % (self.in_volume.number, self.number) + if self.in_volume: + return 'Vol. %s issue %s' % (self.in_volume.number, self.number) + return 'Issue %s' % self.number @property def period_as_string(self): @@ -321,8 +325,8 @@ class Issue(models.Model): return '%s - %s' % (self.start_date.strftime('%B'), self.until_date.strftime('%B %Y')) def is_current(self): - return self.start_date <= timezone.now().date() and\ - self.until_date >= timezone.now().date() + today = timezone.now().date() + return self.start_date <= today and self.until_date >= today def nr_publications(self, tier=None): publications = Publication.objects.filter(in_issue=self)