Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3670 adds support for multiple themes in repositories and fixes original preprint templates from the OLH theme. #3811

Merged
merged 9 commits into from
Dec 8, 2023
7 changes: 7 additions & 0 deletions src/core/janeway_global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions src/repository/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ class Meta:
'domain',
'object_name',
'object_name_plural',
'theme',
'publisher',
)
help_texts = {
Expand Down
43 changes: 43 additions & 0 deletions src/repository/migrations/0040_auto_20231207_1002.py
Original file line number Diff line number Diff line change
@@ -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
),
]
14 changes: 13 additions & 1 deletion src/repository/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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()
Expand Down Expand Up @@ -225,6 +231,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'
Expand Down Expand Up @@ -524,7 +536,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):
Expand Down
2 changes: 1 addition & 1 deletion src/repository/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

re_path(r'^list/(?P<subject_id>\d+)/$',
views.repository_list,
name='preprints_list_subject'),
name='repository_list_subject'),

re_path(r'^editors/$',
views.preprints_editors,
Expand Down
2 changes: 1 addition & 1 deletion src/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/admin/repository/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2>Metadata</h2>
</tr>
<tr>
<td colspan="3">
{% include "repository/elements/subject_display.html" %}
{% include "common/repository/subject_display.html" %}
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/admin/repository/author_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2>Metadata</h2>
</tr>
<tr>
<td colspan="2">
{% include "repository/elements/subject_display.html" %}
{% include "common/repository/subject_display.html" %}
</td>
</tr>
<tr>
Expand Down
8 changes: 8 additions & 0 deletions src/templates/common/repository/subject_tree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% for subject in subjects %}
<li><a href="{% url 'repository_list_subject' subject.pk %}">{{ subject }} ({{ subject.published_preprints_count }})</a></li>
{% if subject.children.count > 0 %}
<ul class="nested tree">
{% include "common/repository/subject_tree.html" with subjects=subject.children.all %}
</ul>
{% endif %}
{% endfor %}
8 changes: 8 additions & 0 deletions src/themes/OLH/templates/core/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
{% else %}
<a href="{{ request.journal.site_url }}"><img src="{% static "common/img/sample/janeway.png" %}"></a>
{% 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 %}
<a href="/">{% svg request.press_cover %}</a>
Expand Down Expand Up @@ -125,6 +131,8 @@ <h1 class="menu-text">{{ request.journal.name }}</h1>
<a href="#" data-options="is_hover:true; hover_timeout:5000">{{ request.user.full_name }}</a>
{% 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 %}
Expand Down
10 changes: 3 additions & 7 deletions src/themes/OLH/templates/repository/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
{% block title %}{{ request.repository.name }}{% endblock %}

{% block navbar %}
{% include "press/nav.html" %}
{% include "repository/nav.html" %}
{% endblock navbar %}

{% block body %}

<section id="content">
<div class="row column">
<div class="large-12 columns">
<h2 class="text-center">{% trans "About" %} {{ request.repository.name }}</h2>
{% if request.press.preprints_about %}
{{ request.press.preprints_about|safe }}
{% else %}
<p></p>
{% endif %}
<h1>{% trans "About" %} {{ request.repository.name }}</h1>
{{ request.repository.about|safe }}
</div>
</div>
</section>
Expand Down
150 changes: 0 additions & 150 deletions src/themes/OLH/templates/repository/article.html

This file was deleted.

Loading