From 0c9b2f1a20f55c374415803329bea26326071ad6 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Thu, 14 Jun 2018 12:13:10 +0200
Subject: [PATCH] Remove preprints from master branch

---
 preprints/admin.py                            | 10 -----
 preprints/apps.py                             |  9 ----
 preprints/helpers.py                          | 28 ------------
 preprints/migrations/0001_initial.py          | 32 --------------
 .../migrations/0002_auto_20180610_2014.py     | 36 ---------------
 preprints/migrations/__init__.py              |  0
 preprints/models.py                           | 44 -------------------
 preprints/tests.py                            |  7 ---
 preprints/urls.py                             | 12 -----
 preprints/views.py                            | 18 --------
 10 files changed, 196 deletions(-)
 delete mode 100644 preprints/admin.py
 delete mode 100644 preprints/apps.py
 delete mode 100644 preprints/helpers.py
 delete mode 100644 preprints/migrations/0001_initial.py
 delete mode 100644 preprints/migrations/0002_auto_20180610_2014.py
 delete mode 100644 preprints/migrations/__init__.py
 delete mode 100644 preprints/models.py
 delete mode 100644 preprints/tests.py
 delete mode 100644 preprints/urls.py
 delete mode 100644 preprints/views.py

diff --git a/preprints/admin.py b/preprints/admin.py
deleted file mode 100644
index 007cfbf49..000000000
--- a/preprints/admin.py
+++ /dev/null
@@ -1,10 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.contrib import admin
-
-from .models import Preprint
-
-
-admin.site.register(Preprint)
diff --git a/preprints/apps.py b/preprints/apps.py
deleted file mode 100644
index df188c72b..000000000
--- a/preprints/apps.py
+++ /dev/null
@@ -1,9 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.apps import AppConfig
-
-
-class ProceedingsConfig(AppConfig):
-    name = 'preprints'
diff --git a/preprints/helpers.py b/preprints/helpers.py
deleted file mode 100644
index 6c6c0577a..000000000
--- a/preprints/helpers.py
+++ /dev/null
@@ -1,28 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.db.models import Max
-from django.utils import timezone
-
-from .models import Preprint
-
-
-def generate_new_scipost_identifier():
-    """Return an identifier for a new SciPost preprint series without version number."""
-    now = timezone.now()
-    existing_identifier = Preprint.objects.filter(
-        created__year=now.year, created__month=now.month).aggregate(
-        identifier=Max('scipost_preprint_identifier'))['identifier']
-    if not existing_identifier:
-        existing_identifier = '1'
-    else:
-        existing_identifier = str(existing_identifier + 1)
-    return '{year}{month}_{identifier}'.format(
-        year=now.year, month=str(now.month).rjust(2, '0'),
-        identifier=existing_identifier.rjust(5, '0'))
-
-
-def format_scipost_identifier(self, identifier, version=1):
-    return 'scipost_{identifier}v{version}'.format(
-        identifier=identifier, version=version)
diff --git a/preprints/migrations/0001_initial.py b/preprints/migrations/0001_initial.py
deleted file mode 100644
index 25a0fe796..000000000
--- a/preprints/migrations/0001_initial.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.11.4 on 2018-06-10 18:14
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
-    initial = True
-
-    dependencies = [
-        ('submissions', '0025_auto_20180520_1430'),
-    ]
-
-    operations = [
-        migrations.CreateModel(
-            name='Preprint',
-            fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('scipost_preprint_identifier', models.PositiveIntegerField(blank=True, null=True)),
-                ('identifier_wo_vn_nr', models.CharField(blank=True, max_length=25)),
-                ('vn_nr', models.PositiveSmallIntegerField(default=1)),
-                ('url', models.URLField()),
-                ('_file', models.FileField(blank=True, max_length=200, upload_to='UPLOADS/PREPRINTS/%Y/%m/')),
-                ('modified', models.DateTimeField(auto_now=True)),
-                ('created', models.DateTimeField(auto_now_add=True)),
-                ('submission', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='submissions.Submission')),
-            ],
-        ),
-    ]
diff --git a/preprints/migrations/0002_auto_20180610_2014.py b/preprints/migrations/0002_auto_20180610_2014.py
deleted file mode 100644
index 138259df6..000000000
--- a/preprints/migrations/0002_auto_20180610_2014.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.11.4 on 2018-06-10 18:14
-from __future__ import unicode_literals
-from datetime import datetime
-
-from django.db import migrations
-
-
-def create_preprint_instances(apps, schema_editor):
-    """Add a Preprint instance for each existing Submission."""
-    Preprint = apps.get_model('preprints', 'Preprint')
-    Submission = apps.get_model('submissions', 'Submission')
-
-    for submission in Submission.objects.all():
-        dt = datetime(
-            year=submission.submission_date.year,
-            month=submission.submission_date.month,
-            day=submission.submission_date.day)
-        Preprint.objects.create(
-            submission=submission,
-            identifier_wo_vn_nr=submission.arxiv_identifier_wo_vn_nr,
-            vn_nr=submission.arxiv_vn_nr,
-            url=submission.arxiv_link,
-            modifier=submission.latest_activity,
-            created=dt)
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('preprints', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.RunPython(create_preprint_instances),
-    ]
diff --git a/preprints/migrations/__init__.py b/preprints/migrations/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/preprints/models.py b/preprints/models.py
deleted file mode 100644
index f08ad2e5b..000000000
--- a/preprints/models.py
+++ /dev/null
@@ -1,44 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.core.urlresolvers import reverse
-from django.db import models
-from django.http import Http404
-
-
-class Preprint(models.Model):
-    """A link with ArXiv or standalone/SciPost-hosted preprint.
-
-    If the instance is a scipost preprint, the `_file` and `scipost_preprint_identifier` fields
-    should be filled. Else, these fields should be left blank.
-    """
-
-    submission = models.OneToOneField('submissions.Submission')
-
-    # (ArXiv) identifiers with/without version number
-    # identifier_w_vn_nr = models.CharField(max_length=25, blank=True)
-    scipost_preprint_identifier = models.PositiveIntegerField(null=True, blank=True)
-    identifier_wo_vn_nr = models.CharField(max_length=25, blank=True)
-    vn_nr = models.PositiveSmallIntegerField(default=1)
-    url = models.URLField()
-
-    _file = models.FileField(upload_to='UPLOADS/PREPRINTS/%Y/%m/', max_length=200, blank=True)
-
-    # Dates
-    modified = models.DateTimeField(auto_now=True)
-    created = models.DateTimeField(auto_now_add=True)
-
-    def __str__(self):
-        return 'Preprint {}'.format(self.identifier_w_vn_nr)
-
-    def get_absolute_url(self):
-        if self.url:
-            return self.url
-        if self._file:
-            return reverse('preprints:pdf', self.identifier_w_vn_nr)
-        raise Http404
-
-    @property
-    def identifier_w_vn_nr(self):
-        return '{}v{}'.format(self.identifier_wo_vn_nr, self.vn_nr)
diff --git a/preprints/tests.py b/preprints/tests.py
deleted file mode 100644
index 9135c42ab..000000000
--- a/preprints/tests.py
+++ /dev/null
@@ -1,7 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.test import TestCase
-
-# Create your tests here.
diff --git a/preprints/urls.py b/preprints/urls.py
deleted file mode 100644
index 6f5dc5eec..000000000
--- a/preprints/urls.py
+++ /dev/null
@@ -1,12 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.conf.urls import url
-
-from . import views
-
-
-urlpatterns = [
-    url(r'^$', views.preprint_pdf, name='pdf'),
-]
diff --git a/preprints/views.py b/preprints/views.py
deleted file mode 100644
index 67222f676..000000000
--- a/preprints/views.py
+++ /dev/null
@@ -1,18 +0,0 @@
-__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django.http import HttpResponse
-from django.shortcuts import get_object_or_404
-
-from .models import Preprint
-
-
-def preprint_pdf(request, identifier_w_vn_nr):
-    """Download the attachment of a Report if available."""
-    preprint = get_object_or_404(Preprint, identifier_w_vn_nr=identifier_w_vn_nr, _file__isnull=False)
-
-    response = HttpResponse(preprint._file.read(), content_type='application/pdf')
-    filename = '{}_preprint.pdf'.format(preprint.identifier_w_vn_nr)
-    response['Content-Disposition'] = ('filename=' + filename)
-    return response
-- 
GitLab