Skip to content

Commit

Permalink
Merge branch 'master' into v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrbyers committed Aug 10, 2018
2 parents 87632c9 + 7b4d036 commit 6899c46
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 678 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ src/texture/**
Dockerfile

*.ipynb

janeway\.sublime-project

janeway\.sublime-workspace

terminal\.glue
758 changes: 97 additions & 661 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ markdown2
mock
mysqlclient
pdfkit
Pillow==3.1.1
Pillow==5.2.0
pyasn1==0.1.9
pycparser==2.14
PyJWT==1.6.1
Expand Down
16 changes: 11 additions & 5 deletions src/production/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def production_list(request):
"""
assigned_table = models.ProductionAssignment.objects.all()
my_table = models.ProductionAssignment.objects.values_list('article_id', flat=True).filter(
production_manager=request.user)
production_manager=request.user, article__journal=request.journal)

assigned = [assignment.article.pk for assignment in assigned_table]
unassigned_articles = submission_models.Article.objects.filter(stage=submission_models.STAGE_TYPESETTING).exclude(
unassigned_articles = submission_models.Article.objects.filter(
stage=submission_models.STAGE_TYPESETTING, journal=request.journal).exclude(
id__in=assigned)
assigned_articles = submission_models.Article.objects.filter(stage=submission_models.STAGE_TYPESETTING).exclude(
assigned_articles = submission_models.Article.objects.filter(
stage=submission_models.STAGE_TYPESETTING, journal=request.journal).exclude(
id__in=unassigned_articles)

my_articles = submission_models.Article.objects.filter(stage=submission_models.STAGE_TYPESETTING, id__in=my_table)
Expand Down Expand Up @@ -81,7 +83,7 @@ def production_assign_article(request, user_id, article_id):
else:
messages.add_message(request, messages.WARNING, 'User is not a production manager.')

return redirect('production_list')
return redirect(reverse('production_list'))


@editor_user_required
Expand All @@ -97,7 +99,7 @@ def production_unassign_article(request, article_id):

models.ProductionAssignment.objects.filter(article=article).delete()

return redirect('production_list')
return redirect(reverse('production_list'))


@require_POST
Expand Down Expand Up @@ -141,6 +143,7 @@ def production_done(request, article_id):
return redirect('proofing_list')


@article_stage_production_required
@production_user_or_editor_required
def production_article(request, article_id):
"""
Expand Down Expand Up @@ -197,6 +200,7 @@ def production_article(request, article_id):
return render(request, template, context)


@article_stage_production_required
@production_user_or_editor_required
def assign_typesetter(request, article_id, production_assignment_id):
"""
Expand Down Expand Up @@ -237,6 +241,7 @@ def assign_typesetter(request, article_id, production_assignment_id):
return render(request, template, context)


@article_stage_production_required
@production_user_or_editor_required
def notify_typesetter(request, typeset_id):
"""
Expand Down Expand Up @@ -270,6 +275,7 @@ def notify_typesetter(request, typeset_id):
return render(request, template, context)


@article_stage_production_required
@production_user_or_editor_required
def edit_typesetter_assignment(request, typeset_id):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/security/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def wrapper(request, *args, **kwargs):

article = models.Article.get_article(request.journal, 'id', article_id)

if article.stage == models.STAGE_TYPESETTING:
if article and article.stage == models.STAGE_TYPESETTING:
return func(request, *args, **kwargs)
else:
raise PermissionDenied
Expand Down
1 change: 1 addition & 0 deletions src/submission/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FrozenAuthorAdmin(admin.ModelAdmin):


class ArticleAdmin(admin.ModelAdmin):
list_display = ('title', 'date_submitted', 'journal', 'stage', 'owner', 'is_import', 'ithenticate_score')
list_display = ('pk', 'title', 'date_submitted', 'stage', 'owner', 'is_import', 'ithenticate_score')
search_fields = ('title', 'subtitle')
list_filter = ('stage', 'is_import', 'journal')
Expand Down
20 changes: 20 additions & 0 deletions src/submission/migrations/0027_auto_20180806_1005.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-08-06 10:05
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('submission', '0026_auto_20180510_0845'),
]

operations = [
migrations.AlterField(
model_name='article',
name='abstract',
field=models.TextField(blank=True, null=True),
),
]
7 changes: 4 additions & 3 deletions src/submission/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class Article(models.Model):
title = models.CharField(max_length=300, help_text=_('Your article title'))
subtitle = models.CharField(max_length=300, blank=True, null=True,
help_text=_('Subtitle of the article display format; Title: Subtitle'))
abstract = models.TextField(blank=True)
abstract = models.TextField(blank=True, null=True)
non_specialist_summary = models.TextField(blank=True, null=True, help_text='A summary of the article for'
' non specialists.')
keywords = models.ManyToManyField(Keyword, blank=True, null=True)
Expand Down Expand Up @@ -569,10 +569,11 @@ def get_article(journal, identifier_type, identifier):
# resolve an article from an identifier type and an identifier
if identifier_type.lower() == 'id':
# this is the hardcoded fallback type: using built-in id
article = Article.allarticles.filter(id=identifier)[0]
article = Article.allarticles.filter(id=identifier, journal=journal)[0]
else:
# this looks up an article by an ID type and an identifier string
article = identifier_models.Identifier.objects.filter(id_type=identifier_type, identifier=identifier)[0].article
article = identifier_models.Identifier.objects.filter(
id_type=identifier_type, identifier=identifier)[0].article

# check that the retrieved article is listed in an issue TOC for the current journal
article_journals = [issue.journal for issue in article.issues.all()]
Expand Down
5 changes: 5 additions & 0 deletions src/utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ class LogAdmin(admin.ModelAdmin):
list_display = ('types', 'date', 'level', 'actor', 'ip_address', 'is_email', 'target')


class VersionAdmin(admin.ModelAdmin):
list_display = ('number', 'date')


admin_list = [
(models.LogEntry, LogAdmin),
(models.Plugin, PluginAdmin),
(models.PluginSetting, PluginSettingAdmin),
(models.PluginSettingValue, SettingValueAdmin),
(models.ImportCacheEntry, ImportCacheAdmin),
(models.Version, VersionAdmin)
]

[admin.site.register(*t) for t in admin_list]
24 changes: 24 additions & 0 deletions src/utils/migrations/0008_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-08-08 15:07
from __future__ import unicode_literals

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('utils', '0007_auto_20171215_1051'),
]

operations = [
migrations.CreateModel(
name='Version',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('number', models.CharField(max_length=5)),
('date', models.DateTimeField(default=django.utils.timezone.now)),
],
),
]
32 changes: 32 additions & 0 deletions src/utils/migrations/0009_auto_20180808_1514.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-08-08 15:14
from __future__ import unicode_literals

from django.db import migrations


def create_version(apps, schema_editor):
Version = apps.get_model('utils', 'Version')

versions = Version.objects.all()

print(versions)

if not versions:
print('hi')
Version.objects.create(number='1.2')


def delete_version(apps, schema_editor):
pass


class Migration(migrations.Migration):

dependencies = [
('utils', '0008_version'),
]

operations = [
migrations.RunPython(create_version, reverse_code=delete_version)
]
9 changes: 8 additions & 1 deletion src/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from hvad.models import TranslatableModel, TranslatedFields
from utils.shared import get_ip_address
from utils import notify


LOG_TYPES = [
Expand Down Expand Up @@ -109,6 +108,14 @@ def add_entry(types, description, level, actor=None, request=None, target=None,
return new_entry


class Version(models.Model):
number = models.CharField(max_length=5)
date = models.DateTimeField(default=timezone.now)

def __str__(self):
return 'Version {number}, upgraded {date}'.format(number=self.number, date=self.date)


class Plugin(models.Model):
name = models.CharField(max_length=200)
version = models.CharField(max_length=10)
Expand Down
14 changes: 8 additions & 6 deletions src/utils/upgrade/12_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from core import models as core_models

from utils import setting_handler
from utils.upgrade import shared


SETTINGS_TO_CHANGE = [
{'group': 'email', 'name': 'copyeditor_reopen_task', 'action': 'update'},
{'group': 'email', 'name': 'author_copyedit_complete', 'action': 'update'},
{'group': 'email', 'name': 'production_manager_notification', 'action': 'update'},
{'group': 'email', 'name': 'review_complete_reviewer_acknowledgement', 'action': 'update'},
#{'group': 'general', 'name': 'submission_competing_interests', 'action': 'drop'},
# {'group': 'general', 'name': 'submission_competing_interests', 'action': 'drop'},
]


Expand Down Expand Up @@ -84,11 +85,12 @@ def update_settings():

def delete_existing_workflows():
core_models.Workflow.objects.all().delete()
core_models.Workflow.objects.all().delete()
core_models.WorkflowElement.objects.all().delete()


def execute():
delete_existing_workflows()
run_journal_signals()
process_article_workflow()
update_settings()
shared.current_version()
# delete_existing_workflows()
# run_journal_signals()
# process_article_workflow()
# update_settings()
22 changes: 22 additions & 0 deletions src/utils/upgrade/shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import json

from django.conf import settings

from utils import models


def versions():
file = open(os.path.join(settings.BASE_DIR, 'utils', 'upgrade', 'versions.json'))

versions = json.loads(file.read())


def current_version():
versions = models.Version.objects.all().order_by('-date')

if versions:
return versions[0]

else:
# Its possible that versioning didn't exist as it was only introduced in 1.3.
22 changes: 22 additions & 0 deletions src/utils/upgrade/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"number": "1.0",
"date": "2017-06-10 00:00:00",
"code": "kathryn"
}
{
"number": "1.1",
"date": "2017-09-01 00:00:00",
"code": "chakotay"
},
{
"number": "1.2",
"date": "2017-11-06 00:00:00",
"code": "tuvok"
},
{
"number": "1.3",
"date": "2018-08-01 00:00:00",
"code": "doctor"
}
]

0 comments on commit 6899c46

Please sign in to comment.