forked from Fediversity/Fediversity
Add page showing account info
Co-authored-by: lois <lois@procolix.eu> Co-authored-by: Kiara Grouwstra <kiara.grouwstra@gmail.com>
This commit is contained in:
parent
d5632a795b
commit
ac2b544a9a
7 changed files with 37 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
||||||
lib,
|
lib,
|
||||||
buildPythonPackage,
|
buildPythonPackage,
|
||||||
setuptools,
|
setuptools,
|
||||||
|
sqlite,
|
||||||
django_4,
|
django_4,
|
||||||
django-compressor,
|
django-compressor,
|
||||||
django-libsass,
|
django-libsass,
|
||||||
|
@ -46,6 +47,7 @@ buildPythonPackage {
|
||||||
django-compressor
|
django-compressor
|
||||||
django-libsass
|
django-libsass
|
||||||
dj-database-url
|
dj-database-url
|
||||||
|
sqlite
|
||||||
];
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
|
|
|
@ -119,6 +119,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
LOGIN_URL = 'login'
|
||||||
|
LOGIN_REDIRECT_URL = '/' # Redirect to homepage after login
|
||||||
|
LOGOUT_REDIRECT_URL = '/' # Redirect to homepage after logout
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||||
|
|
8
panel/src/panel/templates/accountdetail.html
Normal file
8
panel/src/panel/templates/accountdetail.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ user.username }}</h1>
|
||||||
|
<dl>
|
||||||
|
<dt>e-mail</dt><dd>{{ user.email}}</dd>
|
||||||
|
</dl>
|
||||||
|
{% endblock %}
|
|
@ -17,9 +17,9 @@
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<p>Welcome, {{ user.username }}!</p>
|
<p>Welcome, {{ user.username }}! <a href="{% url 'logout' %}">Logout</a></p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>You are not logged in.</p>
|
<p><a href="{% url 'login' %}">Login</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
|
|
10
panel/src/panel/templates/login.html
Normal file
10
panel/src/panel/templates/login.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Login</h2>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
|
@ -15,10 +15,12 @@ Including another URLconf
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
from panel import views
|
from panel import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('', views.Index.as_view(), name='index'),
|
path('', views.Index.as_view(), name='index'),
|
||||||
|
path("", include("django.contrib.auth.urls")),
|
||||||
|
path("account/", views.AccountDetail.as_view(), name='accountdetail')
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.auth.models import User
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
from django.views.generic import DetailView
|
||||||
|
|
||||||
class Index(TemplateView):
|
class Index(TemplateView):
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
|
||||||
|
class AccountDetail(LoginRequiredMixin, DetailView):
|
||||||
|
model = User
|
||||||
|
template_name = 'accountdetail.html'
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.user
|
||||||
|
|
Loading…
Add table
Reference in a new issue