diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5380010893c92c2fb770a0bb44a844b4dd425d3b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +db.sqlite3 +geckodriver.log +virtualenv +__pycache__ +*.pyc diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..63877038967ae9d7027855e1fa33d0fd9a216b69 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn djangoherokuapp.wsgi --log-file - \ No newline at end of file diff --git a/functional_tests.py b/functional_tests.py new file mode 100644 index 0000000000000000000000000000000000000000..249731aef2b238e3909890b78fb845b0e40506ca --- /dev/null +++ b/functional_tests.py @@ -0,0 +1,31 @@ +from selenium import webdriver +import unittest + +class NewVisitorTest(unittest.TestCase): + + def setUp(self): + self.browser = webdriver.Firefox() + + def tearDown(self): + self.browser.quit() + + def test_can_start_a_list_and_retrieve_it_later(self): + # Edith has heard about a cool new online to-do app. She goes + # to check out its homepage + self.browser.get('http://localhost:8000') + + # She notices the page title and header mention to-do lists + self.assertIn('Aviliani\'s Homepage', self.browser.title) + + def test_body_contains_name_in_h1(self): + self.browser.get('http://localhost:8000') + h1_elem = self.browser.find_element_by_tag_name('h1') + assert h1_elem.text == 'Aviliani Pramestya' + + def test_body_contains_npm_in_h1(self): + self.browser.get('http://localhost:8000') + h1_elem = self.browser.find_element_by_tag_name('h2') + assert h1_elem.text == '1606829402' + +if __name__ == '__main__': + unittest.main(warnings='ignore') \ No newline at end of file diff --git a/lists/__init__.py b/lists/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lists/admin.py b/lists/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..8c38f3f3dad51e4585f3984282c2a4bec5349c1e --- /dev/null +++ b/lists/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/lists/apps.py b/lists/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..efe43f03b32216436c4e15becbab60ef7d342598 --- /dev/null +++ b/lists/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ListsConfig(AppConfig): + name = 'lists' diff --git a/lists/migrations/__init__.py b/lists/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lists/models.py b/lists/models.py new file mode 100644 index 0000000000000000000000000000000000000000..71a836239075aa6e6e4ecb700e9c42c95c022d91 --- /dev/null +++ b/lists/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/lists/templates/index.html b/lists/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e193e787c3d8114f7032033f337dc1f939ecc2b2 --- /dev/null +++ b/lists/templates/index.html @@ -0,0 +1,22 @@ + + + + + Aviliani's Homepage + + + + + + +

Aviliani Pramestya

+

1606829402

+ + \ No newline at end of file diff --git a/lists/tests.py b/lists/tests.py new file mode 100644 index 0000000000000000000000000000000000000000..2fe7a35ad18161ef27d794c5f6f9513750545dc6 --- /dev/null +++ b/lists/tests.py @@ -0,0 +1,33 @@ +from django.urls import resolve +from django.test import TestCase +from django.http import HttpRequest + +from lists.views import home_page + + +class HomePageTest(TestCase): + + def test_root_url_resolves_to_home_page_view(self): + found = resolve('/') + self.assertEqual(found.func, home_page) + + + def test_home_page_returns_correct_html(self): + request = HttpRequest() + response = home_page(request) + html = response.content.decode('utf8') + self.assertTrue(html.startswith('')) + self.assertIn('Aviliani\'s Homepage', html) + self.assertTrue(html.endswith('')) + + def test_home_page_contains_name(self): + request = HttpRequest() + response = home_page(request) + html = response.content.decode('utf8') + self.assertIn('Aviliani Pramestya', html) + + def test_home_page_contains_npm(self): + request = HttpRequest() + response = home_page(request) + html = response.content.decode('utf8') + self.assertIn('1606829402', html) \ No newline at end of file diff --git a/lists/views.py b/lists/views.py new file mode 100644 index 0000000000000000000000000000000000000000..0949a77ff9528262e4a88c3cc3b7f3458a81bf67 --- /dev/null +++ b/lists/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. +def home_page(request): + return render(request, 'index.html') \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000000000000000000000000000000000000..3e6d019efdb2ede66fac178b28fed8a65f5db99c --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..b2c9fc6f1fee3d7a84610b3117b3bbe7fa057504 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +dj-database-url==0.5.0 +Django==1.11.24 +gunicorn==19.9.0 +psycopg2==2.8.3 +pytz==2019.2 +selenium==3.141.0 +urllib3==1.25.3 +whitenoise==4.1.3 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000000000000000000000000000000000000..07261fe855fdd102d2ec3808b5553d8ea58d0f7c --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.7.4 \ No newline at end of file diff --git a/superlists/__init__.py b/superlists/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/superlists/settings.py b/superlists/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..5c0e8bbe4f6ed456c195fe086539c8b4bd4f0caf --- /dev/null +++ b/superlists/settings.py @@ -0,0 +1,131 @@ +""" +Django settings for superlists project. + +Generated by 'django-admin startproject' using Django 1.11.24. + +For more information on this file, see +https://docs.djangoproject.com/en/1.11/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.11/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'e8m^qa9wjci95!-)ph00k3v@4fq8fm$h)8&0ktpio+4-7r=u-$' + +# 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', + 'lists', +] + +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', + 'whitenoise.middleware.WhiteNoiseMiddleware', +] + +ROOT_URLCONF = 'superlists.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + '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 = 'superlists.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.11/howto/static-files/ + +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') +STATIC_URL = '/static/' + +# Extra lookup directories for collectstatic to find static files +STATICFILES_DIRS = ( + os.path.join(PROJECT_ROOT, 'static'), +) + +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' \ No newline at end of file diff --git a/superlists/urls.py b/superlists/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..d07405e9fa1287826f91ad2bc92da15c7a5ea283 --- /dev/null +++ b/superlists/urls.py @@ -0,0 +1,21 @@ +"""superlists URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.11/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from lists import views + +urlpatterns = [ + url(r'^$', views.home_page, name='home'), +] diff --git a/superlists/wsgi.py b/superlists/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..e2d9e59895efa538f1dc0aa10345329a79dbdd5b --- /dev/null +++ b/superlists/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for superlists project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings") + +application = get_wsgi_application()