diff --git a/README.md b/README.md index e4a47fd..ab542f9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ By popular demand, I'm building a better anonkun. It doesn't do much right now t Python 3.6+ PostgreSQL 10.4+ Redis 4.0.10+ -Python packages: `django psycopg2 channels channels_redis jinja2 argon2-cffi` +Python packages: `django psycopg2 channels channels_redis jinja2 argon2-cffi bleach` ## Install ``` diff --git a/create_quest/views.py b/create_quest/views.py index 96ae897..2881cf9 100644 --- a/create_quest/views.py +++ b/create_quest/views.py @@ -13,6 +13,7 @@ def index(request): The index page for creating new quests. """ if request.method == 'POST': + # TODO: clean the post body quest = Quest(owner=request.user) quest_form = QuestForm(request.POST, instance=quest) post = Post(post_type='text', page_num=1) diff --git a/quest/migrations/0001_initial.py b/quest/migrations/0001_initial.py index 5ea3c9d..a047359 100644 --- a/quest/migrations/0001_initial.py +++ b/quest/migrations/0001_initial.py @@ -1,6 +1,6 @@ -# Generated by Django 2.1 on 2018-08-12 20:09 +# Generated by Django 2.1.1 on 2018-09-05 17:44 -from django.conf import settings +import django.core.validators from django.db import migrations, models import django.db.models.deletion @@ -10,10 +10,17 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ + migrations.CreateModel( + name='Message', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('timestamp', models.DateTimeField(auto_now=True)), + ('message', models.TextField(max_length=512)), + ], + ), migrations.CreateModel( name='PageTitle', fields=[ @@ -22,6 +29,20 @@ class Migration(migrations.Migration): ('title', models.CharField(max_length=200)), ], ), + migrations.CreateModel( + name='PollOption', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=200)), + ], + ), + migrations.CreateModel( + name='PollVote', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('ip_address', models.GenericIPAddressField()), + ], + ), migrations.CreateModel( name='Post', fields=[ @@ -36,19 +57,36 @@ class Migration(migrations.Migration): name='Quest', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('quest_name', models.CharField(max_length=200)), - ('open_post_id', models.IntegerField(null=True)), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('title', models.CharField(max_length=200)), ], ), - migrations.AddField( - model_name='post', - name='quest', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest'), + migrations.CreateModel( + name='DiceCall', + fields=[ + ('post', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Post')), + ('dice_roll', models.CharField(max_length=9)), + ('strict', models.BooleanField()), + ('dice_challenge', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(999), django.core.validators.MinValueValidator(1)])), + ('rolls_taken', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(99), django.core.validators.MinValueValidator(1)])), + ('open', models.BooleanField()), + ], ), - migrations.AddField( - model_name='pagetitle', - name='quest', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest'), + migrations.CreateModel( + name='DiceRoll', + fields=[ + ('message', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Message')), + ('roll', models.CharField(max_length=9)), + ('results', models.TextField()), + ('total', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Poll', + fields=[ + ('post', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Post')), + ('multi_choice', models.BooleanField()), + ('allow_writein', models.BooleanField()), + ('open', models.BooleanField()), + ], ), ] diff --git a/quest/migrations/0002_auto_20180812_1612.py b/quest/migrations/0002_auto_20180812_1612.py deleted file mode 100644 index 293bc35..0000000 --- a/quest/migrations/0002_auto_20180812_1612.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1 on 2018-08-12 20:12 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0001_initial'), - ] - - operations = [ - migrations.RenameField( - model_name='quest', - old_name='quest_name', - new_name='title', - ), - ] diff --git a/quest/migrations/0002_auto_20180905_1344.py b/quest/migrations/0002_auto_20180905_1344.py new file mode 100644 index 0000000..1673c54 --- /dev/null +++ b/quest/migrations/0002_auto_20180905_1344.py @@ -0,0 +1,67 @@ +# Generated by Django 2.1.1 on 2018-09-05 17:44 + +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), + ('quest', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='quest', + name='owner', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='post', + name='quest', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest'), + ), + migrations.AddField( + model_name='pollvote', + name='option', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.PollOption'), + ), + migrations.AddField( + model_name='pollvote', + name='user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='pagetitle', + name='quest', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest'), + ), + migrations.AddField( + model_name='message', + name='quest', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest'), + ), + migrations.AddField( + model_name='message', + name='user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AlterUniqueTogether( + name='pollvote', + unique_together={('option', 'ip_address')}, + ), + migrations.AddField( + model_name='polloption', + name='poll', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Poll'), + ), + migrations.AddField( + model_name='diceroll', + name='dicecall', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.DiceCall'), + ), + ] diff --git a/quest/migrations/0003_message.py b/quest/migrations/0003_message.py deleted file mode 100644 index f393c10..0000000 --- a/quest/migrations/0003_message.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 2.1 on 2018-08-17 11:19 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('quest', '0002_auto_20180812_1612'), - ] - - operations = [ - migrations.CreateModel( - name='Message', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('date', models.DateTimeField(auto_now=True)), - ('message', models.TextField(max_length=512)), - ('quest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Quest')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/quest/migrations/0004_auto_20180817_0724.py b/quest/migrations/0004_auto_20180817_0724.py deleted file mode 100644 index 99f276f..0000000 --- a/quest/migrations/0004_auto_20180817_0724.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.1 on 2018-08-17 11:24 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0003_message'), - ] - - operations = [ - migrations.AlterField( - model_name='message', - name='user', - field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/quest/migrations/0005_auto_20180817_0739.py b/quest/migrations/0005_auto_20180817_0739.py deleted file mode 100644 index 2975aac..0000000 --- a/quest/migrations/0005_auto_20180817_0739.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.1 on 2018-08-17 11:39 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0004_auto_20180817_0724'), - ] - - operations = [ - migrations.AlterField( - model_name='message', - name='user', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/quest/migrations/0006_auto_20180817_0921.py b/quest/migrations/0006_auto_20180817_0921.py deleted file mode 100644 index 58b5193..0000000 --- a/quest/migrations/0006_auto_20180817_0921.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1 on 2018-08-17 13:21 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0005_auto_20180817_0739'), - ] - - operations = [ - migrations.RenameField( - model_name='message', - old_name='date', - new_name='timestamp', - ), - ] diff --git a/quest/migrations/0007_dicecall.py b/quest/migrations/0007_dicecall.py deleted file mode 100644 index 1da2705..0000000 --- a/quest/migrations/0007_dicecall.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 2.1 on 2018-08-23 15:46 - -import django.core.validators -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0006_auto_20180817_0921'), - ] - - operations = [ - migrations.CreateModel( - name='DiceCall', - fields=[ - ('post', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Post')), - ('dice_roll', models.CharField(max_length=9)), - ('strict', models.BooleanField()), - ('dice_challenge', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(999), django.core.validators.MinValueValidator(1)])), - ('rolls_taken', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(99), django.core.validators.MinValueValidator(1)])), - ], - ), - ] diff --git a/quest/migrations/0008_auto_20180824_0855.py b/quest/migrations/0008_auto_20180824_0855.py deleted file mode 100644 index 5cfc820..0000000 --- a/quest/migrations/0008_auto_20180824_0855.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 2.1 on 2018-08-24 12:55 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0007_dicecall'), - ] - - operations = [ - migrations.RemoveField( - model_name='quest', - name='open_post_id', - ), - migrations.AddField( - model_name='dicecall', - name='open', - field=models.BooleanField(default=False), - ), - ] diff --git a/quest/migrations/0009_diceroll.py b/quest/migrations/0009_diceroll.py deleted file mode 100644 index 56e44af..0000000 --- a/quest/migrations/0009_diceroll.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.1 on 2018-08-25 01:06 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0008_auto_20180824_0855'), - ] - - operations = [ - migrations.CreateModel( - name='DiceRoll', - fields=[ - ('message', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Message')), - ('roll', models.CharField(max_length=9)), - ('results', models.TextField()), - ('total', models.IntegerField()), - ('dicecall', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.DiceCall')), - ], - ), - ] diff --git a/quest/migrations/0010_auto_20180829_1308.py b/quest/migrations/0010_auto_20180829_1308.py deleted file mode 100644 index f9d0020..0000000 --- a/quest/migrations/0010_auto_20180829_1308.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Django 2.1 on 2018-08-29 17:08 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('quest', '0009_diceroll'), - ] - - operations = [ - migrations.CreateModel( - name='Poll', - fields=[ - ('post', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='quest.Post')), - ('multi_choice', models.BooleanField()), - ('allow_writein', models.BooleanField()), - ('open', models.BooleanField()), - ], - ), - migrations.CreateModel( - name='PollOption', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('text', models.CharField(max_length=200)), - ('poll', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.Poll')), - ], - ), - migrations.CreateModel( - name='PollVote', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('ip_address', models.GenericIPAddressField()), - ('option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quest.PollOption')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.AlterField( - model_name='dicecall', - name='open', - field=models.BooleanField(), - ), - ] diff --git a/quest/migrations/0011_auto_20180902_2007.py b/quest/migrations/0011_auto_20180902_2007.py deleted file mode 100644 index f7de7ce..0000000 --- a/quest/migrations/0011_auto_20180902_2007.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.1 on 2018-09-03 00:07 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0010_auto_20180829_1308'), - ] - - operations = [ - migrations.AlterField( - model_name='pollvote', - name='user', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/quest/migrations/0012_auto_20180904_0732.py b/quest/migrations/0012_auto_20180904_0732.py deleted file mode 100644 index eb987ca..0000000 --- a/quest/migrations/0012_auto_20180904_0732.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 2.1 on 2018-09-04 11:32 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('quest', '0011_auto_20180902_2007'), - ] - - operations = [ - migrations.AlterUniqueTogether( - name='pollvote', - unique_together={('option', 'ip_address')}, - ), - ] diff --git a/signup/forms.py b/signup/forms.py index 9a5a67d..633eb6e 100644 --- a/signup/forms.py +++ b/signup/forms.py @@ -5,7 +5,7 @@ Form(s) for the signup app. from django import forms from django.contrib.auth.forms import UserCreationForm -from users.models import User +from user.models import User class SignupForm(UserCreationForm): """ diff --git a/titivillus/settings.py b/titivillus/settings.py index c18e0b5..62e599f 100644 --- a/titivillus/settings.py +++ b/titivillus/settings.py @@ -32,7 +32,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'channels', - 'users.apps.UsersConfig', + 'user.apps.UserConfig', 'homepage.apps.HomepageConfig', 'create_quest.apps.CreateQuestConfig', 'quest.apps.QuestConfig', @@ -107,7 +107,7 @@ AUTH_PASSWORD_VALIDATORS = [ } }, { - 'NAME': 'users.validators.MaximumLengthValidator', + 'NAME': 'user.validators.MaximumLengthValidator', 'OPTIONS': { 'max_length': 1024, } @@ -138,7 +138,7 @@ STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] -AUTH_USER_MODEL = 'users.User' +AUTH_USER_MODEL = 'user.User' PASSWORD_HASHERS = [ 'django.contrib.auth.hashers.Argon2PasswordHasher', diff --git a/user/.views.py.swo b/user/.views.py.swo new file mode 100644 index 0000000..22b533d Binary files /dev/null and b/user/.views.py.swo differ diff --git a/users/__init__.py b/user/__init__.py similarity index 100% rename from users/__init__.py rename to user/__init__.py diff --git a/users/admin.py b/user/admin.py similarity index 100% rename from users/admin.py rename to user/admin.py diff --git a/user/apps.py b/user/apps.py new file mode 100644 index 0000000..35048d4 --- /dev/null +++ b/user/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserConfig(AppConfig): + name = 'user' diff --git a/users/migrations/0001_initial.py b/user/migrations/0001_initial.py similarity index 80% rename from users/migrations/0001_initial.py rename to user/migrations/0001_initial.py index 7cf93c0..fe0d2aa 100644 --- a/users/migrations/0001_initial.py +++ b/user/migrations/0001_initial.py @@ -1,9 +1,10 @@ -# Generated by Django 2.0.7 on 2018-08-10 20:30 +# Generated by Django 2.1.1 on 2018-09-05 17:44 import django.contrib.auth.models -import django.contrib.auth.validators +import django.core.validators from django.db import migrations, models import django.utils.timezone +import user.validators class Migration(migrations.Migration): @@ -25,7 +26,7 @@ class Migration(migrations.Migration): ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 20 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=20, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Must be between 3 and 20 characters. Letters and digits only.', max_length=20, unique=True, validators=[user.validators.CharValidator('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 'Username must only contain alphanumeric characters.'), django.core.validators.MinLengthValidator(3, 'Username must contain more than 3 characters.'), django.core.validators.MaxLengthValidator(20, 'Username must contain less than 20 characters.')], verbose_name='username')), ('email', models.EmailField(max_length=254, verbose_name='email address')), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), diff --git a/users/migrations/__init__.py b/user/migrations/__init__.py similarity index 100% rename from users/migrations/__init__.py rename to user/migrations/__init__.py diff --git a/users/models.py b/user/models.py similarity index 100% rename from users/models.py rename to user/models.py diff --git a/users/tests.py b/user/tests.py similarity index 100% rename from users/tests.py rename to user/tests.py diff --git a/users/validators.py b/user/validators.py similarity index 100% rename from users/validators.py rename to user/validators.py diff --git a/user/views.py b/user/views.py new file mode 100644 index 0000000..c32bc0c --- /dev/null +++ b/user/views.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +""" +/user app views. +""" +from django.http import HttpResponse +from django.shortcuts import redirect, render +from django.core.exceptions import ObjectDoesNotExist + +from .models import User +from quest.models import Quest + +def index(request): + """ + The user index page. + """ + return HttpResponse("Hello, world. You're at the user index.") diff --git a/users/apps.py b/users/apps.py deleted file mode 100644 index 4ce1fab..0000000 --- a/users/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class UsersConfig(AppConfig): - name = 'users' diff --git a/users/migrations/0002_auto_20180812_1609.py b/users/migrations/0002_auto_20180812_1609.py deleted file mode 100644 index 29040f5..0000000 --- a/users/migrations/0002_auto_20180812_1609.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.1 on 2018-08-12 20:09 - -import django.core.validators -from django.db import migrations, models -import users.validators - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='username', - field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Must be between 3 and 20 characters. Letters and digits only.', max_length=20, unique=True, validators=[users.validators.CharValidator('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 'Username must only contain alphanumeric characters.'), django.core.validators.MinLengthValidator(3, 'Username must contain more than 3 characters.'), django.core.validators.MaxLengthValidator(20, 'Username must contain less than 20 characters.')], verbose_name='username'), - ), - ] diff --git a/users/views.py b/users/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/users/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here.