Skip to content
Snippets Groups Projects
Commit 55f5ee2d authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'feature-user-registration' into 'master'

User Registration

Closes #40

See merge request !35
parents 1f4b5334 3bb1aa27
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 %}
...@@ -14,3 +14,14 @@ def footer_info(): ...@@ -14,3 +14,14 @@ def footer_info():
@register.filter @register.filter
def check_app_installed(name): def check_app_installed(name):
return apps.is_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"
...@@ -20,4 +20,5 @@ urlpatterns = [ ...@@ -20,4 +20,5 @@ urlpatterns = [
path('api/', include(api_router.urls), name='api'), 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.shortcuts import get_object_or_404
from django.views.generic import TemplateView
from rest_framework import viewsets, permissions, mixins from rest_framework import viewsets, permissions, mixins
from AKModel.models import Event, AK, AKSlot, Room, AKTrack, AKCategory, AKOwner from AKModel.models import Event, AK, AKSlot, Room, AKTrack, AKCategory, AKOwner
...@@ -95,3 +96,7 @@ class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelM ...@@ -95,3 +96,7 @@ class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelM
def get_queryset(self): def get_queryset(self):
return AKSlot.objects.filter(event=self.event) return AKSlot.objects.filter(event=self.event)
class UserView(TemplateView):
template_name = "AKModel/user.html"
...@@ -48,6 +48,7 @@ INSTALLED_APPS = [ ...@@ -48,6 +48,7 @@ INSTALLED_APPS = [
'timezone_field', 'timezone_field',
'rest_framework', 'rest_framework',
'simple_history', 'simple_history',
'registration',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -169,4 +170,8 @@ PLAN_SHOW_HIERARCHY = True ...@@ -169,4 +170,8 @@ PLAN_SHOW_HIERARCHY = True
# For which time (in seconds) should changes of akslots be highlighted in plan? # For which time (in seconds) should changes of akslots be highlighted in plan?
PLAN_MAX_HIGHLIGHT_UPDATE_SECONDS = 2 * 60 * 60 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")) include(optional("settings/*.py"))
...@@ -19,8 +19,10 @@ from django.urls import path, include ...@@ -19,8 +19,10 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), 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('', 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) # Load URLs dynamically (only if components are active)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{% endif %} {% endif %}
{% block content %} {% block content %}
{% include "AKSubmission/messages.html" %} {% include "messages.html" %}
<div class="text-right"> <div class="text-right">
{% if ak.interest_counter >= 0 %} {% if ak.interest_counter >= 0 %}
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% include "AKSubmission/messages.html" %} {% include "messages.html" %}
<div class="float-right"> <div class="float-right">
<a href='{% url 'submit:ak_detail' event_slug=ak.event.slug pk=ak.pk %}' data-toggle="tooltip" <a href='{% url 'submit:ak_detail' event_slug=ak.event.slug pk=ak.pk %}' data-toggle="tooltip"
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
{% block content %} {% block content %}
<h1>{% trans "AKs" %}: {{ event.name }}</h1> <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 %} {% blocktrans %}On this page you can see a list of current AKs, change them and add new ones.{% endblocktrans %}
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% include "AKSubmission/messages.html" %} {% include "messages.html" %}
{% block headline %} {% block headline %}
<h2>{% trans 'New AK' %}</h2> <h2>{% trans 'New AK' %}</h2>
......
...@@ -29,15 +29,3 @@ def category_list(categories, event_slug): ...@@ -29,15 +29,3 @@ def category_list(categories, event_slug):
@register.inclusion_tag("AKSubmission/category_linked_badge.html") @register.inclusion_tag("AKSubmission/category_linked_badge.html")
def category_linked_badge(category, event_slug): def category_linked_badge(category, event_slug):
return {"category": category, "event_slug": 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"
...@@ -4,4 +4,5 @@ django-fontawesome-5==1.0.18 ...@@ -4,4 +4,5 @@ django-fontawesome-5==1.0.18
django-split-settings==1.0.1 django-split-settings==1.0.1
django-timezone-field==4.0 django-timezone-field==4.0
djangorestframework==3.11.0 djangorestframework==3.11.0
django-simple-history==2.10.0 django-simple-history==2.10.0
\ No newline at end of file django-registration-redux==2.8
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
{% block meta %}{% endblock%}
<title>{% block title %}AK Planning{% endblock %}</title> <title>{% block title %}AK Planning{% endblock %}</title>
{# Load Bootstrap CSS and JavaScript as well as font awesome #} {# Load Bootstrap CSS and JavaScript as well as font awesome #}
......
{% load tags_AKSubmission %} {% load tags_AKModel %}
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment