allow guest login

This commit is contained in:
Seth Ladygo
2019-03-13 21:00:36 -07:00
parent 0db088d8f9
commit 16c004e291
4 changed files with 15 additions and 3 deletions

View File

@ -8,6 +8,6 @@ from lazysignup.decorators import allow_lazy_user
from account.decorators import login_required
@allow_lazy_user
@login_required
def dashboard(request):
return render(request, 'dashboard/dashboard.html')

View File

@ -20,10 +20,11 @@ from dashboard.views import dashboard
from lazysignup.views import convert
from .forms import UserCreationForm
from .views import lazy_convert_done
from .views import login_guest, lazy_convert_done
urlpatterns = [
path('guest', login_guest, name='login_guest'),
path('', dashboard, name='home'),
path('dashboard', dashboard, name='dashboard'),
path('admin/', admin.site.urls),

View File

@ -2,6 +2,16 @@ from django.shortcuts import redirect
from django.contrib import messages
from django.utils.translation import gettext as _
from lazysignup.decorators import allow_lazy_user
from account.decorators import login_required
@allow_lazy_user
def login_guest(request):
"""Create a lazy user if necessary and redirect."""
messages.info(request, _('Welcome, guest!'))
return redirect('home')
def lazy_convert_done(request):
"""Called after converting a lazy user."""

View File

@ -24,7 +24,8 @@
{% trans "Don't have an account?" %} <strong><a href="{% urlnext 'account_signup' %}">{% trans "Sign up" %}</a></strong>
</small>
</p>
{% endif %}
{% endif %}
<a href="{% url 'login_guest' %}" class="btn btn-link">{% trans "Log in as guest" %}</a>
</div>
<div class="col-md-4">
{% include "account/_login_sidebar.html" %}