Skip to content
Snippets Groups Projects
Commit 5a8aab39 authored by frekk's avatar frekk
Browse files

override admin site login view with our custom one (even though it's uglier)

parent 11e46013
No related merge requests found
......@@ -3,6 +3,6 @@ from django.urls import path, include
from . import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('memberdb.urls')),
path('admin/', admin.site.urls),
]
......@@ -5,6 +5,7 @@
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% static "shared.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "main.css" %}">
<link rel="shortcut icon" type="image/png" href="{% static 'ucc-logo.png' %}"/>
{% block extrahead %}{% endblock %}
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE">{% endblock %}
</head>
......@@ -26,10 +27,16 @@
{# fancy automatic navbar thing from https://stackoverflow.com/questions/39639264 #}
{% with url_name=request.resolver_match.url_name %}
<a class="navtab {% if url_name == 'home' %}active{% endif %}" href="{% url "memberdb:home" %}">Member home</a>
{% if not request.user.is_authenticated %}
<a class="navtab {% if url_name == 'home' %}active{% endif %}" href="{% url "memberdb:home" %}">Login</a>
<a class="navtab {% if url_name == 'register' %}active{% endif %}" href="{% url "memberdb:register" %}">Register</a>
{% else %}
<a class="navtab {% if url_name == 'home' %}active{% endif %}" href="{% url "memberdb:home" %}">Member home</a>
<a class="navtab {% if url_name == 'renew' %}active{% endif %}" href="{% url "memberdb:renew" %}">Renew membership</a>
{% endif %}
{% if request.user.is_staff %}
<a class="navtab" href="{% url "admin:index" %}">Admin site</a>
{% endif %}
{% endwith %}
</nav>
{% endblock %}
......@@ -38,7 +45,7 @@
<!-- Content -->
<div id="content">
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
{% block content_title %}{% endblock %}
{% block content %}
{% endblock %}
</div>
......
......@@ -29,12 +29,16 @@
{% endfor %}
{% endif %}
<p class="tips">
{% if user.is_authenticated %}
<p class="errornote">
You are authenticated as {{ user.username }}, but are not authorized to
access this page. Would you like to login to a different account?
</p>
You are already logged in as {{ user.username }}.
Would you like to login to a different account?
{% else %}
<b>Please enter your UCC username and password below.</b> <br><br>
If you do not have a UCC account yet, please apply for a membership by going to the <a href="{% url 'memberdb:register' %}">registration page</a>.
{% endif %}
</p>
<form action="{% url 'memberdb:login' %}" method="post" id="login-form">
{% csrf_token %}
......
{% extends "base.html" %}
{% load static %}
{% block title %}UCC Member Logout{% endblock %}
{% block extrahead %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "login.css" %}">
{{ form.media }}
{% endblock %}
{% block content_title %}<h1>Logout</h1>{% endblock %}
{% block content %}
<div class="form-container">
<p>
<b>You are now logged out of MemberDB.</b>
</p>
<p>
<a href="{% url 'memberdb:login' %}">Click here</a> to log back in again.
</p>
{% endblock %}
\ No newline at end of file
......@@ -2,15 +2,21 @@ from django.urls import path
from django.contrib.auth import views as auth_views
from . import views
from .views import MemberHomeView
from .register import RegisterView, RenewView
app_name = 'memberdb'
urlpatterns = [
path('', views.index, name='index'),
path('', MemberHomeView.as_view(), name='home'),
path('login/', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
path('logout/', auth_views.LogoutView.as_view(template_name='logout.html'), name='logout'),
# override the admin login/logout views
path('admin/login/', auth_views.LoginView.as_view(template_name='login.html')),
path('admin/logout/', auth_views.LogoutView.as_view(template_name='logout.html')),
path('register/', RegisterView.as_view(), name='register'),
path('renew/', RenewView.as_view(), name='renew'),
path('home/', views.index, name='home'),
path('active/', views.getactive, name='actives'),
#path('<str:username>/', views.info, name='info'),
]
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment