diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b63cfd --- /dev/null +++ b/.gitignore @@ -0,0 +1,153 @@ +*.log +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/action_provision b/.vagrant/machines/default/virtualbox/action_provision new file mode 100644 index 0000000..fd4efad --- /dev/null +++ b/.vagrant/machines/default/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:48663c53-7439-4742-ac3e-7e21216f9ea2 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/action_set_name b/.vagrant/machines/default/virtualbox/action_set_name new file mode 100644 index 0000000..05ea356 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/action_set_name @@ -0,0 +1 @@ +1639502897 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/box_meta b/.vagrant/machines/default/virtualbox/box_meta new file mode 100644 index 0000000..5446084 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/box_meta @@ -0,0 +1 @@ +{"name":"ubuntu/bionic64","version":"20210108.0.0","provider":"virtualbox","directory":"boxes/ubuntu-VAGRANTSLASH-bionic64/20210108.0.0/virtualbox"} \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/creator_uid b/.vagrant/machines/default/virtualbox/creator_uid new file mode 100644 index 0000000..99f9f07 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/creator_uid @@ -0,0 +1 @@ +502 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/id b/.vagrant/machines/default/virtualbox/id new file mode 100644 index 0000000..60a3f6a --- /dev/null +++ b/.vagrant/machines/default/virtualbox/id @@ -0,0 +1 @@ +48663c53-7439-4742-ac3e-7e21216f9ea2 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/index_uuid b/.vagrant/machines/default/virtualbox/index_uuid new file mode 100644 index 0000000..9aff5d0 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/index_uuid @@ -0,0 +1 @@ +93321e6843204835bbe7dd88e66c3e58 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/private_key b/.vagrant/machines/default/virtualbox/private_key new file mode 100644 index 0000000..ccb4827 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/private_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA0zAegdDtGoLznW26AHmGSavG0OgxEqkKcYwFlTTNwUtijXnG +O5CbcBewLdZSBIpkA6gDp7vceR9VMQYntopfiwWoilPXhgYA/H2jxF0M5U/Q8bg5 +Sc4ma0nwT+vMDJlo4ecpVCSvp1PDp6Gjhswo8MDbyFOSKW9HG7zMyBnL+pr8olcR +yE47mSRKj74Pd7rFlcHfX03GbP2H0cLrb6A87ETHIMmmkC2KnHv+v8DLajlI86Ta +mal1Qqlni+sY7fVqxgN2bWWJNYkxosBk/iW409UDa/wH/d02EwwjapkvP1brZlKP +If4AEfUZi+BNYlUMaTGqmzHCY3iqGs5W516MOQIDAQABAoIBAHHxEVSbA4H9SzES +BXvCFVjkLBWEYQ2fVHokwNJatfRnFtob7H8wqxyUO0LP0lqOzB1I5gf2jKJw7EbR ++lU7XQcl22QejjbKQHf51YTZa17BbIsuCQKwDfxu3RBRuTrG/lZ7oMm8LWVLBVIJ +HLBasHAMrcfshvyCBEyL1bTUbkBbqakEBVHxAgocCZWOxROXvjNW0JsOog3qTsRc +VhIVkBMvJ6RpyF2ovt8MA0VPr/iUBbrkZupyWC8KARHQIe04yVRAZr6RHCsdSpmU +/TAM4EQyi6mrWiqF+n4rLUgPeXj9nVE/52BW76dBuXoFSdC6EGoFEXlJkLdAHzpe +zKgtbF0CgYEA7FFFRdJ0Lph8oZkxUjRQ3ROX0GgHfWbdNetHwhB6raUKulVGnLhH +yEE0+qCecEzNr+yCcBLI2amI/RF3GaQ6g6WV0afPc02LeiIPhAOcEJ4bm4VHOlms +AAyxu2CbAGDTAh4Hnu4Fgrg/IdOZS6yDYKnkf3kzuFT9PSvav1uMYoMCgYEA5McK +cDydBldESvu3cZD2gPYGukBW0haNHjkyl3ttzKsQpUIuFeqgauuX+MRUg0Qj1vPR +LV0+z3hbXuNsvMOcWJAmq3KFxLq805hL3/qwdhgIxaLf1tRyKUJ0eXbMORptBB1q +a64K3WjgPKHZd1//JPsZvTDBJLc2SX1rpzEpKZMCgYEAgAPukMpW4b79FNVV4IAy +pfAtN1qDZC1K/CB+eORQcKyNSS9U1yUEzbh1KKfF7HPOoNRwPKIQZ8jtSpoheKR8 +hkA3DqHnQUDqo7i7yvnhmybrMa5bTYKyKDy4Mxc8IFJTPDxkSHYMSinhGUP1MQc9 +DCo8e8l+eQahQHf3Qd4oCF0CgYBOtfxtaS1NRTEF61zOAeYNsJfX9NLqLUAYKe2y +GJFKXYC4mvBoMfVHVA9RU5sQHp2GExTg2rgFgY9OMkjzGQntnorvadOEQAs/caKJ +SSL1PoemF8eTjjxI3chdEfZpnyHqzIQU0CiEzNR5h+XeIHUUMCBG60NIcpCG8FPd +jhhvaQKBgQDLjCHQIVSOPhbN1D7Bu6YWqn0lcL7T9vbUiQQhytysWHWrQP5jdFgJ +HphpuW05jY3TFXi9Fs/oWj/Tpyn24CxlMwaDbCYymhZzBMip/+QGCAJwwA2GthRE +TpSbsARTDxGYjZGnpvP6f4uclUfNMK7mky3tK8naxX37mhHT4tMpUg== +-----END RSA PRIVATE KEY----- diff --git a/.vagrant/machines/default/virtualbox/synced_folders b/.vagrant/machines/default/virtualbox/synced_folders new file mode 100644 index 0000000..b4f4788 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/synced_folders @@ -0,0 +1 @@ +{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/darnold/git/HealthTracker","disabled":false,"__vagrantfile":true}}} \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/vagrant_cwd b/.vagrant/machines/default/virtualbox/vagrant_cwd new file mode 100644 index 0000000..a23e2fd --- /dev/null +++ b/.vagrant/machines/default/virtualbox/vagrant_cwd @@ -0,0 +1 @@ +/Users/darnold/git/HealthTracker \ No newline at end of file diff --git a/.vagrant/rgloader/loader.rb b/.vagrant/rgloader/loader.rb new file mode 100644 index 0000000..c3c05b0 --- /dev/null +++ b/.vagrant/rgloader/loader.rb @@ -0,0 +1,9 @@ +# This file loads the proper rgloader/loader.rb file that comes packaged +# with Vagrant so that encoded files can properly run with Vagrant. + +if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] + require File.expand_path( + "rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]) +else + raise "Encoded files can't be read outside of the Vagrant installer." +end diff --git a/Inputs.ipynb b/Inputs.ipynb new file mode 100644 index 0000000..73df8f1 --- /dev/null +++ b/Inputs.ipynb @@ -0,0 +1,33 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "6ec17b72", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..4bcd016 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +### PyMongo Docs: https://www.mongodb.com/blog/post/getting-started-with-python-and-mongodb +### Django-Mongo Integration Docs: https://www.mongodb.com/compatibility/mongodb-and-django \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..6f5e1b5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,9 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/bionic64" + config.vm.network "forwarded_port", guest: 8888, host: 8888 + config.vm.provision "shell", path: "./scripts/init.sh" +end diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100644 index 0000000..2c82e32 --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,14 @@ +#!/bin/bash +echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list + +wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - + +apt-get update +apt-get install -y python3 python3-pip wget gnupg mongodb-org + +pip3 install jupyter +pip3 install django +pip3 install pymongo pymongo[snappy,gssapi,srv,tls] +pip3 install dnspython +pip3 install mongoengine +pip3 install djongo diff --git a/scripts/load_training.py b/scripts/load_training.py new file mode 100644 index 0000000..01285de --- /dev/null +++ b/scripts/load_training.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +import json + +def weight_load(cur_reps, weight, desired_reps): + rep_map = [100, 95, 93, 90, 87, 83, 80, 77, 75, 70] + if not (cur_reps >= 1 and cur_reps <= 10): + raise ValueError("reps must be between 1 and 10 inclusive") + if not (desired_reps >= 1 and desired_reps <= 10): + raise ValueError("desired reps must be between 1 and 10 inclusive") + + percentage_of_single = rep_map[cur_reps-1] + single_rep_max = weight/(percentage_of_single/100) + return dict( + percentage=percentage_of_single, + single=int(single_rep_max), + desired_weight=int(single_rep_max*(rep_map[desired_reps-1]/100)) + ) + +if __name__ == '__main__': + from optparse import OptionParser + p = OptionParser() + p.add_option("--weight", type="int") + p.add_option("--reps", type="int") + p.add_option("--desired-reps", type="int") + opt, arg = p.parse_args() + print( + json.dumps( + weight_load(opt.reps, opt.weight, opt.desired_reps), + separators=(',', ':'), + indent=4, + sort_keys=True + ) + ) \ No newline at end of file diff --git a/tracker/manage.py b/tracker/manage.py new file mode 100755 index 0000000..2eaaf17 --- /dev/null +++ b/tracker/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', 'tracker.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/tracker/tracker/__init__.py b/tracker/tracker/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tracker/tracker/asgi.py b/tracker/tracker/asgi.py new file mode 100644 index 0000000..00b0cf5 --- /dev/null +++ b/tracker/tracker/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for tracker 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.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracker.settings') + +application = get_asgi_application() diff --git a/tracker/tracker/settings.py b/tracker/tracker/settings.py new file mode 100644 index 0000000..c51cbe7 --- /dev/null +++ b/tracker/tracker/settings.py @@ -0,0 +1,125 @@ +""" +Django settings for tracker project. + +Generated by 'django-admin startproject' using Django 3.2.10. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +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.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-w=41t92yv6@nc1p_igbfy$g_#tes*-%gnt+fnex)g75#h8!=xm' + +# 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', +] + +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 = 'tracker.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 = 'tracker.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.2/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.2/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.2/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/tracker/tracker/urls.py b/tracker/tracker/urls.py new file mode 100644 index 0000000..877e9f2 --- /dev/null +++ b/tracker/tracker/urls.py @@ -0,0 +1,21 @@ +"""tracker URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/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 + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/tracker/tracker/wsgi.py b/tracker/tracker/wsgi.py new file mode 100644 index 0000000..1b1ccd2 --- /dev/null +++ b/tracker/tracker/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for tracker 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.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracker.settings') + +application = get_wsgi_application()