diff --git a/Pipfile b/Pipfile index 07519e7..21f8ddf 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,8 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] +black = "*" +pywatchman = "*" [packages] django-taggit = "*" @@ -11,6 +13,10 @@ waitress = "*" dj-database-url = "*" django-heroku = "*" requests-html = "*" +mistune = "*" [requires] python_version = "3.7" + +[pipenv] +allow_prereleases = true diff --git a/Pipfile.lock b/Pipfile.lock index 8cb3549..9e63682 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "46d44fe107746acc63c4535e7582f8a8533d6ec4a8b61379ca0adb51321de281" + "sha256": "e4bcdc5126081b5e658b02e477f0005b146257d438afd298d80ca1429d7ff185" }, "pipfile-spec": 6, "requires": { @@ -68,10 +68,10 @@ }, "django": { "hashes": [ - "sha256:275bec66fd2588dd517ada59b8bfb23d4a9abc5a362349139ddda3c7ff6f5ade", - "sha256:939652e9d34d7d53d74d5d8ef82a19e5f8bb2de75618f7e5360691b6e9667963" + "sha256:58819ca72a13b963c16383687421261657abe5754aad9ad66166a921dd17559f", + "sha256:62644444551e8e6fd36600e741a4d24dd2b4b58acf7bae8847a8da952468d771" ], - "version": "==2.1.7" + "version": "==2.2b1" }, "django-heroku": { "hashes": [ @@ -133,6 +133,14 @@ ], "version": "==4.3.2" }, + "mistune": { + "hashes": [ + "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e", + "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4" + ], + "index": "pypi", + "version": "==0.8.4" + }, "parse": { "hashes": [ "sha256:870dd675c1ee8951db3e29b81ebe44fd131e3eb8c03a79483a58ea574f3145c2" @@ -230,6 +238,13 @@ ], "version": "==1.8" }, + "sqlparse": { + "hashes": [ + "sha256:ce028444cfab83be538752a2ffdb56bc417b7784ff35bb9a3062413717807dec", + "sha256:d9cf190f51cbb26da0412247dfe4fb5f4098edb73db84e02f9fc21fdca31fed4" + ], + "version": "==0.2.4" + }, "tqdm": { "hashes": [ "sha256:d385c95361699e5cf7622485d9b9eae2d4864b21cd5a2374a9c381ffed701021", @@ -293,5 +308,49 @@ "version": "==4.1.2" } }, - "develop": {} + "develop": { + "appdirs": { + "hashes": [ + "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92", + "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e" + ], + "version": "==1.4.3" + }, + "attrs": { + "hashes": [ + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" + ], + "version": "==19.1.0" + }, + "black": { + "hashes": [ + "sha256:817243426042db1d36617910df579a54f1afd659adb96fc5032fcf4b36209739", + "sha256:e030a9a28f542debc08acceb273f228ac422798e5215ba2a791a6ddeaaca22a5" + ], + "index": "pypi", + "version": "==18.9b0" + }, + "click": { + "hashes": [ + "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", + "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + ], + "version": "==7.0" + }, + "pywatchman": { + "hashes": [ + "sha256:d0047eb275deafb0011eda0a1a815fbd9742478c3d2b5ad6956d300e447dc2f9" + ], + "index": "pypi", + "version": "==1.4.1" + }, + "toml": { + "hashes": [ + "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", + "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + ], + "version": "==0.10.0" + } + } } diff --git a/core/migrations/0004_auto_20190311_0749.py b/core/migrations/0004_auto_20190311_0749.py new file mode 100644 index 0000000..bb38d28 --- /dev/null +++ b/core/migrations/0004_auto_20190311_0749.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2b1 on 2019-03-11 11:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_auto_20190311_0641'), + ] + + operations = [ + migrations.AlterField( + model_name='post', + name='uri', + field=models.URLField(null=True), + ), + ] diff --git a/core/models.py b/core/models.py index 33254ad..a5f5f7e 100644 --- a/core/models.py +++ b/core/models.py @@ -8,11 +8,12 @@ from taggit.managers import TaggableManager class Post(models.Model): """A Post, posted on the site.""" + title = models.TextField() text = models.TextField() timestamp = models.DateTimeField(default=timezone.now) tags = TaggableManager() - uri = models.URLField() + uri = models.URLField(null=True) uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) published = models.BooleanField(editable=True, default=False) diff --git a/core/templates/index.html b/core/templates/index.html new file mode 100644 index 0000000..a28583e --- /dev/null +++ b/core/templates/index.html @@ -0,0 +1,5 @@ +{% for article in object_list %} + +{{ article }} + +{% endfor %} diff --git a/core/views.py b/core/views.py index 91ea44a..8490854 100644 --- a/core/views.py +++ b/core/views.py @@ -1,3 +1,26 @@ +from django.views.generic import ListView, DetailView from django.shortcuts import render +from .models import Post + # Create your views here. +class PostListView(ListView): + model = Post + paginate_by = 50 + + def get_queryset(): + Post.objects.filter(published=True) + + def get(self, request, *args, **kwargs): + return render(request, template_name="index.html") + + +# Create your views here. +class PostDetailView(DetailView): + model = Post + + def get_queryset(): + Post.objects.filter(published=True) + + def get(self, request, *args, **kwargs): + return render(request, template_name="index.html") diff --git a/morepython/settings.py b/morepython/settings.py index 8d5cfc4..238db24 100644 --- a/morepython/settings.py +++ b/morepython/settings.py @@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 't$o!fse7g1fq%r5e&cgpzvklp%+1wf@^5fp3a7!!z__)_ti*7u' +SECRET_KEY = "t$o!fse7g1fq%r5e&cgpzvklp%+1wf@^5fp3a7!!z__)_ti*7u" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -31,54 +31,54 @@ ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - # 'django.contrib.messages', - 'django.contrib.staticfiles', - 'taggit', - 'core' + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "taggit", + "core", ] 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', + "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 = 'morepython.urls' +ROOT_URLCONF = "morepython.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', - ], + "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 = 'morepython.wsgi.application' +WSGI_APPLICATION = "morepython.wsgi.application" # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), } } @@ -88,26 +88,20 @@ DATABASES = { 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', + "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/2.1/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -119,8 +113,9 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ -STATIC_URL = '/static/' +STATIC_URL = "/static/" import django_heroku + django_heroku.settings(locals()) diff --git a/morepython/urls.py b/morepython/urls.py index 14f78c1..98233c2 100644 --- a/morepython/urls.py +++ b/morepython/urls.py @@ -16,6 +16,10 @@ Including another URLconf from django.contrib import admin from django.urls import path +import core.views + urlpatterns = [ - path('admin/', admin.site.urls), + path("admin/", admin.site.urls), + path("", core.views.PostListView.as_view()), + path("", core.views.PostDetailView.as_view()), ]