Small fixes to admin & script

This commit is contained in:
R. Miles McCain 2020-04-16 10:00:18 -04:00
parent 595d6cfd20
commit ac0f4cee73
No known key found for this signature in database
GPG Key ID: 91CB47BDDF2671A5
4 changed files with 12 additions and 5 deletions

View File

@ -44,6 +44,7 @@ class HitAdmin(admin.ModelAdmin):
"heartbeats",
"tracker",
"load_time",
"location",
)
list_display_links = ("session",)
search_fields = ("initial", "tracker", "location", "referrer")

View File

@ -7,8 +7,7 @@ window.onload = function () {
var xhr = new XMLHttpRequest();
xhr.open(
"POST",
self.location.protocol +
"//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
"{{protocol}}://{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
true
);
xhr.setRequestHeader("Content-Type", "application/json");

View File

@ -6,6 +6,7 @@ from django.shortcuts import render, reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from django.views.generic import TemplateView, View
from ipware import get_client_ip
@ -64,6 +65,7 @@ class ScriptView(View):
return resp
def get(self, *args, **kwargs):
protocol = "https" if settings.SCRIPT_USE_HTTPS else "http"
endpoint = (
reverse(
"ingress:endpoint_script",
@ -81,7 +83,7 @@ class ScriptView(View):
return render(
self.request,
"analytics/scripts/page.js",
context={"endpoint": endpoint},
context={"endpoint": endpoint, "protocol": protocol},
content_type="application/javascript",
)

View File

@ -205,7 +205,7 @@ ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_SUBJECT_PREFIX = ""
ACCOUNT_USER_DISPLAY = lambda k: k.email
ACCOUNT_SIGNUPS_ENABLED = os.getenv("SIGNUPS_ENABLED", "False") == True
ACCOUNT_SIGNUPS_ENABLED = os.getenv("ACCOUNT_SIGNUPS_ENABLED", "False") == "True"
LOGIN_REDIRECT_URL = "/"
@ -247,8 +247,13 @@ else:
# Shynet
ONLY_SUPERUSERS_CREATE = True
# Can everyone create services, or only superusers?
# Note that in the current version of Shynet, being able to edit a service allows
# you to see every registered user on the Shynet instance. This will be changed in
# a future version.
ONLY_SUPERUSERS_CREATE = os.getenv("ONLY_SUPERUSERS_CREATE", "True") == "True"
# Should the script use HTTPS to send the POST requests? The hostname is from
# the django SITE default. (Edit it using the admin panel.)
SCRIPT_USE_HTTPS = os.getenv("SCRIPT_USE_HTTPS", "True") == "True"