added banner images
This commit is contained in:
parent
3db28b38a6
commit
f2f6095080
|
@ -56,7 +56,7 @@ class QuestForm(forms.ModelForm):
|
|||
"""
|
||||
class Meta:
|
||||
model = Quest
|
||||
fields = ('title', 'description', 'tags')
|
||||
fields = ('title', 'description', 'tags', 'banner_url')
|
||||
|
||||
|
||||
class PostForm(forms.ModelForm):
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<form method="post" action="{{ url('quest:new_quest') }}">
|
||||
{{ csrf_input }}
|
||||
<input type="text" placeholder="Quest Title" name="title" maxlength="100" required><br>
|
||||
<input type="text" placeholder="Banner URL" name="banner_url" maxlength="200" required><br>
|
||||
<textarea name="description" maxlength="256"></textarea><br>
|
||||
<input type="text" placeholder="Tags" name="tags" id=><br>
|
||||
<input type="submit" name="submit" value="Submit">
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
{% endblock %}
|
||||
{% block content %}
|
||||
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};">
|
||||
<center><h1>{{ quest.title }}</h1></center>
|
||||
<h1 id="questTitle">{{ quest.title }}</h1>
|
||||
{% if quest.banner_url %}<img id="banner" src="{{ quest.banner_url }}">{% endif %}
|
||||
<div id="questPosts">
|
||||
{% for post in posts %}
|
||||
{% if post.post_type == "text" %}
|
||||
|
|
|
@ -54,7 +54,9 @@
|
|||
{% endblock %}
|
||||
{% block content %}
|
||||
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};">
|
||||
<center><h1>{{ quest.title }}</h1></center>
|
||||
<h1 id="questTitle">{{ quest.title }}</h1>
|
||||
{% if quest.banner_url %}<img id="banner" src="{{ quest.banner_url }}">{% endif %}
|
||||
{% if quest.description %}<div id="description">{{ quest.description }}</div>{% endif %}
|
||||
<div id="tags">
|
||||
Tags: {% for tag in quest.tags.names() %}<a href="{{ url('quest:index') + '?tags=' + tag }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</div>
|
||||
|
|
18
quest/migrations/0010_quest_banner_url.py
Normal file
18
quest/migrations/0010_quest_banner_url.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.1.1 on 2018-10-11 12:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('quest', '0009_quest_latest_post_date'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='quest',
|
||||
name='banner_url',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
]
|
|
@ -22,6 +22,7 @@ class Quest(models.Model):
|
|||
anonymize = models.BooleanField(default=True)
|
||||
description = models.CharField(max_length=256, blank=True, null=True)
|
||||
latest_post_date = models.DateTimeField(null=True, blank=True)
|
||||
banner_url = models.URLField(null=True, blank=True)
|
||||
|
||||
def update_post_date(self):
|
||||
try:
|
||||
|
|
|
@ -26,6 +26,10 @@ h3 {
|
|||
width: 70%;
|
||||
}
|
||||
|
||||
#questTitle {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#tags {
|
||||
padding-bottom: 0.25em;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.conf import settings
|
|||
from .models import Quest, DiceRoll, PollOption, PollVote, Page, Post
|
||||
from .forms import EditQuestForm, QuestForm, PostForm
|
||||
from user.models import User
|
||||
from .tools import send_to_websocket
|
||||
from .tools import download_img, send_to_websocket
|
||||
|
||||
def index(request):
|
||||
"""The quest page index."""
|
||||
|
@ -135,6 +135,9 @@ def new_quest(request):
|
|||
if quest_form.is_valid():
|
||||
quest = quest_form.save(commit=False)
|
||||
quest.owner = request.user
|
||||
quest.banner_url = download_img(quest.banner_url)
|
||||
if not quest.banner_url.startswith('http'):
|
||||
quest.banner_url = None
|
||||
quest.save()
|
||||
quest_form.save_m2m()
|
||||
print(quest.tags.names())
|
||||
|
|
Loading…
Reference in New Issue
Block a user