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 { .button:hover {
background-color: var(--dark-color); background-color: var(--dark-color);
}
.login-info {
padding: 10px;
} }

View file

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

View file

@ -75,8 +75,13 @@
> >
</form> </form>
<div is="mwmbl-save"></div> <div is="mwmbl-save"></div>
<a class="button" href="/accounts/login/">Login</a> {% if user.is_authenticated %}
<a class="button" href="/accounts/signup/">Sign up</a> <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> </header>
<main> <main>
<mwmbl-results> <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.contrib import admin
from django.urls import path, include from django.urls import path, include
from mwmbl.api import api_original as api, api_v1 from mwmbl.api import api_v1
from mwmbl.views import profile, search_results, fetch_url, home from mwmbl.views import search_results, fetch_url, home
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
# path('', api.urls),
path('api/v1/', api_v1.urls), path('api/v1/', api_v1.urls),
path('accounts/', include('allauth.urls')), path('accounts/', include('allauth.urls')),
path('', home, name="home"), path('', home, name="home"),
path('accounts/profile/', profile, name="profile"),
path('app/search/', search_results, name="search_results"), path('app/search/', search_results, name="search_results"),
path('app/fetch/', fetch_url, name="fetch_url") 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 return paragraphs, title
@login_required
def profile(request):
return render(request, 'profile.html')
def home(request): def home(request):
query = request.GET.get("q") query = request.GET.get("q")
results = ranker.search(query) if query else None 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): def search_results(request):