Logout/Login functionality added
This commit is contained in:
parent
595ba93e39
commit
12cb9cafe5
@ -21,10 +21,25 @@ body {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav a:hover {
|
.nav .nav-link {
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: none;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 12px;
|
||||||
|
font: inherit;
|
||||||
|
color: #333;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav a:hover,
|
||||||
|
.nav .nav-link:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logout-form {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.spacer {
|
.spacer {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,25 +9,30 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<header class="topbar">
|
||||||
|
<nav class="nav">
|
||||||
|
<a href="{% url 'home' %}">Home</a>
|
||||||
|
<a href="{% url 'dashboard' %}">Dashboard</a>
|
||||||
|
<a href="{% url 'expense_list' %}">Gastos</a>
|
||||||
|
<a href="{% url 'account_list' %}">Cuentas</a>
|
||||||
|
<a href="{% url 'income_list' %}">Ingresos</a>
|
||||||
|
<a href="{% url 'tag_list' %}">Etiquetas</a>
|
||||||
|
|
||||||
<header class="topbar">
|
<span class="spacer"></span>
|
||||||
<nav class="nav">
|
|
||||||
<a href="{% url 'home' %}">Home</a>
|
|
||||||
<a href="{% url 'dashboard' %}">Dashboard</a>
|
|
||||||
<a href="{% url 'expense_list' %}">Gastos</a>
|
|
||||||
<a href="{% url 'account_list' %}">Cuentas</a>
|
|
||||||
<a href="{% url 'income_list' %}">Ingresos</a>
|
|
||||||
<a href="{% url 'tag_list' %}">Etiquetas</a>
|
|
||||||
|
|
||||||
<span class="spacer"></span>
|
<span class="user">
|
||||||
|
Hola {{ request.user.username }}
|
||||||
|
</span>
|
||||||
|
|
||||||
<span class="user">
|
<form method="post" action="{% url 'logout' %}" class="logout-form">
|
||||||
{{ request.user.username }}
|
{% csrf_token %}
|
||||||
</span>
|
<button type="submit" class="nav-link">Salir</button>
|
||||||
<!-- <a href="{ url 'logout' }">Salir</a> -->
|
</form>
|
||||||
|
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<main class="content">
|
<main class="content">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
|
|||||||
15
expenses_manager/expenses/templates/registration/login.html
Normal file
15
expenses_manager/expenses/templates/registration/login.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends "expenses/base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Login{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h2>Iniciar sesión</h2>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">Entrar</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@ -129,5 +129,6 @@ STATIC_URL = 'static/'
|
|||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
LOGIN_URL = '/admin/login/'
|
LOGIN_URL = 'login'
|
||||||
LOGIN_REDIRECT_URL = '/'
|
LOGIN_REDIRECT_URL = 'home'
|
||||||
|
LOGOUT_REDIRECT_URL = 'login'
|
||||||
@ -15,9 +15,11 @@ 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.contrib.auth import urls
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('accounts/', include(urls)),
|
||||||
path('', include('expenses.urls')),
|
path('', include('expenses.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user