mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +00:00
Merge pull request #2013 from bookwyrm-social/theme-path
Manually add theme path rather than options
This commit is contained in:
commit
57cba4eb7a
4 changed files with 10 additions and 28 deletions
|
@ -468,7 +468,12 @@ class ThemeForm(CustomForm):
|
||||||
fields = ["name", "path"]
|
fields = ["name", "path"]
|
||||||
widgets = {
|
widgets = {
|
||||||
"name": forms.TextInput(attrs={"aria-describedby": "desc_name"}),
|
"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",
|
||||||
|
}
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
||||||
env = Env()
|
env = Env()
|
||||||
env.read_env()
|
env.read_env()
|
||||||
DOMAIN = env("DOMAIN")
|
DOMAIN = env("DOMAIN")
|
||||||
VERSION = "0.3.2"
|
VERSION = "0.3.3"
|
||||||
|
|
||||||
RELEASE_API = env(
|
RELEASE_API = env(
|
||||||
"RELEASE_API",
|
"RELEASE_API",
|
||||||
|
@ -21,7 +21,7 @@ RELEASE_API = env(
|
||||||
PAGE_LENGTH = env("PAGE_LENGTH", 15)
|
PAGE_LENGTH = env("PAGE_LENGTH", 15)
|
||||||
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
|
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
|
||||||
|
|
||||||
JS_CACHE = "c7154efb"
|
JS_CACHE = "bc93172a"
|
||||||
|
|
||||||
# email
|
# email
|
||||||
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")
|
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")
|
||||||
|
|
|
@ -56,12 +56,7 @@
|
||||||
class="box"
|
class="box"
|
||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
>
|
>
|
||||||
{% if not choices %}
|
<fieldset>
|
||||||
<div class="notification is-warning">
|
|
||||||
{% trans "No available theme files detected" %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<fieldset {% if not choices %}disabled{% endif %}>
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-half">
|
<div class="column is-half">
|
||||||
|
@ -79,20 +74,7 @@
|
||||||
{% trans "Theme filename" %}
|
{% trans "Theme filename" %}
|
||||||
</label>
|
</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<div class="select">
|
{{ theme_form.path }}
|
||||||
<select
|
|
||||||
name="path"
|
|
||||||
aria-describedby="desc_path"
|
|
||||||
class=""
|
|
||||||
id="id_path"
|
|
||||||
>
|
|
||||||
{% for choice in choices %}
|
|
||||||
<option value="{{ choice }}">
|
|
||||||
{{ choice }}
|
|
||||||
</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
{% include 'snippets/form_errors.html' with errors_list=theme_form.path.errors id="desc_path" %}
|
{% include 'snippets/form_errors.html' with errors_list=theme_form.path.errors id="desc_path" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
""" manage themes """
|
""" manage themes """
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
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.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
@ -41,11 +39,8 @@ class Themes(View):
|
||||||
|
|
||||||
def get_view_data():
|
def get_view_data():
|
||||||
"""data for view"""
|
"""data for view"""
|
||||||
choices = list(get_files(StaticFilesStorage(), location="css/themes"))
|
|
||||||
current = models.Theme.objects.values_list("path", flat=True)
|
|
||||||
return {
|
return {
|
||||||
"themes": models.Theme.objects.all(),
|
"themes": models.Theme.objects.all(),
|
||||||
"choices": [c for c in choices if c not in current and c[-5:] == ".scss"],
|
|
||||||
"theme_form": forms.ThemeForm(),
|
"theme_form": forms.ThemeForm(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue