diff --git a/src/core/homepage_elements/news/forms.py b/src/core/homepage_elements/news/forms.py new file mode 100644 index 0000000000..21264afea2 --- /dev/null +++ b/src/core/homepage_elements/news/forms.py @@ -0,0 +1,51 @@ +from django import forms + +from utils import setting_handler +from core.homepage_elements.popular import plugin_settings, logic + + +class NewsForm(forms.Form): + number_of_articles = forms.IntegerField( + help_text='Number of news articles to display on the homepage.' + ) + display_images = forms.BooleanField( + help_text='When enabled the News Plugin will display news images. ' + 'Note: this setting has no effect on the clean theme ' + 'which does not display images for news.', + required=False + ) + + def __init__(self, *args, **kwargs): + self.journal = kwargs.pop('journal', None) + super(NewsForm, self).__init__(*args, **kwargs) + number_of_articles = setting_handler.get_setting( + 'plugin:News', + 'number_of_articles', + self.journal, + ) + display_images = setting_handler.get_setting( + 'plugin:News', + 'display_images', + self.journal, + ) + self.fields['number_of_articles'].initial = number_of_articles.value + self.fields['display_images'].initial = True if display_images.value else False + + def save(self, commit=True): + number_of_articles = self.cleaned_data.get('number_of_articles') + display_images = self.cleaned_data.get('display_images') + + if commit: + setting_handler.save_setting( + 'plugin:News', + 'number_of_articles', + self.journal, + number_of_articles, + ) + setting_handler.save_setting( + 'plugin:News', + 'display_images', + self.journal, + 'On' if display_images else '', + ) + diff --git a/src/core/homepage_elements/news/hooks.py b/src/core/homepage_elements/news/hooks.py index 72d3886ea3..bedc2ed0b4 100755 --- a/src/core/homepage_elements/news/hooks.py +++ b/src/core/homepage_elements/news/hooks.py @@ -21,6 +21,11 @@ def yield_homepage_element_context(request, homepage_elements): request.journal if request.journal else None).value number_of_articles = int( number_of_articles) if number_of_articles else 2 + display_images = setting_handler.get_setting( + 'plugin:News', + 'display_images', + request.journal, + ).value news_items = comms_models.NewsItem.objects.filter( (Q(content_type=request.model_content_type) & Q( @@ -29,6 +34,9 @@ def yield_homepage_element_context(request, homepage_elements): (Q(end_display__gte=timezone.now()) | Q(end_display=None)) ).order_by('-posted')[:number_of_articles] - return {'news_items': news_items} + return { + 'news_items': news_items, + 'display_images': display_images, + } else: return {} diff --git a/src/core/homepage_elements/news/plugin_settings.py b/src/core/homepage_elements/news/plugin_settings.py index 4825fb19e7..0fe2277c09 100755 --- a/src/core/homepage_elements/news/plugin_settings.py +++ b/src/core/homepage_elements/news/plugin_settings.py @@ -40,6 +40,18 @@ def install(): setting, default_value=DEFAULT_NEWS, ) + setting = setting_handler.create_setting( + setting_group_name=plugin_group_name, + setting_name='display_images', + type='boolean', + pretty_name='Display Images', + description='When enabled the News Plugin will display news images.', + is_translatable=False, + ) + setting_handler.get_or_create_default_setting( + setting, + default_value='', + ) for journal in journals: content_type = ContentType.objects.get_for_model(journal) diff --git a/src/core/homepage_elements/news/templates/news_settings.html b/src/core/homepage_elements/news/templates/news_settings.html index a8bdb1c6a4..9297783e8d 100644 --- a/src/core/homepage_elements/news/templates/news_settings.html +++ b/src/core/homepage_elements/news/templates/news_settings.html @@ -13,18 +13,12 @@ {% endblock %} {% block body %} -
+
+ {% include "admin/elements/forms/errors.html" with form=form %}
{% csrf_token %} - You can set the number of news articles to display. - + {{ form|foundation }}
{% endblock body %} - -{% block js %} -{% include "elements/jqte.html" %} -{% endblock js %} - - diff --git a/src/core/homepage_elements/news/views.py b/src/core/homepage_elements/news/views.py index 00b8691dcf..f999a79cf3 100755 --- a/src/core/homepage_elements/news/views.py +++ b/src/core/homepage_elements/news/views.py @@ -4,30 +4,29 @@ from utils import setting_handler, models from security.decorators import editor_user_required +from core.homepage_elements.news import forms @editor_user_required def news_config(request): - plugin = models.Plugin.objects.get(name='News') - number_of_articles = setting_handler.get_plugin_setting( - plugin, - 'number_of_articles', - request.journal, - create=True, - pretty='Number of Articles', - ).value - number_of_articles = int( - number_of_articles - ) if number_of_articles else 2 + form = forms.NewsForm(journal=request.journal) if request.POST: - number_of_articles = request.POST.get('number_of_articles') - setting_handler.save_plugin_setting(plugin, 'number_of_articles', number_of_articles, request.journal) - messages.add_message(request, messages.INFO, 'Number of articles updated.') - return redirect(reverse('home_settings_index')) + form = forms.NewsForm( + request.POST, + journal=request.journal, + ) + if form.is_valid(): + form.save() + messages.add_message( + request, + messages.INFO, + 'News settings updated.' + ) + return redirect(reverse('home_settings_index')) template = 'news_settings.html' context = { - 'number_of_articles': number_of_articles, + 'form': form, } return render(request, template, context) diff --git a/src/core/janeway_global_settings.py b/src/core/janeway_global_settings.py index f5eefca4b9..6e878085e9 100755 --- a/src/core/janeway_global_settings.py +++ b/src/core/janeway_global_settings.py @@ -600,6 +600,13 @@ def __len__(self): 'clean', ] +# Repository theme setting determines which themes currently +# support repositories. +REPOSITORY_THEMES = [ + 'OLH', + 'material', +] + INSTALLATION_BASE_THEME = 'OLH' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' diff --git a/src/journal/models.py b/src/journal/models.py index 0b0687b72b..135b955c73 100644 --- a/src/journal/models.py +++ b/src/journal/models.py @@ -35,6 +35,7 @@ from utils import setting_handler, logic, install from utils.function_cache import cache, mutable_cached_property from utils.logger import get_logger +from review import models as review_models logger = get_logger(__name__) @@ -511,6 +512,28 @@ def description_for_press(self): setting_name='journal_description', ) + def setup_default_review_form(self): + default_review_form, c = review_models.ReviewForm.objects.get_or_create( + journal=self, + name='Default Form', + defaults={ + 'intro': 'Please complete the form below.', + 'thanks': 'Thank you for completing the review.', + } + ) + + if c: + main_element = review_models.ReviewFormElement.objects.create( + name='Review', + kind='textarea', + required=True, + order=1, + width='large-12 columns', + help_text=gettext('Please add as much detail as you can.'), + ) + + default_review_form.elements.add(main_element) + class PinnedArticle(models.Model): journal = models.ForeignKey( @@ -1259,30 +1282,13 @@ def setup_submission_items(sender, instance, created, **kwargs): @receiver(post_save, sender=Journal) def setup_default_form(sender, instance, created, **kwargs): - if created: - from review import models as review_models - - if not review_models.ReviewForm.objects.filter( - journal=instance, - ).exists(): - - default_review_form = review_models.ReviewForm.objects.create( - journal=instance, - name='Default Form', - intro='Please complete the form below.', - thanks='Thank you for completing the review.' - ) - - main_element = review_models.ReviewFormElement.objects.create( - name='Review', - kind='textarea', - required=True, - order=1, - width='large-12 columns', - help_text=gettext('Please add as much detail as you can.'), - ) + # if this is a new journal and there is not default review for already + # create a new one with a default review element. + if created and not review_models.ReviewForm.objects.filter( + journal=instance, + ).exists(): + instance.setup_default_review_form() - default_review_form.elements.add(main_element) @receiver(post_save, sender=Journal) diff --git a/src/repository/admin.py b/src/repository/admin.py index 0e913dee08..676d38840b 100755 --- a/src/repository/admin.py +++ b/src/repository/admin.py @@ -190,6 +190,14 @@ class ReviewAdmin(admin_utils.PreprintFKModelAdmin): date_hierarchy = ('date_assigned') +class ReviewRecommendationAdmin(admin.ModelAdmin): + list_display = ('pk', 'name', 'repository') + list_display_links = ('pk', 'name',) + list_filter = ('repository',) + raw_id_fields = ('repository',) + search_fields = ('name',) + + admin_list = [ (models.Repository, RepositoryAdmin), (models.RepositoryRole, RepositoryRoleAdmin), @@ -206,7 +214,7 @@ class ReviewAdmin(admin_utils.PreprintFKModelAdmin): (models.Subject, SubjectAdmin), (models.VersionQueue, VersionQueueAdmin), (models.Review, ReviewAdmin), - + (models.ReviewRecommendation, ReviewRecommendationAdmin), ] [admin.site.register(*t) for t in admin_list] diff --git a/src/repository/forms.py b/src/repository/forms.py index f3b71d6d71..db487c863c 100755 --- a/src/repository/forms.py +++ b/src/repository/forms.py @@ -457,6 +457,7 @@ class Meta: 'domain', 'object_name', 'object_name_plural', + 'theme', 'publisher', ) help_texts = { @@ -673,6 +674,9 @@ class ReviewCommentForm(forms.Form): widget=SummernoteWidget(), label="Comments", ) + recommendation = forms.ModelChoiceField( + queryset=models.ReviewRecommendation.objects.none(), + ) anonymous = forms.BooleanField( help_text='Check if you want your comments to be displayed anonymously.', label="Comment Anonymously", @@ -685,6 +689,12 @@ def __init__(self, *args, **kwargs): if self.review.comment: self.fields['body'].initial = self.review.comment.body self.fields['anonymous'].initial = self.review.anonymous + self.fields['recommendation'].initial = self.review.recommendation.pk + + self.fields['recommendation'].queryset = models.ReviewRecommendation.objects.filter( + repository=self.review.preprint.repository, + active=True, + ) def save(self): if self.cleaned_data: @@ -700,77 +710,27 @@ def save(self): self.review.anonymous = self.cleaned_data.get('anonymous', False) self.review.comment = comment + self.review.recommendation = self.cleaned_data.get('recommendation') self.review.save() -class ReviewForm(forms.ModelForm): +class RecommendationForm(forms.ModelForm): class Meta: - model = models.Review + model = models.ReviewRecommendation fields = ( - 'reviewer', - 'date_due', + 'name', + 'active', ) - widgets = { - 'date_due': utils_forms.HTMLDateInput(), - } def __init__(self, *args, **kwargs): - self.preprint = kwargs.pop('preprint') - self.manager = kwargs.pop('manager') - super(ReviewForm, self).__init__(*args, **kwargs) - self.fields['reviewer'].queryset = self.preprint.repository.reviewer_accounts() + self.repository = kwargs.pop('repository') + super(RecommendationForm, self).__init__(*args, **kwargs) def save(self, commit=True): - review = super(ReviewForm, self).save(commit=False) - review.preprint = self.preprint - review.manager = self.manager - review.status = 'new' + recommendation = super(RecommendationForm, self).save(commit=False) + recommendation.repository = self.repository if commit: - review.save() - - return review - - -class ReviewDueDateForm(forms.ModelForm): - class Meta: - model = models.Review - fields = ('date_due',) - widgets = { - 'date_due': utils_forms.HTMLDateInput(), - } - + recommendation.save() -class ReviewCommentForm(forms.Form): - body = forms.CharField( - widget=SummernoteWidget(), - label="Comments", - ) - anonymous = forms.BooleanField( - help_text='Check if you want your comments to be displayed anonymously.', - label="Comment Anonymously", - required=False, - ) - - def __init__(self, *args, **kwargs): - self.review = kwargs.pop('review') - super(ReviewCommentForm, self).__init__(*args, **kwargs) - if self.review.comment: - self.fields['body'].initial = self.review.comment.body - self.fields['anonymous'].initial = self.review.anonymous - - def save(self): - if self.cleaned_data: - if self.review.comment: - comment = self.review.comment - else: - comment = models.Comment() - - comment.author = self.review.reviewer - comment.preprint = self.review.preprint - comment.body = self.cleaned_data.get('body') - comment.save() - - self.review.anonymous = self.cleaned_data.get('anonymous', False) - self.review.comment = comment - self.review.save() + return recommendation diff --git a/src/repository/logic.py b/src/repository/logic.py index d27472db55..176c78fa90 100755 --- a/src/repository/logic.py +++ b/src/repository/logic.py @@ -162,20 +162,40 @@ def raise_comment_event(request, comment): def comment_manager_post(request, preprint): if 'comment_public' in request.POST: comment_id = request.POST.get('comment_public') - else: + elif 'comment_reviewed' in request.POST: comment_id = request.POST.get('comment_reviewed') + elif 'comment_delete' in request.POST: + comment_id = request.POST.get('comment_delete') + else: + return comment = get_object_or_404( models.Comment, - pk=comment_id,preprint=preprint, + pk=comment_id, + preprint=preprint, + preprint__repository=request.repository, ) if 'comment_public' in request.POST: comment.toggle_public() - - else: + elif 'comment_reviewed' in request.POST: comment.mark_reviewed() + if 'comment_delete' in request.POST: + if request.user in request.repository.managers.all(): + comment.delete() + messages.add_message( + request, + messages.SUCCESS, + 'Comment deleted', + ) + else: + messages.add_message( + request, + messages.WARNING, + 'You do not have permission to delete this comment.', + ) + # TODO: Update this implementation def handle_author_post(request, preprint): diff --git a/src/repository/migrations/0040_auto_20231207_1002.py b/src/repository/migrations/0040_auto_20231207_1002.py new file mode 100644 index 0000000000..14e567bd9f --- /dev/null +++ b/src/repository/migrations/0040_auto_20231207_1002.py @@ -0,0 +1,43 @@ +# Generated by Django 3.2.20 on 2023-12-07 10:02 + +from django.db import migrations, models + + +def set_repo_themes(apps, schema_editor): + """ + For existing repositories we should set the theme back to material. + """ + Repository = apps.get_model( + 'repository', + 'Repository', + ) + Repository.objects.all().update(theme='material') + + +class Migration(migrations.Migration): + + dependencies = [ + ('repository', '0039_alter_preprintversion_title'), + ] + + operations = [ + migrations.AddField( + model_name='historicalrepository', + name='theme', + field=models.CharField(choices=[('material', 'material'), ('OLH', 'OLH')], default='material', max_length=20), + ), + migrations.AddField( + model_name='repository', + name='theme', + field=models.CharField(choices=[('material', 'material'), ('OLH', 'OLH')], default='OLH', max_length=20), + ), + migrations.AlterField( + model_name='preprintversion', + name='title', + field=models.CharField(blank=True, help_text='Your article title', max_length=300), + ), + migrations.RunPython( + set_repo_themes, + reverse_code=migrations.RunPython.noop + ), + ] diff --git a/src/repository/migrations/0040_auto_20231207_1658.py b/src/repository/migrations/0040_auto_20231207_1658.py new file mode 100644 index 0000000000..36d7c5e9cf --- /dev/null +++ b/src/repository/migrations/0040_auto_20231207_1658.py @@ -0,0 +1,52 @@ +# Generated by Django 3.2.20 on 2023-12-07 16:58 +import os +import json +from django.db import migrations, models +import django.db.models.deletion +from django.conf import settings + +def add_default_recommendations(apps, schema_editor): + ReviewRecommendation = apps.get_model("repository", "ReviewRecommendation") + Repository = apps.get_model("repository", "Repository") + + defaults_file = open( + os.path.join( + settings.BASE_DIR, + 'utils', + 'install', + 'default_repository_review_recommendations.json', + ) + ) + defaults = json.load(defaults_file) + for repo in Repository.objects.all(): + for default in defaults: + ReviewRecommendation.objects.get_or_create( + repository=repo, + name=default, + ) + defaults_file.close() + + +class Migration(migrations.Migration): + + dependencies = [ + ('repository', '0039_alter_preprintversion_title'), + ] + + operations = [ + migrations.CreateModel( + name='ReviewRecommendation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='repository.repository')), + ('active', models.BooleanField(default=True)), + ], + ), + migrations.AddField( + model_name='review', + name='recommendation', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='repository.reviewrecommendation'), + ), + migrations.RunPython(add_default_recommendations, reverse_code=migrations.RunPython.noop) + ] diff --git a/src/repository/models.py b/src/repository/models.py index 644672ed28..16fa22f0b2 100755 --- a/src/repository/models.py +++ b/src/repository/models.py @@ -5,6 +5,7 @@ import os import uuid +import json from dateutil import parser as dateparser from django.db import models @@ -60,6 +61,12 @@ def width_choices(): ) +def theme_choices(): + return( + (theme, theme) for theme in settings.REPOSITORY_THEMES + ) + + fs_path = os.path.join('files/') preprint_file_store = JanewayFileSystemStorage(location=fs_path) preprint_media_store = JanewayFileSystemStorage() @@ -225,6 +232,12 @@ class Repository( blank=True, ) history = HistoricalRecords() + theme = models.CharField( + max_length=20, + blank=False, + default='OLH', + choices=theme_choices(), + ) class Meta: verbose_name_plural = 'repositories' @@ -524,7 +537,7 @@ def authors(self): preprint=self, ).select_related('account') - return [pa.account for pa in preprint_authors] + return [pa.account for pa in preprint_authors if pa.account] @property def safe_title(self): @@ -1216,6 +1229,22 @@ def review_status_choices(): ) +class ReviewRecommendation(models.Model): + repository = models.ForeignKey( + 'Repository', + on_delete=models.CASCADE, + ) + name = models.CharField( + max_length=255, + ) + active = models.BooleanField( + default=True, + ) + + def __str__(self): + return self.name + + class Review(models.Model): preprint = models.ForeignKey( 'Preprint', @@ -1277,6 +1306,11 @@ class Review(models.Model): notification_sent = models.BooleanField( default=False, ) + recommendation = models.ForeignKey( + 'ReviewRecommendation', + null=True, + on_delete=models.SET_NULL, + ) def accept(self, request): self.date_accepted = timezone.now() @@ -1425,3 +1459,19 @@ def add_email_setting_defaults(sender, instance, **kwargs): """ if instance._state.adding: install.load_settings(instance) + + with open( + os.path.join( + settings.BASE_DIR, + 'utils', + 'install', + 'default_repository_review_recommendations.json', + ) + ) as defaults_file: + defaults = json.load(defaults_file) + for repo in Repository.objects.all(): + for default in defaults: + ReviewRecommendation.objects.get_or_create( + repository=repo, + name=default, + ) diff --git a/src/repository/tests/test_views.py b/src/repository/tests/test_views.py index c3dbbe5a3e..61af74195b 100644 --- a/src/repository/tests/test_views.py +++ b/src/repository/tests/test_views.py @@ -51,6 +51,10 @@ def setUp(self): self.subject, title='Preprint Number One', ) + self.recommendation, _ = rm.ReviewRecommendation.objects.get_or_create( + repository=self.repository, + name='Accept', + ) self.server_name = "repo.test.com" update_settings() clear_script_prefix() @@ -121,6 +125,7 @@ def test_do_review(self): data = { 'body': 'This is my review.', 'anonymous': True, + 'recommendation': self.recommendation.pk, } path = reverse( 'repository_submit_review', @@ -236,7 +241,8 @@ def test_edit_review_comment(self): manager=self.repo_manager, date_due=timezone.now(), status='complete', - comment=comment + comment=comment, + recommendation=self.recommendation, ) path = reverse( 'repository_edit_review_comment', @@ -251,6 +257,7 @@ def test_edit_review_comment(self): data={ 'body': 'This is my slightly different review.', 'anonymous': False, + 'recommendation': self.recommendation.pk, }, SERVER_NAME=self.server_name, ) diff --git a/src/repository/urls.py b/src/repository/urls.py index bd9c66f888..1b0a167050 100755 --- a/src/repository/urls.py +++ b/src/repository/urls.py @@ -55,7 +55,7 @@ re_path(r'^list/(?P\d+)/$', views.repository_list, - name='preprints_list_subject'), + name='repository_list_subject'), re_path(r'^editors/$', views.preprints_editors, @@ -233,6 +233,15 @@ re_path(r'^manager/(?P\d+)/send_to_journal/(?P\d+)/$', views.send_preprint_to_journal, name='repository_send_to_journal'), + re_path(r'^manager/recommendations/$', + views.list_review_recommendations, + name='repository_list_review_recommendations'), + re_path(r'^manager/recommendations/create/$', + views.manage_review_recommendation, + name='repository_create_review_recommendation'), + re_path(r'^manager/recommendations/(?P\d+)/edit/$', + views.manage_review_recommendation, + name='repository_edit_review_recommendation'), # Popup email re_path(r'^email/user/(?P\d+)/preprint/(?P\d+)/$', diff --git a/src/repository/views.py b/src/repository/views.py index b0f3cf0319..b7da6bf044 100644 --- a/src/repository/views.py +++ b/src/repository/views.py @@ -495,7 +495,7 @@ def repository_pdf(request, preprint_id): pdf_url = request.GET.get('file') - template = 'repository/pdf.html' + template = 'common/repository/pdf.html' context = { 'pdf_url': pdf_url, } @@ -2391,3 +2391,88 @@ def send_user_email(request, user_id, preprint_id): 'article': article, } return render(request, template, context) + + +@is_repository_manager +def list_review_recommendations(request): + recommendations = models.ReviewRecommendation.objects.filter( + repository=request.repository, + ) + if request.POST and 'delete' in request.POST: + recommendation_id = request.POST.get('delete') + try: + recommendation = models.ReviewRecommendation.objects.get( + pk=recommendation_id, + ) + if not recommendation.review_set.exists(): + recommendation.delete() + messages.add_message( + request, + messages.SUCCESS, + 'Recommendation deleted.', + ) + else: + messages.add_message( + request, + messages.INFO, + 'Recommendation is linked to reviews. You can mark it as' + ' inactive if you no longer wish to use it.', + ) + except models.ReviewRecommendation.DoesNotExist: + messages.add_message( + request, + messages.WARNING, + 'No recommendation found with that ID.', + ) + return redirect( + reverse( + 'repository_list_review_recommendations' + ) + ) + template = 'admin/repository/review/list_review_recommendations.html' + context = { + 'recommendations': recommendations, + } + return render( + request, + template, + context, + ) + + +@is_repository_manager +def manage_review_recommendation(request, recommendation_id=None): + recommendation = None + if recommendation_id: + recommendation = get_object_or_404( + models.ReviewRecommendation, + pk=recommendation_id, + repository=request.repository, + ) + form = forms.RecommendationForm( + instance=recommendation, + repository=request.repository, + ) + if request.POST: + form = forms.RecommendationForm( + request.POST, + instance=recommendation, + repository=request.repository, + ) + if form.is_valid(): + form.save() + return redirect( + reverse( + 'repository_list_review_recommendations' + ) + ) + template = 'admin/repository/review/manage_review_recommendation.html' + context = { + 'recommendation': recommendation, + 'form': form, + } + return render( + request, + template, + context, + ) diff --git a/src/templates/admin/elements/repository/review_box.html b/src/templates/admin/elements/repository/review_box.html index 31f9cb2866..4f5e0860b9 100644 --- a/src/templates/admin/elements/repository/review_box.html +++ b/src/templates/admin/elements/repository/review_box.html @@ -10,6 +10,7 @@

