diff --git a/.gitignore b/.gitignore index 418c9e3..a1b194b 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,6 @@ dmypy.json # Cython debug symbols cython_debug/ + +#VSCODE +.vscode/* diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/asgi.py b/config/asgi.py new file mode 100644 index 0000000..8a9fda7 --- /dev/null +++ b/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_asgi_application() diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..26291c6 --- /dev/null +++ b/config/settings.py @@ -0,0 +1,132 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 3.1. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +from pathlib import Path +import os + +from my_secrets import secrets + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve(strict=True).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 = secrets.SECRET_KEY + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'pushup', + 'users', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'django_extensions', + 'django_secrets' + #'chartjs', +] + +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 = 'config.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 = 'config.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 = 'America/New_York' + +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/' +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'static'), +) \ No newline at end of file diff --git a/config/urls.py b/config/urls.py new file mode 100644 index 0000000..1bf4b4a --- /dev/null +++ b/config/urls.py @@ -0,0 +1,28 @@ +"""config URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +from pushup import views as pushup_views +from users import views as users_views + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', pushup_views.home, name="home"), + path('login/', users_views.login, name="login"), + path('signup/', users_views.signup, name="signup"), + path('logout/', users_views.logout, name="logout") +] diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..94fcaf1 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config 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/3.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..7b4eef9 --- /dev/null +++ b/manage.py @@ -0,0 +1,25 @@ +#!/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', 'config.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__': + + from django_secrets.startup import check + check() + main() diff --git a/my_secrets/.gitignore b/my_secrets/.gitignore new file mode 100644 index 0000000..ef418f5 --- /dev/null +++ b/my_secrets/.gitignore @@ -0,0 +1 @@ +secrets.py diff --git a/my_secrets/__init__.py b/my_secrets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/my_secrets/definitions.py b/my_secrets/definitions.py new file mode 100644 index 0000000..67c7212 --- /dev/null +++ b/my_secrets/definitions.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +# Add your secrets to this list and run manage.py to set their values. +# Use them in settings.py like this: +# from secrets import secrets +# SECRET_KEY = secrets.SECRET_KEY + +SECRET_KEYS = [ + # start with your Django secret key like this: + "SECRET_KEY", +] diff --git a/pushup/__init__.py b/pushup/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pushup/admin.py b/pushup/admin.py new file mode 100644 index 0000000..bf0ecde --- /dev/null +++ b/pushup/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import StockValue + +# Register your models here. +admin.site.register(StockValue) \ No newline at end of file diff --git a/pushup/apps.py b/pushup/apps.py new file mode 100644 index 0000000..c5c66a6 --- /dev/null +++ b/pushup/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PushupConfig(AppConfig): + name = 'pushup' diff --git a/pushup/migrations/0001_initial.py b/pushup/migrations/0001_initial.py new file mode 100644 index 0000000..1343fca --- /dev/null +++ b/pushup/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.2 on 2020-10-19 03:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='StockValue', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('value', models.TextField()), + ('time', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/pushup/migrations/0002_auto_20201019_0341.py b/pushup/migrations/0002_auto_20201019_0341.py new file mode 100644 index 0000000..dfb3e6d --- /dev/null +++ b/pushup/migrations/0002_auto_20201019_0341.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2020-10-19 03:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pushup', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='stockvalue', + name='value', + field=models.DecimalField(decimal_places=3, max_digits=5), + ), + ] diff --git a/pushup/migrations/0003_auto_20201019_0153.py b/pushup/migrations/0003_auto_20201019_0153.py new file mode 100644 index 0000000..5b4a8c5 --- /dev/null +++ b/pushup/migrations/0003_auto_20201019_0153.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.2 on 2020-10-19 05:53 + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('pushup', '0002_auto_20201019_0341'), + ] + + operations = [ + migrations.AlterField( + model_name='stockvalue', + name='time', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 19, 5, 53, 55, 274646, tzinfo=utc)), + ), + ] diff --git a/pushup/migrations/0004_auto_20201019_0156.py b/pushup/migrations/0004_auto_20201019_0156.py new file mode 100644 index 0000000..b3d87f2 --- /dev/null +++ b/pushup/migrations/0004_auto_20201019_0156.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-10-19 05:56 + +from django.db import migrations, models +import pushup.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pushup', '0003_auto_20201019_0153'), + ] + + operations = [ + migrations.AlterField( + model_name='stockvalue', + name='time', + field=models.DateTimeField(default=pushup.models.get_time), + ), + ] diff --git a/pushup/migrations/__init__.py b/pushup/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pushup/models.py b/pushup/models.py new file mode 100644 index 0000000..fb5fc71 --- /dev/null +++ b/pushup/models.py @@ -0,0 +1,14 @@ +from django.db import models +from django.utils import timezone + +# Create your models here. + +def get_time(): + return timezone.localtime(timezone.now()) + +class StockValue(models.Model): + value = models.DecimalField(max_digits=5, decimal_places=3) + time = models.DateTimeField(default=get_time) + + def __str__(self): + return f"Price at {self.time}" \ No newline at end of file diff --git a/pushup/templates/pushup/base.html b/pushup/templates/pushup/base.html new file mode 100644 index 0000000..f4e9abf --- /dev/null +++ b/pushup/templates/pushup/base.html @@ -0,0 +1,51 @@ +{% load static %} + + + +
+# | +Name | +Push-Ups | +
---|---|---|
{{forloop.counter}} | +{{profile.user.first_name}} {{profile.user.last_name}} | +{{profile.pushups}} | +