allow guest login
This commit is contained in:
@ -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')
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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."""
|
||||
|
||||
@ -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" %}
|
||||
|
||||
Reference in New Issue
Block a user