This commit is contained in:
Robert R George 2024-04-25 07:14:37 +02:00 committed by GitHub
commit bc56e1158c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 0 deletions

View file

@ -89,6 +89,9 @@
{% url 'settings-schedules' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Scheduled tasks" %}</a>
</li>
<li>
<a href="/flower/"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Flower" %}</a>
</li>
<li>
{% url 'settings-email-config' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Email Configuration" %}</a>

View file

@ -29,6 +29,7 @@ BOOK_PATH = r"^book/(?P<book_id>\d+)"
STREAMS = "|".join(s["key"] for s in settings.STREAMS)
urlpatterns = [
views.FlowerProxyView.as_url(),
path("admin/", admin.site.urls),
path(
"robots.txt",

View file

@ -0,0 +1,17 @@
from django.contrib.auth.mixins import UserPassesTestMixin
from django.urls import path, re_path
from revproxy.views import ProxyView
class FlowerProxyView(UserPassesTestMixin, ProxyView):
upstream = 'http://{}:{}'.format('localhost', 8888)
url_prefix = 'flower'
rewrite = (
(r'^/{}$'.format(url_prefix), r'/{}/'.format(url_prefix)),
)
def test_func(self):
return self.request.user.is_superuser
@classmethod
def as_url(cls):
return re_path(r'^(?P<path>{}.*)$'.format(cls.url_prefix), cls.as_view(), name='flower')