diff --git a/SciPost_v1/settings/production.py b/SciPost_v1/settings/production.py index ab2cfb01f139d2fd78784cccc683cbfb7267adc6..617b72fdfcb8fdedab16b941119320d3ab092fad 100644 --- a/SciPost_v1/settings/production.py +++ b/SciPost_v1/settings/production.py @@ -42,3 +42,8 @@ DOAJ_API_KEY = get_secret("DOAJ_API_KEY") HAYSTACK_CONNECTIONS['default']['PATH'] = '/home/jscaux/webapps/scipost/SciPost_v1/whoosh_index' MAILCHIMP_API_USER = get_secret("MAILCHIMP_API_USER") MAILCHIMP_API_KEY = get_secret("MAILCHIMP_API_KEY") + +# iThenticate +ITHENTICATE_USERNAME = get_secret('ITHENTICATE_USERNAME') +ITHENTICATE_PASSWORD = get_secret('ITHENTICATE_PASSWORD') +ITHENTICATE_DEFAULT_FOLDER_ID = get_secret('ITHENTICATE_FOLDER_ID') diff --git a/comments/templatetags/comment_extras.py b/comments/templatetags/comment_extras.py index cd426b4d4612a57bfa1965159507b7ce43f1abd8..5ae3d8261883134688183e76825356cf8ec0d209 100644 --- a/comments/templatetags/comment_extras.py +++ b/comments/templatetags/comment_extras.py @@ -21,13 +21,13 @@ class CommentTemplateNode(template.Node): content_object = self.content_object.resolve(context) if isinstance(content_object, Submission): t = context.template.engine.get_template('submissions/_submission_summary_short.html') - return t.render({'submission': content_object}) + return t.render(template.Context({'submission': content_object})) elif isinstance(content_object, Commentary): t = context.template.engine.get_template('commentaries/_commentary_summary.html') - return t.render({'commentary': content_object}) + return t.render(template.Context({'commentary': content_object})) elif isinstance(content_object, ThesisLink): t = context.template.engine.get_template('theses/_thesislink_information.html') - return t.render({'thesislink': content_object}) + return t.render(template.Context({'thesislink': content_object})) else: raise template.TemplateSyntaxError( "The instance type given as an argument is not supported.") diff --git a/journals/migrations/0042_doajdeposit_metadata_doaj_file.py b/journals/migrations/0042_doajdeposit_metadata_doaj_file.py new file mode 100644 index 0000000000000000000000000000000000000000..7902c605713e7271fb92ba8e48bb9b0a7ecec119 --- /dev/null +++ b/journals/migrations/0042_doajdeposit_metadata_doaj_file.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-08-29 18:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0041_publication_funders_generic'), + ] + + operations = [ + migrations.AddField( + model_name='doajdeposit', + name='metadata_DOAJ_file', + field=models.FileField(blank=True, max_length=512, null=True, upload_to=''), + ), + ] diff --git a/journals/models.py b/journals/models.py index f472114235bed8485792f20c0e08e290ab5ad12d..d9d71060450d31e0ccf2cfb617367abb29947426 100644 --- a/journals/models.py +++ b/journals/models.py @@ -222,6 +222,7 @@ class DOAJDeposit(models.Model): publication = models.ForeignKey(Publication, on_delete=models.CASCADE) timestamp = models.CharField(max_length=40, default='') metadata_DOAJ = JSONField() + metadata_DOAJ_file = models.FileField(blank=True, null=True, max_length=512) deposition_date = models.DateTimeField(blank=True, null=True) response_text = models.TextField(blank=True, null=True) deposit_successful = models.NullBooleanField(default=None) diff --git a/journals/views.py b/journals/views.py index a6e7f7a07866bfc29282365ea443f8ad0afd7b89..fcbae8ad546907d6e99a3695337db626bf11861b 100644 --- a/journals/views.py +++ b/journals/views.py @@ -1,4 +1,5 @@ import hashlib +import json import os import random import requests @@ -790,39 +791,36 @@ def metadata_DOAJ_deposit(request, doi_label): url = 'https://doaj.org/api/v1/articles' params = { - 'operation': 'doMDUpload', 'api_key': settings.DOAJ_API_KEY, - } - files = {'fname': ('metadata.json', publication.metadata_xml, 'application/json')} + 'article_json': publication.metadata_DOAJ, + } try: - r = requests.post(url, params=params, files=files) + r = requests.post(url, params=params) r.raise_for_status() except requests.exceptions.HTTPError: - messages.warning(request, '<h3>%s</h3>Failed: Post went wrong. Did you set the right ' - 'DOAJ API KEY?' % publication.doi_label) - return redirect(reverse('journals:manage_metadata')) + messages.warning(request, '<h3>%s</h3>Failed: Post went wrong, response text: %s' % ( + publication.doi_label, r.text)) # Then create the associated Deposit object (saving the metadata to a file) - content = ContentFile(publication.metadata_xml) + content = ContentFile(json.dumps(publication.metadata_DOAJ)) deposit = DOAJDeposit(publication=publication, timestamp=timestamp, metadata_DOAJ=publication.metadata_DOAJ, deposition_date=timezone.now()) - deposit.metadata_xml_file.save(path, content) + deposit.metadata_DOAJ_file.save(path, content) deposit.response_text = r.text deposit.save() - publication.latest_crossref_deposit = timezone.now() - publication.save() # Save a copy to the filename without timestamp path1 = (settings.MEDIA_ROOT + publication.in_issue.path + '/' + publication.get_paper_nr() + '/' + publication.doi_label.replace('.', '_') + '_DOAJ.json') f = open(path1, 'w') - f.write(publication.metadata_DOAJ) + f.write(json.dumps(publication.metadata_DOAJ)) f.close() messages.success(request, '<h3>%s</h3>Successfull deposit of metadata DOAJ.' % publication.doi_label) - return redirect(reverse('journals:manage_metadata')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -833,7 +831,8 @@ def mark_doaj_deposit_success(request, deposit_id, success): elif success == '0': deposit.deposit_successful = False deposit.save() - return redirect(reverse('journals:manage_metadata')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': deposit.publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) diff --git a/partners/migrations/0032_auto_20170829_0727.py b/partners/migrations/0032_auto_20170829_0727.py new file mode 100644 index 0000000000000000000000000000000000000000..375d21ed46289761e9d4a99156c40bd8196a359e --- /dev/null +++ b/partners/migrations/0032_auto_20170829_0727.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-08-29 05:27 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('partners', '0031_auto_20170815_0901'), + ] + + operations = [ + migrations.RenameField( + model_name='contact', + old_name='_activation_key', + new_name='activation_key', + ), + ] diff --git a/partners/models.py b/partners/models.py index 0de3ca51149e6749c58fdece4c2a300e25be5779..1d7f39a882f9a0ba0d2aa4c2ae123cc1ccecbe33 100644 --- a/partners/models.py +++ b/partners/models.py @@ -157,7 +157,7 @@ class Contact(models.Model): consortia = models.ManyToManyField('partners.Consortium', blank=True, help_text=('All Consortia for which the Contact has' ' explicit permission to view/edit its data.')) - _activation_key = models.CharField(max_length=40, blank=True) + activation_key = models.CharField(max_length=40, blank=True) key_expires = models.DateTimeField(default=timezone.now) def __str__(self): @@ -171,15 +171,13 @@ class Contact(models.Model): feed += random.choice(string.ascii_letters) feed = feed.encode('utf8') salt = self.user.username.encode('utf8') - self._activation_key = hashlib.sha1(salt+salt).hexdigest() + self.activation_key = hashlib.sha1(salt+salt).hexdigest() self.key_expires = datetime.datetime.now() + datetime.timedelta(days=2) - def get_activation_key(self): - if not self._activation_key: + def save(self, *args, **kwargs): + if not self.activation_key: self.generate_key() - return self._activation_key - - activation_key = property(get_activation_key, _activation_key) + super().save(*args, **kwargs) def delete_or_remove_partner(self, partner, *args, **kwargs): """ diff --git a/requirements.txt b/requirements.txt index 8882d53cf9ef79c394fcbb6c3ea32cdacdfd2d4a..1998b0de2cad7bd0cd959c426b09031a3e01b503 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,7 +43,7 @@ Whoosh==2.7.4 # Directly related to Haystack. # Python Utils -ithenticate-api-python==0.4.1 +ithenticate-api-python==0.4.2 mailchimp3==2.0.15 python-dateutil==2.6.0 # Doesn't Django have this functionality built-in? -- JdW Pillow==3.4.2 # Latest version is v4.2.1; need to know about usage before upgrade. -- JdW diff --git a/scipost/migrations/0063_auto_20170829_0727.py b/scipost/migrations/0063_auto_20170829_0727.py new file mode 100644 index 0000000000000000000000000000000000000000..aef6bd439b40ca1780a1c1944cd01bd26c5b43ea --- /dev/null +++ b/scipost/migrations/0063_auto_20170829_0727.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-08-29 05:27 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('scipost', '0062_auto_20170815_0857'), + ] + + operations = [ + migrations.RenameField( + model_name='contributor', + old_name='_activation_key', + new_name='activation_key', + ), + migrations.AlterField( + model_name='remark', + name='contributor', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='scipost.Contributor'), + ), + migrations.AlterField( + model_name='remark', + name='feedback', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='virtualmeetings.Feedback'), + ), + migrations.AlterField( + model_name='remark', + name='motion', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='virtualmeetings.Motion'), + ), + migrations.AlterField( + model_name='remark', + name='nomination', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='virtualmeetings.Nomination'), + ), + migrations.AlterField( + model_name='remark', + name='recommendation', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='submissions.EICRecommendation'), + ), + migrations.AlterField( + model_name='remark', + name='submission', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='submissions.Submission'), + ), + migrations.AlterField( + model_name='unavailabilityperiod', + name='contributor', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='unavailability_periods', to='scipost.Contributor'), + ), + ] diff --git a/scipost/models.py b/scipost/models.py index 99c0619355ba7fdb0902a8a57a435a067d359f12..d6cac15fd9be45affe5c0bfbe9e9ba47ace74861 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -41,7 +41,7 @@ class Contributor(models.Model): """ user = models.OneToOneField(User, on_delete=models.PROTECT, unique=True) invitation_key = models.CharField(max_length=40, blank=True) - _activation_key = models.CharField(max_length=40, blank=True) + activation_key = models.CharField(max_length=40, blank=True) key_expires = models.DateTimeField(default=timezone.now) status = models.SmallIntegerField(default=0, choices=CONTRIBUTOR_STATUS) title = models.CharField(max_length=4, choices=TITLE_CHOICES) @@ -70,6 +70,11 @@ class Contributor(models.Model): def __str__(self): return '%s, %s' % (self.user.last_name, self.user.first_name) + def save(self, *args, **kwargs): + if not self.activation_key: + self.generate_key() + super().save(*args, **kwargs) + def get_absolute_url(self): return reverse('scipost:contributor_info', args=(self.id,)) @@ -90,13 +95,6 @@ class Contributor(models.Model): def is_VE(self): return self.user.groups.filter(name='Vetting Editors').exists() - def get_activation_key(self): - if not self._activation_key: - self.generate_key() - return self._activation_key - - activation_key = property(get_activation_key, _activation_key) - def generate_key(self, feed=''): """ Generate and save a new activation_key for the contributor, given a certain feed. @@ -105,7 +103,7 @@ class Contributor(models.Model): feed += random.choice(string.ascii_letters) feed = feed.encode('utf8') salt = self.user.username.encode('utf8') - self._activation_key = hashlib.sha1(salt+salt).hexdigest() + self.activation_key = hashlib.sha1(salt+salt).hexdigest() self.key_expires = datetime.datetime.now() + datetime.timedelta(days=2) def expertises_as_string(self): diff --git a/scipost/utils.py b/scipost/utils.py index 84e0e4673cf216ecd329e25167496f821bcb4200..9730400f0dcb6c5a004ac9644d57d1ac073ee17a 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -342,7 +342,7 @@ class Utils(BaseMailUtil): email_text_html += SCIPOST_SUMMARY_FOOTER_HTML email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: refereeing request (and registration invitation)', email_text, 'SciPost Refereeing <refereeing@scipost.org>', @@ -380,7 +380,7 @@ class Utils(BaseMailUtil): email_text_html += summary_text_html email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: invitation', email_text, 'SciPost registration <registration@scipost.org>', @@ -417,7 +417,7 @@ class Utils(BaseMailUtil): email_text_html += summary_text_html email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: invitation', email_text, 'SciPost registration <registration@scipost.org>', @@ -438,7 +438,7 @@ class Utils(BaseMailUtil): 'called SciPost, and to invite you to become an active Contributor.</p>') email_text_html += summary_text_html + '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: invitation', email_text, 'SciPost registration <registration@scipost.org>', @@ -597,7 +597,7 @@ class Utils(BaseMailUtil): email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost registration invitation', email_text, 'J-S Caux <jscaux@scipost.org>', @@ -654,7 +654,7 @@ class Utils(BaseMailUtil): email_context['citation'] = cls.notification.cited_in_publication.citation() email_context['key'] = cls.notification.contributor.activation_key html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) elif cls.notification.cited_in_submission: url_unsubscribe = reverse('scipost:unsubscribe', args=[cls.notification.contributor.id, diff --git a/scipost/views.py b/scipost/views.py index 349d0f80f379177a332171bc03a053b906f9b5cc..b2a04826966cf778595b70b0fb5fed260f9ead1b 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -1094,7 +1094,7 @@ def email_group_members(request): 'key': member.contributor.activation_key, } html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) message = EmailMultiAlternatives( form.cleaned_data['email_subject'], email_text, 'SciPost Admin <admin@scipost.org>', @@ -1128,7 +1128,7 @@ def email_particular(request): email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) message = EmailMultiAlternatives( form.cleaned_data['email_subject'], email_text, 'SciPost Admin <admin@scipost.org>', @@ -1170,7 +1170,7 @@ def send_precooked_email(request): email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) message = EmailMultiAlternatives( precookedEmail.email_subject, email_text, diff --git a/submissions/forms.py b/submissions/forms.py index 6786337b8b2e0dbdc592e9c2886ee6a74d0a39b3..33d4ebb5d3c04b06344932f6cf85f5f44e94b7a6 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -677,16 +677,23 @@ class iThenticateReportForm(forms.ModelForm): return None def save(self, *args, **kwargs): - data = self.response['data'] - if self.instance: - report = self.instance + data = self.response['data'][0] + + report, created = iThenticateReport.objects.get_or_create(doc_id=data['id']) + + if not created: + try: + iThenticateReport.objects.filter(doc_id=data['id']).update( + uploaded_time=data['uploaded_time'], + processed_time=data['processed_time'], + percent_match=data['percent_match'] + ) + except KeyError: + pass else: - report = iThenticateReport.objects.get_or_create(doc_id=data['id']) - report.submission = self.submission - report.uploaded_time = data['uploaded_time'] - report.processed_time = data['processed_time'] - report.percent_match = data['percent_match'] - report.save() + report.save() + self.submission.plagiarism_report = report + self.submission.save() return report def call_ithenticate(self): @@ -709,7 +716,7 @@ class iThenticateReportForm(forms.ModelForm): client = self.client response = client.documents.get(self.document_id) if response['status'] == 200: - return response['data'] + return response self.add_error(None, "Updating failed. iThenticate didn't return valid data [1]") self.add_error(None, client.messages[0]) return None @@ -742,7 +749,7 @@ class iThenticateReportForm(forms.ModelForm): if response['status'] == 200: self.submission.add_general_event(('The document has been submitted ' 'for a plagiarism check.')) - return response['data'] + return response self.add_error(None, "Updating failed. iThenticate didn't return valid data [3]") self.add_error(None, client.messages[0]) diff --git a/submissions/migrations/0065_auto_20170829_0727.py b/submissions/migrations/0065_auto_20170829_0727.py new file mode 100644 index 0000000000000000000000000000000000000000..f185ec8b7990c1c9def136b892b772391bb4e31a --- /dev/null +++ b/submissions/migrations/0065_auto_20170829_0727.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-08-29 05:27 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0064_auto_20170815_0826'), + ] + + operations = [ + migrations.AlterModelOptions( + name='editorialassignment', + options={'ordering': ['-date_created']}, + ), + migrations.AlterField( + model_name='editorialassignment', + name='submission', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='editorial_assignments', to='submissions.Submission'), + ), + migrations.AlterField( + model_name='editorialassignment', + name='to', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='editorial_assignments', to='scipost.Contributor'), + ), + ] diff --git a/submissions/mixins.py b/submissions/mixins.py index 6f82693b101bc7bcad1e706d73f1c381ef4f36a2..44cc263a517ec01384419d4684333e9921954b6b 100644 --- a/submissions/mixins.py +++ b/submissions/mixins.py @@ -1,3 +1,4 @@ +from django.core.exceptions import ImproperlyConfigured from django.contrib.auth.mixins import PermissionRequiredMixin from django.views.generic.list import ListView @@ -22,6 +23,16 @@ class FriendlyPermissionMixin(PermissionRequiredMixin): class SubmissionFormViewMixin: + def get_success_url(self): + if not self.success_url: + try: + return str(self.get_object().get_absolute_url()) + except: + raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.") + + return str(self.success_url) # success_url may be lazy + + def get_form_kwargs(self): """ Ideally all ModelForms on Submission-related objects have a required argument `submission`. diff --git a/submissions/models.py b/submissions/models.py index f5a03da1d5c5e3bd6f4ff811d39a3162bf9b3a39..5bfa657572ab51bdbf6e4a8a4e5340893c0478ba 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -540,9 +540,9 @@ class iThenticateReport(TimeStampedModel): arxiv=self.to_submission.arxiv_identifier_w_vn_nr) return _str - def save(self, commit=True, **kwargs): - obj = super().save(commit, **kwargs) - if hasattr(self, 'to_submission') and commit: + def save(self, *args, **kwargs): + obj = super().save(*args, **kwargs) + if hasattr(self, 'to_submission') and kwargs.get('commit', True): self.to_submission.touch() return obj diff --git a/submissions/templates/submissions/_submission_card_base.html b/submissions/templates/submissions/_submission_card_base.html index 1ae9aa194280261c3e1bfed398bd75f3818a32d1..fa4d0d8c90afdca722169f35e2d1865095471efc 100644 --- a/submissions/templates/submissions/_submission_card_base.html +++ b/submissions/templates/submissions/_submission_card_base.html @@ -1,7 +1,7 @@ <div class="card-body {% block cardblock_class_block %}{% endblock %}"> <h5 class="pb-0">{{submission.get_subject_area_display}}</h5> <h3 class="card-title {% block title_class_block %}{% endblock %}"> - <a href="{% url 'submissions:submission' submission.arxiv_identifier_w_vn_nr %}">{{submission.title}}</a> + <a href="{{submission.get_absolute_url}}">{{submission.title}}</a> </h3> {% block card_block_footer %}{% endblock %} diff --git a/submissions/utils.py b/submissions/utils.py index 2fe298451595321a8b7485c1cf43227d57f4b833..6df48fd32740f147c74a35676855a543309df841 100644 --- a/submissions/utils.py +++ b/submissions/utils.py @@ -330,7 +330,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: Submission received', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -369,7 +369,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: Resubmission received', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -422,7 +422,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: potential Submission assignment', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -479,7 +479,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: assignment as EIC', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -564,7 +564,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: pre-screening passed', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -614,7 +614,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: pre-screening not passed', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -733,7 +733,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: reminder (refereeing request and registration invitation)', email_text, 'SciPost Refereeing <refereeing@scipost.org>', @@ -819,7 +819,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: reminder (refereeing request and registration invitation)', email_text, 'SciPost Refereeing <refereeing@scipost.org>', @@ -887,7 +887,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: report no longer needed', email_text, 'SciPost Refereeing <refereeing@scipost.org>', @@ -1006,7 +1006,7 @@ class SubmissionUtils(BaseMailUtil): email_context['refusal_reason'] = cls.report.get_status_display() email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: Report acknowledgement', email_text, 'SciPost Refereeing <refereeing@scipost.org>', @@ -1059,7 +1059,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: Report received on your Submission', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -1101,7 +1101,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: Comment received on your Submission', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -1232,7 +1232,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: revision requested', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -1322,7 +1322,7 @@ class SubmissionUtils(BaseMailUtil): } email_text_html += '<br/>' + EMAIL_FOOTER html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: College decision', email_text, 'SciPost Editorial Admin <submissions@scipost.org>', @@ -1359,7 +1359,7 @@ class SubmissionUtils(BaseMailUtil): '<p>The SciPost Team.</p><br/>' + EMAIL_FOOTER) email_context = {} html_template = Template(email_text_html) - html_version = html_template.render(email_context) + html_version = html_template.render(Context(email_context)) emailmessage = EmailMultiAlternatives( 'SciPost: voting duties', email_text, 'SciPost Editorial Admin <admin@scipost.org>', diff --git a/submissions/views.py b/submissions/views.py index e4f4615f536b2899e8aaa992ec4299c3675b3c37..8468bdf8cfd4cad5d017399f7bb895c2d551310d 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -1389,7 +1389,7 @@ def remind_Fellows_to_vote(request): for name in sorted(Fellow_names): ack_message += '<li>' + name + '</li>' ack_message += '</ul>' - context = {'ack_message': Template(ack_message).render({}), + context = {'ack_message': Template(ack_message).render(Context({})), 'followup_message': 'Return to the ', 'followup_link': reverse('submissions:pool'), 'followup_link_label': 'Submissions pool'} @@ -1486,7 +1486,6 @@ class PlagiarismView(SubmissionAdminViewMixin, UpdateView): permission_required = 'scipost.can_do_plagiarism_checks' template_name = 'submissions/admin/plagiarism_report.html' editorial_page = True - success_url = reverse_lazy('submissions:plagiarism') form_class = iThenticateReportForm def get_object(self): diff --git a/theses/migrations/0007_auto_20170829_0727.py b/theses/migrations/0007_auto_20170829_0727.py new file mode 100644 index 0000000000000000000000000000000000000000..a6c696068375c047a4a721c31bc1206972ab42d2 --- /dev/null +++ b/theses/migrations/0007_auto_20170829_0727.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-08-29 05:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('theses', '0006_auto_20161219_2012'), + ] + + operations = [ + migrations.AlterField( + model_name='thesislink', + name='supervisor', + field=models.CharField(max_length=1000), + ), + ] diff --git a/virtualmeetings/views.py b/virtualmeetings/views.py index 23e3c3e3d3d0e5b8e0b58052793d687564b177b6..cb3d7984b9d226a453a2a43fdd4e91df6ea40057 100644 --- a/virtualmeetings/views.py +++ b/virtualmeetings/views.py @@ -27,7 +27,7 @@ def VGMs(request): @permission_required('scipost.can_attend_VGMs') def VGM_detail(request, VGM_id): VGM_instance = get_object_or_404(VGM, id=VGM_id) - VGM_information = Template(VGM_instance.information).render({}) + VGM_information = Template(VGM_instance.information).render(Context({})) feedback_received = Feedback.objects.filter(VGM=VGM_instance).order_by('date') feedback_form = FeedbackForm() current_Fellows = Contributor.objects.filter(