Skip to content

Commit

Permalink
setting up django
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-arnold-clover committed Dec 14, 2021
0 parents commit 14f8754
Show file tree
Hide file tree
Showing 22 changed files with 488 additions and 0 deletions.
153 changes: 153 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/action_provision
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5:48663c53-7439-4742-ac3e-7e21216f9ea2
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/action_set_name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1639502897
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/box_meta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"ubuntu/bionic64","version":"20210108.0.0","provider":"virtualbox","directory":"boxes/ubuntu-VAGRANTSLASH-bionic64/20210108.0.0/virtualbox"}
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/creator_uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
502
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
48663c53-7439-4742-ac3e-7e21216f9ea2
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/index_uuid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
93321e6843204835bbe7dd88e66c3e58
27 changes: 27 additions & 0 deletions .vagrant/machines/default/virtualbox/private_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQ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4b79FNVV4IAy
pfAtN1qDZC1K/CB+eORQcKyNSS9U1yUEzbh1KKfF7HPOoNRwPKIQZ8jtSpoheKR8
hkA3DqHnQUDqo7i7yvnhmybrMa5bTYKyKDy4Mxc8IFJTPDxkSHYMSinhGUP1MQc9
DCo8e8l+eQahQHf3Qd4oCF0CgYBOtfxtaS1NRTEF61zOAeYNsJfX9NLqLUAYKe2y
GJFKXYC4mvBoMfVHVA9RU5sQHp2GExTg2rgFgY9OMkjzGQntnorvadOEQAs/caKJ
SSL1PoemF8eTjjxI3chdEfZpnyHqzIQU0CiEzNR5h+XeIHUUMCBG60NIcpCG8FPd
jhhvaQKBgQDLjCHQIVSOPhbN1D7Bu6YWqn0lcL7T9vbUiQQhytysWHWrQP5jdFgJ
HphpuW05jY3TFXi9Fs/oWj/Tpyn24CxlMwaDbCYymhZzBMip/+QGCAJwwA2GthRE
TpSbsARTDxGYjZGnpvP6f4uclUfNMK7mky3tK8naxX37mhHT4tMpUg==
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/synced_folders
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/darnold/git/HealthTracker","disabled":false,"__vagrantfile":true}}}
1 change: 1 addition & 0 deletions .vagrant/machines/default/virtualbox/vagrant_cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/darnold/git/HealthTracker
9 changes: 9 additions & 0 deletions .vagrant/rgloader/loader.rb
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions Inputs.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions scripts/load_training.py
Original file line number Diff line number Diff line change
@@ -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
)
)
22 changes: 22 additions & 0 deletions tracker/manage.py
Original file line number Diff line number Diff line change
@@ -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()
Empty file added tracker/tracker/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions tracker/tracker/asgi.py
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 14f8754

Please sign in to comment.