mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 17:41:08 +00:00
Delete themes
This commit is contained in:
parent
106ef2e3a4
commit
c82042f506
4 changed files with 23 additions and 3 deletions
|
@ -123,8 +123,12 @@
|
|||
<td>{{ theme.name }}</td>
|
||||
<td><code>{{ theme.path }}</code></td>
|
||||
<td>
|
||||
<form>
|
||||
<button type="submit" class="button is-danger is-light">{% trans "Remove theme" %}</button>
|
||||
<form method="POST" action="{% url 'settings-themes-delete' theme.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="button is-danger is-light is-small">
|
||||
<span class="icon icon-x" aria-hideen="true"></span>
|
||||
<span>{% trans "Remove theme" %}</span>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -87,6 +87,11 @@ urlpatterns = [
|
|||
),
|
||||
re_path(r"^settings/site-settings/?$", views.Site.as_view(), name="settings-site"),
|
||||
re_path(r"^settings/themes/?$", views.Themes.as_view(), name="settings-themes"),
|
||||
re_path(
|
||||
r"^settings/themes/(?P<theme_id>\d+)/delete/?$",
|
||||
views.delete_theme,
|
||||
name="settings-themes-delete",
|
||||
),
|
||||
re_path(
|
||||
r"^settings/announcements/?$",
|
||||
views.Announcements.as_view(),
|
||||
|
|
|
@ -21,7 +21,7 @@ from .admin.reports import (
|
|||
moderator_delete_user,
|
||||
)
|
||||
from .admin.site import Site
|
||||
from .admin.themes import Themes
|
||||
from .admin.themes import Themes, delete_theme
|
||||
from .admin.user_admin import UserAdmin, UserAdminList
|
||||
|
||||
# user preferences
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
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
|
||||
from django.views import View
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from bookwyrm import forms, models
|
||||
|
||||
|
@ -46,3 +48,12 @@ def get_view_data():
|
|||
"choices": [c for c in choices if c not in current and c[-5:] == ".scss"],
|
||||
"theme_form": forms.ThemeForm(),
|
||||
}
|
||||
|
||||
|
||||
@require_POST
|
||||
@permission_required("bookwyrm.edit_instance_settings", raise_exception=True)
|
||||
# pylint: disable=unused-argument
|
||||
def delete_theme(request, theme_id):
|
||||
"""Remove a theme"""
|
||||
get_object_or_404(models.Theme, id=theme_id).delete()
|
||||
return redirect("settings-themes")
|
||||
|
|
Loading…
Reference in a new issue