diff --git a/boards/templates/boards/aliases.html b/boards/templates/boards/aliases.html new file mode 100644 --- /dev/null +++ b/boards/templates/boards/aliases.html @@ -0,0 +1,17 @@ +{% extends "boards/base.html" %} + +{% load i18n %} +{% load tz %} + +{% block head %} + + {% trans 'Aliases' %} - {{ site_name }} +{% endblock %} + +{% block content %} +
+ {% for image in image_aliases %} +
{{ image.alias }}: {{ image.get_view|safe }}
+ {% endfor %} +
+{% endblock %} diff --git a/boards/templates/boards/settings.html b/boards/templates/boards/settings.html --- a/boards/templates/boards/settings.html +++ b/boards/templates/boards/settings.html @@ -24,10 +24,6 @@ {% else %}

{% trans 'No hidden tags.' %}

{% endif %} - - {% for image in image_aliases %} -
{{ image.alias }}: {{ image.get_view|safe }}
- {% endfor %}
diff --git a/boards/urls.py b/boards/urls.py --- a/boards/urls.py +++ b/boards/urls.py @@ -5,7 +5,7 @@ import neboard from boards import views from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed from boards.views import api, tag_threads, all_threads, \ - settings, all_tags, feed + settings, all_tags, feed, alias from boards.views.authors import AuthorsView from boards.views.notifications import NotificationView from boards.views.static import StaticPageView @@ -39,6 +39,7 @@ urlpatterns = [ url(r'^feed/$', views.feed.FeedView.as_view(), name='feed'), url(r'^settings/$', settings.SettingsView.as_view(), name='settings'), + url(r'^aliases/(?P\w+)/$', alias.AliasesView.as_view(), name='aliases'), url(r'^tags/(?P\w+)?/?$', all_tags.AllTagsView.as_view(), name='tags'), url(r'^authors/$', AuthorsView.as_view(), name='authors'), diff --git a/boards/views/alias.py b/boards/views/alias.py new file mode 100644 --- /dev/null +++ b/boards/views/alias.py @@ -0,0 +1,32 @@ +from django.db import transaction +from django.shortcuts import render, redirect +from django.utils import timezone +from django.utils.decorators import method_decorator +from django.views.decorators.csrf import csrf_protect + +from boards.abstracts.settingsmanager import get_settings_manager, \ + SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER +from boards.middlewares import SESSION_TIMEZONE +from boards.views.base import BaseBoardView, CONTEXT_FORM +from boards.forms import SettingsForm, PlainErrorList +from boards import settings +from boards.models import Attachment + +CONTEXT_IMAGE_ALIASES = 'image_aliases' + +TEMPLATE = 'boards/aliases.html' + + +class AliasesView(BaseBoardView): + @method_decorator(csrf_protect) + def get(self, request, category): + params = dict() + settings_manager = get_settings_manager(request) + + selected_theme = settings_manager.get_theme() + + params[CONTEXT_IMAGE_ALIASES] = Attachment.objects.exclude(alias='')\ + .exclude(alias=None).filter(alias__startswith=(category + '/')) + + return render(request, TEMPLATE, params) + diff --git a/boards/views/settings.py b/boards/views/settings.py --- a/boards/views/settings.py +++ b/boards/views/settings.py @@ -18,7 +18,6 @@ FORM_TIMEZONE = 'timezone' FORM_IMAGE_VIEWER = 'image_viewer' CONTEXT_HIDDEN_TAGS = 'hidden_tags' -CONTEXT_IMAGE_ALIASES = 'image_aliases' TEMPLATE = 'boards/settings.html' @@ -45,7 +44,6 @@ class SettingsView(BaseBoardView): params[CONTEXT_FORM] = form params[CONTEXT_HIDDEN_TAGS] = settings_manager.get_hidden_tags() - params[CONTEXT_IMAGE_ALIASES] = Attachment.objects.exclude(alias='').exclude(alias=None) return render(request, TEMPLATE, params)