Skip to content

Commit

Permalink
Example project updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Mar 20, 2015
1 parent 9dc11f9 commit b15eed5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
8 changes: 2 additions & 6 deletions example_projects/vanilla/src/example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from machina.app import board

# Local application / specific library imports
from example_project.forms import UserCreationForm
from example_project.views import UserCreateView


# Admin autodiscover
Expand All @@ -26,11 +26,7 @@
# Admin
url(r'^' + settings.ADMIN_URL, include(admin.site.urls)),
url(r'^account/', include('django.contrib.auth.urls')),
url('^register/', CreateView.as_view(
template_name='registration/register.html',
form_class=UserCreationForm,
success_url='/'
), name='register'),
url('^register/', UserCreateView.as_view(), name='register'),
url('^markdown/', include( 'django_markdown.urls')),

# Apps
Expand Down
28 changes: 28 additions & 0 deletions example_projects/vanilla/src/example_project/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-

# Standard library imports
# Third party imports
from django.contrib.auth import authenticate
from django.contrib.auth import login
from django.views.generic.edit import CreateView

# Local application / specific library imports
from example_project.forms import UserCreationForm


class UserCreateView(CreateView):
template_name = 'registration/register.html'
form_class = UserCreationForm

success_url = '/'

def form_valid(self, form):
response = super(UserCreateView, self).form_valid(form)

# We log the user in
new_authenticated_user = authenticate(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'])
login(self.request, new_authenticated_user)

return response

0 comments on commit b15eed5

Please sign in to comment.