Use sites framework to get current site
This commit is contained in:
@@ -29,11 +29,3 @@ class DateRangeMixin:
|
||||
data["start_date"] = self.get_start_date()
|
||||
data["end_date"] = self.get_end_date()
|
||||
return data
|
||||
|
||||
|
||||
class BaseUrlMixin:
|
||||
def get_context_data(self, **kwargs):
|
||||
data = super().get_context_data(**kwargs)
|
||||
url_data = urlparse(self.request.build_absolute_uri())
|
||||
data["base_url"] = f"{url_data.scheme}://{url_data.netloc}"
|
||||
return data
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{% block card %}
|
||||
<form class="login" method="POST" action="{% url 'account_login' %}">
|
||||
<aside class="aside ~info mb-4">
|
||||
<p>Welcome to Shynet, a self-hosted analytics tool that's open source and privacy conscious. View the <a href="https://github.com/milesmcc/shynet">source code</a>.</p>
|
||||
<p>Welcome to {{request.site.name|default:"Shynet"}}, a self-hosted analytics tool that's open source and privacy conscious. Powered by Shynet. View the <a href="https://github.com/milesmcc/shynet">source code</a>.</p>
|
||||
</aside>
|
||||
{% csrf_token %}
|
||||
{{ form|a17t }}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>{% block head_title %}Privacy-oriented analytics{% endblock %} | Shynet</title>
|
||||
<title>{% block head_title %}Privacy-oriented analytics{% endblock %} | {{request.site.name}}</title>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{% include 'a17t/head.html' %}
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
{% for object in services %}
|
||||
{% include 'dashboard/includes/service_overview.html' %}
|
||||
{% empty %}
|
||||
<p>You don't have any services on this Shynet instance yet.</p>
|
||||
<p>You don't have any services on {{request.site.name|default:"Shynet"}} yet.</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
{% block content %}
|
||||
<section class="content">
|
||||
<h2>Shynet Analytics</h2>
|
||||
<p>Eventually, more information about Shynet will be available here.</p>
|
||||
<h2>{{request.site.name}} Analytics</h2>
|
||||
<p>{{request.site.name}} uses Shynet. Eventually, more information about Shynet will be available here.</p>
|
||||
<a href="{% url 'account_login' %}" class="button ~urge !high">Log In</a>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -15,7 +15,7 @@ from django.db.models import Q
|
||||
from analytics.models import Session
|
||||
|
||||
from .forms import ServiceForm
|
||||
from .mixins import BaseUrlMixin, DateRangeMixin
|
||||
from .mixins import DateRangeMixin
|
||||
from core.models import Service
|
||||
|
||||
class DashboardView(LoginRequiredMixin, DateRangeMixin, TemplateView):
|
||||
@@ -64,7 +64,7 @@ class ServiceView(
|
||||
|
||||
|
||||
class ServiceUpdateView(
|
||||
LoginRequiredMixin, PermissionRequiredMixin, BaseUrlMixin, UpdateView
|
||||
LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
||||
):
|
||||
model = Service
|
||||
form_class = ServiceForm
|
||||
|
||||
Reference in New Issue
Block a user