improve lazysignup convert: more fields, redirect on done
This commit is contained in:
@ -1,56 +1,13 @@
|
|||||||
# from datetime import datetime
|
|
||||||
# from dateutil import tz
|
|
||||||
# from dateutil.parser import parse
|
|
||||||
# import feedparser
|
|
||||||
# import json
|
|
||||||
# import grequests
|
|
||||||
# import time
|
|
||||||
|
|
||||||
# from django.conf import settings
|
|
||||||
# from django.core.urlresolvers import reverse
|
|
||||||
# from django.http import HttpResponse, JsonResponse, Http404
|
|
||||||
# from django.shortcuts import render
|
|
||||||
# from django.views.generic import View, TemplateView
|
|
||||||
# from django.contrib.staticfiles.templatetags.staticfiles import static
|
|
||||||
# from django.utils.html import strip_tags
|
|
||||||
|
|
||||||
# from meta.views import Meta
|
|
||||||
|
|
||||||
from django.shortcuts import render, get_object_or_404
|
|
||||||
from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
|
|
||||||
from django.urls import reverse
|
|
||||||
#from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
|
||||||
#from django.core.mail import EmailMultiAlternatives
|
|
||||||
#from django.template.loader import get_template
|
|
||||||
#from django.utils import timezone
|
|
||||||
#from datetime import date
|
|
||||||
#import datetime as DT
|
|
||||||
#from django.db.models import Q
|
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
|
||||||
|
from django.shortcuts import render, get_object_or_404
|
||||||
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
#from .forms import SourceForm, DestinationForm, PostForm, MoverForm, ClaimForm, SourceLoginForm, MoverLoginForm, CustomFormDestination
|
from lazysignup.decorators import allow_lazy_user
|
||||||
#from .models import Source, Destination, Post, Mover, Claim
|
from account.decorators import login_required
|
||||||
|
|
||||||
|
|
||||||
|
@allow_lazy_user
|
||||||
def dashboard(request):
|
def dashboard(request):
|
||||||
#messages.info(request, 'Three credits remain in your account.')
|
|
||||||
return render(request, 'dashboard/dashboard.html')
|
return render(request, 'dashboard/dashboard.html')
|
||||||
|
|
||||||
def unused(request):
|
|
||||||
return HttpResponse(_("Hello, world."))
|
|
||||||
|
|
||||||
# def sources(request):
|
|
||||||
# sources = Source.objects.all()
|
|
||||||
# paginator = Paginator(sources, 10)
|
|
||||||
# page = request.GET.get('page')
|
|
||||||
|
|
||||||
# try:
|
|
||||||
# source_list = paginator.page(page)
|
|
||||||
# except PageNotAnInteger:
|
|
||||||
# source_list = paginator.page(1)
|
|
||||||
# except EmptyPage:
|
|
||||||
# source_list = paginator.page(paginator.num_pages)
|
|
||||||
|
|
||||||
# return render(request, 'source/index.html', {'sources': source_list,})
|
|
||||||
|
|||||||
29
procat2/forms.py
Normal file
29
procat2/forms.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.forms import UserCreationForm as UserCreationFormBase
|
||||||
|
|
||||||
|
|
||||||
|
class UserCreationForm(UserCreationFormBase):
|
||||||
|
"""Account creation with added email, first, and last names."""
|
||||||
|
email = forms.EmailField(required=True)
|
||||||
|
first_name = forms.CharField(required=True, label="First name")
|
||||||
|
last_name = forms.CharField(required=True, label="Last name")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2')
|
||||||
|
|
||||||
|
def get_credentials(self):
|
||||||
|
return {
|
||||||
|
'username': self.cleaned_data['username'],
|
||||||
|
'password': self.cleaned_data['password1']
|
||||||
|
}
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
user = super(UserCreationForm, self).save(commit=False)
|
||||||
|
user.email = self.cleaned_data["email"]
|
||||||
|
user.first_name = self.cleaned_data["first_name"]
|
||||||
|
user.last_name = self.cleaned_data["last_name"]
|
||||||
|
if commit:
|
||||||
|
user.save()
|
||||||
|
return user
|
||||||
@ -17,13 +17,19 @@ from django.contrib import admin
|
|||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
from dashboard.views import dashboard
|
from dashboard.views import dashboard
|
||||||
|
from lazysignup.views import convert
|
||||||
|
|
||||||
|
from .forms import UserCreationForm
|
||||||
|
from .views import lazy_convert_done
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', dashboard, name='home'),
|
path('', dashboard, name='home'),
|
||||||
path('dashboard', dashboard, name='dashboard'),
|
path('dashboard', dashboard, name='dashboard'),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path('convert/', include('lazysignup.urls')),
|
path('convert/', convert, { 'form_class': UserCreationForm }, name='lazysignup_convert'),
|
||||||
|
path('convert/done/', lazy_convert_done, name='lazysignup_convert_done'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# accounts/login/ [name='login']
|
# accounts/login/ [name='login']
|
||||||
|
|||||||
9
procat2/views.py
Normal file
9
procat2/views.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from django.shortcuts import redirect
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
|
||||||
|
def lazy_convert_done(request):
|
||||||
|
"""Called after converting a lazy user."""
|
||||||
|
messages.info(request, _('Account created. Welcome!'))
|
||||||
|
return redirect('home')
|
||||||
Reference in New Issue
Block a user