edit_quest page added

This commit is contained in:
iou1name 2018-09-05 12:48:24 -04:00
parent eaef094444
commit ab5061c2fa
5 changed files with 51 additions and 5 deletions

View File

@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block title %}Edit {{ quest.title }}{% endblock %}
{% block content %}
<center><h1>{{ quest.title }}</h1></center>
<form method="post" action="{{ url('quest:edit_quest', args=[quest_id]) }}">
{{ csrf_input }}
<table>
<tr>
<td>Quest Title:</td>
<td><input type="text" name="quest_title" value="{{ quest.title }}"></td>
</tr>
<tr>
<td>Visible:</td>
<td><input type="checkbox" name="visible" value="on"></td>
</tr>
<tr>
<td>Anonymous Name:</td>
<td><input type="text" name="anon_name" value="Anonymous"></td>
</tr>
<tr>
<td>Live:</td>
<td><input type="checkbox" name="live" value="off"></td>
</tr>
<tr>
<td>Live In:</td>
<td>Placeholder</td>
</tr>
</table>
<input type="submit">
</form>
{% endblock %}

View File

@ -15,7 +15,7 @@
{% endblock %}
{% block header %}
{% if request.user == quest.owner %}
<li><a href="{# url('edit_quest:index', quest_id=quest_id) #}">Edit Quest</a></li>
<li><a href="{{ url('quest:edit_quest', args=[quest_id]) }}">Edit Quest</a></li>
{% endif %}
<li>
<select onChange="window.location.href=this.value">

View File

@ -11,4 +11,6 @@ urlpatterns = [
path('', views.index, name='index'),
path('<int:quest_id>', views.quest, name='quest'),
path('<int:quest_id>/<int:page_num>', views.quest, name='quest'),
path('<int:quest_id>/edit_quest', views.edit_quest, name='edit_quest'),
path('<int:quest_id>/<int:page_num>/edit_quest', views.edit_quest, name='edit_quest'),
]

View File

@ -2,7 +2,7 @@
"""
Quest and quest accessory views.
"""
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
@ -11,7 +11,6 @@ def index(request):
"""
/quest page index. Possibly not needed.
"""
#return render(request, "Hello, world. You're at the quest index.", {})
return HttpResponse("Hello, world. You're at the quest index.")
@ -29,3 +28,18 @@ def quest(request, quest_id, page_num=1):
ip_address = request.META['REMOTE_ADDR']
context = locals()
return render(request, 'quest/quest.html', context)
def edit_quest(request, quest_id, page_num=1):
"""
Edit quest page. Only available to the QM.
"""
quest = Quest.objects.get(id=quest_id)
if quest.owner != request.user:
return redirect('quest:quest', quest_id=quest_id, page_num=page_num)
if request.method == 'POST':
pass
else:
pass
context = locals()
return render(request, 'quest/edit_quest.html', context)

3
todo
View File

@ -31,6 +31,5 @@ Adjust quote preview postioning
Port from old code:
Edit post
Edit quest
Pages
Images
User page