added banner images

This commit is contained in:
iou1name 2018-10-11 09:10:55 -04:00
parent 3db28b38a6
commit f2f6095080
9 changed files with 36 additions and 5 deletions

View File

@ -56,7 +56,7 @@ class QuestForm(forms.ModelForm):
""" """
class Meta: class Meta:
model = Quest model = Quest
fields = ('title', 'description', 'tags') fields = ('title', 'description', 'tags', 'banner_url')
class PostForm(forms.ModelForm): class PostForm(forms.ModelForm):

View File

@ -5,6 +5,7 @@
<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="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> <textarea name="description" maxlength="256"></textarea><br>
<input type="text" placeholder="Tags" name="tags" id=><br> <input type="text" placeholder="Tags" name="tags" id=><br>
<input type="submit" name="submit" value="Submit"> <input type="submit" name="submit" value="Submit">

View File

@ -47,7 +47,8 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};"> <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"> <div id="questPosts">
{% for post in posts %} {% for post in posts %}
{% if post.post_type == "text" %} {% if post.post_type == "text" %}

View File

@ -54,7 +54,9 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};"> <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"> <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 %} Tags: {% for tag in quest.tags.names() %}<a href="{{ url('quest:index') + '?tags=' + tag }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
</div> </div>

View 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),
),
]

View File

@ -22,6 +22,7 @@ class Quest(models.Model):
anonymize = models.BooleanField(default=True) anonymize = models.BooleanField(default=True)
description = models.CharField(max_length=256, blank=True, null=True) description = models.CharField(max_length=256, blank=True, null=True)
latest_post_date = models.DateTimeField(null=True, blank=True) latest_post_date = models.DateTimeField(null=True, blank=True)
banner_url = models.URLField(null=True, blank=True)
def update_post_date(self): def update_post_date(self):
try: try:

View File

@ -26,6 +26,10 @@ h3 {
width: 70%; width: 70%;
} }
#questTitle {
text-align: center;
}
#tags { #tags {
padding-bottom: 0.25em; padding-bottom: 0.25em;
} }

View File

@ -14,7 +14,7 @@ from django.conf import settings
from .models import Quest, DiceRoll, PollOption, PollVote, Page, Post from .models import Quest, DiceRoll, PollOption, PollVote, Page, Post
from .forms import EditQuestForm, QuestForm, PostForm from .forms import EditQuestForm, QuestForm, PostForm
from user.models import User from user.models import User
from .tools import send_to_websocket from .tools import download_img, send_to_websocket
def index(request): def index(request):
"""The quest page index.""" """The quest page index."""
@ -135,6 +135,9 @@ def new_quest(request):
if quest_form.is_valid(): if quest_form.is_valid():
quest = quest_form.save(commit=False) quest = quest_form.save(commit=False)
quest.owner = request.user 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.save()
quest_form.save_m2m() quest_form.save_m2m()
print(quest.tags.names()) print(quest.tags.names())

3
todo
View File

@ -1,12 +1,13 @@
New Features: New Features:
Notifications Notifications
Banner images
Front page to show new quests Front page to show new quests
Webm posting Webm posting
(you) counter (you) counter
Account managament Account managament
Display profile link in header bar Display profile link in header bar
Quote backlinks Quote backlinks
Email
RSS
Improvements: Improvements:
More options for text posts (lists and so on) More options for text posts (lists and so on)