2021-08-22 20:10:29 +02:00
|
|
|
from django.http import HttpResponse
|
2021-09-11 19:09:22 +02:00
|
|
|
from django.shortcuts import render
|
2022-04-11 22:43:06 +02:00
|
|
|
from django.views.decorators.http import condition
|
2021-09-14 17:32:51 +02:00
|
|
|
from django.views.generic import TemplateView
|
2021-09-24 18:36:51 +02:00
|
|
|
from ipware import get_client_ip
|
2021-09-11 19:09:22 +02:00
|
|
|
from sentry_sdk import last_event_id
|
2021-08-22 20:10:29 +02:00
|
|
|
|
2021-09-11 19:09:22 +02:00
|
|
|
from rpg_notes.secrets import SENTRY_DSN
|
2022-04-11 22:43:06 +02:00
|
|
|
from utils.assets import get_css, get_file_hash
|
2021-08-22 20:10:29 +02:00
|
|
|
|
2021-09-11 19:09:22 +02:00
|
|
|
|
2021-09-14 17:32:51 +02:00
|
|
|
class PublicHomepageView(TemplateView):
|
2021-10-15 20:10:50 +02:00
|
|
|
template_name = "common/homepage.jinja"
|
2021-09-14 17:32:51 +02:00
|
|
|
|
|
|
|
|
2021-09-25 20:31:08 +02:00
|
|
|
class LanguageSelectView(TemplateView):
|
2021-10-15 21:47:49 +02:00
|
|
|
template_name = "common/languageselect.jinja"
|
2021-09-25 20:31:08 +02:00
|
|
|
|
|
|
|
|
2021-09-24 18:36:51 +02:00
|
|
|
def print_ip(request):
|
|
|
|
client_ip, is_routable = get_client_ip(request)
|
2021-09-24 18:41:30 +02:00
|
|
|
return HttpResponse(repr(client_ip), content_type="text/plain")
|
2021-09-24 18:36:51 +02:00
|
|
|
|
|
|
|
|
2022-04-11 22:43:06 +02:00
|
|
|
def calc_etag(*args, **kwargs):
|
|
|
|
return get_file_hash()[:6]
|
|
|
|
|
|
|
|
|
|
|
|
@condition(etag_func=calc_etag)
|
2021-08-22 20:10:29 +02:00
|
|
|
def debug_css(request):
|
|
|
|
css, source_map = get_css(debug=True)
|
|
|
|
return HttpResponse(css, content_type="text/css")
|
|
|
|
|
2021-09-11 19:09:22 +02:00
|
|
|
|
2022-04-11 22:43:06 +02:00
|
|
|
@condition(etag_func=calc_etag)
|
2021-08-22 20:10:29 +02:00
|
|
|
def debug_css_sourcemap(request):
|
|
|
|
css, source_map = get_css(debug=True)
|
|
|
|
return HttpResponse(source_map, content_type="application/json")
|
2021-09-11 19:09:22 +02:00
|
|
|
|
2022-04-11 22:43:06 +02:00
|
|
|
|
2021-09-11 19:09:22 +02:00
|
|
|
def handler500(request, *args, **argv):
|
2021-10-15 21:47:49 +02:00
|
|
|
return render(request, "500.jinja", {
|
2021-09-11 19:09:22 +02:00
|
|
|
"sentry_event_id": last_event_id(),
|
|
|
|
"sentry_dsn": SENTRY_DSN
|
|
|
|
}, status=500)
|