From: David Kerkeslager Date: Sat, 27 Feb 2021 06:10:24 +0000 (-0500) Subject: Fix issue where both route and boulder were required on attempts/todos in admin interface X-Git-Url: https://code.kerkeslager.com/?p=tickle;a=commitdiff_plain;h=678c6c361771c6c67e21c76c1b6c3a67a7f6ee70 Fix issue where both route and boulder were required on attempts/todos in admin interface --- diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..306e4b6 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tickle.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index b4d47a2..f1ffd01 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import pathlib from setuptools import setup, find_packages HERE = pathlib.Path(__file__).parent -VERSION = '0.0.9' +VERSION = '0.0.10.pre-alpha' PACKAGE_NAME = 'django_predrill_tickle' AUTHOR = 'David Kerkeslager' AUTHOR_EMAIL = 'david@kerkeslager.com' diff --git a/tickle/migrations/0003_auto_20210227_0609.py b/tickle/migrations/0003_auto_20210227_0609.py new file mode 100644 index 0000000..b9ac6a4 --- /dev/null +++ b/tickle/migrations/0003_auto_20210227_0609.py @@ -0,0 +1,53 @@ +# Generated by Django 3.1.7 on 2021-02-27 06:09 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tickle', '0002_auto_20210226_0543'), + ] + + operations = [ + migrations.AlterModelOptions( + name='pitch', + options={'ordering': ('order',), 'verbose_name_plural': 'Pitches'}, + ), + migrations.AlterField( + model_name='area', + name='parent', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='tickle.area'), + ), + migrations.AlterField( + model_name='attempt', + name='boulder', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='attempts', to='tickle.boulder'), + ), + migrations.AlterField( + model_name='attempt', + name='route', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='attempts', to='tickle.route'), + ), + migrations.AlterField( + model_name='boulder', + name='area', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='boulders', to='tickle.area'), + ), + migrations.AlterField( + model_name='route', + name='area', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='routes', to='tickle.area'), + ), + migrations.AlterField( + model_name='todo', + name='boulder', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='todos', to='tickle.boulder'), + ), + migrations.AlterField( + model_name='todo', + name='route', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='todos', to='tickle.route'), + ), + ] diff --git a/tickle/models.py b/tickle/models.py index 86cb752..6dc17ca 100644 --- a/tickle/models.py +++ b/tickle/models.py @@ -169,8 +169,20 @@ class Attempt(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) date = models.DateField() notes = models.TextField(blank=True) - boulder = models.ForeignKey('Boulder', null=True, on_delete=models.PROTECT, related_name='attempts') - route = models.ForeignKey('Route', null=True, on_delete=models.PROTECT, related_name='attempts') + boulder = models.ForeignKey( + 'Boulder', + blank=True, + null=True, + on_delete=models.PROTECT, + related_name='attempts', + ) + route = models.ForeignKey( + 'Route', + blank=True, + null=True, + on_delete=models.PROTECT, + related_name='attempts', + ) result = models.CharField(max_length=8, choices=ATTEMPT_RESULT_CHOICES) prior_knowledge = models.BooleanField(default=True) protection_used = models.CharField(max_length=8, choices=PROTECTION_CHOICES) @@ -196,8 +208,20 @@ class Todo(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) notes = models.TextField(blank=True) protection = models.CharField(max_length=8, choices=PROTECTION_CHOICES) - boulder = models.ForeignKey('Boulder', null=True, on_delete=models.PROTECT, related_name='todos') - route = models.ForeignKey('Route', null=True, on_delete=models.PROTECT, related_name='todos') + boulder = models.ForeignKey( + 'Boulder', + blank=True, + null=True, + on_delete=models.PROTECT, + related_name='todos', + ) + route = models.ForeignKey( + 'Route', + blank=True, + null=True, + on_delete=models.PROTECT, + related_name='todos', + ) style = models.CharField(max_length=8, choices=STYLE_CHOICES) class Meta: diff --git a/tickle/settings.py b/tickle/settings.py new file mode 100644 index 0000000..4d153a5 --- /dev/null +++ b/tickle/settings.py @@ -0,0 +1,110 @@ +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'b&-!%$%jyabi^e#9gz!^&=3#z7-c$zc0c#@o&q*-9z17pnbok8' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'tickle', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'tickle.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +#WSGI_APPLICATION = 'core.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.1/howto/static-files/ + +STATIC_URL = '/static/'