diff --git a/AKModel/templates/AKModel/user.html b/AKModel/templates/AKModel/user.html new file mode 100644 index 0000000000000000000000000000000000000000..7c74fde8f4bd8dc8bd0d0113cdf7bb87640f2657 --- /dev/null +++ b/AKModel/templates/AKModel/user.html @@ -0,0 +1,42 @@ +{% 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 %} diff --git a/AKModel/templatetags/tags_AKModel.py b/AKModel/templatetags/tags_AKModel.py index 4540e85997647ba46b2cae4ac1404d03194e329c..6913391392105810177bc5799b1600f09986a1d6 100644 --- a/AKModel/templatetags/tags_AKModel.py +++ b/AKModel/templatetags/tags_AKModel.py @@ -14,3 +14,14 @@ def footer_info(): @register.filter def check_app_installed(name): return apps.is_installed(name) + + +@register.filter +def message_bootstrap_class(tag): + if tag == "error": + return "alert-danger" + elif tag == "success": + return "alert-success" + elif tag == "warning": + return "alert-warning" + return "alert-info" diff --git a/AKModel/urls.py b/AKModel/urls.py index 4ed6404cbcef947a48f92ea6828989bcf7d3bc03..a469c54f96e8f3cd29a2008f1deffc537050a8cc 100644 --- a/AKModel/urls.py +++ b/AKModel/urls.py @@ -20,4 +20,5 @@ urlpatterns = [ path('api/', include(api_router.urls), name='api'), ]) ), + path('user/', views.UserView.as_view(), name="user"), ] diff --git a/AKModel/views.py b/AKModel/views.py index 88656ef7c9a7f6b32a75a777856344596f78575f..1d6b95eb26e2d456f76e6c55f8fd6c759cedb5a9 100644 --- a/AKModel/views.py +++ b/AKModel/views.py @@ -1,4 +1,5 @@ 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" diff --git a/AKPlanning/settings.py b/AKPlanning/settings.py index d9bcb96dd3c48be20c310689fccfd5a018216195..83d1340a243f6db363953824c7fb4343d5653fe4 100644 --- a/AKPlanning/settings.py +++ b/AKPlanning/settings.py @@ -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")) diff --git a/AKPlanning/urls.py b/AKPlanning/urls.py index aa5f4538314580bb4a638999a532ee222859d4eb..e7c592d83ca30995a68119d3c43077f20827bbc6 100644 --- a/AKPlanning/urls.py +++ b/AKPlanning/urls.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) diff --git a/AKSubmission/templates/AKSubmission/ak_detail.html b/AKSubmission/templates/AKSubmission/ak_detail.html index b7b9342d4ce69452cd70ed9750d4d606a786699f..bb99e830744bb3d6516a78ecd6bc6f2dfe8ae9a0 100644 --- a/AKSubmission/templates/AKSubmission/ak_detail.html +++ b/AKSubmission/templates/AKSubmission/ak_detail.html @@ -23,7 +23,7 @@ {% endif %} {% block content %} - {% include "AKSubmission/messages.html" %} + {% include "messages.html" %} <div class="text-right"> {% if ak.interest_counter >= 0 %} diff --git a/AKSubmission/templates/AKSubmission/ak_history.html b/AKSubmission/templates/AKSubmission/ak_history.html index 61094ad2ab2aba82a90aa9cb3c0ca388c809dedc..586fc0b1b19fd7e4c8e0a7702ff7bf652f53cfc0 100644 --- a/AKSubmission/templates/AKSubmission/ak_history.html +++ b/AKSubmission/templates/AKSubmission/ak_history.html @@ -20,7 +20,7 @@ {% endblock %} {% block content %} - {% include "AKSubmission/messages.html" %} + {% include "messages.html" %} <div class="float-right"> <a href='{% url 'submit:ak_detail' event_slug=ak.event.slug pk=ak.pk %}' data-toggle="tooltip" diff --git a/AKSubmission/templates/AKSubmission/submission_overview.html b/AKSubmission/templates/AKSubmission/submission_overview.html index f26cf36ad07019a6fed34f990555e1544dae1c19..6265d4c34b867d99e8b4bac455334f1b02f85ec2 100644 --- a/AKSubmission/templates/AKSubmission/submission_overview.html +++ b/AKSubmission/templates/AKSubmission/submission_overview.html @@ -37,7 +37,7 @@ {% block content %} <h1>{% trans "AKs" %}: {{ event.name }}</h1> - {% include "AKSubmission/messages.html" %} + {% include "messages.html" %} {% blocktrans %}On this page you can see a list of current AKs, change them and add new ones.{% endblocktrans %} diff --git a/AKSubmission/templates/AKSubmission/submit_new.html b/AKSubmission/templates/AKSubmission/submit_new.html index 2a07c2b280348ecd9b65d035f9339a85ac1ccdbe..489806f4cf8716e2d2f71b27010ba4d1a7a18243 100644 --- a/AKSubmission/templates/AKSubmission/submit_new.html +++ b/AKSubmission/templates/AKSubmission/submit_new.html @@ -22,7 +22,7 @@ {% endblock %} {% block content %} - {% include "AKSubmission/messages.html" %} + {% include "messages.html" %} {% block headline %} <h2>{% trans 'New AK' %}</h2> diff --git a/AKSubmission/templatetags/tags_AKSubmission.py b/AKSubmission/templatetags/tags_AKSubmission.py index e8a60e2cd4754e7a4671f4f9a0aea3e5cce70ad7..7be35e1e028b885099634c470bad54a6ea08c045 100644 --- a/AKSubmission/templatetags/tags_AKSubmission.py +++ b/AKSubmission/templatetags/tags_AKSubmission.py @@ -29,15 +29,3 @@ def category_list(categories, event_slug): @register.inclusion_tag("AKSubmission/category_linked_badge.html") def category_linked_badge(category, event_slug): return {"category": category, "event_slug": event_slug} - - -@register.filter -def message_bootstrap_class(tag): - print(tag) - if tag == "error": - return "alert-danger" - elif tag == "success": - return "alert-success" - elif tag == "warning": - return "alert-warning" - return "alert-info" diff --git a/requirements.txt b/requirements.txt index cb5e8031dee45997a5cda0c1cadc140e87e2fdd5..646382702dab0b482758fbe2f4d7985c37ef7dc8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/templates/base.html b/templates/base.html index 37311f1e8c8ffa9a296838fe9de4fd16a677f497..2b24b9460d1c0a36d716de33d6545f6739491552 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,8 @@ <html lang="en"> <head> <meta charset="UTF-8"> + {% block meta %}{% endblock%} + <title>{% block title %}AK Planning{% endblock %}</title> {# Load Bootstrap CSS and JavaScript as well as font awesome #} diff --git a/AKSubmission/templates/AKSubmission/messages.html b/templates/messages.html similarity index 90% rename from AKSubmission/templates/AKSubmission/messages.html rename to templates/messages.html index dc8dd31f18b78e92597e39ac66447e778efec8d9..7aacbaa66e2fee13e5c315e87de56e980f4c2401 100644 --- a/AKSubmission/templates/AKSubmission/messages.html +++ b/templates/messages.html @@ -1,4 +1,4 @@ -{% load tags_AKSubmission %} +{% load tags_AKModel %} {% if messages %} {% for message in messages %}