Skip to content
Snippets Groups Projects
Commit 2846768e authored by Benjamin Hättasch's avatar Benjamin Hättasch Committed by Nadja Geisler
Browse files

Introduce self-registration and add simple user startpage

Add django-registration-redux dependency
Adapt settings and urls
Add view logged-in users to either proceed to the backend or logout
parent d7bdd48c
No related branches found
No related tags found
1 merge request!35User Registration
{% extends 'base.html' %}
{% load fontawesome_5 %}
{% load i18n %}
{% load static %}
{% load tags_AKModel %}
{% block imports %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AKDashboard/style.css' %}">
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item">
{% if 'AKDashboard'|check_app_installed %}
<a href="{% url 'dashboard:dashboard' %}">AKPlanning</a>
{% else %}
AKPlanning
{% endif %}
</li>
<li class="breadcrumb-item">User: {{ user.get_username }}</li>
{% endblock %}
{% block content %}
{% include "messages.html" %}
<h1>{% trans "Hello" %} {{ user }}!</h1>
{% if user.is_staff %}
<a class="btn btn-primary" href="{% url "admin:index" %}">{% trans "Go to backend" %}</a>
{% else %}
<div class="alert alert-warning" style="margin-top:20px;margin-bottom: 20px;">
{% trans "Please wait for an administrator to confirm your account" %}
</div>
{% endif %}
<a class="btn btn-danger" href="{% url "logout" %}">{% trans "Logout" %}</a>
{% endblock %}
......@@ -20,4 +20,5 @@ urlpatterns = [
path('api/', include(api_router.urls), name='api'),
])
),
path('user/', views.UserView.as_view(), name="user"),
]
from django.shortcuts import get_object_or_404
from django.views.generic import TemplateView
from rest_framework import viewsets, permissions, mixins
from AKModel.models import Event, AK, AKSlot, Room, AKTrack, AKCategory, AKOwner
......@@ -95,3 +96,7 @@ class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelM
def get_queryset(self):
return AKSlot.objects.filter(event=self.event)
class UserView(TemplateView):
template_name = "AKModel/user.html"
......@@ -48,6 +48,7 @@ INSTALLED_APPS = [
'timezone_field',
'rest_framework',
'simple_history',
'registration',
]
MIDDLEWARE = [
......@@ -169,4 +170,8 @@ PLAN_SHOW_HIERARCHY = True
# For which time (in seconds) should changes of akslots be highlighted in plan?
PLAN_MAX_HIGHLIGHT_UPDATE_SECONDS = 2 * 60 * 60
# Registration/login behavior
SIMPLE_BACKEND_REDIRECT_URL = "/user/"
LOGIN_REDIRECT_URL = SIMPLE_BACKEND_REDIRECT_URL
include(optional("settings/*.py"))
......@@ -19,8 +19,10 @@ from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
path('accounts/', include('registration.backends.simple.urls')),
path('', include('AKModel.urls', namespace='model')),
path('i18n/', include('django.conf.urls.i18n'))
path('i18n/', include('django.conf.urls.i18n')),
]
# Load URLs dynamically (only if components are active)
......
......@@ -4,4 +4,5 @@ django-fontawesome-5==1.0.18
django-split-settings==1.0.1
django-timezone-field==4.0
djangorestframework==3.11.0
django-simple-history==2.10.0
\ No newline at end of file
django-simple-history==2.10.0
django-registration-redux==2.8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment