本文整理匯總了Python中registration.backends.simple.views.RegistrationView類的典型用法代碼示例。如果您正苦於以下問題:Python RegistrationView類的具體用法?Python RegistrationView怎麽用?Python RegistrationView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RegistrationView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Authenticate
def Authenticate(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password'].encode('utf-8')
email = None
authenticated = False
#Setup request url and parameter for API
moodleUrl = os.environ['MOODLE_API_URL']
payload = {'username': username}
#Get values from the API
try:
api = requests.get(moodleUrl, params=payload).json()[0]
salt = api['password'].encode('utf-8')
email = api['email']
#Check if the user and password match with moodle
if clean(password, salt):
authenticated = True
#Check if the user is in the local database and if the password matches
new_user = authenticate(username=username, password=password)
#Check if the username exists
try:
user = get_object_or_404(User, username=username)
except:
user = None
#If the user exists, is authenticated but wrong password
#then the username exists in our database.
if authenticated and new_user is None and user is not None:
messages.error(request, "Username already in local database")
return MoodleLogin(request)
#Login the user with moodle
if new_user:
login(request, new_user)
#If this is the first moodle login then register the user
else:
reg = RegistrationView()
data = {'username': username,
'email': email,
'password1': password}
#Register the user and log him in
reg.register(request, **data)
#Username in moodle but wrong password
else:
messages.error(request, "Invalid moodle credentials")
return MoodleLogin(request)
#Username not in moodle
except:
messages.error(request, "Username not in our moodle database")
return MoodleLogin(request)
return HttpResponseRedirect('/')
示例2: register_home
def register_home(request):
loginform = AuthenticationForm()
if request.method == "POST": # If the form registration has been submitted
form = RegistrationFormUniqueEmail(request.POST)
if form.is_valid():
usr, em, pw = form.cleaned_data["username"], form.cleaned_data["email"], form.cleaned_data["password1"]
user = RegistrationView.register(RegistrationView, request=request, username=usr, email=em, password1=pw)
return HttpResponseRedirect("/playlist")
else:
return render(request, "home.html", {"regform": form, "anchor": "register", "loginform": loginform})
else:
form = RegistrationFormUniqueEmail()
return render(request, "home.html", {"regform": form, "loginform": loginform})
示例3: url
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url, patterns
from django.contrib import admin
from django.views.generic.base import RedirectView
from registration.backends.simple.views import RegistrationView
class MyRegistrationView(RegistrationView):
def get_success_url(self, request=None, user=None):
return "/rango/"
urlpatterns = patterns(
"",
url(r"^admin/", include(admin.site.urls)),
url(r"^rango/", include("rango.urls")),
url(r"^$", RedirectView.as_view(url="http://127.0.0.1:8000/rango")),
url(r"^accounts/register/$", RegistrationView.as_view(), name="registration_register"),
(r"^accounts/", include("registration.backends.simple.urls")),
)
示例4: include
for registration::
(r'^accounts/', include('registration.backends.simple.urls')),
This will also automatically set up the views in
``django.contrib.auth`` at sensible default locations.
If you'd like to customize registration behavior, feel free to set up
your own URL patterns for these views instead.
"""
from django.conf.urls import include
from django.conf.urls import patterns
from django.conf.urls import url
from django.views.generic.base import TemplateView
from registration.backends.simple.views import RegistrationView
urlpatterns = patterns('',
url(r'^register/$',
RegistrationView.as_view(),
name='registration_register'),
url(r'^register/closed/$',
TemplateView.as_view(template_name='registration/registration_closed.html'),
name='registration_disallowed'),
(r'', include('registration.auth_urls')),
)
示例5: url
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from plank.forms import PlankRegistrationForm
from plank.forms import PlankUserCreationForm
from plank.forms import PlankUserRegistrationForm
# from registration.backends.default.views import RegistrationView
from registration.backends.simple.views import RegistrationView
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^plank/', include('plank.urls')),
# url(r'^accounts/register/$', RegistrationView.as_view(form_class = PlankRegistrationForm), name = 'registration_register'),
# url(r'^accounts/register/$', RegistrationView.as_view(form_class = PlankUserCreationForm), name = 'registration_register'),
url(r'^accounts/register/$', RegistrationView.as_view(form_class = PlankUserRegistrationForm), name = 'registration_register'),
url(r'^accounts/', include('registration.backends.simple.urls')), # One-step registration
# url(r'^accounts/', include('registration.backends.default.urls')), #Two-step registratoin
]
示例6: MyRegistration
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings ##settings allows us to access vars in our projs settings.py file
from registration.backends.simple.views import RegistrationView
class MyRegistration(RegistrationView):
def get_success_url(self, request, user):
return '/rango/'
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'tango_with_django_project1.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^rango/', include('rango.urls')),
url(r'^accounts/register/$', RegistrationView.as_view(), name='registration_register'),
url(r'^accounts/', include('registration.backends.simple.urls')),
)
if settings.DEBUG: ##Checks if the Django project is being run in DEBUG
urlpatterns += patterns( ##if DEBUG is true, additional URL patterns are appended to the urlpatterns tuple
'django.views.static',
(r'^media/(?P<path>.*)', ##any file requested with a URL starting with media/
'serve',
{'document_root': settings.MEDIA_ROOT}), )
示例7: url
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from registration.backends.simple.views import RegistrationView
from shopping.forms import MyCustomUserForm
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/register/$',
RegistrationView.as_view(
form_class=MyCustomUserForm
),
name='registration_register',
),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'', include('shopping.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
示例8: url
url(r'^delete_a/(?P<a_id>[0-9]+)/$',
'cab.views.delete_answer', name='delete_answer'),
url(r'^edit_a/(?P<a_id>[0-9]+)/$',
'cab.views.edit_answer', name='edit_answer'),
#####################################################
# Seperate view into another app and check functionality
url(
r'^register/$',
RegistrationView.as_view(form_class=RegistrationFormUniqueEmail),
name='registration_register',
),
url(r'', include('registration.backends.simple.urls')),
######################################################
# Bookmarking (i.e Favoriting Views)
url(r'^favs/', 'cab.views.user_bookmarks', name='cab_user_bookmarks'),
url(r'^add_fav/(?P<question_id>\d+)/$',
'cab.views.add_bookmark', name='cab_bookmark_add'),
url(r'^delete_fav/(?P<question_id>\d+)/$',
'cab.views.delete_bookmark', name='cab_bookmark_delete'),
示例9: patterns
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic.base import TemplateView
from registration.backends.simple.views import RegistrationView
from opendata.views import Home
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', Home.as_view(), name='home'),
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration.auth_urls')),
url(r'^accounts/register/$', RegistrationView.as_view(),
name='registration_register'),
url(r'^accounts/register/closed/$',
TemplateView.as_view(template_name='registration/registration_closed.html'),
name='registration_disallowed'),
url(r'^catalog/', include("catalog.urls")),
url(r'^comments/', include('django.contrib.comments.urls')),
url(r'^selectable/', include('selectable.urls')),
url(r'^scribbler/', include('scribbler.urls')),
url(r'^request-data/', include('suggestions.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
示例10: url
"""
from django.conf.urls import include
from django.conf.urls import url
from django.conf import settings
from django.views.generic.base import TemplateView
from registration.backends.simple.views import RegistrationView
urlpatterns = [
url(
r"^register/closed/$",
TemplateView.as_view(template_name="registration/registration_closed.html"),
name="registration_disallowed",
),
url(
r"^register/complete/$",
TemplateView.as_view(template_name="registration/registration_complete.html"),
name="registration_complete",
),
]
if getattr(settings, "INCLUDE_REGISTER_URL", True):
urlpatterns += [url(r"^register/$", RegistrationView.as_view(), name="registration_register")]
if getattr(settings, "INCLUDE_AUTH_URLS", True):
urlpatterns += [url(r"", include("registration.auth_urls"))]
示例11: url
#from registration.backends.hmac.views import RegistrationView
#from registration.backends.model_activation.views import RegistrationView
from registration.backends.simple.views import RegistrationView
from registration.forms import RegistrationForm
from editor.forms import UserRegistrationForm
from editor import views
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('editor.urls')),
url(r'^editor/', include('editor.urls')),
url(r'^internal/content/', include('content.urls')),
url(r'^internal/library/', include('library.urls')),
url(r'^internal/', include('jhome.urls')),
# url(r'^accounts/', include('registration.backends.hmac.urls')),
# url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^accounts/profile/$', views.dispatch_ad_source, name='dispatch_ad_source'),
url(r'^accounts/register/$',
RegistrationView.as_view(
form_class = UserRegistrationForm
),
name='registration_register',
),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^admin/', admin.site.urls),
]
示例12: patterns
from django.conf.urls import patterns, include, url
from django.contrib import admin
from registration.backends.simple.views import RegistrationView
from core.views import UserProfileDetailView
from django.contrib.auth.decorators import login_required
from django.contrib.auth import views as auth_views
from core.views import UserProfileEditView
from core.models import UserProfile
from core.forms import UserProfileForm
from core import views
urlpatterns = patterns('',
url(r'^$','core.views.home', name = 'home' ),
url(r'^admin/', include(admin.site.urls)),
url(r'^activities/',include('core.urls', namespace = 'core')),
url(r'^users/(?P<slug>\w+)/$', UserProfileDetailView.as_view(), name="profile"),
url(r'^edit_profile/$', login_required(UserProfileEditView.as_view()), name="edit_profile"),
url(r'^accounts/register/$', RegistrationView.as_view(form_class = UserProfileForm ) , name = 'registration_register'),
url(r'^accounts/logout/$', auth_views.logout, {'template_name': 'registration/logout.html', 'next_page':'home'}, name='auth_logout'),
url(r'^accounts/', include('registration.backends.simple.urls')),
)
示例13: url
# fbUsers in user_app
url(r'^fbusers/$', 'user_app.views.fbusers', name='fbusers'),
url(r'^fbusers/add_profile/$', 'user_app.views.fbaddprofile', name='fbadd_profile'),
url(r'^fbusers/newsfeed/$', 'user_app.views.fbnewsfeed', name='fbnewsfeed'),
url(r'^fbusers/home/$', 'user_app.views.fbusers_home', name='fbusers_home'),
url(r'^fbusers/profile/$', 'user_app.views.fbuser_profile', name='fbuser_profile'),
# Admin
url(r'^admin/', include(admin.site.urls)),
# Django Auth
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^register/charity/$',
RegistrationView.as_view(success_url='/charity/new/'),
name='registration_register_charity', ),
url(r'^register/giver/$',
RegistrationView.as_view(success_url='/giver/new/'),
name='registration_register_giver', ),
url(r'^register/user/$',
RegistrationView.as_view(success_url='/user/home/'),
name='registration_register_giver', ),
url(r'^accounts/password/change/$',
auth_views.password_change,
name='password_change'),
url(r'^accounts/password/change/done/$',
auth_views.password_change_done,
示例14: patterns
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', views.index, name='home'),
url(r'^admin/', include(admin.site.urls)),
url(r'^edit/$', views.edit, name="edit"),
url(r'^authorize/$', views.authorize, name='authorize'),
url(r'^farmers/buy/(?P<pk>\d+)/$',
views.buy, name='buy'),
url(r'^farmers/(?P<pk>\d+)/$',
views.profile, name='profile'),
url(r'^register/$', RegistrationView.as_view(
form_class=CustomRegistrationForm),
name='registration_register'),
url(r'^', include(
'registration.backends.simple.urls')),
)
urlpatterns += staticfiles_urlpatterns()
示例15: register
def register(self, request, **cleaned_data):
new_user = RegistrationView.register(self, request, **cleaned_data)
UserProfile(user=new_user).save()
return new_user