kopia lustrzana https://github.com/hholzgra/maposmatic/
basic login/logout navbar integration
* no password recovery * registration form not working yetuser-mgmt
rodzic
74f6518a90
commit
0c821cde4e
|
@ -30,6 +30,8 @@ from django.utils.safestring import mark_safe
|
|||
from django.utils.html import escape
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.forms.utils import ErrorList
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
|
||||
import time
|
||||
|
||||
import ocitysmap
|
||||
|
@ -334,3 +336,8 @@ class MapCancelForm(forms.Form):
|
|||
cleaned_data["id"] = 0
|
||||
|
||||
return cleaned_data
|
||||
|
||||
class CustomUserCreationForm(UserCreationForm):
|
||||
class Meta(UserCreationForm.Meta):
|
||||
# fields = UserCreationForm.Meta.fields + ("email",)
|
||||
pass
|
||||
|
|
|
@ -72,6 +72,14 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<li class="nav-item">
|
||||
{% if user.is_authenticated %}
|
||||
<a class="nav-link" href="{% url "logout" %}"><i class="fas fa-user"></i> {%trans "Logout" %}</a>
|
||||
{% else %}
|
||||
<a class="nav-link" href="{% url "login" %}"><i class="fas fa-user"></i> {%trans "Login" %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<form action="{% url "maps" %}" method="get" class="form-inline">
|
||||
|
@ -80,6 +88,7 @@
|
|||
{{ searchform.query }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -34,7 +34,7 @@ from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
|||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect, HttpResponseBadRequest, HttpResponseNotFound, HttpResponse, Http404
|
||||
from django.db.transaction import TransactionManagementError
|
||||
from django.shortcuts import get_object_or_404, render_to_response, render
|
||||
from django.shortcuts import get_object_or_404, render_to_response, render, redirect
|
||||
from django.template import RequestContext
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
from django.core import serializers
|
||||
|
@ -43,6 +43,9 @@ from django.core.exceptions import ValidationError
|
|||
from django.urls import get_script_prefix
|
||||
from django.db import connections
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.urls import reverse
|
||||
|
||||
from www.maposmatic.forms import CustomUserCreationForm
|
||||
|
||||
import ocitysmap
|
||||
from www.maposmatic import helpers, forms, nominatim, models
|
||||
|
@ -658,3 +661,17 @@ def api_rendering_status(request, id, nonce=None):
|
|||
|
||||
def dashboard(request):
|
||||
return render(request, "users/dashboard.html")
|
||||
|
||||
def register(request):
|
||||
if request.method == "GET":
|
||||
return render(
|
||||
request, "users/register.html",
|
||||
{"form": CustomUserCreationForm}
|
||||
)
|
||||
elif request.method == "POST":
|
||||
form = CustomUserCreationForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = form.save()
|
||||
login(request, user)
|
||||
return redirect(reverse("dashboard"))
|
||||
|
||||
|
|
|
@ -325,3 +325,12 @@ a.carousel-control { display: none; }
|
|||
letter-spacing: -2px; vertical-align: top; z-index: 999;
|
||||
}
|
||||
|
||||
|
||||
|
||||
* > .fa-hover-show,
|
||||
*:hover > .fa-hover-hidden {
|
||||
display: none;
|
||||
}
|
||||
*:hover > .fa-hover-show {
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
<input type="submit" value="Login">
|
||||
</form>
|
||||
|
||||
<a href="{% url 'dashboard' %}">Back to dashboard</a>
|
||||
{% endblock %}
|
||||
<a href="{% url 'register' %}">Register</a>
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{% extends "maposmatic/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load l10n %}
|
||||
{% load extratags %}
|
||||
|
||||
{% block title %}Registration{% endblock %}
|
||||
{% block page %}
|
||||
<h2>Register</h2>
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{form}}
|
||||
<input type="submit" value="{%trans "Register" %}"/>
|
||||
</form>
|
||||
|
||||
<a href="{% url 'login' %}">Back to login</a>
|
||||
{% endblock %}
|
|
@ -136,6 +136,7 @@ urlpatterns = [
|
|||
# user management
|
||||
url(r"^accounts/", include("django.contrib.auth.urls")),
|
||||
url(r"^dashboard/", views.dashboard, name="dashboard"),
|
||||
url(r"^register/", views.register, name="register"),
|
||||
|
||||
# test
|
||||
url(r'heatmap/', TemplateView.as_view(template_name='heatmap.html', content_type='text/html')),
|
||||
|
|
Ładowanie…
Reference in New Issue