anonymous names are editable

This commit is contained in:
iou1name 2018-09-21 14:18:54 -04:00
parent df1bd15e49
commit 1fbc398a9a
8 changed files with 37 additions and 7 deletions

View File

@ -36,3 +36,9 @@ class PollForm(forms.Form):
if not value:
continue
self.fields[key] = forms.CharField(max_length=200)
class EditQuest(forms.Form):
"""
Form for the /edit_quest page.
"""
anon_name = forms.CharField(max_length=20)

View File

@ -15,7 +15,7 @@
</tr>
<tr>
<td>Anonymous Name:</td>
<td><input type="text" name="anon_name" value="Anonymous"></td>
<td><input type="text" name="anon_name" value="{{ quest.anon_name }}"></td>
</tr>
<tr>
<td>Live:</td>

View File

@ -9,6 +9,7 @@
const quest_id = {{ quest.id }};
const page_num = {{ page_num }};
const SCRIPT_NAME = '{{ request.META["SCRIPT_NAME"] }}';
const anon_name = '{{ quest.anon_name }}';
</script>
<script type="text/javascript" src="{{ static('quest.js') }}"></script>
{% if request.user == quest.owner %}
@ -148,7 +149,7 @@
{% for message in messages %}
<div id="msg-{{ message.id }}" class="message">
<div class="messageHeader">
<span class="messageName">{{ message.user.username or 'Anonymous' }}</span>
<span class="messageName">{{ message.user.username or quest.anon_name }}</span>
<span class="messageDate">{{ localtime(message.timestamp).strftime('%Y-%m-%d %H:%M:%S') }}</span>
<span class="messageID">No.<a href="javascript:quote('{{ message.id }}')">{{ message.id }}</a></span>
</div>

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.1 on 2018-09-21 16:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('quest', '0002_auto_20180905_1344'),
]
operations = [
migrations.AddField(
model_name='quest',
name='anon_name',
field=models.CharField(default='Anonymous', max_length=20),
),
]

View File

@ -14,6 +14,7 @@ class Quest(models.Model):
owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
anon_name = models.CharField(max_length=20, default="Anonymous")
class Message(models.Model):

View File

@ -50,7 +50,7 @@ function load() {
/* Websocket receive */
socket.events['message'] = function(data) {
let msg_str = '<div id="message-' + data.message_id + '" class="message">';
msg_str = '<div class="messageHeader"><span class="messageName">' + data.name + '</span> ';
msg_str = '<div class="messageHeader"><span class="messageName">' + ((data.name) ? data.name : anon_name) + '</span> ';
msg_str += '<span class="messageDate">' + strftime(data.date) + '</span> ';
msg_str += '<span class="messageID">No.<a href="javascript:quote(' + data.message_id + ')">' + data.message_id + '</a></span></div>';
msg_str += '<div class="messageContent">' + data.message + '</div></div><hr>';

View File

@ -6,6 +6,7 @@ from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
from .forms import EditQuest
def index(request):
"""
@ -38,7 +39,13 @@ def edit_quest(request, quest_id, page_num=1):
if quest.owner != request.user:
return redirect('quest:quest', quest_id=quest_id, page_num=page_num)
if request.method == 'POST':
pass
form = EditQuest(request.POST)
if form.is_valid():
quest.anon_name = form.cleaned_data['anon_name']
quest.save()
return redirect('quest:quest',quest_id=quest.id, page_num=page_num)
else:
messages.error(request, "Error")
else:
pass
context = locals()

3
todo
View File

@ -2,18 +2,15 @@ New Features:
Pages/appendixes
Live indicator/countdown
Notifications
Anonymous names
Banner images
Search page
Front page to show new quests
Webm posting
(you) counter
Enable namefagging
Account managament/logout
Display profile link in header bar
Tagging system
Quote backlinks
Make chat hideable
Improvements:
More options for text posts (lists and so on)