Compare commits

...

3 Commits

Author SHA1 Message Date
Fred e9d2d4fea0 [WIP] implementing registration 2016-10-03 20:48:45 +02:00
Fred 48aa115a17 fix templates loader error 2016-10-03 20:23:23 +02:00
Fred e41c4975cb add owner field on wishlists 2016-10-03 20:22:49 +02:00
7 changed files with 44 additions and 5 deletions

View File

@ -50,7 +50,7 @@ ROOT_URLCONF = 'gwift.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

View File

@ -22,5 +22,6 @@ import wish
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^', include('wish.urls', namespace='wish')),
]

View File

@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block title %}Registration{% endblock %}
{% block content %}
{{ form }}
<input type="submit"/>
{% endblock %}

16
src/wish/forms.py Normal file
View File

@ -0,0 +1,16 @@
# coding: utf-8
from django.contrib.auth.models import User
"""
Voir l'explication complète ici:
http://stackoverflow.com/questions/3523745/best-way-to-do-register-a-user-in-django
"""
class UserForm(django.forms.ModelForm):
class Meta:
model = User
class UserFormProfile(django.forms.ModelForm):
class Meta:
model = User

View File

@ -24,7 +24,7 @@ class Wishlist(AbstractModel):
name = models.CharField(max_length=255)
description = models.TextField()
external_id = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
owner = models.ForeignKey(User)
class Wish(AbstractModel):

View File

@ -14,8 +14,13 @@ Class-based views
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))
See http://www.obeythetestinggoat.com/using-the-built-in-views-and-forms-for-new-user-registration-in-django.html
for user registration
"""
from django.conf.urls import url
from django.conf.urls import url, include
from django.views.generic.edit import CreateView
from django.contrib.auth.forms import UserCreationForm
from .views import WishListList, WishListDetail, WishDetail, UpdateWishView
@ -24,4 +29,10 @@ urlpatterns = [
url(r'^list/(?P<pk>\d+)/$', WishListDetail.as_view(), name='wishlist'),
url(r'^wish/(?P<pk>\d+)/$', WishDetail.as_view(), name='wish'),
url(r'^wish/(?P<pk>\d+)/edit$', UpdateWishView.as_view(), name='wish-edit'),
url(r'^register/', CreateView.as_view(
template_name='register.html',
form_class=UserCreationForm,
success_url='/'
)),
url('^accounts/', include('django.contrib.auth.urls'))
]

View File

@ -10,16 +10,19 @@ class WishListList(ListView):
model = Wishlist
template_name = 'wish/list.html'
class WishListDetail(DetailView):
context_object_name = 'wishlist'
model = Wishlist
template_name = 'wish/list_detail.html'
class WishDetail(DetailView):
context_object_name = 'wish'
model = Wish
template_name = 'wish/wish_detail.html'
class UpdateWishView(UpdateView):
model = Wish
fields = ('name', 'description')