forked from mirrors/bookwyrm
Manually add theme path rather than options
This commit is contained in:
parent
753cd36f86
commit
3885ae789b
3 changed files with 8 additions and 26 deletions
|
@ -468,7 +468,12 @@ class ThemeForm(CustomForm):
|
|||
fields = ["name", "path"]
|
||||
widgets = {
|
||||
"name": forms.TextInput(attrs={"aria-describedby": "desc_name"}),
|
||||
"path": forms.Select(attrs={"aria-describedby": "desc_path"}),
|
||||
"path": forms.TextInput(
|
||||
attrs={
|
||||
"aria-describedby": "desc_path",
|
||||
"placeholder": "css/themes/theme-name.scss",
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,12 +56,7 @@
|
|||
class="box"
|
||||
enctype="multipart/form-data"
|
||||
>
|
||||
{% if not choices %}
|
||||
<div class="notification is-warning">
|
||||
{% trans "No available theme files detected" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<fieldset {% if not choices %}disabled{% endif %}>
|
||||
<fieldset>
|
||||
{% csrf_token %}
|
||||
<div class="columns">
|
||||
<div class="column is-half">
|
||||
|
@ -79,20 +74,7 @@
|
|||
{% trans "Theme filename" %}
|
||||
</label>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select
|
||||
name="path"
|
||||
aria-describedby="desc_path"
|
||||
class=""
|
||||
id="id_path"
|
||||
>
|
||||
{% for choice in choices %}
|
||||
<option value="{{ choice }}">
|
||||
{{ choice }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{{ theme_form.path }}
|
||||
{% include 'snippets/form_errors.html' with errors_list=theme_form.path.errors id="desc_path" %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
""" manage themes """
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.contrib.staticfiles.utils import get_files
|
||||
from django.contrib.staticfiles.storage import StaticFilesStorage
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
|
@ -41,11 +39,8 @@ class Themes(View):
|
|||
|
||||
def get_view_data():
|
||||
"""data for view"""
|
||||
choices = list(get_files(StaticFilesStorage(), location="css/themes"))
|
||||
current = models.Theme.objects.values_list("path", flat=True)
|
||||
return {
|
||||
"themes": models.Theme.objects.all(),
|
||||
"choices": [c for c in choices if c not in current and c[-5:] == ".scss"],
|
||||
"theme_form": forms.ThemeForm(),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue