anonymous names are editable
This commit is contained in:
parent
df1bd15e49
commit
1fbc398a9a
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
18
quest/migrations/0003_quest_anon_name.py
Normal file
18
quest/migrations/0003_quest_anon_name.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -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>';
|
||||
|
|
|
@ -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
3
todo
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user