Building a voucher-verify form.
This commit is contained in:
parent
ea9b46961b
commit
9bd85aba7a
@ -7,6 +7,11 @@ from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
||||
from .models import Explorer, Place, PlaceImage, Voucher
|
||||
|
||||
class VoucherVerifyForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Voucher
|
||||
fields = ['code']
|
||||
|
||||
class ExplorerCreationForm(UserCreationForm):
|
||||
class Meta:
|
||||
model = Explorer
|
||||
|
15
lostplaces/lostplaces_app/templates/voucher-verify.html
Normal file
15
lostplaces/lostplaces_app/templates/voucher-verify.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends 'global.html'%}
|
||||
{% load static %}
|
||||
|
||||
# {% block title %}Voucher-Überprüfung{% endblock %}
|
||||
|
||||
{% block maincontent %}
|
||||
|
||||
<h2>Voucher-Überprüfung</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
||||
{% endblock maincontent %}
|
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import (
|
||||
hello_world,
|
||||
VoucherVerify,
|
||||
place_detail_view,
|
||||
place_list_view,
|
||||
SignUpView,
|
||||
@ -11,6 +12,8 @@ from .views import (
|
||||
urlpatterns = [
|
||||
path('hello_world/', hello_world), # You know what this is :P
|
||||
path('signup/', SignUpView.as_view(), name='signup'),
|
||||
path('voucher/<slug:code>/', VoucherVerify.as_view(), name='voucher_verify'),
|
||||
path('voucher/', VoucherVerify.as_view(), name='enter_voucher'),
|
||||
path('place/<int:pk>/', place_detail_view, name='place_detail'),
|
||||
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
||||
path('place/update/<int:pk>/', PlaceUpdateView.as_view(), name='place_edit'),
|
||||
|
@ -5,16 +5,24 @@
|
||||
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic.edit import CreateView
|
||||
from django.views.generic.edit import CreateView, UpdateView
|
||||
from django.views import View
|
||||
from django.http import Http404
|
||||
from django.views.generic.edit import UpdateView
|
||||
|
||||
from .forms import ExplorerCreationForm, PlaceForm, PlaceImageCreateForm
|
||||
from .forms import ExplorerCreationForm, PlaceForm, PlaceImageCreateForm, VoucherVerifyForm
|
||||
from .models import Place, PlaceImage, Voucher
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class VoucherVerify(View):
|
||||
formclass = VoucherVerifyForm
|
||||
voucher_form = VoucherVerifyForm()
|
||||
success_url = reverse_lazy('signin')
|
||||
fields = ['code']
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, 'voucher-verify.html')
|
||||
|
||||
class SignUpView(CreateView):
|
||||
form_class = ExplorerCreationForm
|
||||
success_url = reverse_lazy('login')
|
||||
|
Loading…
Reference in New Issue
Block a user