Merge pull request #2013 from bookwyrm-social/theme-path

Manually add theme path rather than options
This commit is contained in:
Mouse Reeve 2022-03-13 13:30:32 -07:00 committed by GitHub
commit 57cba4eb7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 28 deletions

View file

@ -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",
}
),
}

View file

@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
env = Env()
env.read_env()
DOMAIN = env("DOMAIN")
VERSION = "0.3.2"
VERSION = "0.3.3"
RELEASE_API = env(
"RELEASE_API",
@ -21,7 +21,7 @@ RELEASE_API = env(
PAGE_LENGTH = env("PAGE_LENGTH", 15)
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
JS_CACHE = "c7154efb"
JS_CACHE = "bc93172a"
# email
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")

View file

@ -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>

View file

@ -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(),
}