revamped new_quest page, added description field
This commit is contained in:
parent
75f5384723
commit
e7d73023eb
|
@ -56,7 +56,7 @@ class QuestForm(forms.ModelForm):
|
||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Quest
|
model = Quest
|
||||||
fields = ('title',)
|
fields = ('title', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class PostForm(forms.ModelForm):
|
class PostForm(forms.ModelForm):
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{% for quest in results %}
|
{% for quest in results %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title"><a href="{{ url('quest:quest', args=[quest.id, '0']) }}">{{ quest.title }}</a></td>
|
<td class="title"><a href="{{ url('quest:quest', args=[quest.id, '0']) }}">{{ quest.title }}</a></td>
|
||||||
<td class="summary"></td>
|
<td class="summary">{{ quest.description or "" }}</td>
|
||||||
<td class="author"><a href="{{ url('user:profile', args=[quest.owner.id]) }}">{{ quest.owner.username }}</a></td>
|
<td class="author"><a href="{{ url('user:profile', args=[quest.owner.id]) }}">{{ quest.owner.username }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
<h1>New Quest</h1>
|
<h1>New Quest</h1>
|
||||||
<form method="post" action="{{ url('quest:new_quest') }}">
|
<form method="post" action="{{ url('quest:new_quest') }}">
|
||||||
{{ csrf_input }}
|
{{ csrf_input }}
|
||||||
{#
|
<input type="text" placeholder="Quest Title" name="title" maxlength="100" required><br>
|
||||||
<input type="text" placeholder="Quest Title" name="quest_title" maxlength="300" required/><br/>
|
<textarea name="description" maxlength="256"></textarea><br>
|
||||||
<textarea id="create_textarea" name="quest_body"></textarea>
|
<input type="text" placeholder="Tags" name="tags" id=><br>
|
||||||
#}
|
<input type="submit" name="submit" value="Submit">
|
||||||
{{ quest_form.as_p() }}
|
|
||||||
{{ post_form.as_p() }}
|
|
||||||
<input type="submit" name="submit" value="Submit"/>
|
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
18
quest/migrations/0007_quest_description.py
Normal file
18
quest/migrations/0007_quest_description.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.1.1 on 2018-10-05 11:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('quest', '0006_quest_anonymize'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='quest',
|
||||||
|
name='description',
|
||||||
|
field=models.CharField(blank=True, max_length=256, null=True),
|
||||||
|
),
|
||||||
|
]
|
18
quest/migrations/0008_auto_20181005_0825.py
Normal file
18
quest/migrations/0008_auto_20181005_0825.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.1.1 on 2018-10-05 12:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('quest', '0007_quest_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='quest',
|
||||||
|
name='live',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
|
@ -16,10 +16,11 @@ class Quest(models.Model):
|
||||||
settings.AUTH_USER_MODEL,
|
settings.AUTH_USER_MODEL,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
anon_name = models.CharField(max_length=20, default="Anonymous")
|
anon_name = models.CharField(max_length=20, default="Anonymous")
|
||||||
live = models.BooleanField()
|
live = models.BooleanField(default=False)
|
||||||
live_time = models.DateTimeField(blank=True, null=True)
|
live_time = models.DateTimeField(blank=True, null=True)
|
||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
anonymize = models.BooleanField(default=True)
|
anonymize = models.BooleanField(default=True)
|
||||||
|
description = models.CharField(max_length=256, blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
class Message(models.Model):
|
class Message(models.Model):
|
||||||
|
|
|
@ -106,35 +106,24 @@ def new_quest(request):
|
||||||
return redirect('login:index')
|
return redirect('login:index')
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
# TODO: clean the post body
|
# TODO: clean the post body
|
||||||
quest = Quest(owner=request.user)
|
quest_form = QuestForm(request.POST)
|
||||||
quest_form = QuestForm(request.POST, instance=quest)
|
if quest_form.is_valid():
|
||||||
post = Post(post_type='text')
|
quest = quest_form.save(commit=False)
|
||||||
post_form = PostForm(request.POST, instance=post)
|
quest.owner = request.user
|
||||||
if all((quest_form.is_valid(), post_form.is_valid())):
|
|
||||||
quest.live = False
|
|
||||||
quest.save()
|
quest.save()
|
||||||
page0 = Page(
|
quest_form.save_m2m()
|
||||||
|
print(quest.tags.names())
|
||||||
|
page = Page(
|
||||||
quest=quest,
|
quest=quest,
|
||||||
page_num=0,
|
page_num=0,
|
||||||
title="Homepage",
|
title="Homepage",
|
||||||
appendix=False,
|
appendix=False,
|
||||||
)
|
)
|
||||||
page0.save()
|
page.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)
|
return redirect('quest:quest', quest_id=quest.id)
|
||||||
else:
|
else:
|
||||||
quest_form = QuestForm()
|
quest_form = QuestForm()
|
||||||
post_form = PostForm()
|
context = locals()
|
||||||
context = {'quest_form': quest_form, 'post_form': post_form}
|
|
||||||
return render(request, 'quest/new_quest.html', context)
|
return render(request, 'quest/new_quest.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user