Compare commits
No commits in common. "75f53847236cb74308acbadd7f20e2a1c1a62574" and "672e1fff1dd56e8959532847e383374cd61f803a" have entirely different histories.
75f5384723
...
672e1fff1d
|
@ -5,7 +5,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Quests 'n Shiet</h1>
|
<h1>Quests 'n Shiet</h1>
|
||||||
<form method="get" action="{{ url('quest:index') }}">
|
<form method="get" action="{{ url('search:index') }}">
|
||||||
<input type="text" name="title" placeholder="Search">
|
<input type="text" name="title" placeholder="Search">
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -79,24 +79,21 @@ def message(socket, data):
|
||||||
roll_msg += " = " + str(total)
|
roll_msg += " = " + str(total)
|
||||||
message += '<hr class="msgSrvHr"><b>' + roll_msg + "</b>"
|
message += '<hr class="msgSrvHr"><b>' + roll_msg + "</b>"
|
||||||
|
|
||||||
|
|
||||||
user = socket.scope['user']
|
user = socket.scope['user']
|
||||||
quest = Quest.objects.get(id=socket.quest_id)
|
|
||||||
|
|
||||||
m = Message(
|
m = Message(
|
||||||
quest=quest,
|
quest=Quest.objects.get(id=socket.quest_id),
|
||||||
message=message)
|
message=message)
|
||||||
if user.username:
|
if user.username:
|
||||||
m.user = user
|
m.user = user
|
||||||
m.save()
|
m.save()
|
||||||
|
|
||||||
anonymize = (user.anonymize or quest.anonymize) and user != quest.owner
|
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
data['message_id'] = m.id
|
data['message_id'] = m.id
|
||||||
data['message'] = message
|
data['message'] = message
|
||||||
data['date'] = int(time.time())
|
data['date'] = int(time.time())
|
||||||
data['name'] = user.username
|
data['name'] = user.username
|
||||||
data['anonymize'] = anonymize
|
|
||||||
socket.send('message', data)
|
socket.send('message', data)
|
||||||
|
|
||||||
# append rolls to dicecall
|
# append rolls to dicecall
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<div id="chatPane" style="display:{% if request.session.get("hide_chat") == True %}none{% else %}flex{% endif %};">
|
|
||||||
<h1>Chat</h1>
|
|
||||||
<div id="chatWindow">
|
|
||||||
{% autoescape false %}
|
|
||||||
{% for message in chat_messages %}
|
|
||||||
<div id="msg-{{ message.id }}" class="message">
|
|
||||||
<div class="messageHeader">
|
|
||||||
<span class="messageName">{% if quest.owner.username == message.user.username or not quest.anonymize %}{{ message.user.username or quest.anon_name }}{% else %}{{ quest.anon_name }}{% endif %}</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>
|
|
||||||
<div class="messageContent">{{ message.message }}</div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
{% endfor %}
|
|
||||||
{% endautoescape %}
|
|
||||||
</div>
|
|
||||||
<div id="messageTextDiv"><textarea id="messageTextArea" maxlength="512"></textarea></div>
|
|
||||||
</div>
|
|
||||||
<div id="preview" style="display:none;"></div>
|
|
|
@ -175,5 +175,24 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% include "quest/chat.html" %}
|
<div id="chatPane" style="display:{% if request.session.get("hide_chat") == True %}none{% else %}flex{% endif %};">
|
||||||
|
<h1>Chat</h1>
|
||||||
|
<div id="chatWindow">
|
||||||
|
{% autoescape false %}
|
||||||
|
{% for message in chat_messages %}
|
||||||
|
<div id="msg-{{ message.id }}" class="message">
|
||||||
|
<div class="messageHeader">
|
||||||
|
<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>
|
||||||
|
<div class="messageContent">{{ message.message }}</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endautoescape %}
|
||||||
|
</div>
|
||||||
|
<div id="messageTextDiv"><textarea id="messageTextArea" maxlength="512"></textarea></div>
|
||||||
|
</div>
|
||||||
|
<div id="preview" style="display:none;"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
{% block title %}{{ quest.title }}{% endblock %}
|
{% block title %}{{ quest.title }}{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ static('quest.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ static('quest.css') }}">
|
||||||
|
{% endblock %}
|
||||||
|
{% block header %}
|
||||||
|
{% if request.user == quest.owner %}
|
||||||
|
<span><a href="{{ url('quest:edit_quest', args=[quest_id, page_num]) }}">Edit Quest</a></span>
|
||||||
<script>
|
<script>
|
||||||
const quest_id = {{ quest.id }};
|
const quest_id = {{ quest.id }};
|
||||||
const page_num = '{{ page_num }}';
|
const page_num = '{{ page_num }}';
|
||||||
|
@ -10,11 +14,6 @@
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="{{ static('quest.js') }}"></script>
|
<script type="text/javascript" src="{{ static('quest.js') }}"></script>
|
||||||
<script>window.onload = load;</script>
|
<script>window.onload = load;</script>
|
||||||
<!-- We only want the message event on this page, others will error. Hacky solution, but it will do for now. -->
|
|
||||||
{% endblock %}
|
|
||||||
{% block header %}
|
|
||||||
{% if request.user == quest.owner %}
|
|
||||||
<span><a href="{{ url('quest:edit_quest', args=[quest_id, page_num]) }}">Edit Quest</a></span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span>
|
<span>
|
||||||
<select onChange="window.location.href=this.value">
|
<select onChange="window.location.href=this.value">
|
||||||
|
@ -78,5 +77,24 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% include "quest/chat.html" %}
|
<div id="chatPane" style="display:{% if request.session.get("hide_chat") == True %}none{% else %}flex{% endif %};">
|
||||||
|
<h1>Chat</h1>
|
||||||
|
<div id="chatWindow">
|
||||||
|
{% autoescape false %}
|
||||||
|
{% for message in chat_messages %}
|
||||||
|
<div id="msg-{{ message.id }}" class="message">
|
||||||
|
<div class="messageHeader">
|
||||||
|
<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>
|
||||||
|
<div class="messageContent">{{ message.message }}</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endautoescape %}
|
||||||
|
</div>
|
||||||
|
<div id="messageTextDiv"><textarea id="messageTextArea" maxlength="512"></textarea></div>
|
||||||
|
</div>
|
||||||
|
<div id="preview" style="display:none;"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 2.1.1 on 2018-10-03 16:53
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('quest', '0005_auto_20181003_1217'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='quest',
|
|
||||||
name='anonymize',
|
|
||||||
field=models.BooleanField(default=True),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -19,7 +19,6 @@ class Quest(models.Model):
|
||||||
live = models.BooleanField()
|
live = models.BooleanField()
|
||||||
live_time = models.DateTimeField(blank=True, null=True)
|
live_time = models.DateTimeField(blank=True, null=True)
|
||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
anonymize = models.BooleanField(default=True)
|
|
||||||
|
|
||||||
|
|
||||||
class Message(models.Model):
|
class Message(models.Model):
|
||||||
|
|
|
@ -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 && !data.anonymize) ? data.name : anon_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>';
|
||||||
|
|
|
@ -15,20 +15,22 @@ from user.models import User
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""The quest page index."""
|
"""The quest page index."""
|
||||||
author = request.GET.get('author')
|
if request.GET:
|
||||||
title = request.GET.get('title')
|
author = request.GET.get('author')
|
||||||
tags = request.GET.get('tags')
|
title = request.GET.get('title')
|
||||||
|
tags = request.GET.get('tags')
|
||||||
results = Quest.objects.all()
|
if not any((author, title, tags)):
|
||||||
if author:
|
return
|
||||||
results = results.filter(
|
|
||||||
owner__username__unaccent__icontains=author)
|
|
||||||
if title:
|
|
||||||
results = results.filter(title__unaccent__icontains=title)
|
|
||||||
if tags:
|
|
||||||
results = results.filter(tags__name__in=tags.split())
|
|
||||||
results = results.distinct().order_by('-id')
|
|
||||||
|
|
||||||
|
results = Quest.objects.all()
|
||||||
|
if author:
|
||||||
|
results = results.filter(
|
||||||
|
owner__username__unaccent__icontains=author)
|
||||||
|
if title:
|
||||||
|
results = results.filter(title__unaccent__icontains=title)
|
||||||
|
if tags:
|
||||||
|
results = results.filter(tags__name__in=tags.split())
|
||||||
|
results = results.distinct()
|
||||||
context = locals()
|
context = locals()
|
||||||
return render(request, 'quest/index.html', context)
|
return render(request, 'quest/index.html', context)
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,5 @@ urlpatterns = [
|
||||||
path('login/', include('login.urls')),
|
path('login/', include('login.urls')),
|
||||||
path('logout/', include('logout.urls')),
|
path('logout/', include('logout.urls')),
|
||||||
path('user/', include('user.urls')),
|
path('user/', include('user.urls')),
|
||||||
|
path('search/', include('search.urls')),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 2.1.1 on 2018-10-03 16:51
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('user', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='user',
|
|
||||||
name='anonymize',
|
|
||||||
field=models.BooleanField(default=True, help_text="Let's be honest, your name doesn't add anything to the conversation."),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -40,11 +40,6 @@ class User(AbstractUser):
|
||||||
first_name = None
|
first_name = None
|
||||||
last_name = None
|
last_name = None
|
||||||
email = models.EmailField('email address')
|
email = models.EmailField('email address')
|
||||||
anonymize = models.BooleanField(
|
|
||||||
default=True,
|
|
||||||
help_text="Let's be honest, your name doesn't add anything to " \
|
|
||||||
+ "the conversation."
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_full_name(self):
|
def get_full_name(self):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user