Removed need for 'Server' user
This commit is contained in:
parent
48c307778e
commit
c99a6ba24e
|
@ -24,8 +24,8 @@ titivillus=# \q
|
|||
1. Get on the floor
|
||||
2. Walk the dinosaur
|
||||
3. Set `STATIC_ROOT` under `settings.py` appropriately
|
||||
4. Run `python manage.py collectstatic`
|
||||
5. Create \[super\]user named `Server` and set id in settings.py
|
||||
4. Run `python manage.py collectstatic --link`
|
||||
5. Run `python manage.py makemigrations` and `python manage.py migrate`
|
||||
|
||||
## Usage
|
||||
`gunicorn -b localhost:5100 -e SCRIPT_NAME=/titivillus titivillus.wsgi`
|
||||
|
|
|
@ -191,10 +191,9 @@ def text_post(socket, data):
|
|||
data['post_id'] = p.id
|
||||
socket.send('new_post', data)
|
||||
|
||||
server = User.objects.get(id=settings.SERVER_USER_ID)
|
||||
m = Message(
|
||||
quest=quest,
|
||||
user=server,
|
||||
server=True,
|
||||
message=f"{quest.owner.username} made a new post!",
|
||||
)
|
||||
m.save()
|
||||
|
@ -202,7 +201,7 @@ def text_post(socket, data):
|
|||
data['message_id'] = m.id
|
||||
data['message'] = m.message
|
||||
data['date'] = int(time.time())
|
||||
data['name'] = server.username
|
||||
data['name'] = 'Server'
|
||||
data['anonymize'] = False
|
||||
socket.send('message', data)
|
||||
|
||||
|
@ -273,10 +272,9 @@ def dice_post(socket, data):
|
|||
data['date'] = localtime(p.timestamp).strftime('%Y-%m-%d %H:%M')
|
||||
socket.send('new_post', data)
|
||||
|
||||
server = User.objects.get(id=settings.SERVER_USER_ID)
|
||||
m = Message(
|
||||
quest=quest,
|
||||
user=server,
|
||||
server=True,
|
||||
message=f"{quest.owner.username} made a new dice call!",
|
||||
)
|
||||
m.save()
|
||||
|
@ -284,7 +282,7 @@ def dice_post(socket, data):
|
|||
data['message_id'] = m.id
|
||||
data['message'] = m.message
|
||||
data['date'] = int(time.time())
|
||||
data['name'] = server.username
|
||||
data['name'] = 'Server'
|
||||
data['anonymize'] = False
|
||||
socket.send('message', data)
|
||||
|
||||
|
@ -343,10 +341,9 @@ def poll_post(socket, data):
|
|||
data['allow_writein'] = allow_writein
|
||||
socket.send('new_post', data)
|
||||
|
||||
server = User.objects.get(id=settings.SERVER_USER_ID)
|
||||
m = Message(
|
||||
quest=quest,
|
||||
user=server,
|
||||
server=True,
|
||||
message=f"{quest.owner.username} made a new poll!",
|
||||
)
|
||||
m.save()
|
||||
|
@ -354,7 +351,7 @@ def poll_post(socket, data):
|
|||
data['message_id'] = m.id
|
||||
data['message'] = m.message
|
||||
data['date'] = int(time.time())
|
||||
data['name'] = server.username
|
||||
data['name'] = 'Server'
|
||||
data['anonymize'] = False
|
||||
socket.send('message', data)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{% for message in chat_messages %}
|
||||
<div id="msg-{{ message.id }}" class="message">
|
||||
<div class="messageHeader">
|
||||
<span class="messageName">{% if quest.owner == message.user or message.user.id == server_user_id or not quest.anonymize %}{{ message.user.username or quest.anon_name }}{% else %}{{ quest.anon_name }}{% endif %}</span>
|
||||
<span class="messageName">{% if message.server %}Server{% else %}{% if quest.owner == message.user or message.user.id == server_user_id or not quest.anonymize %}{{ message.user.username or quest.anon_name }}{% else %}{{ quest.anon_name }}{% endif %}{% 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>
|
||||
|
|
18
quest/migrations/0011_message_server.py
Normal file
18
quest/migrations/0011_message_server.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2 on 2019-04-15 14:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('quest', '0010_quest_banner_url'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='message',
|
||||
name='server',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
|
@ -43,6 +43,7 @@ class Message(models.Model):
|
|||
on_delete=models.CASCADE,
|
||||
blank=True,
|
||||
null=True)
|
||||
server = models.BooleanField(default=False)
|
||||
timestamp = models.DateTimeField(auto_now=True)
|
||||
message = models.TextField(max_length=512)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user