made quest title, description and banner image editable to the qm

This commit is contained in:
iou1name 2018-10-11 10:19:46 -04:00
parent f2f6095080
commit af482c7449
3 changed files with 18 additions and 2 deletions

View File

@ -43,11 +43,14 @@ class EditQuestForm(forms.Form):
""" """
Form for the /edit_quest page. Form for the /edit_quest page.
""" """
quest_title = forms.CharField(max_length=100)
anon_name = forms.CharField(max_length=20) anon_name = forms.CharField(max_length=20)
live = forms.BooleanField(required=False) live = forms.BooleanField(required=False)
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()
description = forms.CharField(max_length=256, required=False)
banner_url = forms.URLField(required=False)
class QuestForm(forms.ModelForm): class QuestForm(forms.ModelForm):

View File

@ -29,8 +29,16 @@
</tr> </tr>
<tr> <tr>
<td>Live time:</td> <td>Live time:</td>
<td><input type="date" name="live_date" id="live_date" value="{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%Y-%m-%d') }}{% endif %}"></td> <td><input type="date" name="live_date" id="live_date" value="{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%Y-%m-%d') }}{% endif %}">
<td><input type="time" name="live_time" id="live_time" step="60" value="{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%H:%M:%S') }}{% endif %}"></td> <input type="time" name="live_time" id="live_time" step="60" value="{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%H:%M:%S') }}{% endif %}"></td>
</tr>
<tr>
<td>Description:</td>
<td><textarea name="description">{{ quest.description }}</textarea></td>
</tr>
<tr>
<td>Banner Image URL:</td>
<td><input type="text" name="banner_url" maxlength="200" value="{% if quest.banner_url %}{{ quest.banner_url }}{% endif %}"></td>
</tr> </tr>
</table> </table>
<input type="hidden" name="timezone" id="timezone"> <input type="hidden" name="timezone" id="timezone">

View File

@ -90,8 +90,13 @@ def edit_quest(request, quest_id, page_num='0'):
if request.method == 'POST': if request.method == 'POST':
form = EditQuestForm(request.POST) form = EditQuestForm(request.POST)
if form.is_valid(): if form.is_valid():
quest.title = form.cleaned_data['quest_title']
quest.anon_name = form.cleaned_data['anon_name'] quest.anon_name = form.cleaned_data['anon_name']
quest.live = form.cleaned_data['live'] quest.live = form.cleaned_data['live']
quest.description = form.cleaned_data['description']
quest.banner_url = download_img(form.cleaned_data['banner_url'])
if not quest.banner_url.startswith('http'):
quest.banner_url = None
live_date = form.cleaned_data['live_date'] live_date = form.cleaned_data['live_date']
live_time = form.cleaned_data['live_time'] live_time = form.cleaned_data['live_time']