From 7cd247fb3432d6062ff01f3f05cda82c66cdbbdf Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Sun, 23 Sep 2018 21:31:04 +0200
Subject: [PATCH] Step 1.

---
 journals/constants.py                         |  4 +--
 .../migrations/0042_auto_20180923_2130.py     | 26 +++++++++++++++++++
 journals/models.py                            | 12 ++++++---
 3 files changed, 36 insertions(+), 6 deletions(-)
 create mode 100644 journals/migrations/0042_auto_20180923_2130.py

diff --git a/journals/constants.py b/journals/constants.py
index 529c204ef..477f07a6b 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 000000000..70e6f4956
--- /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 6858d5d59..6f2cd352e 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)
-- 
GitLab