Add logout button

This commit is contained in:
Daoud Clarke 2023-11-08 08:45:39 +00:00
parent 6d8facf977
commit ae39eb98e9
6 changed files with 20 additions and 20 deletions

View File

@ -340,4 +340,8 @@ a {
.button:hover {
background-color: var(--dark-color);
}
.login-info {
padding: 10px;
}

View File

@ -131,3 +131,5 @@ ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
DEFAULT_FROM_EMAIL = "admin@mwmbl.org"
LOGIN_REDIRECT_URL = "/"

View File

@ -75,8 +75,13 @@
>
</form>
<div is="mwmbl-save"></div>
<a class="button" href="/accounts/login/">Login</a>
<a class="button" href="/accounts/signup/">Sign up</a>
{% if user.is_authenticated %}
<p class="login-info">Logged in as {{ user.username }}</p>
<a class="button" href="/accounts/logout/">Log out</a>
{% else %}
<a class="button" href="/accounts/login/">Login</a>
<a class="button" href="/accounts/signup/">Sign up</a>
{% endif %}
</header>
<main>
<mwmbl-results>

View File

@ -1,8 +0,0 @@
{% extends "base.html" %}
{% block title %}Profile Page{% endblock title %}
{% block content %}
<div class="row my-3 p-3">
<h1>This is the profile page for {{user.username}}</h1>
</div>
{% endblock content %}

View File

@ -17,17 +17,15 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from mwmbl.api import api_original as api, api_v1
from mwmbl.views import profile, search_results, fetch_url, home
from mwmbl.api import api_v1
from mwmbl.views import search_results, fetch_url, home
urlpatterns = [
path('admin/', admin.site.urls),
# path('', api.urls),
path('api/v1/', api_v1.urls),
path('accounts/', include('allauth.urls')),
path('', home, name="home"),
path('accounts/profile/', profile, name="profile"),
path('app/search/', search_results, name="search_results"),
path('app/fetch/', fetch_url, name="fetch_url")
]

View File

@ -41,15 +41,14 @@ def justext_with_dom(html_text, stoplist, length_low=LENGTH_LOW_DEFAULT,
return paragraphs, title
@login_required
def profile(request):
return render(request, 'profile.html')
def home(request):
query = request.GET.get("q")
results = ranker.search(query) if query else None
return render(request, "index.html", {"results": results, "query": query})
return render(request, "index.html", {
"results": results,
"query": query,
"user": request.user,
})
def search_results(request):