From e176b59b8a7b7ca5fe1af315e655a9c035715190 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Tue, 13 Feb 2024 15:45:25 +0100 Subject: [PATCH 1/2] Add login form for admin that uses OIDC --- .../core/admin.py | 1 + .../core/templates/core/login.html | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 {{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/templates/core/login.html diff --git a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/admin.py b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/admin.py index 9e0c953..d96dc90 100644 --- a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/admin.py +++ b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/admin.py @@ -4,3 +4,4 @@ from . import models admin.site.register(models.MafiasiUser, UserAdmin) +admin.site.login_template = 'core/login.html' diff --git a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/templates/core/login.html b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/templates/core/login.html new file mode 100644 index 0000000..df3abae --- /dev/null +++ b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/templates/core/login.html @@ -0,0 +1,22 @@ +{% extends "admin/login.html" %} +{% load i18n %} +{% block content %} +
+ +{% if user.is_authenticated %} +

+{% blocktranslate trimmed %} + You are authenticated as {{ username }}, but are not authorized to + access this page. Would you like to login to a different account? +{% endblocktranslate %} +

+{% endif %} + +
+
+ +
+
+ +
+{% endblock %} From ee7c89ec80736a3cb00bcfe3397762b5cfa98b41 Mon Sep 17 00:00:00 2001 From: ftsell Date: Wed, 14 Feb 2024 09:55:16 +0100 Subject: [PATCH 2/2] exclude django templates from cookiecutter rendering --- cookiecutter.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index e8d5968..b36169d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -2,5 +2,9 @@ "project_name": "", "project_slug": "{{ cookiecutter.project_name | slugify(separator='_') }}", "author": "Fachschaft Informatik der Universität Hamburg (Mafiasi-AG)", - "openid_scope": "openid" + "openid_scope": "openid", + + "_copy_without_render": [ + "src/{{ cookiecutter.project_slug }}/*/templates/*" + ] }