minor bugfixes

This commit is contained in:
iou1name 2019-04-13 17:08:32 -04:00
parent 5bba661208
commit 05a618a15f
5 changed files with 45 additions and 10 deletions

View File

@ -90,7 +90,10 @@ def message(socket, data):
m.user = user
m.save()
anonymize = (user.anonymize or quest.anonymize) and user != quest.owner
if user.is_authenticated:
anonymize = (user.anonymize or quest.anonymize) and user != quest.owner
else:
anonymize = True
data = {}
data['message_id'] = m.id
@ -288,16 +291,18 @@ def poll_post(socket, data):
if quest.owner != user:
return # error message?
page_num = data.get('page_num')
try:
page = Page.objects.get(quest=quest, page_num=page_num)
except Page.DoesNotExist:
return
page_num = data.get('page_num')
form = PollForm(data)
if not form.is_valid():
return # error message?
form = form.cleaned_data
multi_choice = form.pop('multi_choice')
allow_writein = form.pop('allow_writein')
p = Post(
quest=quest,
@ -308,8 +313,8 @@ def poll_post(socket, data):
p.save()
pl = Poll(
post=p,
multi_choice=form.pop('multi_choice'),
allow_writein=form.pop('allow_writein'),
multi_choice=multi_choice,
allow_writein=allow_writein,
open=True
)
pl.save()
@ -328,6 +333,7 @@ def poll_post(socket, data):
data['post_text'] = "Poll"
data['date'] = localtime(p.timestamp).strftime('%Y-%m-%d %H:%M')
data['options'] = [(o.id, o.text) for o in options]
data['allow_writein'] = allow_writein
socket.send('new_post', data)
server = User.objects.get(id=settings.SERVER_USER_ID)
@ -577,7 +583,7 @@ def write_in(socket, data):
option_text = option_text.strip()
if not option_text:
return
option_text = "Write in: " + bleach.clean(option_text)
option_text = "Write-in: " + bleach.clean(option_text)
if len(option_text) > 200:
# error message?
return

View File

@ -13,7 +13,7 @@ from django.conf import settings
from channels.layers import get_channel_layer
from asgiref.sync import async_to_sync
IMG_DIR = "/usr/local/www/html/img/"
IMG_DIR = "/var/www/html/img/"
ALLOWED_MIMES = [
"image/jpeg",
"image/png",

View File

@ -0,0 +1,25 @@
# Generated by Django 2.2 on 2019-04-13 00:02
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Confirmation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=32)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

View File

View File

@ -81,6 +81,10 @@ TEMPLATES = [
},
]
SILENCED_SYSTEM_CHECKS = [
'admin.E404',
]
WSGI_APPLICATION = 'titivillus.wsgi.application'
@ -93,8 +97,8 @@ DATABASES = {
'NAME': 'titivillus',
'USER': 'titivillus',
'PASSWORD': titivillus.settings_secret.DB_KEY,
'HOST': '',
'PORT': '',
'HOST': 'localhost',
'PORT': '5432',
}
}
@ -136,7 +140,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/usr/local/www/html/static/'
STATIC_ROOT = '/var/www/html/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
@ -167,7 +171,7 @@ IMG_SVR_URL = "https://img.steelbea.me/"
TAGGIT_CASE_INSENSITIVE = True
# Server user id
SERVER_USER_ID = 3
SERVER_USER_ID = 1
DEFAULT_FROM_EMAIL = "scribe@steelbea.me"
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'