merged /create_quest into /quest/new
This commit is contained in:
parent
172200eea3
commit
452d6f22be
|
@ -1,3 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
|
@ -1,5 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class CreateQuestConfig(AppConfig):
|
|
||||||
name = 'create_quest'
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Form(s) for the create_quest page.
|
|
||||||
"""
|
|
||||||
from django import forms
|
|
||||||
|
|
||||||
from quest.models import Quest, Post
|
|
||||||
|
|
||||||
class QuestForm(forms.ModelForm):
|
|
||||||
"""
|
|
||||||
The main create_quest form.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Quest
|
|
||||||
fields = ('title',)
|
|
||||||
|
|
||||||
|
|
||||||
class PostForm(forms.ModelForm):
|
|
||||||
"""
|
|
||||||
The form for beginning the first post of the quest.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Post
|
|
||||||
fields = ('post_text',)
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
create_quest app URL configuration.
|
|
||||||
"""
|
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
app_name = 'create_quest'
|
|
||||||
urlpatterns = [
|
|
||||||
path('', views.index, name='index'),
|
|
||||||
]
|
|
|
@ -1,43 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
/create_quest app views.
|
|
||||||
"""
|
|
||||||
from django.contrib import messages
|
|
||||||
from django.shortcuts import redirect, render
|
|
||||||
|
|
||||||
from .forms import QuestForm, PostForm
|
|
||||||
from quest.models import Quest, Post, Page
|
|
||||||
|
|
||||||
def index(request):
|
|
||||||
"""
|
|
||||||
The index page for creating new quests.
|
|
||||||
"""
|
|
||||||
if request.method == 'POST':
|
|
||||||
# TODO: clean the post body
|
|
||||||
quest = Quest(owner=request.user)
|
|
||||||
quest_form = QuestForm(request.POST, instance=quest)
|
|
||||||
post = Post(post_type='text')
|
|
||||||
post_form = PostForm(request.POST, instance=post)
|
|
||||||
if all((quest_form.is_valid(), post_form.is_valid())):
|
|
||||||
quest.save()
|
|
||||||
page0 = Page(
|
|
||||||
quest=quest,
|
|
||||||
page_num=0,
|
|
||||||
title="Homepage"
|
|
||||||
)
|
|
||||||
page0.save()
|
|
||||||
page1 = Page(
|
|
||||||
quest=quest,
|
|
||||||
page_num=1,
|
|
||||||
title="Page 1"
|
|
||||||
)
|
|
||||||
page1.save()
|
|
||||||
post.quest = quest
|
|
||||||
post.page = page1
|
|
||||||
post.save()
|
|
||||||
return redirect('quest:quest', quest_id=quest.id)
|
|
||||||
else:
|
|
||||||
quest_form = QuestForm()
|
|
||||||
post_form = PostForm()
|
|
||||||
context = {'quest_form': quest_form, 'post_form': post_form}
|
|
||||||
return render(request, 'create_quest/index.html', context)
|
|
|
@ -10,7 +10,7 @@
|
||||||
<br>
|
<br>
|
||||||
<a href="./quest/1">Unga Bunga Quest</a><br />
|
<a href="./quest/1">Unga Bunga Quest</a><br />
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<a href="{{ url('create_quest:index') }}">Create New Quest</a><br />
|
<a href="{{ url('quest:new_quest') }}">Create New Quest</a><br />
|
||||||
<a href="{{ url('logout:index') }}">Logout</a><br />
|
<a href="{{ url('logout:index') }}">Logout</a><br />
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ url('signup:index') }}">Sign up</a><br />
|
<a href="{{ url('signup:index') }}">Sign up</a><br />
|
||||||
|
|
|
@ -4,6 +4,8 @@ Form(s) for the quest page.
|
||||||
"""
|
"""
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
|
from .models import Quest, Post
|
||||||
|
|
||||||
class DiceCallForm(forms.Form):
|
class DiceCallForm(forms.Form):
|
||||||
"""
|
"""
|
||||||
The form for the QM making dice calls.
|
The form for the QM making dice calls.
|
||||||
|
@ -46,3 +48,21 @@ class EditQuestForm(forms.Form):
|
||||||
live_date = forms.DateField(required=False)
|
live_date = forms.DateField(required=False)
|
||||||
live_time = forms.TimeField(required=False)
|
live_time = forms.TimeField(required=False)
|
||||||
timezone = forms.IntegerField()
|
timezone = forms.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class QuestForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
The main create_quest form.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Quest
|
||||||
|
fields = ('title',)
|
||||||
|
|
||||||
|
|
||||||
|
class PostForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
The form for beginning the first post of the quest.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Post
|
||||||
|
fields = ('post_text',)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% block title %}Start a new quest{% endblock %}
|
{% block title %}Start a new quest{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>New Quest</h1>
|
<h1>New Quest</h1>
|
||||||
<form method="post" action="{{ url('create_quest:index') }}">
|
<form method="post" action="{{ url('quest:new_quest') }}">
|
||||||
{{ csrf_input }}
|
{{ csrf_input }}
|
||||||
{#
|
{#
|
||||||
<input type="text" placeholder="Quest Title" name="quest_title" maxlength="300" required/><br/>
|
<input type="text" placeholder="Quest Title" name="quest_title" maxlength="300" required/><br/>
|
|
@ -13,4 +13,5 @@ urlpatterns = [
|
||||||
path('<int:quest_id>/<page_num>/edit_quest', views.edit_quest, name='edit_quest'),
|
path('<int:quest_id>/<page_num>/edit_quest', views.edit_quest, name='edit_quest'),
|
||||||
path('<int:quest_id>', views.quest, name='quest'),
|
path('<int:quest_id>', views.quest, name='quest'),
|
||||||
path('<int:quest_id>/<page_num>', views.quest, name='quest'),
|
path('<int:quest_id>/<page_num>', views.quest, name='quest'),
|
||||||
|
path('new', views.new_quest, name='new_quest'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,8 +8,8 @@ from django.contrib import messages
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
|
|
||||||
from .models import Quest, DiceRoll, PollOption, PollVote, Page
|
from .models import Quest, DiceRoll, PollOption, PollVote, Page, Post
|
||||||
from .forms import EditQuestForm
|
from .forms import EditQuestForm, QuestForm, PostForm
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""
|
"""
|
||||||
|
@ -81,3 +81,41 @@ def edit_quest(request, quest_id, page_num=1):
|
||||||
pass
|
pass
|
||||||
context = locals()
|
context = locals()
|
||||||
return render(request, 'quest/edit_quest.html', context)
|
return render(request, 'quest/edit_quest.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
def new_quest(request):
|
||||||
|
"""
|
||||||
|
The page for creating new quests.
|
||||||
|
"""
|
||||||
|
if request.method == 'POST':
|
||||||
|
# TODO: clean the post body
|
||||||
|
quest = Quest(owner=request.user)
|
||||||
|
quest_form = QuestForm(request.POST, instance=quest)
|
||||||
|
post = Post(post_type='text')
|
||||||
|
post_form = PostForm(request.POST, instance=post)
|
||||||
|
if all((quest_form.is_valid(), post_form.is_valid())):
|
||||||
|
quest.live = False
|
||||||
|
quest.save()
|
||||||
|
page0 = Page(
|
||||||
|
quest=quest,
|
||||||
|
page_num=0,
|
||||||
|
title="Homepage",
|
||||||
|
appendix=False,
|
||||||
|
)
|
||||||
|
page0.save()
|
||||||
|
page1 = Page(
|
||||||
|
quest=quest,
|
||||||
|
page_num=1,
|
||||||
|
title="Page 1",
|
||||||
|
appendix=False,
|
||||||
|
)
|
||||||
|
page1.save()
|
||||||
|
post.quest = quest
|
||||||
|
post.page = page1
|
||||||
|
post.save()
|
||||||
|
return redirect('quest:quest', quest_id=quest.id)
|
||||||
|
else:
|
||||||
|
quest_form = QuestForm()
|
||||||
|
post_form = PostForm()
|
||||||
|
context = {'quest_form': quest_form, 'post_form': post_form}
|
||||||
|
return render(request, 'quest/new_quest.html', context)
|
||||||
|
|
|
@ -36,7 +36,6 @@ INSTALLED_APPS = [
|
||||||
'taggit',
|
'taggit',
|
||||||
'user.apps.UserConfig',
|
'user.apps.UserConfig',
|
||||||
'homepage.apps.HomepageConfig',
|
'homepage.apps.HomepageConfig',
|
||||||
'create_quest.apps.CreateQuestConfig',
|
|
||||||
'quest.apps.QuestConfig',
|
'quest.apps.QuestConfig',
|
||||||
'login.apps.LoginConfig',
|
'login.apps.LoginConfig',
|
||||||
'signup.apps.SignupConfig',
|
'signup.apps.SignupConfig',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user