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: if not value:
continue continue
self.fields[key] = forms.CharField(max_length=200) 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>
<tr> <tr>
<td>Anonymous Name:</td> <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>
<tr> <tr>
<td>Live:</td> <td>Live:</td>

View File

@ -9,6 +9,7 @@
const quest_id = {{ quest.id }}; const quest_id = {{ quest.id }};
const page_num = {{ page_num }}; const page_num = {{ page_num }};
const SCRIPT_NAME = '{{ request.META["SCRIPT_NAME"] }}'; const SCRIPT_NAME = '{{ request.META["SCRIPT_NAME"] }}';
const anon_name = '{{ quest.anon_name }}';
</script> </script>
<script type="text/javascript" src="{{ static('quest.js') }}"></script> <script type="text/javascript" src="{{ static('quest.js') }}"></script>
{% if request.user == quest.owner %} {% if request.user == quest.owner %}
@ -148,7 +149,7 @@
{% for message in messages %} {% for message in messages %}
<div id="msg-{{ message.id }}" class="message"> <div id="msg-{{ message.id }}" class="message">
<div class="messageHeader"> <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="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> <span class="messageID">No.<a href="javascript:quote('{{ message.id }}')">{{ message.id }}</a></span>
</div> </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( owner = models.ForeignKey(
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")
class Message(models.Model): class Message(models.Model):

View File

@ -50,7 +50,7 @@ function load() {
/* Websocket receive */ /* Websocket receive */
socket.events['message'] = function(data) { socket.events['message'] = function(data) {
let msg_str = '<div id="message-' + data.message_id + '" class="message">'; 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="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 += '<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>'; 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 django.http import HttpResponse
from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
from .forms import EditQuest
def index(request): def index(request):
""" """
@ -38,7 +39,13 @@ def edit_quest(request, quest_id, page_num=1):
if quest.owner != request.user: if quest.owner != request.user:
return redirect('quest:quest', quest_id=quest_id, page_num=page_num) return redirect('quest:quest', quest_id=quest_id, page_num=page_num)
if request.method == 'POST': 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: else:
pass pass
context = locals() context = locals()

3
todo
View File

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