From 94954b9fea46cee6724561701b2623fb9ecb2e04 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Thu, 14 Jan 2016 12:01:18 +0100 Subject: [PATCH] App consolidation: contributors merged into scipost --- SciPost_v1/settings.py | 2 +- SciPost_v1/urls.py | 2 +- commentaries/migrations/0001_initial.py | 20 +- commentaries/models.py | 2 +- comments/migrations/0001_initial.py | 52 +++-- comments/models.py | 2 +- contributors/__init__.py | 0 contributors/admin.py | 5 - contributors/forms.py | 49 ---- contributors/migrations/0001_initial.py | 61 ----- contributors/migrations/__init__.py | 0 contributors/models.py | 92 -------- contributors/tests.py | 3 - contributors/urls.py | 19 -- contributors/views.py | 214 ------------------ ratings/migrations/0001_initial.py | 74 +++--- ratings/models.py | 2 +- reports/migrations/0001_initial.py | 18 +- reports/models.py | 2 +- scipost/admin.py | 3 + scipost/forms.py | 44 ++++ scipost/models.py | 85 +++++++ .../templates/scipost}/change_password.html | 0 .../scipost}/change_password_ack.html | 0 .../templates/scipost}/login.html | 0 .../templates/scipost}/login_error.html | 0 .../templates/scipost}/logout.html | 0 .../templates/scipost}/personal_page.html | 0 .../templates/scipost}/register.html | 0 .../scipost}/thanks_for_registering.html | 0 .../scipost}/update_personal_data.html | 0 .../scipost}/update_personal_data_ack.html | 0 .../vet_registration_request_ack.html | 0 .../scipost}/vet_registration_requests.html | 0 scipost/urls.py | 16 ++ scipost/views.py | 198 ++++++++++++++++ submissions/migrations/0001_initial.py | 22 +- submissions/models.py | 2 +- 38 files changed, 450 insertions(+), 539 deletions(-) delete mode 100644 contributors/__init__.py delete mode 100644 contributors/admin.py delete mode 100644 contributors/forms.py delete mode 100644 contributors/migrations/0001_initial.py delete mode 100644 contributors/migrations/__init__.py delete mode 100644 contributors/models.py delete mode 100644 contributors/tests.py delete mode 100644 contributors/urls.py delete mode 100644 contributors/views.py rename {contributors/templates/contributors => scipost/templates/scipost}/change_password.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/change_password_ack.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/login.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/login_error.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/logout.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/personal_page.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/register.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/thanks_for_registering.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/update_personal_data.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/update_personal_data_ack.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/vet_registration_request_ack.html (100%) rename {contributors/templates/contributors => scipost/templates/scipost}/vet_registration_requests.html (100%) diff --git a/SciPost_v1/settings.py b/SciPost_v1/settings.py index a2cb79a80..65894af86 100644 --- a/SciPost_v1/settings.py +++ b/SciPost_v1/settings.py @@ -54,7 +54,7 @@ INSTALLED_APPS = ( 'django_mathjax', 'commentaries', 'comments', - 'contributors', +# 'contributors', 'journals', 'ratings', 'reports', diff --git a/SciPost_v1/urls.py b/SciPost_v1/urls.py index 1f5979fdc..3d8ea9cf8 100644 --- a/SciPost_v1/urls.py +++ b/SciPost_v1/urls.py @@ -22,7 +22,7 @@ urlpatterns = [ url(r'^', include('scipost.urls', namespace="scipost")), url(r'^commentaries/', include('commentaries.urls', namespace="commentaries")), url(r'^comments/', include('comments.urls', namespace="comments")), - url(r'^contributors/', include('contributors.urls', namespace="contributors")), +# url(r'^contributors/', include('contributors.urls', namespace="contributors")), url(r'^journals/', include('journals.urls', namespace="journals")), url(r'^ratings/', include('ratings.urls', namespace="ratings")), url(r'^reports/', include('reports.urls', namespace="reports")), diff --git a/commentaries/migrations/0001_initial.py b/commentaries/migrations/0001_initial.py index 1ecadfa89..b9422f052 100644 --- a/commentaries/migrations/0001_initial.py +++ b/commentaries/migrations/0001_initial.py @@ -8,14 +8,14 @@ import django.utils.timezone class Migration(migrations.Migration): dependencies = [ - ('contributors', '0001_initial'), + ('scipost', '0001_initial'), ] operations = [ migrations.CreateModel( name='Commentary', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('vetted', models.BooleanField(default=False)), ('type', models.CharField(max_length=9)), ('open_for_commenting', models.BooleanField(default=True)), @@ -26,19 +26,19 @@ class Migration(migrations.Migration): ('pub_date', models.DateField(verbose_name='date of original publication')), ('pub_abstract', models.TextField()), ('nr_clarity_ratings', models.IntegerField(default=0)), - ('clarity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('clarity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_validity_ratings', models.IntegerField(default=0)), - ('validity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('validity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_rigour_ratings', models.IntegerField(default=0)), - ('rigour_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('rigour_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_originality_ratings', models.IntegerField(default=0)), - ('originality_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('originality_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_significance_ratings', models.IntegerField(default=0)), - ('significance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('significance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('latest_activity', models.DateTimeField(default=django.utils.timezone.now)), - ('authors', models.ManyToManyField(related_name='authors_com', blank=True, to='contributors.Contributor')), - ('requested_by', models.ForeignKey(null=True, related_name='requested_by', blank=True, to='contributors.Contributor')), - ('vetted_by', models.ForeignKey(null=True, to='contributors.Contributor', blank=True)), + ('authors', models.ManyToManyField(related_name='authors_com', to='scipost.Contributor', blank=True)), + ('requested_by', models.ForeignKey(related_name='requested_by', null=True, blank=True, to='scipost.Contributor')), + ('vetted_by', models.ForeignKey(null=True, blank=True, to='scipost.Contributor')), ], ), ] diff --git a/commentaries/models.py b/commentaries/models.py index e842d6236..b90e7d139 100644 --- a/commentaries/models.py +++ b/commentaries/models.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User from .models import * -from contributors.models import Contributor +from scipost.models import Contributor COMMENTARY_TYPES = ( ('published', 'published paper'), diff --git a/comments/migrations/0001_initial.py b/comments/migrations/0001_initial.py index 30f9afa2f..ef5ef7ddc 100644 --- a/comments/migrations/0001_initial.py +++ b/comments/migrations/0001_initial.py @@ -7,7 +7,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('contributors', '0001_initial'), + ('scipost', '0001_initial'), ('submissions', '0001_initial'), ('reports', '0001_initial'), ('commentaries', '0001_initial'), @@ -17,60 +17,68 @@ class Migration(migrations.Migration): migrations.CreateModel( name='AuthorReply', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('status', models.SmallIntegerField(default=0)), ('reply_text', models.TextField()), ('date_submitted', models.DateTimeField(verbose_name='date submitted')), ('nr_relevance_ratings', models.IntegerField(default=0)), - ('relevance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('relevance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_importance_ratings', models.IntegerField(default=0)), - ('importance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('importance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_clarity_ratings', models.IntegerField(default=0)), - ('clarity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('clarity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_validity_ratings', models.IntegerField(default=0)), - ('validity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('validity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_rigour_ratings', models.IntegerField(default=0)), - ('rigour_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), - ('author', models.ForeignKey(to='contributors.Contributor')), - ('commentary', models.ForeignKey(null=True, to='commentaries.Commentary', blank=True)), + ('rigour_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), + ('author', models.ForeignKey(to='scipost.Contributor')), + ('commentary', models.ForeignKey(null=True, blank=True, to='commentaries.Commentary')), ], ), migrations.CreateModel( name='Comment', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('status', models.SmallIntegerField(default=0)), + ('is_rem', models.BooleanField(verbose_name='remark', default=False)), + ('is_que', models.BooleanField(verbose_name='question', default=False)), + ('is_ans', models.BooleanField(verbose_name='answer to question', default=False)), + ('is_obj', models.BooleanField(verbose_name='objection', default=False)), + ('is_rep', models.BooleanField(verbose_name='reply to objection', default=False)), + ('is_val', models.BooleanField(verbose_name='validation or rederivation', default=False)), + ('is_lit', models.BooleanField(verbose_name='pointer to related literature', default=False)), + ('is_sug', models.BooleanField(verbose_name='suggestion for further work', default=False)), ('comment_text', models.TextField()), ('date_submitted', models.DateTimeField(verbose_name='date submitted')), ('nr_relevance_ratings', models.IntegerField(default=0)), - ('relevance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('relevance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_importance_ratings', models.IntegerField(default=0)), - ('importance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('importance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_clarity_ratings', models.IntegerField(default=0)), - ('clarity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('clarity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_validity_ratings', models.IntegerField(default=0)), - ('validity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('validity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_rigour_ratings', models.IntegerField(default=0)), - ('rigour_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), - ('author', models.ForeignKey(to='contributors.Contributor')), - ('commentary', models.ForeignKey(null=True, to='commentaries.Commentary', blank=True)), - ('in_reply_to', models.ForeignKey(null=True, to='comments.Comment', blank=True)), - ('submission', models.ForeignKey(null=True, to='submissions.Submission', blank=True)), + ('rigour_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), + ('author', models.ForeignKey(to='scipost.Contributor')), + ('commentary', models.ForeignKey(null=True, blank=True, to='commentaries.Commentary')), + ('in_reply_to', models.ForeignKey(null=True, blank=True, to='comments.Comment')), + ('submission', models.ForeignKey(null=True, blank=True, to='submissions.Submission')), ], ), migrations.AddField( model_name='authorreply', name='in_reply_to_comment', - field=models.ForeignKey(null=True, to='comments.Comment', blank=True), + field=models.ForeignKey(null=True, blank=True, to='comments.Comment'), ), migrations.AddField( model_name='authorreply', name='in_reply_to_report', - field=models.ForeignKey(null=True, to='reports.Report', blank=True), + field=models.ForeignKey(null=True, blank=True, to='reports.Report'), ), migrations.AddField( model_name='authorreply', name='submission', - field=models.ForeignKey(null=True, to='submissions.Submission', blank=True), + field=models.ForeignKey(null=True, blank=True, to='submissions.Submission'), ), ] diff --git a/comments/models.py b/comments/models.py index b9d11fbe4..4fde04c53 100644 --- a/comments/models.py +++ b/comments/models.py @@ -11,7 +11,7 @@ from .models import * #from submissions.models import * from commentaries.models import Commentary -from contributors.models import Contributor +from scipost.models import Contributor from reports.models import Report from submissions.models import Submission diff --git a/contributors/__init__.py b/contributors/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/contributors/admin.py b/contributors/admin.py deleted file mode 100644 index cb0f8d56b..000000000 --- a/contributors/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.contrib import admin - -from contributors.models import * - -admin.site.register(Contributor) diff --git a/contributors/forms.py b/contributors/forms.py deleted file mode 100644 index 056504809..000000000 --- a/contributors/forms.py +++ /dev/null @@ -1,49 +0,0 @@ -from django import forms - -from .models import * - -REGISTRATION_REFUSAL_CHOICES = ( - (0, '-'), - (-1, 'not a professional scientist (>= PhD student)'), - (-2, 'another account already exists for this person'), - (-3, 'barred from SciPost (abusive behaviour)'), - ) - - -class RegistrationForm(forms.Form): - title = forms.ChoiceField(choices=TITLE_CHOICES) - first_name = forms.CharField(label='First name', max_length=100) - last_name = forms.CharField(label='Last name', max_length=100) - email = forms.EmailField(label='email') - orcid_id = forms.CharField(label="ORCID id", max_length=20, required=False) - affiliation = forms.CharField(label='Affiliation', max_length=300) - address = forms.CharField(label='Address', max_length=1000, required=False) - personalwebpage = forms.URLField(label='Personal web page', required=False) - username = forms.CharField(label='username', max_length=100) - password = forms.CharField(label='password', widget=forms.PasswordInput()) - password_verif = forms.CharField(label='verify pwd', widget=forms.PasswordInput()) - -class UpdatePersonalDataForm(forms.Form): - title = forms.ChoiceField(choices=TITLE_CHOICES) - first_name = forms.CharField(label='First name', max_length=100) - last_name = forms.CharField(label='Last name', max_length=100) - email = forms.EmailField(label='email') - orcid_id = forms.CharField(label="ORCID id", max_length=20, required=False) - affiliation = forms.CharField(label='Affiliation', max_length=300) - address = forms.CharField(label='Address', max_length=1000, required=False) - personalwebpage = forms.URLField(label='Personal web page', required=False) - -class VetRegistrationForm(forms.Form): - promote_to_rank_1 = forms.BooleanField(required=False) - refusal_reason = forms.ChoiceField(choices=REGISTRATION_REFUSAL_CHOICES, required=False) - email_response_field = forms.CharField(widget=forms.Textarea(), label='Justification (optional)', required=False) - -class AuthenticationForm(forms.Form): - username = forms.CharField(label='username', max_length=100) - password = forms.CharField(label='password', widget=forms.PasswordInput()) - -class PasswordChangeForm(forms.Form): - password_prev = forms.CharField(label='Existing password', widget=forms.PasswordInput()) - password_new = forms.CharField(label='New password', widget=forms.PasswordInput()) - password_verif = forms.CharField(label='Reenter new password', widget=forms.PasswordInput()) - diff --git a/contributors/migrations/0001_initial.py b/contributors/migrations/0001_initial.py deleted file mode 100644 index 23d294569..000000000 --- a/contributors/migrations/0001_initial.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models -from django.conf import settings - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Contributor', - fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('rank', models.SmallIntegerField(default=0, choices=[(0, 'newly registered'), (1, 'normal user'), (2, 'SciPost Commentary Editor'), (3, 'SciPost Journal Editor'), (4, 'SciPost Journal Editor-in-chief'), (5, 'SciPost Lead Editor'), (-1, 'not a professional scientist'), (-2, 'other account already exists'), (-3, 'barred from SciPost'), (-4, 'account disabled')])), - ('title', models.CharField(max_length=4, choices=[('PR', 'Prof.'), ('DR', 'Dr'), ('MR', 'Mr'), ('MRS', 'Mrs')])), - ('orcid_id', models.CharField(verbose_name='ORCID id', default='', null=True, blank=True, max_length=20)), - ('affiliation', models.CharField(verbose_name='affiliation', max_length=300)), - ('address', models.CharField(verbose_name='address', blank=True, max_length=1000)), - ('personalwebpage', models.URLField(verbose_name='personal web page', blank=True)), - ('nr_comments', models.PositiveSmallIntegerField(default=0)), - ('nr_comment_relevance_ratings', models.IntegerField(default=0)), - ('comment_relevance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_comment_importance_ratings', models.IntegerField(default=0)), - ('comment_importance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_comment_clarity_ratings', models.IntegerField(default=0)), - ('comment_clarity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_comment_validity_ratings', models.IntegerField(default=0)), - ('comment_validity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_comment_rigour_ratings', models.IntegerField(default=0)), - ('comment_rigour_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_authorreplies', models.PositiveSmallIntegerField(default=0)), - ('nr_authorreply_relevance_ratings', models.IntegerField(default=0)), - ('authorreply_relevance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_authorreply_importance_ratings', models.IntegerField(default=0)), - ('authorreply_importance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_authorreply_clarity_ratings', models.IntegerField(default=0)), - ('authorreply_clarity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_authorreply_validity_ratings', models.IntegerField(default=0)), - ('authorreply_validity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_authorreply_rigour_ratings', models.IntegerField(default=0)), - ('authorreply_rigour_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_reports', models.PositiveSmallIntegerField(default=0)), - ('nr_report_relevance_ratings', models.IntegerField(default=0)), - ('report_relevance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_report_importance_ratings', models.IntegerField(default=0)), - ('report_importance_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_report_clarity_ratings', models.IntegerField(default=0)), - ('report_clarity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_report_validity_ratings', models.IntegerField(default=0)), - ('report_validity_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('nr_report_rigour_ratings', models.IntegerField(default=0)), - ('report_rigour_rating', models.DecimalField(max_digits=3, default=0, decimal_places=0)), - ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/contributors/migrations/__init__.py b/contributors/migrations/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/contributors/models.py b/contributors/models.py deleted file mode 100644 index f1cb08c7a..000000000 --- a/contributors/models.py +++ /dev/null @@ -1,92 +0,0 @@ -from django.utils import timezone -from django.db import models -from django.contrib.auth.models import User - -from .models import * - -CONTRIBUTOR_RANKS = ( - # ranks determine the type of Contributor: - # 0: newly registered (unverified; not allowed to submit, comment or vote) - # 1: normal user (allowed to submit, comment and vote) - # 2: scipost editor (1 + no need for vetting of comments, also allowed to vet commentary request and comments from normal users) - # 3: scipost journal editor (2 + allowed to accept papers in SciPost Journals) - # 4: scipost journal editor-in-chief - # 5: Lead Editor (all rights granted, including rank promotions and overriding all) - # - # Negative ranks denote rejected requests or : - # -1: not a professional scientist (defined as at least PhD student in known university) - # -2: other account already exists for this person - # -3: barred from SciPost (abusive behaviour) - # -4: disabled account (deceased) - (0, 'newly registered'), - (1, 'normal user'), - (2, 'SciPost Commentary Editor'), - (3, 'SciPost Journal Editor'), - (4, 'SciPost Journal Editor-in-chief'), - (5, 'SciPost Lead Editor'), - (-1, 'not a professional scientist'), - (-2, 'other account already exists'), - (-3, 'barred from SciPost'), - (-4, 'account disabled'), - ) - -TITLE_CHOICES = ( - ('PR', 'Prof.'), - ('DR', 'Dr'), - ('MR', 'Mr'), - ('MRS', 'Mrs'), - ) - -class Contributor(models.Model): - """ All users of SciPost are Contributors. Permissions determine the sub-types. """ - user = models.OneToOneField(User) - rank = models.SmallIntegerField(default=0, choices=CONTRIBUTOR_RANKS) - title = models.CharField(max_length=4, choices=TITLE_CHOICES) - # username, password, email, first_name and last_name are inherited from User - orcid_id = models.CharField(max_length=20, blank=True, null=True, verbose_name="ORCID id", default='') - affiliation = models.CharField(max_length=300, verbose_name='affiliation') - address = models.CharField(max_length=1000, blank=True, verbose_name="address") - personalwebpage = models.URLField(blank=True, verbose_name='personal web page') - #vetted_by = models.OneToOneField(Contributor, related_name='vetted_by') TO ACTIVATE - - nr_comments = models.PositiveSmallIntegerField(default=0) - nr_comment_relevance_ratings = models.IntegerField(default=0) - comment_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_comment_importance_ratings = models.IntegerField(default=0) - comment_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_comment_clarity_ratings = models.IntegerField(default=0) - comment_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_comment_validity_ratings = models.IntegerField(default=0) - comment_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_comment_rigour_ratings = models.IntegerField(default=0) - comment_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - - nr_authorreplies = models.PositiveSmallIntegerField(default=0) - nr_authorreply_relevance_ratings = models.IntegerField(default=0) - authorreply_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_authorreply_importance_ratings = models.IntegerField(default=0) - authorreply_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_authorreply_clarity_ratings = models.IntegerField(default=0) - authorreply_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_authorreply_validity_ratings = models.IntegerField(default=0) - authorreply_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_authorreply_rigour_ratings = models.IntegerField(default=0) - authorreply_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - - nr_reports = models.PositiveSmallIntegerField(default=0) - nr_report_relevance_ratings = models.IntegerField(default=0) - report_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_report_importance_ratings = models.IntegerField(default=0) - report_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_report_clarity_ratings = models.IntegerField(default=0) - report_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_report_validity_ratings = models.IntegerField(default=0) - report_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - nr_report_rigour_ratings = models.IntegerField(default=0) - report_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) - - - - def __str__ (self): - return self.user.username - diff --git a/contributors/tests.py b/contributors/tests.py deleted file mode 100644 index 7ce503c2d..000000000 --- a/contributors/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/contributors/urls.py b/contributors/urls.py deleted file mode 100644 index 3c1ef889f..000000000 --- a/contributors/urls.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.conf.urls import include, url - -from . import views - -urlpatterns = [ - # Registration - url(r'^register$', views.register, name='register'), - url(r'^thanks_for_registering$', views.thanks_for_registering, name='thanks for registering'), - url(r'^vet_registration_requests$', views.vet_registration_requests, name='vet_registration_requests'), - url(r'^vet_registration_request_ack/(?P<contributor_id>[0-9]+)$', views.vet_registration_request_ack, name='vet_registration_request_ack'), - # Authentication - url(r'^login$', views.login_view, name='login'), - url(r'^logout$', views.logout_view, name='logout'), - url(r'^personal_page$', views.personal_page, name='personal_page'), - url(r'^change_password$', views.change_password, name='change_password'), - url(r'^change_password_ack$', views.change_password_ack, name='change_password_ack'), - url(r'^update_personal_data$', views.update_personal_data, name='update_personal_data'), - url(r'^update_personal_data_ack$', views.update_personal_data_ack, name='update_personal_data_ack'), -] diff --git a/contributors/views.py b/contributors/views.py deleted file mode 100644 index 253e28fe0..000000000 --- a/contributors/views.py +++ /dev/null @@ -1,214 +0,0 @@ -import datetime -from django.utils import timezone -from django.shortcuts import get_object_or_404, render -from django.contrib.auth import authenticate, login, logout -from django.contrib.auth.models import User -#from django.core.mail import send_mail -from django.core.mail import EmailMessage -from django.core.urlresolvers import reverse -from django.http import HttpResponse, HttpResponseRedirect -from django.views.decorators.csrf import csrf_protect -from django.db.models import Avg - -from .models import * -from .forms import * - -from commentaries.models import Commentary -from comments.models import Comment, AuthorReply -#from contributors.models import Contributor -from reports.models import Report -from submissions.models import Submission - -title_dict = dict(TITLE_CHOICES) -reg_ref_dict = dict(REGISTRATION_REFUSAL_CHOICES) - -################ -# Registration -################ - -def register(request): - # If POST, process the form data - if request.method == 'POST': - # create a form instance and populate it with the form data - form = RegistrationForm(request.POST) - # check whether it's valid - if form.is_valid(): - # check for mismatching passwords - if form.cleaned_data['password'] != form.cleaned_data['password_verif']: - return render(request, 'contributors/register.html', {'form': form, 'errormessage': 'Your passwords must match'}) - # check for already-existing username - if User.objects.filter(username=form.cleaned_data['username']).exists(): - return render(request, 'contributors/register.html', {'form': form, 'errormessage': 'This username is already in use'}) - # create the user - user = User.objects.create_user ( - first_name = form.cleaned_data['first_name'], - last_name = form.cleaned_data['last_name'], - email = form.cleaned_data['email'], - username = form.cleaned_data['username'], - password = form.cleaned_data['password'] - ) - contributor = Contributor ( - user=user, - title = form.cleaned_data['title'], - orcid_id = form.cleaned_data['orcid_id'], - address = form.cleaned_data['address'], - affiliation = form.cleaned_data['affiliation'], - personalwebpage = form.cleaned_data['personalwebpage'], - ) - contributor.save() - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour request for registration to the SciPost publication portal has been received, and will be processed soon. Many thanks for your interest. \n\nThe SciPost Team.' - emailmessage = EmailMessage('SciPost registration request received', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) - emailmessage.send(fail_silently=False) - return HttpResponseRedirect('thanks_for_registering') - # if GET or other method, create a blank form - else: - form = RegistrationForm() - - errormessage = '' - return render(request, 'contributors/register.html', {'form': form, 'errormessage': errormessage}) - - -def thanks_for_registering(request): - return render(request, 'contributors/thanks_for_registering.html') - - -def vet_registration_requests(request): - contributor = Contributor.objects.get(user=request.user) - registration_requests_to_vet = Contributor.objects.filter(rank=0) - form = VetRegistrationForm() - context = {'contributor': contributor, 'registration_requests_to_vet': registration_requests_to_vet, 'form': form } - return render(request, 'contributors/vet_registration_requests.html', context) - - -def vet_registration_request_ack(request, contributor_id): - # process the form - if request.method == 'POST': - form = VetRegistrationForm(request.POST) - contributor = Contributor.objects.get(pk=contributor_id) - if form.is_valid(): - if form.cleaned_data['promote_to_rank_1']: - contributor.rank = 1 - contributor.save() - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been accepted. You can now login and contribute. \n\nThe SciPost Team.' - emailmessage = EmailMessage('SciPost registration accepted', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) - emailmessage.send(fail_silently=False) - else: - ref_reason = int(form.cleaned_data['refusal_reason']) - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been turned down, the reason being: ' + reg_ref_dict[ref_reason] + '. You can however still view all SciPost contents, just not submit papers, comments or votes. We nonetheless thank you for your interest. \n\nThe SciPost Team.' - if form.cleaned_data['email_response_field']: - email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] - emailmessage = EmailMessage('SciPost registration: unsuccessful', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) - emailmessage.send(fail_silently=False) - contributor.rank = form.cleaned_data['refusal_reason'] - contributor.save() - - context = {} - return render(request, 'contributors/vet_registration_request_ack.html', context) - - -def login_view(request): - if request.method == 'POST': - username = request.POST['username'] - password = request.POST['password'] - user = authenticate(username=username, password=password) - if user is not None and user.contributor.rank > 0: - if user.is_active: - login(request, user) - contributor = Contributor.objects.get(user=request.user) - context = {'contributor': contributor } - return render(request, 'contributors/personal_page.html', context) - else: - return render(request, 'contributors/disabled_account.html') - else: - return render(request, 'contributors/login_error.html') - else: - form = AuthenticationForm() - return render(request, 'contributors/login.html', {'form': form}) - - -def logout_view(request): - logout(request) - return render(request, 'contributors/logout.html') - - -def personal_page(request): - if request.user.is_authenticated(): - contributor = Contributor.objects.get(user=request.user) - # if an editor, count the number of actions required: - nr_reg_to_vet = 0 - nr_submissions_to_process = 0 - if contributor.rank >= 4: - # count the number of pending registration request - nr_reg_to_vet = Contributor.objects.filter(rank=0).count() - nr_submissions_to_process = Submission.objects.filter(vetted=False).count() - nr_commentary_page_requests_to_vet = 0 - nr_comments_to_vet = 0 - nr_author_replies_to_vet = 0 - nr_reports_to_vet = 0 - if contributor.rank >= 2: - nr_commentary_page_requests_to_vet = Commentary.objects.filter(vetted=False).count() - nr_comments_to_vet = Comment.objects.filter(status=0).count() - nr_author_replies_to_vet = AuthorReply.objects.filter(status=0).count() - nr_reports_to_vet = Report.objects.filter(status=0).count() - context = {'contributor': contributor, 'nr_reg_to_vet': nr_reg_to_vet, 'nr_commentary_page_requests_to_vet': nr_commentary_page_requests_to_vet, 'nr_comments_to_vet': nr_comments_to_vet, 'nr_author_replies_to_vet': nr_author_replies_to_vet, 'nr_reports_to_vet': nr_reports_to_vet, 'nr_submissions_to_process': nr_submissions_to_process } - return render(request, 'contributors/personal_page.html', context) - else: - form = AuthenticationForm() - context = {'form': form} - return render(request, 'contributors/login.html', context) - - -def change_password(request): - if request.user.is_authenticated and request.method == 'POST': - form = PasswordChangeForm(request.POST) - if form.is_valid(): - # verify existing password: - if not request.user.check_password(form.cleaned_data['password_prev']): - return render(request, 'contributors/change_password.html', {'form': form, 'errormessage': 'The currently existing password you entered is incorrect'}) - # check for mismatching new passwords - if form.cleaned_data['password_new'] != form.cleaned_data['password_verif']: - return render(request, 'contributors/change_password.html', {'form': form, 'errormessage': 'Your new password entries must match'}) - # otherwise simply change the pwd: - request.user.set_password(form.cleaned_data['password_new']) - request.user.save() - return render(request, 'contributors/change_password_ack.html') - else: - form = PasswordChangeForm() - return render (request, 'contributors/change_password.html', {'form': form}) - - -def change_password_ack(request): - return render (request, 'contributors/change_password_ack.html') - - -def update_personal_data(request): - if request.user.is_authenticated: - contributor = Contributor.objects.get(user=request.user) - if request.method == 'POST': - form = UpdatePersonalDataForm(request.POST) - if form.is_valid(): - request.user.email = form.cleaned_data['email'] - request.user.first_name = form.cleaned_data['first_name'] - request.user.last_name = form.cleaned_data['last_name'] - request.user.contributor.title = form.cleaned_data['title'] - request.user.contributor.orcid = form.cleaned_data['orcid_id'] - request.user.contributor.address = form.cleaned_data['address'] - request.user.contributor.affiliation = form.cleaned_data['affiliation'] - request.user.contributor.personalwebpage = form.cleaned_data['personalwebpage'] - request.user.save() - request.user.contributor.save() - return render(request, 'contributors/update_personal_data_ack.html') - else: - #form = UpdatePersonalDataForm() - aff = contributor.affiliation - prefilldata = {'affiliation': aff} - form = UpdatePersonalDataForm(initial=prefilldata) - return render(request, 'contributors/update_personal_data.html', {'form': form, 'contributor': contributor}) - else: - form = AuthenticationForm() - return render(request, 'contributors/login.html', {'form': form}) - - -def update_personal_data_ack(request): - return render (request, 'contributors/update_personal_data_ack.html') - diff --git a/ratings/migrations/0001_initial.py b/ratings/migrations/0001_initial.py index 52ae5b00f..e1e59bb0d 100644 --- a/ratings/migrations/0001_initial.py +++ b/ratings/migrations/0001_initial.py @@ -7,10 +7,10 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('contributors', '0001_initial'), + ('comments', '0001_initial'), + ('scipost', '0001_initial'), ('submissions', '0001_initial'), ('reports', '0001_initial'), - ('comments', '0001_initial'), ('commentaries', '0001_initial'), ] @@ -18,14 +18,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='AuthorReplyRating', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), ('authorreply', models.ForeignKey(to='comments.AuthorReply')), - ('rater', models.ForeignKey(to='contributors.Contributor')), + ('rater', models.ForeignKey(to='scipost.Contributor')), ], options={ 'abstract': False, @@ -34,14 +34,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CommentaryRating', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('originality', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('significance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('originality', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('significance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), ('commentary', models.ForeignKey(to='commentaries.Commentary')), - ('rater', models.ForeignKey(to='contributors.Contributor')), + ('rater', models.ForeignKey(to='scipost.Contributor')), ], options={ 'abstract': False, @@ -50,14 +50,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CommentRating', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), ('comment', models.ForeignKey(to='comments.Comment')), - ('rater', models.ForeignKey(to='contributors.Contributor')), + ('rater', models.ForeignKey(to='scipost.Contributor')), ], options={ 'abstract': False, @@ -66,13 +66,13 @@ class Migration(migrations.Migration): migrations.CreateModel( name='ReportRating', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rater', models.ForeignKey(to='contributors.Contributor')), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('relevance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('importance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rater', models.ForeignKey(to='scipost.Contributor')), ('report', models.ForeignKey(to='reports.Report')), ], options={ @@ -82,13 +82,13 @@ class Migration(migrations.Migration): migrations.CreateModel( name='SubmissionRating', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), - ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('originality', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('significance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), default=0, null=True)), - ('rater', models.ForeignKey(to='contributors.Contributor')), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('clarity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('validity', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rigour', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('originality', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('significance', models.PositiveSmallIntegerField(verbose_name=((101, '-'), (100, '100%'), (90, '90%'), (80, '80%'), (70, '70%'), (60, '60%'), (50, '50%'), (40, '40%'), (30, '30%'), (20, '20%'), (10, '10%'), (0, '0%')), null=True, default=0)), + ('rater', models.ForeignKey(to='scipost.Contributor')), ('submission', models.ForeignKey(to='submissions.Submission')), ], options={ diff --git a/ratings/models.py b/ratings/models.py index a9eeb3674..1a5a35781 100644 --- a/ratings/models.py +++ b/ratings/models.py @@ -7,7 +7,7 @@ from .models import * from commentaries.models import Commentary from comments.models import Comment, AuthorReply -from contributors.models import Contributor +from scipost.models import Contributor from reports.models import Report from submissions.models import Submission diff --git a/reports/migrations/0001_initial.py b/reports/migrations/0001_initial.py index 1f4c45c7a..9bf888a4b 100644 --- a/reports/migrations/0001_initial.py +++ b/reports/migrations/0001_initial.py @@ -7,7 +7,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('contributors', '0001_initial'), + ('scipost', '0001_initial'), ('submissions', '0001_initial'), ] @@ -15,7 +15,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Report', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('status', models.SmallIntegerField(default=0)), ('qualification', models.PositiveSmallIntegerField(default=0)), ('strengths', models.TextField()), @@ -26,17 +26,17 @@ class Migration(migrations.Migration): ('date_invited', models.DateTimeField(verbose_name='date invited', null=True, blank=True)), ('date_submitted', models.DateTimeField(verbose_name='date submitted')), ('nr_relevance_ratings', models.IntegerField(default=0)), - ('relevance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('relevance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_importance_ratings', models.IntegerField(default=0)), - ('importance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('importance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_clarity_ratings', models.IntegerField(default=0)), - ('clarity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('clarity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_validity_ratings', models.IntegerField(default=0)), - ('validity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('validity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_rigour_ratings', models.IntegerField(default=0)), - ('rigour_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), - ('author', models.ForeignKey(to='contributors.Contributor')), - ('invited_by', models.ForeignKey(null=True, related_name='invited_by', blank=True, to='contributors.Contributor')), + ('rigour_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), + ('author', models.ForeignKey(to='scipost.Contributor')), + ('invited_by', models.ForeignKey(related_name='invited_by', null=True, blank=True, to='scipost.Contributor')), ('submission', models.ForeignKey(to='submissions.Submission')), ], ), diff --git a/reports/models.py b/reports/models.py index ff721c766..1d2e41291 100644 --- a/reports/models.py +++ b/reports/models.py @@ -12,7 +12,7 @@ from .models import * #from submissions.models import * #from commentaries.models import Commentary -from contributors.models import Contributor +from scipost.models import Contributor #from reports.models import Report from submissions.models import Submission diff --git a/scipost/admin.py b/scipost/admin.py index f3c9fd9c8..2f628fd02 100644 --- a/scipost/admin.py +++ b/scipost/admin.py @@ -3,6 +3,8 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User +from scipost.models import Contributor + #class ContributorInline(admin.StackedInline): # model = Contributor @@ -12,3 +14,4 @@ from django.contrib.auth.models import User #admin.site.unregister(User) #admin.site.register(User, UserAdmin) +admin.site.register(Contributor) diff --git a/scipost/forms.py b/scipost/forms.py index 4bac12fab..39550cb84 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -4,3 +4,47 @@ from .models import * +REGISTRATION_REFUSAL_CHOICES = ( + (0, '-'), + (-1, 'not a professional scientist (>= PhD student)'), + (-2, 'another account already exists for this person'), + (-3, 'barred from SciPost (abusive behaviour)'), + ) + +class RegistrationForm(forms.Form): + title = forms.ChoiceField(choices=TITLE_CHOICES) + first_name = forms.CharField(label='First name', max_length=100) + last_name = forms.CharField(label='Last name', max_length=100) + email = forms.EmailField(label='email') + orcid_id = forms.CharField(label="ORCID id", max_length=20, required=False) + affiliation = forms.CharField(label='Affiliation', max_length=300) + address = forms.CharField(label='Address', max_length=1000, required=False) + personalwebpage = forms.URLField(label='Personal web page', required=False) + username = forms.CharField(label='username', max_length=100) + password = forms.CharField(label='password', widget=forms.PasswordInput()) + password_verif = forms.CharField(label='verify pwd', widget=forms.PasswordInput()) + +class UpdatePersonalDataForm(forms.Form): + title = forms.ChoiceField(choices=TITLE_CHOICES) + first_name = forms.CharField(label='First name', max_length=100) + last_name = forms.CharField(label='Last name', max_length=100) + email = forms.EmailField(label='email') + orcid_id = forms.CharField(label="ORCID id", max_length=20, required=False) + affiliation = forms.CharField(label='Affiliation', max_length=300) + address = forms.CharField(label='Address', max_length=1000, required=False) + personalwebpage = forms.URLField(label='Personal web page', required=False) + +class VetRegistrationForm(forms.Form): + promote_to_rank_1 = forms.BooleanField(required=False) + refusal_reason = forms.ChoiceField(choices=REGISTRATION_REFUSAL_CHOICES, required=False) + email_response_field = forms.CharField(widget=forms.Textarea(), label='Justification (optional)', required=False) + +class AuthenticationForm(forms.Form): + username = forms.CharField(label='username', max_length=100) + password = forms.CharField(label='password', widget=forms.PasswordInput()) + +class PasswordChangeForm(forms.Form): + password_prev = forms.CharField(label='Existing password', widget=forms.PasswordInput()) + password_new = forms.CharField(label='New password', widget=forms.PasswordInput()) + password_verif = forms.CharField(label='Reenter new password', widget=forms.PasswordInput()) + diff --git a/scipost/models.py b/scipost/models.py index 35004b50f..38521759a 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -4,3 +4,88 @@ from django.contrib.auth.models import User from .models import * + +CONTRIBUTOR_RANKS = ( + # ranks determine the type of Contributor: + # 0: newly registered (unverified; not allowed to submit, comment or vote) + # 1: normal user (allowed to submit, comment and vote) + # 2: scipost editor (1 + no need for vetting of comments, also allowed to vet commentary request and comments from normal users) + # 3: scipost journal editor (2 + allowed to accept papers in SciPost Journals) + # 4: scipost journal editor-in-chief + # 5: Lead Editor (all rights granted, including rank promotions and overriding all) + # + # Negative ranks denote rejected requests or : + # -1: not a professional scientist (defined as at least PhD student in known university) + # -2: other account already exists for this person + # -3: barred from SciPost (abusive behaviour) + # -4: disabled account (deceased) + (0, 'newly registered'), + (1, 'normal user'), + (2, 'SciPost Commentary Editor'), + (3, 'SciPost Journal Editor'), + (4, 'SciPost Journal Editor-in-chief'), + (5, 'SciPost Lead Editor'), + (-1, 'not a professional scientist'), + (-2, 'other account already exists'), + (-3, 'barred from SciPost'), + (-4, 'account disabled'), + ) + +TITLE_CHOICES = ( + ('PR', 'Prof.'), + ('DR', 'Dr'), + ('MR', 'Mr'), + ('MRS', 'Mrs'), + ) + +class Contributor(models.Model): + """ All users of SciPost are Contributors. Permissions determine the sub-types. """ + user = models.OneToOneField(User) + rank = models.SmallIntegerField(default=0, choices=CONTRIBUTOR_RANKS) + title = models.CharField(max_length=4, choices=TITLE_CHOICES) + # username, password, email, first_name and last_name are inherited from User + orcid_id = models.CharField(max_length=20, blank=True, null=True, verbose_name="ORCID id", default='') + affiliation = models.CharField(max_length=300, verbose_name='affiliation') + address = models.CharField(max_length=1000, blank=True, verbose_name="address") + personalwebpage = models.URLField(blank=True, verbose_name='personal web page') + #vetted_by = models.OneToOneField(Contributor, related_name='vetted_by') TO ACTIVATE + + nr_comments = models.PositiveSmallIntegerField(default=0) + nr_comment_relevance_ratings = models.IntegerField(default=0) + comment_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_comment_importance_ratings = models.IntegerField(default=0) + comment_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_comment_clarity_ratings = models.IntegerField(default=0) + comment_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_comment_validity_ratings = models.IntegerField(default=0) + comment_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_comment_rigour_ratings = models.IntegerField(default=0) + comment_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + + nr_authorreplies = models.PositiveSmallIntegerField(default=0) + nr_authorreply_relevance_ratings = models.IntegerField(default=0) + authorreply_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_authorreply_importance_ratings = models.IntegerField(default=0) + authorreply_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_authorreply_clarity_ratings = models.IntegerField(default=0) + authorreply_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_authorreply_validity_ratings = models.IntegerField(default=0) + authorreply_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_authorreply_rigour_ratings = models.IntegerField(default=0) + authorreply_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + + nr_reports = models.PositiveSmallIntegerField(default=0) + nr_report_relevance_ratings = models.IntegerField(default=0) + report_relevance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_report_importance_ratings = models.IntegerField(default=0) + report_importance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_report_clarity_ratings = models.IntegerField(default=0) + report_clarity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_report_validity_ratings = models.IntegerField(default=0) + report_validity_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + nr_report_rigour_ratings = models.IntegerField(default=0) + report_rigour_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) + + def __str__ (self): + return self.user.username + diff --git a/contributors/templates/contributors/change_password.html b/scipost/templates/scipost/change_password.html similarity index 100% rename from contributors/templates/contributors/change_password.html rename to scipost/templates/scipost/change_password.html diff --git a/contributors/templates/contributors/change_password_ack.html b/scipost/templates/scipost/change_password_ack.html similarity index 100% rename from contributors/templates/contributors/change_password_ack.html rename to scipost/templates/scipost/change_password_ack.html diff --git a/contributors/templates/contributors/login.html b/scipost/templates/scipost/login.html similarity index 100% rename from contributors/templates/contributors/login.html rename to scipost/templates/scipost/login.html diff --git a/contributors/templates/contributors/login_error.html b/scipost/templates/scipost/login_error.html similarity index 100% rename from contributors/templates/contributors/login_error.html rename to scipost/templates/scipost/login_error.html diff --git a/contributors/templates/contributors/logout.html b/scipost/templates/scipost/logout.html similarity index 100% rename from contributors/templates/contributors/logout.html rename to scipost/templates/scipost/logout.html diff --git a/contributors/templates/contributors/personal_page.html b/scipost/templates/scipost/personal_page.html similarity index 100% rename from contributors/templates/contributors/personal_page.html rename to scipost/templates/scipost/personal_page.html diff --git a/contributors/templates/contributors/register.html b/scipost/templates/scipost/register.html similarity index 100% rename from contributors/templates/contributors/register.html rename to scipost/templates/scipost/register.html diff --git a/contributors/templates/contributors/thanks_for_registering.html b/scipost/templates/scipost/thanks_for_registering.html similarity index 100% rename from contributors/templates/contributors/thanks_for_registering.html rename to scipost/templates/scipost/thanks_for_registering.html diff --git a/contributors/templates/contributors/update_personal_data.html b/scipost/templates/scipost/update_personal_data.html similarity index 100% rename from contributors/templates/contributors/update_personal_data.html rename to scipost/templates/scipost/update_personal_data.html diff --git a/contributors/templates/contributors/update_personal_data_ack.html b/scipost/templates/scipost/update_personal_data_ack.html similarity index 100% rename from contributors/templates/contributors/update_personal_data_ack.html rename to scipost/templates/scipost/update_personal_data_ack.html diff --git a/contributors/templates/contributors/vet_registration_request_ack.html b/scipost/templates/scipost/vet_registration_request_ack.html similarity index 100% rename from contributors/templates/contributors/vet_registration_request_ack.html rename to scipost/templates/scipost/vet_registration_request_ack.html diff --git a/contributors/templates/contributors/vet_registration_requests.html b/scipost/templates/scipost/vet_registration_requests.html similarity index 100% rename from contributors/templates/contributors/vet_registration_requests.html rename to scipost/templates/scipost/vet_registration_requests.html diff --git a/scipost/urls.py b/scipost/urls.py index 199cf0779..82c864196 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -9,4 +9,20 @@ urlpatterns = [ url(r'^about$', views.about, name='about'), url(r'^description$', views.description, name='description'), url(r'^peer_witnessed_refereeing$', views.peer_witnessed_refereeing, name='peer_witnessed_refereeing'), + ################ + # Contributors: + ################ + ## Registration + url(r'^register$', views.register, name='register'), + url(r'^thanks_for_registering$', views.thanks_for_registering, name='thanks for registering'), + url(r'^vet_registration_requests$', views.vet_registration_requests, name='vet_registration_requests'), + url(r'^vet_registration_request_ack/(?P<contributor_id>[0-9]+)$', views.vet_registration_request_ack, name='vet_registration_request_ack'), + ## Authentication + url(r'^login$', views.login_view, name='login'), + url(r'^logout$', views.logout_view, name='logout'), + url(r'^personal_page$', views.personal_page, name='personal_page'), + url(r'^change_password$', views.change_password, name='change_password'), + url(r'^change_password_ack$', views.change_password_ack, name='change_password_ack'), + url(r'^update_personal_data$', views.update_personal_data, name='update_personal_data'), + url(r'^update_personal_data_ack$', views.update_personal_data_ack, name='update_personal_data_ack'), ] diff --git a/scipost/views.py b/scipost/views.py index 54fdb0be4..4da8766fa 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -12,6 +12,12 @@ from django.db.models import Avg from .models import * from .forms import * +from commentaries.models import Commentary +from comments.models import Comment, AuthorReply +#from contributors.models import Contributor +from reports.models import Report +from submissions.models import Submission + ############# # Main view @@ -40,4 +46,196 @@ def peer_witnessed_refereeing(request): return render(request, 'scipost/peer_witnessed_refereeing.html') +################ +# Contributors: +################ + +title_dict = dict(TITLE_CHOICES) +reg_ref_dict = dict(REGISTRATION_REFUSAL_CHOICES) + +def register(request): + # If POST, process the form data + if request.method == 'POST': + # create a form instance and populate it with the form data + form = RegistrationForm(request.POST) + # check whether it's valid + if form.is_valid(): + # check for mismatching passwords + if form.cleaned_data['password'] != form.cleaned_data['password_verif']: + return render(request, 'register.html', {'form': form, 'errormessage': 'Your passwords must match'}) + # check for already-existing username + if User.objects.filter(username=form.cleaned_data['username']).exists(): + return render(request, 'register.html', {'form': form, 'errormessage': 'This username is already in use'}) + # create the user + user = User.objects.create_user ( + first_name = form.cleaned_data['first_name'], + last_name = form.cleaned_data['last_name'], + email = form.cleaned_data['email'], + username = form.cleaned_data['username'], + password = form.cleaned_data['password'] + ) + contributor = Contributor ( + user=user, + title = form.cleaned_data['title'], + orcid_id = form.cleaned_data['orcid_id'], + address = form.cleaned_data['address'], + affiliation = form.cleaned_data['affiliation'], + personalwebpage = form.cleaned_data['personalwebpage'], + ) + contributor.save() + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour request for registration to the SciPost publication portal has been received, and will be processed soon. Many thanks for your interest. \n\nThe SciPost Team.' + emailmessage = EmailMessage('SciPost registration request received', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) + emailmessage.send(fail_silently=False) + return HttpResponseRedirect('thanks_for_registering') + # if GET or other method, create a blank form + else: + form = RegistrationForm() + + errormessage = '' + return render(request, 'register.html', {'form': form, 'errormessage': errormessage}) + + +def thanks_for_registering(request): + return render(request, 'thanks_for_registering.html') + + +def vet_registration_requests(request): + contributor = Contributor.objects.get(user=request.user) + registration_requests_to_vet = Contributor.objects.filter(rank=0) + form = VetRegistrationForm() + context = {'contributor': contributor, 'registration_requests_to_vet': registration_requests_to_vet, 'form': form } + return render(request, 'vet_registration_requests.html', context) + + +def vet_registration_request_ack(request, contributor_id): + # process the form + if request.method == 'POST': + form = VetRegistrationForm(request.POST) + contributor = Contributor.objects.get(pk=contributor_id) + if form.is_valid(): + if form.cleaned_data['promote_to_rank_1']: + contributor.rank = 1 + contributor.save() + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been accepted. You can now login and contribute. \n\nThe SciPost Team.' + emailmessage = EmailMessage('SciPost registration accepted', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) + emailmessage.send(fail_silently=False) + else: + ref_reason = int(form.cleaned_data['refusal_reason']) + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been turned down, the reason being: ' + reg_ref_dict[ref_reason] + '. You can however still view all SciPost contents, just not submit papers, comments or votes. We nonetheless thank you for your interest. \n\nThe SciPost Team.' + if form.cleaned_data['email_response_field']: + email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] + emailmessage = EmailMessage('SciPost registration: unsuccessful', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) + emailmessage.send(fail_silently=False) + contributor.rank = form.cleaned_data['refusal_reason'] + contributor.save() + + context = {} + return render(request, 'vet_registration_request_ack.html', context) + + +def login_view(request): + if request.method == 'POST': + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(username=username, password=password) + if user is not None and user.contributor.rank > 0: + if user.is_active: + login(request, user) + contributor = Contributor.objects.get(user=request.user) + context = {'contributor': contributor } + return render(request, 'personal_page.html', context) + else: + return render(request, 'disabled_account.html') + else: + return render(request, 'login_error.html') + else: + form = AuthenticationForm() + return render(request, 'login.html', {'form': form}) + + +def logout_view(request): + logout(request) + return render(request, 'logout.html') + + +def personal_page(request): + if request.user.is_authenticated(): + contributor = Contributor.objects.get(user=request.user) + # if an editor, count the number of actions required: + nr_reg_to_vet = 0 + nr_submissions_to_process = 0 + if contributor.rank >= 4: + # count the number of pending registration request + nr_reg_to_vet = Contributor.objects.filter(rank=0).count() + nr_submissions_to_process = Submission.objects.filter(vetted=False).count() + nr_commentary_page_requests_to_vet = 0 + nr_comments_to_vet = 0 + nr_author_replies_to_vet = 0 + nr_reports_to_vet = 0 + if contributor.rank >= 2: + nr_commentary_page_requests_to_vet = Commentary.objects.filter(vetted=False).count() + nr_comments_to_vet = Comment.objects.filter(status=0).count() + nr_author_replies_to_vet = AuthorReply.objects.filter(status=0).count() + nr_reports_to_vet = Report.objects.filter(status=0).count() + context = {'contributor': contributor, 'nr_reg_to_vet': nr_reg_to_vet, 'nr_commentary_page_requests_to_vet': nr_commentary_page_requests_to_vet, 'nr_comments_to_vet': nr_comments_to_vet, 'nr_author_replies_to_vet': nr_author_replies_to_vet, 'nr_reports_to_vet': nr_reports_to_vet, 'nr_submissions_to_process': nr_submissions_to_process } + return render(request, 'personal_page.html', context) + else: + form = AuthenticationForm() + context = {'form': form} + return render(request, 'login.html', context) + + +def change_password(request): + if request.user.is_authenticated and request.method == 'POST': + form = PasswordChangeForm(request.POST) + if form.is_valid(): + # verify existing password: + if not request.user.check_password(form.cleaned_data['password_prev']): + return render(request, 'change_password.html', {'form': form, 'errormessage': 'The currently existing password you entered is incorrect'}) + # check for mismatching new passwords + if form.cleaned_data['password_new'] != form.cleaned_data['password_verif']: + return render(request, 'change_password.html', {'form': form, 'errormessage': 'Your new password entries must match'}) + # otherwise simply change the pwd: + request.user.set_password(form.cleaned_data['password_new']) + request.user.save() + return render(request, 'change_password_ack.html') + else: + form = PasswordChangeForm() + return render (request, 'change_password.html', {'form': form}) + + +def change_password_ack(request): + return render (request, 'change_password_ack.html') + + +def update_personal_data(request): + if request.user.is_authenticated: + contributor = Contributor.objects.get(user=request.user) + if request.method == 'POST': + form = UpdatePersonalDataForm(request.POST) + if form.is_valid(): + request.user.email = form.cleaned_data['email'] + request.user.first_name = form.cleaned_data['first_name'] + request.user.last_name = form.cleaned_data['last_name'] + request.user.contributor.title = form.cleaned_data['title'] + request.user.contributor.orcid = form.cleaned_data['orcid_id'] + request.user.contributor.address = form.cleaned_data['address'] + request.user.contributor.affiliation = form.cleaned_data['affiliation'] + request.user.contributor.personalwebpage = form.cleaned_data['personalwebpage'] + request.user.save() + request.user.contributor.save() + return render(request, 'update_personal_data_ack.html') + else: + #form = UpdatePersonalDataForm() + aff = contributor.affiliation + prefilldata = {'affiliation': aff} + form = UpdatePersonalDataForm(initial=prefilldata) + return render(request, 'update_personal_data.html', {'form': form, 'contributor': contributor}) + else: + form = AuthenticationForm() + return render(request, 'login.html', {'form': form}) + + +def update_personal_data_ack(request): + return render (request, 'update_personal_data_ack.html') diff --git a/submissions/migrations/0001_initial.py b/submissions/migrations/0001_initial.py index c86385d75..c3f11b855 100644 --- a/submissions/migrations/0001_initial.py +++ b/submissions/migrations/0001_initial.py @@ -8,17 +8,17 @@ import django.utils.timezone class Migration(migrations.Migration): dependencies = [ - ('contributors', '0001_initial'), + ('scipost', '0001_initial'), ] operations = [ migrations.CreateModel( name='Submission', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('vetted', models.BooleanField(default=False)), ('submitted_to_journal', models.CharField(max_length=30, choices=[('SciPost Physics Select', 'SciPost Physics Select'), ('SciPost Physics Letters', 'SciPost Physics Letters'), ('SciPost Physics X', 'SciPost Physics X (cross-division)'), ('SciPost Physics', 'SciPost Physics (Experimental, Theoretical and Computational)'), ('SciPost Physics Lecture Notes', 'SciPost Physics Lecture Notes')])), - ('domain', models.CharField(default='E', max_length=1, choices=[('E', 'Experimental'), ('T', 'Theoretical'), ('C', 'Computational')])), + ('domain', models.CharField(max_length=1, choices=[('E', 'Experimental'), ('T', 'Theoretical'), ('C', 'Computational')], default='E')), ('specialization', models.CharField(max_length=1, choices=[('A', 'Atomic, Molecular and Optical Physics'), ('B', 'Biophysics'), ('C', 'Condensed Matter Physics'), ('F', 'Fluid Dynamics'), ('G', 'Gravitation, Cosmology and Astroparticle Physics'), ('H', 'High-Energy Physics'), ('M', 'Mathematical Physics'), ('N', 'Nuclear Physics'), ('Q', 'Quantum Statistical Mechanics'), ('S', 'Statistical and Soft Matter Physics')])), ('status', models.SmallIntegerField(choices=[(0, 'unassigned'), (1, 'editor in charge assigned'), (2, 'under review'), (3, 'reviewed, peer checking period'), (4, 'reviewed, peer checked, editorial decision pending'), (5, 'editorial decision')])), ('open_for_reporting', models.BooleanField(default=True)), @@ -29,19 +29,19 @@ class Migration(migrations.Migration): ('arxiv_link', models.URLField(verbose_name='arXiv link (including version nr)')), ('submission_date', models.DateField(verbose_name='date of original publication')), ('nr_clarity_ratings', models.IntegerField(default=0)), - ('clarity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('clarity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_validity_ratings', models.IntegerField(default=0)), - ('validity_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('validity_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_rigour_ratings', models.IntegerField(default=0)), - ('rigour_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('rigour_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_originality_ratings', models.IntegerField(default=0)), - ('originality_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('originality_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('nr_significance_ratings', models.IntegerField(default=0)), - ('significance_rating', models.DecimalField(max_digits=3, default=0, null=True, decimal_places=0)), + ('significance_rating', models.DecimalField(decimal_places=0, max_digits=3, null=True, default=0)), ('latest_activity', models.DateTimeField(default=django.utils.timezone.now)), - ('authors', models.ManyToManyField(related_name='authors_sub', blank=True, to='contributors.Contributor')), - ('editor_in_charge', models.ForeignKey(null=True, related_name='editor_in_charge', blank=True, to='contributors.Contributor')), - ('submitted_by', models.ForeignKey(to='contributors.Contributor')), + ('authors', models.ManyToManyField(related_name='authors_sub', to='scipost.Contributor', blank=True)), + ('editor_in_charge', models.ForeignKey(related_name='editor_in_charge', null=True, blank=True, to='scipost.Contributor')), + ('submitted_by', models.ForeignKey(to='scipost.Contributor')), ], ), ] diff --git a/submissions/models.py b/submissions/models.py index e61084e41..47d438f2a 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User from .models import * -from contributors.models import Contributor +from scipost.models import Contributor from journals.models import * -- GitLab