#{{ review.pk }} {{ review.reviewer.full_name }}

Date Due Invite Status Completed + Recommendation Detail @@ -31,6 +32,9 @@

#{{ review.pk }} {{ review.reviewer.full_name }}

{% if review.date_completed %} {{ review.date_completed }}{% else %}--{% endif %} + + {{ review.recommendation }} + View Review Detail diff --git a/src/templates/admin/press/nav.html b/src/templates/admin/press/nav.html index 15d1d2844d..efb44b0e43 100644 --- a/src/templates/admin/press/nav.html +++ b/src/templates/admin/press/nav.html @@ -41,6 +41,7 @@
  •  Subjects
  •  Licences
  •  Additional Fields
  • +
  •  Recommendations
  •  Settings
  • {% endif %} {% endif %} diff --git a/src/templates/admin/repository/article.html b/src/templates/admin/repository/article.html index d2e60925ee..dbe56afaa5 100644 --- a/src/templates/admin/repository/article.html +++ b/src/templates/admin/repository/article.html @@ -57,7 +57,7 @@

    Metadata

    - {% include "repository/elements/subject_display.html" %} + {% include "common/repository/subject_display.html" %} diff --git a/src/templates/admin/repository/author_article.html b/src/templates/admin/repository/author_article.html index 3daac4240c..6aa4960037 100644 --- a/src/templates/admin/repository/author_article.html +++ b/src/templates/admin/repository/author_article.html @@ -57,7 +57,7 @@

    Metadata

    - {% include "repository/elements/subject_display.html" %} + {% include "common/repository/subject_display.html" %} diff --git a/src/templates/admin/repository/comments.html b/src/templates/admin/repository/comments.html index b6d542e00c..82c09a56a0 100644 --- a/src/templates/admin/repository/comments.html +++ b/src/templates/admin/repository/comments.html @@ -27,8 +27,13 @@

    New Comments

    {{ comment.body|linebreaksbr }}

    {% csrf_token %} - - +
    + + + {% if request.user in request.repository.managers.all %} + + {% endif %} +
    @@ -52,8 +57,13 @@

    Old Comments

    {{ comment.body|linebreaksbr }}

    {% csrf_token %} - - View Comment +
    + + View Comment + {% if request.user in request.repository.managers.all %} + + {% endif %} +
    @@ -63,4 +73,8 @@

    Old Comments

    +{% endblock %} + +{% block js %} + {% include "admin/elements/post_check.html" %} {% endblock %} \ No newline at end of file diff --git a/src/templates/admin/repository/review/list_review_recommendations.html b/src/templates/admin/repository/review/list_review_recommendations.html new file mode 100644 index 0000000000..d7048c8bf4 --- /dev/null +++ b/src/templates/admin/repository/review/list_review_recommendations.html @@ -0,0 +1,63 @@ +{% extends "admin/core/base.html" %} +{% load static %} +{% load foundation %} +{% load bool_fa %} + +{% block title %}Review Recommendations{% endblock %} +{% block title-section %}Review Recommendations{% endblock %} +{% block title-sub %}Manange review recommendations{% endblock %} + +{% block breadcrumbs %} + {{ block.super }} +
  • Manager
  • +
  • Review Recommendations
  • +{% endblock %} + +{% block body %} +
    +
    +
    +

    Current Recommendations for {{ request.repository.name }}

    + Add New Recommendation +
    +
    +

    You can create, edit and delete review recommendations for your repository using the interface here.

    +

    Recommendations that are linked to existing reviws cannot be deleted but you can mark them as inactive.

    +
    + {% csrf_token %} + + + + + + + + + + {% for r in recommendations %} + + + + + + + + {% empty %} + + + + {% endfor %} +
    NameActiveLinked to ReviewsEditDelete
    {{ r.name }}{{ r.active|bool_fa }}{{ r.review_set.count }} + Edit + + +
    No recommendations.
    +
    +
    +
    +
    +{% endblock %} + +{% block js %} + +{% endblock js %} diff --git a/src/templates/admin/repository/review/manage_review_recommendation.html b/src/templates/admin/repository/review/manage_review_recommendation.html new file mode 100644 index 0000000000..105666410c --- /dev/null +++ b/src/templates/admin/repository/review/manage_review_recommendation.html @@ -0,0 +1,41 @@ +{% extends "admin/core/base.html" %} +{% load static %} +{% load foundation %} +{% load bool_fa %} + +{% block title %}Review Recommendations{% endblock %} +{% block title-section %}Review Recommendations{% endblock %} +{% block title-sub %}Manange review recommendations{% endblock %} + +{% block breadcrumbs %} + {{ block.super }} +
  • Manager
  • +
  • Review Recommendations
  • +
  • {% if recommendation %}Edit Recommendation{% else %}Add Recommendation{% endif %}
  • +{% endblock %} + +{% block body %} +
    +
    +
    +

    {% if recommendation %}Edit Recommendation{% else %}Add Recommendation{% endif %}

    + < Back +
    +
    +

    You can create, edit and delete review recommendations for your repository using the interface here.

    +

    Recommendations that are linked to existing reviws cannot be deleted but you can mark them as inactive.

    +
    + {% csrf_token %} + {{ form|foundation }} +
    + +
    +
    +
    +
    +
    +{% endblock %} + +{% block js %} + +{% endblock js %} diff --git a/src/templates/admin/repository/review/review_detail.html b/src/templates/admin/repository/review/review_detail.html index f766bed3f7..71593bcd89 100644 --- a/src/templates/admin/repository/review/review_detail.html +++ b/src/templates/admin/repository/review/review_detail.html @@ -87,10 +87,13 @@

    Edit Due Date

    Review

    +

    Recommendation:

    +

    {{ review.recommendation.name|default:"No recommendation" }}

    +

    Comment:

    {{ review.comment.body|safe }} -

    Anonymity: -
    +

    Anonymity:

    +

    {% if review.anonymous %}Reviewer wishes to remain anonymous{% else %} Reviewer would like their name attached to the review{% endif %}

    diff --git a/src/themes/material/templates/repository/pdf.html b/src/templates/common/repository/pdf.html similarity index 100% rename from src/themes/material/templates/repository/pdf.html rename to src/templates/common/repository/pdf.html diff --git a/src/themes/material/templates/repository/elements/subject_display.html b/src/templates/common/repository/subject_display.html similarity index 100% rename from src/themes/material/templates/repository/elements/subject_display.html rename to src/templates/common/repository/subject_display.html diff --git a/src/templates/common/repository/subject_tree.html b/src/templates/common/repository/subject_tree.html new file mode 100644 index 0000000000..310f46146f --- /dev/null +++ b/src/templates/common/repository/subject_tree.html @@ -0,0 +1,8 @@ +{% for subject in subjects %} +
  • {{ subject }} ({{ subject.published_preprints_count }})
  • + {% if subject.children.count > 0 %} + + {% endif %} +{% endfor %} \ No newline at end of file diff --git a/src/themes/OLH/templates/core/base.html b/src/themes/OLH/templates/core/base.html index afa6051171..9e7e82272d 100644 --- a/src/themes/OLH/templates/core/base.html +++ b/src/themes/OLH/templates/core/base.html @@ -63,6 +63,12 @@ {% else %} {% endif %} + {% elif request.repository %} + {% if request.repository.logo %} + {% svg_or_image request.repository.logo %} + {% else %} + {{ request.repository.name }} + {% endif %} {% else %} {% if 'svg' in request.press_cover %} {% svg request.press_cover %} @@ -125,6 +131,8 @@

    {{ request.journal.name }}

    {{ request.user.full_name }} {% if request.journal %} {% include "elements/right_hand_menu.html" %} + {% elif request.repository %} + {% include "repository/elements/right_hand_menu.html" %} {% else %} {% include "press/elements/right_hand_menu.html" %} {% endif %} diff --git a/src/themes/OLH/templates/journal/editorial_team.html b/src/themes/OLH/templates/journal/editorial_team.html index 8afb657a5a..c79d62060b 100644 --- a/src/themes/OLH/templates/journal/editorial_team.html +++ b/src/themes/OLH/templates/journal/editorial_team.html @@ -48,7 +48,7 @@

    {{ group.name }}

    {% if forloop.counter|divisibleby:4 %} -
    +
    {% endif %} {% endfor %}
    diff --git a/src/themes/OLH/templates/journal/homepage_elements/news.html b/src/themes/OLH/templates/journal/homepage_elements/news.html index ee307f527b..10cba84e21 100644 --- a/src/themes/OLH/templates/journal/homepage_elements/news.html +++ b/src/themes/OLH/templates/journal/homepage_elements/news.html @@ -8,15 +8,33 @@

    {% trans 'Latest' %} {{ journal_settings.news.news_title }} {% trans "Posts" %}

    +
    {% for item in news_items %} -
    {{ item.title }}
    -
    {{ item.byline }} {% trans "on" %} {{ item.posted|date:"Y-m-d" }}
    -

    {{ item.body|striptags|truncatesmart:400 }}

    - {% trans "Read More" %} -
    + {% if display_images %} + {% if item.large_image_file or request.journal and request.journal.default_large_image or request.press.default_carousel_image %} +
    + {{ item.title }} +
    + {% endif %} + {% endif %} + {% if display_images %} +
    + {% endif %} +
    {{ item.title }}
    +
    {{ item.byline }} {% trans "on" %} {{ item.posted|date:"Y-m-d" }}
    +

    {{ item.body|striptags|truncatesmart:400 }}

    + {% trans "Read More" %} + {% if display_images %} +
    + {% endif %} +
    {% empty %} -

    {% trans "This journal currently has no news items to display" %}.

    +

    {% trans "This journal currently has no news items to display" %}.

    {% endfor %} +
    diff --git a/src/themes/OLH/templates/repository/about.html b/src/themes/OLH/templates/repository/about.html index f4d65ecc50..9a8e39fbeb 100644 --- a/src/themes/OLH/templates/repository/about.html +++ b/src/themes/OLH/templates/repository/about.html @@ -4,7 +4,7 @@ {% block title %}{{ request.repository.name }}{% endblock %} {% block navbar %} - {% include "press/nav.html" %} + {% include "repository/nav.html" %} {% endblock navbar %} {% block body %} @@ -12,12 +12,8 @@
    -

    {% trans "About" %} {{ request.repository.name }}

    - {% if request.press.preprints_about %} - {{ request.press.preprints_about|safe }} - {% else %} -

    - {% endif %} +

    {% trans "About" %} {{ request.repository.name }}

    + {{ request.repository.about|safe }}
    diff --git a/src/themes/OLH/templates/repository/article.html b/src/themes/OLH/templates/repository/article.html deleted file mode 100644 index cd44f7c453..0000000000 --- a/src/themes/OLH/templates/repository/article.html +++ /dev/null @@ -1,150 +0,0 @@ -{% extends "core/base.html" %} -{% load static %} -{% load hooks %} -{% load i18n %} -{% load foundation %} - -{% block title %}{{ article.title }}{% endblock %} - -{% block body %} - -
    -

    -
    -

    {{ article.title|safe }}

    -
    {% for subject in article.subject_set.all %}{{ subject.name }}{% if not forloop.last %}, - {% endif %}{% endfor %}
    -

    - {% trans "This is a preprint, it has not been peer reviewed or had any extensive editorial over-sight." %} - {% if preprint.doi %}{% trans 'It has been publ %} - -

    -
    -
    -
    {% trans "Authors" %}
    -

    - - {% for author in article.authors.all %} - {% if forloop.last %} - {% if article.authors.all|length > 1 %} &{% endif %} - {% endif %} - {{ author.full_name }} - {% if not forloop.last %} - {% if not forloop.counter == article.authors.all|length|add:-1 %}, - {% endif %} - {% endif %} - {% endfor %} - -

    -
    {% trans "Abstract" %}
    -

    - {{ article.abstract|safe }} -

    -
    - {% if html %} -
    Preprint Body
    - {{ html|safe }} - {% elif pdf %} - - {% endif %} -
    {% trans 'Comments' %}
    - {% if request.user.is_authenticated %} -
    -
    - {% csrf_token %} - {{ form|foundation }} - -
    -
    - {% endif %} - - {% for comment in comments %} -
    -
    -
    - {% if comment.author.profile_image %} - - {% else %} - - {% endif %} -
    -
    -

    - Comment #{{ comment.pk }} {{ comment.author.full_name }} - @ {{ comment.date_time }} -

    -

    - {{ comment.body }} -

    -
    -
    -
    - {% empty %} -
    -

    {% trans "There are no comments or no comments have been made public for this article." %}

    -
    - {% endfor %} - {% hook 'article_footer_block' %} - {% include "elements/journal/citation_modals.html" with article=article %} -
    -
    -
    -
    - -
    {% trans "Download" %}
    - -
    {% trans "Metadata" %}
    -
      -
    • {% trans "Published on" %} {{ article.date_published|date:"d M Y" }}
    • -
    • {% trans "License" %} {{ article.license.name }} -
    • - {% if article.identifier.id_type == 'doi' %} -
    • {{ article.identifier }}
    • {% endif %} -
    -
    {% trans "Metrics" %}
    -
      -
    • {% trans "Views" %}: {{ article.metrics.views }}
    • -
    • {% trans "Downloads" %}: {{ article.metrics.downloads }}
    • -
    -
    {% trans "Citation" %}
    - - - {% trans "All Preprints" %} - -

    - -
    {% trans "Versions" %}
    - -
    -
    -
    -
    -{% endblock %} - diff --git a/src/themes/OLH/templates/repository/authors.html b/src/themes/OLH/templates/repository/authors.html deleted file mode 100644 index 74bb7f9621..0000000000 --- a/src/themes/OLH/templates/repository/authors.html +++ /dev/null @@ -1,116 +0,0 @@ -{% extends "core/base.html" %} - -{% load static %} -{% load i18n %} -{% load foundation %} - -{% block title %}{% trans "Preprint Authors" %}{% endblock title %} - - -{% block body %} -
    -
    -
    - {% csrf_token %} -

    {% trans "Preprint Authors" %}

    -

    {% trans "Add authors to" %} {{ article.safe_title }}.

    -
    -
    - {% include "elements/forms/errors.html" with form=form %} - -
    -

    {% trans "Search for Existing Authors" %}

    - - {% csrf_token %} -
    -
    -

    {% trans "Search for a user using email address or ORCiD. If a user is matched, they will be automatically added as an author. This search only returns exact matches." %}

    -
    -
    -
    -
    - -
    -
    - -
    -
    - - -

    {% trans "Add New Author" %}

    -

    {% trans "If you cannot find the author record by searching, and you are not the only author, you can add one by clicking the button below. This will open a popup modal for you to complete their details." %}

    - {% trans "Add New Author" %} - {% include "elements/submit/author.html" %} -
    - -
    -

    {% trans "Current Authors" %}

    -
    -
    - - - - - - - - - - - {% for order in article.articleauthororder_set.all %} - - - - - - - {% empty %} - - - - {% endfor %} -
    {% trans "Name" %}{% trans "Email" %}
    {{ order.author.full_name }}{{ order.author.email }}
    {% csrf_token %}
    {% trans "No authors yet, add one!" %}
    -
    -
    - {% csrf_token %} -

    {% trans "When you've added all the authors, select Save and Continue to move to the next step of your submission." %}

    -
    - -
    -
    -
    -
    -
    - -
    - -{% endblock body %} - -{% block js %} - {% if modal %} - {% include "elements/open_modal.html" with target=modal %} - {% endif %} - - - - -{% endblock %} diff --git a/src/themes/OLH/templates/repository/editors.html b/src/themes/OLH/templates/repository/editors.html deleted file mode 100644 index 66d91f46e6..0000000000 --- a/src/themes/OLH/templates/repository/editors.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends "core/base.html" %} -{% load static %} -{% load i18n %} - -{% block title %}{{ request.press.name }} {% trans "Preprint Editors" %}{% endblock %} - -{% block navbar %} - {% include "press/nav.html" %} -{% endblock navbar %} - -{% block body %} - -
    -
    -
    -

    {{ request.press.name }} {% trans "Preprint Editors" %}

    - {% for subject in subjects %} -
    -

    {{ subject }}

    - - {% for editor in subject.editors.all %} -
    -
    - Photo of Uranus. - {{ user.full_name }}
    - - {{ editor.affiliation }} -
    - {% if member.enable_public_profile %} -

    - {% trans "View - Profile" %} -

    {% endif %} -
    -
    - {% if forloop.counter|divisibleby:4 or forloop.last %} -
    - {% endif %} - {% endfor %} - - {% empty %} -
    {% trans "This repository has no subjects or editors to display." %}
    - {% endfor %} -
    -
    -
    - -{% endblock %} \ No newline at end of file diff --git a/src/themes/OLH/templates/repository/elements/preprint_home_listing.html b/src/themes/OLH/templates/repository/elements/preprint_home_listing.html new file mode 100644 index 0000000000..c8ed7846ba --- /dev/null +++ b/src/themes/OLH/templates/repository/elements/preprint_home_listing.html @@ -0,0 +1,16 @@ +
    + {% for preprint in preprints %} +
    +
    +

    {{ preprint.title|safe }}

    +

    {{ preprint.display_authors_compact }}

    +

     {{ preprint.date_published|date:"Y-m-d" }}

    +
    +
    + {% if forloop.counter|divisibleby:3 %} +
    +
    + {% endif %} + {% endfor %} +
    \ No newline at end of file diff --git a/src/themes/OLH/templates/repository/elements/right_hand_menu.html b/src/themes/OLH/templates/repository/elements/right_hand_menu.html new file mode 100644 index 0000000000..4404bdb0c9 --- /dev/null +++ b/src/themes/OLH/templates/repository/elements/right_hand_menu.html @@ -0,0 +1,12 @@ +{% load roles %} +{% load i18n %} + + \ No newline at end of file diff --git a/src/themes/OLH/templates/repository/home.html b/src/themes/OLH/templates/repository/home.html index f708e94826..99aa9d5c62 100644 --- a/src/themes/OLH/templates/repository/home.html +++ b/src/themes/OLH/templates/repository/home.html @@ -12,11 +12,11 @@
    -

    {{ request.repository.name }}

    +

    {{ request.repository.name }}

    -
    + {% csrf_token %}
    @@ -33,19 +33,19 @@

    {{ request.repository.name }}

    {% if preprints %}
    -

    {% trans "Latest Preprints" %}

    - {% include "elements/journal/preprint_article_listing.html" with preprints=preprints %} +

    {% trans "Latest Preprints" %}

    + {% include "repository/elements/preprint_home_listing.html" with preprints=preprints %}
    {% endif %} {% if subjects %}
    -

    Filter by Subject

    +

    Filter by Subject

    {% if subjects|length <= 5 %}
    {% for subject in subjects %} - {{ subject.name }} {% endfor %}
    @@ -54,7 +54,7 @@

    Filter by Subject

    {% for subject in subjects %} {% if forloop.counter|divisibleby:2 %} diff --git a/src/themes/OLH/templates/repository/list.html b/src/themes/OLH/templates/repository/list.html index 3f8df67ddd..9f0414a56d 100644 --- a/src/themes/OLH/templates/repository/list.html +++ b/src/themes/OLH/templates/repository/list.html @@ -1,6 +1,7 @@ {% extends "core/base.html" %} {% load static %} {% load i18n %} +{% load truncate %} {% block title %}{% if subject %}{{ subject.name }} {{ request.repository.object_name_plural }}{% else %}{% trans "All" %} {{ request.repository.object_name_plural }} @@ -12,23 +13,30 @@
    -

    {% if subject %}{{ subject.name }} {{ request.repository.object_name_plural }}{% else %}{% trans "All" %} {{ request.repository.object_name_plural }}{% endif %}

    +
    +

    {{ request.repository.object_name_plural }}

    +

    + {% if search_term %} + Search for {{ search_term }} ({{ preprints.paginator.count }} results) + {% elif subject %} + Filtering by Subject: {{ subject }} + {% else %} + There {% if preprints.paginator.count > 1 %}are {{ preprints.paginator.count }} {{ request.repository.object_name_plural }} listed.{% elif preprints.paginator.count == 1 %}is 1 {{ request.repository.object_name }}{% else %}are 0 {{ request.repository.object_name }} listed.{% endif %} + {% endif %} +

    +
    {% for preprint in preprints %}
    -

    {{ preprint.title|safe }}

    -

    {% for author in preprint.authors.all %}{% if forloop.last %} - {% if preprint.authors.all|length > 1 %} and - {% endif %}{% endif %}{{ author.full_name }} - {% if not forloop.last %} - {% if not forloop.counter == preprint.authors.all|length|add:-1 %}, - {% endif %}{% endif %}{% endfor %}

    +

    {{ preprint.display_authors_compact }}

    {{ preprint.date_published|date:"Y-m-d" }}   {{ preprint.get_subject_area }}

    + class="fa fa-paperclip"> {% include "common/repository/subject_display.html" %}

    +

    {{ preprint.abstract|striptags|truncatesmart:400 }}


    @@ -53,7 +61,7 @@

    {{ preprint.title|safe }}