From 0e27638afb583cf4185c1a90424ba5913656e370 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Fri, 26 Feb 2021 09:41:29 +0000 Subject: [PATCH] AAH2-19 Initialise Video Names --- loginapp/main.py | 2 +- loginapp/templates/upload.html | 3 + .../flask1}/.flaskenv | 0 .../flask1}/.gitattributes | 0 .../flask1}/.gitignore | 0 .../flask1/.vscode/settings.json | 3 + microblog-project/flask1/CNAME.md | 1 + .../flask1}/LICENSE | 0 microblog-project/flask1/README.md | 20 ++ microblog-project/flask1/app/__init__.py | 44 ++++ microblog-project/flask1/app/errors.py | 11 + microblog-project/flask1/app/forms.py | 36 +++ microblog-project/flask1/app/models.py | 76 ++++++ microblog-project/flask1/app/routes.py | 147 +++++++++++ .../flask1/app/templates/404.html | 6 + .../flask1/app/templates/500.html | 7 + .../flask1/app/templates/_post.html | 11 + .../flask1/app/templates/_profile.html | 23 ++ .../flask1/app/templates/base.html | 33 +++ .../flask1/app/templates/index.html | 27 ++ .../flask1/app/templates/login.html | 24 ++ .../flask1/app/templates/user.html | 25 ++ microblog-project/flask1/config.py | 16 ++ microblog-project/flask1/microblog.py | 7 + microblog-project/flask1/microblog/pyvenv.cfg | 3 + .../flask1}/migrations/README | 0 .../flask1}/migrations/alembic.ini | 0 microblog-project/flask1/migrations/env.py | 96 +++++++ .../flask1}/migrations/script.py.mako | 0 .../versions/76c86cb9832b_followers.py | 33 +++ .../versions/eb54505e6fb3_users_table.py | 51 ++++ microblog-project/flask1/tests.py | 89 +++++++ microblog-project/microblog-23-api/.flaskenv | 1 + .../microblog-23-api/.gitattributes | 2 + microblog-project/microblog-23-api/.gitignore | 40 +++ .../microblog-23-api}/Dockerfile | 0 microblog-project/microblog-23-api/LICENSE | 21 ++ .../microblog-23-api}/Procfile | 0 .../microblog-23-api}/README.md | 0 .../microblog-23-api}/Vagrantfile | 0 .../microblog-23-api}/app/__init__.py | 0 .../microblog-23-api}/app/api/__init__.py | 0 .../microblog-23-api}/app/api/auth.py | 0 .../microblog-23-api}/app/api/errors.py | 0 .../microblog-23-api}/app/api/tokens.py | 0 .../microblog-23-api}/app/api/users.py | 0 .../microblog-23-api}/app/auth/__init__.py | 0 .../microblog-23-api}/app/auth/email.py | 0 .../microblog-23-api}/app/auth/forms.py | 0 .../microblog-23-api}/app/auth/routes.py | 0 .../microblog-23-api}/app/cli.py | 0 .../microblog-23-api}/app/email.py | 0 .../microblog-23-api}/app/errors/__init__.py | 0 .../microblog-23-api}/app/errors/handlers.py | 0 .../microblog-23-api}/app/main/__init__.py | 0 .../microblog-23-api}/app/main/forms.py | 0 .../microblog-23-api}/app/main/routes.py | 0 .../microblog-23-api}/app/models.py | 0 .../microblog-23-api}/app/search.py | 0 .../microblog-23-api}/app/static/loading.gif | Bin .../microblog-23-api}/app/static/styles.css | 0 .../microblog-23-api}/app/tasks.py | 0 .../app/templates/_post.html | 0 .../app/templates/auth/login.html | 0 .../app/templates/auth/register.html | 0 .../app/templates/auth/reset_password.html | 0 .../auth/reset_password_request.html | 0 .../microblog-23-api}/app/templates/base.html | 0 .../app/templates/edit_profile.html | 0 .../app/templates/email/export_posts.html | 0 .../app/templates/email/export_posts.txt | 0 .../app/templates/email/reset_password.html | 0 .../app/templates/email/reset_password.txt | 0 .../app/templates/errors/404.html | 0 .../app/templates/errors/500.html | 0 .../app/templates/hello.html | 0 .../app/templates/index.html | 0 .../app/templates/messages.html | 0 .../app/templates/search.html | 0 .../app/templates/send_message.html | 0 .../microblog-23-api}/app/templates/user.html | 0 .../app/templates/user_popup.html | 0 .../microblog-23-api}/app/translate.py | 0 .../translations/es/LC_MESSAGES/messages.po | 0 .../microblog-23-api}/babel.cfg | 0 .../microblog-23-api}/boot.sh | 0 .../microblog-23-api}/config.py | 0 .../deployment/nginx/microblog | 0 .../supervisor/microblog-tasks.conf | 0 .../deployment/supervisor/microblog.conf | 0 .../microblog-23-api}/microblog.py | 0 .../microblog-23-api}/microvenv/pyvenv.cfg | 0 .../CacheControl-0.12.6-py2.py3-none-any.whl | Bin .../appdirs-1.4.3-py2.py3-none-any.whl | Bin .../certifi-2019.11.28-py2.py3-none-any.whl | Bin .../chardet-3.0.4-py2.py3-none-any.whl | Bin .../colorama-0.4.3-py2.py3-none-any.whl | Bin .../contextlib2-0.6.0-py2.py3-none-any.whl | Bin .../distlib-0.3.0-py2.py3-none-any.whl | Bin .../distro-1.4.0-py2.py3-none-any.whl | Bin .../html5lib-1.0.1-py2.py3-none-any.whl | Bin .../idna-2.8-py2.py3-none-any.whl | Bin .../ipaddr-2.2.0-py2.py3-none-any.whl | Bin .../lockfile-0.12.2-py2.py3-none-any.whl | Bin .../msgpack-0.6.2-py2.py3-none-any.whl | Bin .../packaging-20.3-py2.py3-none-any.whl | Bin .../pep517-0.8.2-py2.py3-none-any.whl | Bin .../pip-20.0.2-py2.py3-none-any.whl | Bin .../pkg_resources-0.0.0-py2.py3-none-any.whl | Bin .../progress-1.5-py2.py3-none-any.whl | Bin .../pyparsing-2.4.6-py2.py3-none-any.whl | Bin .../pytoml-0.1.21-py2.py3-none-any.whl | Bin .../requests-2.22.0-py2.py3-none-any.whl | Bin .../retrying-1.3.3-py2.py3-none-any.whl | Bin .../setuptools-44.0.0-py2.py3-none-any.whl | Bin .../six-1.14.0-py2.py3-none-any.whl | Bin .../urllib3-1.25.8-py2.py3-none-any.whl | Bin .../webencodings-0.5.1-py2.py3-none-any.whl | Bin .../wheel-0.34.2-py2.py3-none-any.whl | Bin .../microblog-23-api/migrations/README | 1 + .../microblog-23-api/migrations/alembic.ini | 45 ++++ .../microblog-23-api}/migrations/env.py | 0 .../migrations/script.py.mako | 24 ++ .../2b017edaa91f_add_language_to_posts.py | 0 .../37f06a334dbf_new_fields_in_user_model.py | 0 .../versions/780739b227a7_posts_table.py | 0 .../versions/834b1a697901_user_tokens.py | 0 .../versions/ae346256b650_followers.py | 0 .../migrations/versions/c81bac34faab_tasks.py | 0 .../versions/d049de007ccf_private_messages.py | 0 .../versions/e517276bb1c2_users_table.py | 0 .../versions/f7ac3d27bb1d_notifications.py | 0 .../microblog-23-api}/requirements.txt | 0 .../microblog-23-api}/tests.py | 0 microblog/microvenv/bin/Activate.ps1 | 241 ------------------ microblog/microvenv/bin/activate | 76 ------ microblog/microvenv/bin/activate.csh | 37 --- microblog/microvenv/bin/activate.fish | 75 ------ microblog/microvenv/bin/alembic | 12 - microblog/microvenv/bin/chardetect | 8 - microblog/microvenv/bin/dotenv | 8 - microblog/microvenv/bin/easy_install | 8 - microblog/microvenv/bin/easy_install-3.8 | 8 - microblog/microvenv/bin/email_validator | 8 - microblog/microvenv/bin/flask | 8 - microblog/microvenv/bin/mako-render | 12 - microblog/microvenv/bin/pip | 8 - microblog/microvenv/bin/pip3 | 8 - microblog/microvenv/bin/pip3.8 | 8 - microblog/microvenv/bin/pybabel | 8 - microblog/microvenv/bin/pyjwt | 8 - microblog/microvenv/bin/python | 1 - microblog/microvenv/bin/python3 | 1 - microblog/microvenv/bin/rq | 8 - microblog/microvenv/bin/rqinfo | 8 - microblog/microvenv/bin/rqworker | 8 - microblog/microvenv/lib64 | 1 - 157 files changed, 927 insertions(+), 569 deletions(-) rename {microblog => microblog-project/flask1}/.flaskenv (100%) rename {microblog => microblog-project/flask1}/.gitattributes (100%) rename {microblog => microblog-project/flask1}/.gitignore (100%) create mode 100644 microblog-project/flask1/.vscode/settings.json create mode 100644 microblog-project/flask1/CNAME.md rename {microblog => microblog-project/flask1}/LICENSE (100%) create mode 100644 microblog-project/flask1/README.md create mode 100644 microblog-project/flask1/app/__init__.py create mode 100644 microblog-project/flask1/app/errors.py create mode 100644 microblog-project/flask1/app/forms.py create mode 100644 microblog-project/flask1/app/models.py create mode 100644 microblog-project/flask1/app/routes.py create mode 100644 microblog-project/flask1/app/templates/404.html create mode 100644 microblog-project/flask1/app/templates/500.html create mode 100644 microblog-project/flask1/app/templates/_post.html create mode 100644 microblog-project/flask1/app/templates/_profile.html create mode 100644 microblog-project/flask1/app/templates/base.html create mode 100644 microblog-project/flask1/app/templates/index.html create mode 100644 microblog-project/flask1/app/templates/login.html create mode 100644 microblog-project/flask1/app/templates/user.html create mode 100644 microblog-project/flask1/config.py create mode 100644 microblog-project/flask1/microblog.py create mode 100644 microblog-project/flask1/microblog/pyvenv.cfg rename {microblog => microblog-project/flask1}/migrations/README (100%) mode change 100755 => 100644 rename {microblog => microblog-project/flask1}/migrations/alembic.ini (100%) create mode 100644 microblog-project/flask1/migrations/env.py rename {microblog => microblog-project/flask1}/migrations/script.py.mako (100%) mode change 100755 => 100644 create mode 100644 microblog-project/flask1/migrations/versions/76c86cb9832b_followers.py create mode 100644 microblog-project/flask1/migrations/versions/eb54505e6fb3_users_table.py create mode 100644 microblog-project/flask1/tests.py create mode 100644 microblog-project/microblog-23-api/.flaskenv create mode 100644 microblog-project/microblog-23-api/.gitattributes create mode 100644 microblog-project/microblog-23-api/.gitignore rename {microblog => microblog-project/microblog-23-api}/Dockerfile (100%) create mode 100644 microblog-project/microblog-23-api/LICENSE rename {microblog => microblog-project/microblog-23-api}/Procfile (100%) rename {microblog => microblog-project/microblog-23-api}/README.md (100%) rename {microblog => microblog-project/microblog-23-api}/Vagrantfile (100%) rename {microblog => microblog-project/microblog-23-api}/app/__init__.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/api/__init__.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/api/auth.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/api/errors.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/api/tokens.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/api/users.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/auth/__init__.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/auth/email.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/auth/forms.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/auth/routes.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/cli.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/email.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/errors/__init__.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/errors/handlers.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/main/__init__.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/main/forms.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/main/routes.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/models.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/search.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/static/loading.gif (100%) rename {microblog => microblog-project/microblog-23-api}/app/static/styles.css (100%) rename {microblog => microblog-project/microblog-23-api}/app/tasks.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/_post.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/auth/login.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/auth/register.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/auth/reset_password.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/auth/reset_password_request.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/base.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/edit_profile.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/email/export_posts.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/email/export_posts.txt (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/email/reset_password.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/email/reset_password.txt (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/errors/404.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/errors/500.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/hello.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/index.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/messages.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/search.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/send_message.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/user.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/templates/user_popup.html (100%) rename {microblog => microblog-project/microblog-23-api}/app/translate.py (100%) rename {microblog => microblog-project/microblog-23-api}/app/translations/es/LC_MESSAGES/messages.po (100%) rename {microblog => microblog-project/microblog-23-api}/babel.cfg (100%) rename {microblog => microblog-project/microblog-23-api}/boot.sh (100%) rename {microblog => microblog-project/microblog-23-api}/config.py (100%) rename {microblog => microblog-project/microblog-23-api}/deployment/nginx/microblog (100%) rename {microblog => microblog-project/microblog-23-api}/deployment/supervisor/microblog-tasks.conf (100%) rename {microblog => microblog-project/microblog-23-api}/deployment/supervisor/microblog.conf (100%) rename {microblog => microblog-project/microblog-23-api}/microblog.py (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/pyvenv.cfg (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/idna-2.8-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/packaging-20.3-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/progress-1.5-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/six-1.14.0-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl (100%) rename {microblog => microblog-project/microblog-23-api}/microvenv/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl (100%) create mode 100755 microblog-project/microblog-23-api/migrations/README create mode 100644 microblog-project/microblog-23-api/migrations/alembic.ini rename {microblog => microblog-project/microblog-23-api}/migrations/env.py (100%) create mode 100755 microblog-project/microblog-23-api/migrations/script.py.mako rename {microblog => microblog-project/microblog-23-api}/migrations/versions/2b017edaa91f_add_language_to_posts.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/37f06a334dbf_new_fields_in_user_model.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/780739b227a7_posts_table.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/834b1a697901_user_tokens.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/ae346256b650_followers.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/c81bac34faab_tasks.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/d049de007ccf_private_messages.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/e517276bb1c2_users_table.py (100%) rename {microblog => microblog-project/microblog-23-api}/migrations/versions/f7ac3d27bb1d_notifications.py (100%) rename {microblog => microblog-project/microblog-23-api}/requirements.txt (100%) rename {microblog => microblog-project/microblog-23-api}/tests.py (100%) delete mode 100644 microblog/microvenv/bin/Activate.ps1 delete mode 100644 microblog/microvenv/bin/activate delete mode 100644 microblog/microvenv/bin/activate.csh delete mode 100644 microblog/microvenv/bin/activate.fish delete mode 100755 microblog/microvenv/bin/alembic delete mode 100755 microblog/microvenv/bin/chardetect delete mode 100755 microblog/microvenv/bin/dotenv delete mode 100755 microblog/microvenv/bin/easy_install delete mode 100755 microblog/microvenv/bin/easy_install-3.8 delete mode 100755 microblog/microvenv/bin/email_validator delete mode 100755 microblog/microvenv/bin/flask delete mode 100755 microblog/microvenv/bin/mako-render delete mode 100755 microblog/microvenv/bin/pip delete mode 100755 microblog/microvenv/bin/pip3 delete mode 100755 microblog/microvenv/bin/pip3.8 delete mode 100755 microblog/microvenv/bin/pybabel delete mode 100755 microblog/microvenv/bin/pyjwt delete mode 120000 microblog/microvenv/bin/python delete mode 120000 microblog/microvenv/bin/python3 delete mode 100755 microblog/microvenv/bin/rq delete mode 100755 microblog/microvenv/bin/rqinfo delete mode 100755 microblog/microvenv/bin/rqworker delete mode 120000 microblog/microvenv/lib64 diff --git a/loginapp/main.py b/loginapp/main.py index c6af88b2b..1f1c8a943 100644 --- a/loginapp/main.py +++ b/loginapp/main.py @@ -56,4 +56,4 @@ def uploadme(): @main.route('/profile') @login_required def profile(): - return render_template('profile.html', name=current_user.name) \ No newline at end of file + return render_template('profile.html', name=current_user.name) \ No newline at end of file diff --git a/loginapp/templates/upload.html b/loginapp/templates/upload.html index 18e8c2678..67bbbf258 100644 --- a/loginapp/templates/upload.html +++ b/loginapp/templates/upload.html @@ -17,6 +17,9 @@

Select file to upload

+

+ +

diff --git a/microblog/.flaskenv b/microblog-project/flask1/.flaskenv similarity index 100% rename from microblog/.flaskenv rename to microblog-project/flask1/.flaskenv diff --git a/microblog/.gitattributes b/microblog-project/flask1/.gitattributes similarity index 100% rename from microblog/.gitattributes rename to microblog-project/flask1/.gitattributes diff --git a/microblog/.gitignore b/microblog-project/flask1/.gitignore similarity index 100% rename from microblog/.gitignore rename to microblog-project/flask1/.gitignore diff --git a/microblog-project/flask1/.vscode/settings.json b/microblog-project/flask1/.vscode/settings.json new file mode 100644 index 000000000..7709bc616 --- /dev/null +++ b/microblog-project/flask1/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "jira-plugin.workingProject": "" +} \ No newline at end of file diff --git a/microblog-project/flask1/CNAME.md b/microblog-project/flask1/CNAME.md new file mode 100644 index 000000000..f2f4222a9 --- /dev/null +++ b/microblog-project/flask1/CNAME.md @@ -0,0 +1 @@ +flask.skinetics.tech diff --git a/microblog/LICENSE b/microblog-project/flask1/LICENSE similarity index 100% rename from microblog/LICENSE rename to microblog-project/flask1/LICENSE diff --git a/microblog-project/flask1/README.md b/microblog-project/flask1/README.md new file mode 100644 index 000000000..6d4b587b1 --- /dev/null +++ b/microblog-project/flask1/README.md @@ -0,0 +1,20 @@ +# flask1 +Flask web app testing - with user authentication and front end posting + +[ParentRepo](https://github.com/acord-robotics/datascience) + +List of python libraries: +* Flask +* Flask-wtf +* Flask-migrate +* Flask-sqlalchemy +* Flask-login + +E.g. +``` +pip install flask +``` + +# Commit reference guide +* GHC = Github Codespaces +* Venv = `root/microblog` (in root, or main/parent directory) - virtual environment with the above libraries installed \ No newline at end of file diff --git a/microblog-project/flask1/app/__init__.py b/microblog-project/flask1/app/__init__.py new file mode 100644 index 000000000..92c769114 --- /dev/null +++ b/microblog-project/flask1/app/__init__.py @@ -0,0 +1,44 @@ +import logging +from logging.handlers import SMTPHandler, RotatingFileHandler +import os +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from flask_migrate import Migrate +from flask_login import LoginManager +from config import Config +#from app import routes, models, errors + +app = Flask(__name__) +app.config.from_object(Config) +db = SQLAlchemy(app) +migrate = Migrate(app, db) +login = LoginManager(app) +login.login_view = 'login' + +if not app.debug: # Only enable the email logger when the app is running without debug mode + if app.config['MAIL_SERVER']: + auth = None + if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']: + auth = (app.config['MAIL_USERNAME'], app/config['MAIL_PASSWORD']) + secure = None + if app.config['MAIL_USE_TLS']: + secure = () + mail_handler = SMTPHandler( + mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), + fromaddr='no-reply@' + app.config['MAIL_SERVER'], + toaddrs=app.config['ADMINS'], subject='Microblog Failure', + credentials=auth, secure=secure) + mail_handler.setLevel(logging.ERROR) + app.logger.addHandler(mail_handler) + + if not os.path.exists('logs'): + os.mkdir('logs') # create logs directory if it doesn't exist using os library + file_handler = RotatingFileHandler('logs/microblog.log', maxBytes=10240, + backupCount=10) + file_handler.setFormatter(logging.Formatter( + '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) + file_handler.setLevel(logging.INFO) + app.logger.addHandler(file_handler) + + app.logger.setLevel(logging.INFO) + app.logger.info('Microblog startup') \ No newline at end of file diff --git a/microblog-project/flask1/app/errors.py b/microblog-project/flask1/app/errors.py new file mode 100644 index 000000000..1fa9df992 --- /dev/null +++ b/microblog-project/flask1/app/errors.py @@ -0,0 +1,11 @@ +from flask import render_template +from app import app, db + +@app.errorhandler(404) +def not_found_error(error): + return render_template('404.html'), 404 + +@app.errorhandler(500) +def internal_error(error): + db.session.rollback() + return render_template('500.html'), 500 \ No newline at end of file diff --git a/microblog-project/flask1/app/forms.py b/microblog-project/flask1/app/forms.py new file mode 100644 index 000000000..5ec161da9 --- /dev/null +++ b/microblog-project/flask1/app/forms.py @@ -0,0 +1,36 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, PasswordField, BooleanField, SubmitField +from wtforms.validators import DataRequired, Length +from wtforms import StringField, TextAreaField, SubmitField + + +class LoginForm(FlaskForm): + username = StringField('Username', validators=[DataRequired()]) + password = PasswordField('Password', validators=[DataRequired()]) + remember_me = BooleanField('Remember Me') + submit = SubmitField('Sign In') + +class EditProfileForm(FlaskForm): + username = StringField('Username', validators=[DataRequired()]) + about_me = TextAreaField('About me', validators=[Length(min=0, max=140)]) + submit = SubmitField('Submit') + + def __init__(self, original_username, *args, **kwargs): + super(EditProfileForm, self).__init__(*args, **kwargs) + self.original_username = original_username + + def validate_username(self, username): + if username.data != self.original_username: + user = User.query.filter_by(username=self.username.data).first() + if user is not None: + raise ValidationError('Please use a different username') + +# Integrating Followers with the Application - Part 8 +class EmptyForm(FlaskForm): + submit = SubmitField('Submit') + +# allow users to make their own posts +class PostForm(FlaskForm): + post = TextAreaField('Say something', validators=[ + DataRequired(), Length(min=1, max=140]) # The form must be completed with content and the length has to be within 1-140 characters + submit = SubmitField('Submit') # button labelled submit that links to db.commit() \ No newline at end of file diff --git a/microblog-project/flask1/app/models.py b/microblog-project/flask1/app/models.py new file mode 100644 index 000000000..a23c0ad9a --- /dev/null +++ b/microblog-project/flask1/app/models.py @@ -0,0 +1,76 @@ +from datetime import datetime +from hashlib import md5 +from app import db, login +from flask_login import UserMixin +from werkzeug.security import generate_password_hash, check_password_hash + + +followers = db.Table( + 'followers', + db.Column('follower_id', db.Integer, db.ForeignKey('user.id')), + db.Column('followed_id', db.Integer, db.ForeignKey('user.id')) +) + + +class User(UserMixin, db.Model): + id = db.Column(db.Integer, primary_key=True) + username = db.Column(db.String(64), index=True, unique=True) + email = db.Column(db.String(120), index=True, unique=True) + password_hash = db.Column(db.String(128)) + posts = db.relationship('Post', backref='author', lazy='dynamic') + about_me = db.Column(db.String(140)) + last_seen = db.Column(db.DateTime, default=datetime.utcnow) + followed = db.relationship( + 'User', secondary=followers, + primaryjoin=(followers.c.follower_id == id), + secondaryjoin=(followers.c.followed_id == id), + backref=db.backref('followers', lazy='dynamic'), lazy='dynamic') + + def __repr__(self): + return ''.format(self.username) + + def set_password(self, password): + self.password_hash = generate_password_hash(password) + + def check_password(self, password): + return check_password_hash(self.password_hash, password) + + def avatar(self, size): # new function (class method) of the user class + digest = md5(self.email.lower().encode('utf-8')).hexdigest() + return 'https://www.gravatar.com/avatar/{}?d=identicon&s={}'.format( # return the url of the user's Gravatar + digest, size # generates an identicon for users without a gravatar + ) + + def follow(self, user): + if not self.is_following(user): + self.followed.append(user) + + def unfollow(self, user): + if self.is_following(user): + self.followed.remove(user) + + def is_following(self, user): + return self.followed.filter( + followers.c.followed_id == user.id).count() > 0 + + def followed_posts(self): + return Post.query.join( + followers, (followers.c.followed_id == Post.user_id)).filter( + followers.c.follower_id == self.id).order_by( + Post.timestamp.desc()) + own = Post.query.filter_by(user_id=self.id) # show the user's posts in their feed + return followed.union(own).order_by(Post.timestamp.desc()) + + +class Post(db.Model): + id = db.Column(db.Integer, primary_key=True) + body = db.Column(db.String(140)) + timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) + user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + + def __repr__(self): + return ''.format(self.body) + +@login.user_loader +def load_user(id): + return User.query.get(int(id)) \ No newline at end of file diff --git a/microblog-project/flask1/app/routes.py b/microblog-project/flask1/app/routes.py new file mode 100644 index 000000000..5cac23f73 --- /dev/null +++ b/microblog-project/flask1/app/routes.py @@ -0,0 +1,147 @@ +from flask import render_template, flash, redirect, url_for +from app import app +from app.forms import LoginForm +from flask_login import login_user, logout_user, current_user, login_required +from flask_login import logout_user +from app.models import User +from datetime import datetime +from app.forms import EditProfileForm +from app.forms import EmptyForm # note that since the tutorial is open-source we can always just copy the code from that if we ever have any really big questions. Base/core understanding is still there +from app.forms import PostForm +from app.models import Post + +@app.before_request +def before_request(): + if current_user.is_authenticated: + current_user.last_seen = datetime.utcnow() + db.session.commit() + +@app.route('/', methods=['GET', 'POST']) +@app.route('/index', methods=['GET', 'POST']) +@login_required +def index(): + form = PostForm() + if form.validate_on_submit(): + post = Post(body=form.post.data, author=current_user) # create a post variable if the form has been submitted, and then add it to the db: + db.session.add(post) + db.session.commit() + flash('Your post is now live!') + return redirect(url_for('index')) + page = request.args.get('page', 1, type=int) + posts = current_user.followed_posts().paginate( + page, app.config['POSTS_PER_PAGE'], False) + next_url = url_for('index', page=posts.next_num) \ + if posts.has_next else None + prev_url = url_for('index', page=posts.prev_num) \ + if posts.has_prev else None + return render_template('index.html', title='Home', form=form, + posts=posts.items, next_url=next_url, + prev_url=prev_url) + + +@app.route('/login', methods=['GET', 'POST']) +def login(): + if current_user.is_authenticated: + return redirect(url_for('index')) + if form.validate_on_submit(): + user = User.query.filter_by(username=form.username.data).first() + if user is None or not user.check_password(form.password.data): + flash('Invalid username or password') + return redirect(url_for('login')) + login_user(user, remember=form.remember_me.data) + next_page = request.args.get('next') + if not next_page or url_parse(next_page).netloc != '': + next_page = url_for('index') + return redirect(next_page) + return render_template('login.html', title='Sign In', form=form) + +@app.route('/logout') +def logout(): + logout_user() + return redirect(url_for('index')) + +@app.route('/user/') +@login_required +def user(username): + user = User.query.filter_by(username=username).first_or_404() + page = request.args.get('page', 1, type=int) + posts = user.posts.order_by(Post.timestamp.desc()).paginate( + page, app.config['POSTS_PER_PAGE'], False) + next_url = url_for('user', username=user.username, page=posts.next_num) \ + if posts.has_next else None + prev_url = url_for('user', username=user.username, page=posts.prev_num) \ + if posts.has_prev else None + form = EmptyForm() + return render_template('user.html', user=user, posts=posts.items, + next_url=next_url, prev_url=prev_url, form=form) + +@app.route('/edit_profile') +@login_required +def edit_profile(): + form = EditProfileForm(current_user.username) + if form.validate_on_submit(): + current_user.username = form.username.data + current_user.about_me = form.about_me.data + db.session.commit() + flash('Your changes have been saved') + return redirect(url_for('edit_profile')) + elif request.method == 'GET': + form.username.data = current_user.username + form.about_me.data = current_user.about_me + return render_template('edit_profile.html', title='Edit Profile', + form=form) + +# Integrate followers and create a follow page +# ALlow a user to follow another user +@app.route('/follow/', methods=['POST']) # Post result of a form which is to follow a user from another user +@login_required +def follow(username): + form = EmptyForm() + if form.validate_on_submit(): + user = User.query.filter_by(username=username).first() # the user that the account page belongs to, not the logged in user + if user is None: # If the user that the logged in user is trying to follow doesn't exist + flash('user {} not found.'.format(username)) + return redirect(url_for('index')) + if user == current_user: # if the account page's user is the same as the logged in user (l.i.u = current_user) + flash('You cannot follow yourself!') + return redirect(url_for('user', username=username)) + current_user.follow(user) # use the user's "follow" function to follow the user who owns the current page + db.session.commit() # add this latest development/update to the database + flash('You are following {}!'.format(username)) + return redirect(url_for('user', username=username)) + else: + return redirect(url_for('index')) + return render_template('user.html', user=user, posts=posts, form=form) +# Allow a user to unfollow another user +@app.route('/unfollow/', methods=['POST']) +@login_required +def unfollow(username): + form = EmptyForm() + if form.validate_on_submit(): + user = User.query.filter_by(username=username).first() + if user is None: + flash('User {} not found.'.format(username)) + return redirect(url_for('index')) + if user == current_user: + flash('You cannot unfollow yourself!') + return redirect(url_for('user', username=username)) + current_user.unfollow(user) + db.session.commit() + flash('You are not following {}.'.format(username)) + return redirect(url_for('user', username=username)) + else: + return redirect(url_for('index')) + +# Explore page, shows a global post stream from all users to make it easier to find other accounts +@app.route('/explore') +@login_required +def explore(): + page = request.args.get('page', 1, type=int) + posts = Post.query.order_by(Post.timestamp.desc()).paginate( + page, app.config['POSTS_PER_PAGE'], False) + next_url = url_for('explore', page=posts.next_num) \ + if posts.has_next else None + prev_url = url_for('explore', page=posts.prev_num) \ + if posts.has_prev else None + return render_template("index.html", title='Explore', posts=posts.items, + next_url=next_url, prev_url=prev_url) \ No newline at end of file diff --git a/microblog-project/flask1/app/templates/404.html b/microblog-project/flask1/app/templates/404.html new file mode 100644 index 000000000..bdaaef31d --- /dev/null +++ b/microblog-project/flask1/app/templates/404.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block content %} +

File Not Found

+

Back

+{% endblock %} \ No newline at end of file diff --git a/microblog-project/flask1/app/templates/500.html b/microblog-project/flask1/app/templates/500.html new file mode 100644 index 000000000..d641ad244 --- /dev/null +++ b/microblog-project/flask1/app/templates/500.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} +

An unexpected error has occured

+

The administrator has been notified. Sorry for the inconvenience!

+

Back

+{% endblock %} \ No newline at end of file diff --git a/microblog-project/flask1/app/templates/_post.html b/microblog-project/flask1/app/templates/_post.html new file mode 100644 index 000000000..4e326a95b --- /dev/null +++ b/microblog-project/flask1/app/templates/_post.html @@ -0,0 +1,11 @@ + + + + + +
+ + {{ post.author.username }} + + says:
{{ post.body }} +
diff --git a/microblog-project/flask1/app/templates/_profile.html b/microblog-project/flask1/app/templates/_profile.html new file mode 100644 index 000000000..3d4cea226 --- /dev/null +++ b/microblog-project/flask1/app/templates/_profile.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} + +{% block content %} +

Edit Profile

+
+ {{ form.hidden_tag() }} +

+ {{ form.username.label }}
+ {{ form.username(size=32) }}
+ {% for error in form.username.errors %} + [{{ error }}] + {% endfor %} +

+

+ {{ form.about_me.label }}
+ {{ form.about_me(cols=50, rows=4) }}
+ {% for error in form.about_me.errors %} + [{{ error }}] + {% endfor %} +

+

{{ form.submit() }}

+
+{% endblock %} \ No newline at end of file diff --git a/microblog-project/flask1/app/templates/base.html b/microblog-project/flask1/app/templates/base.html new file mode 100644 index 000000000..026c6273b --- /dev/null +++ b/microblog-project/flask1/app/templates/base.html @@ -0,0 +1,33 @@ + + + {% if title %} + {{ title }} - Microblog + {% else %} + Welcome to Microblog + {% endif %} + + +
+ Microblog: + Home + {% if current_user.is_anonymous %} + Login + {% else %} + Profile + Logout + Explore + {% endif %} +
+
+ {% with messages = get_flashed_messages() %} + {% if messages %} + + {% endif %} + {% endwith %} + {% block content %}{% endblock %} + + diff --git a/microblog-project/flask1/app/templates/index.html b/microblog-project/flask1/app/templates/index.html new file mode 100644 index 000000000..cf4f8052d --- /dev/null +++ b/microblog-project/flask1/app/templates/index.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} + +{% block content %} +

Hi, {{ current_user.username }}!

+ {% if form %} +
+ {{ form.hidden_tag() }} +

+ {{ form.post.label }}
+ {{ form.post(cols=32, rows=4) }}
+ {% for error in form.post.errors %} + [{{ error }}] + {% endfor %} +

+

{{ form.submit() }}

+
+ {% endif %} + {% for post in posts %} + {% include '_post.html' %} + {% endfor %} + {% if prev_url %} + Newer posts + {% endif %} + {% if next_url %} + Older posts + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/microblog-project/flask1/app/templates/login.html b/microblog-project/flask1/app/templates/login.html new file mode 100644 index 000000000..806e09a6a --- /dev/null +++ b/microblog-project/flask1/app/templates/login.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block content %} +

Sign In

+
+ {{ form.hidden_tag() }} +

+ {{ form.username.label }}
+ {{ form.username(size=32) }}
+ {% for error in form.username.errors %} + [{{ error }}] + {% endfor %} +

+

+ {{ form.password.label }}
+ {{ form.password(size=32) }}
+ {% for error in form.password.errors %} + [{{ error }}] + {% endfor %} +

+

{{ form.remember_me() }} {{ form.remember_me.label }}

+

{{ form.submit() }}

+
+{% endblock %} diff --git a/microblog-project/flask1/app/templates/user.html b/microblog-project/flask1/app/templates/user.html new file mode 100644 index 000000000..3ab2bdbaa --- /dev/null +++ b/microblog-project/flask1/app/templates/user.html @@ -0,0 +1,25 @@ +{% extends "base.html" %} + +{% block content %} +

Hi, {{ current_user.username }}!

+
+ {{ form.hidden_tag() }} +

+ {{ form.post.label }}
+ {{ form.post(cols=32, rows=4) }}
+ {% for error in form.post.errors %} + [{{ error }}] + {% endfor %} +

+

{{ form.submit() }}

+
+ {% for post in posts %} + {% include '_post.html' %} + {% endfor %} + {% if prev_url %} + Newer posts + {% endif %} + {% if next_url %} + Older posts + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/microblog-project/flask1/config.py b/microblog-project/flask1/config.py new file mode 100644 index 000000000..b3cd65175 --- /dev/null +++ b/microblog-project/flask1/config.py @@ -0,0 +1,16 @@ +import os +basedir = os.path.abspath(os.path.dirname(__file__)) + + +class Config(object): + SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess' + SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \ + 'sqlite:///' + os.path.join(basedir, 'app.db') + SQLALCHEMY_TRACK_MODIFICATIONS = False + MAIL_SERVER = os.environ.get('MAIL_SERVER') + MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25) + MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None + MAIL_USERNAME = os.environ.get('MAIL_USERNAME') + MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') + ADMINS = ['liam@skinetics.tech'] + POSTS_PER_PAGE = 25 \ No newline at end of file diff --git a/microblog-project/flask1/microblog.py b/microblog-project/flask1/microblog.py new file mode 100644 index 000000000..a96ac1664 --- /dev/null +++ b/microblog-project/flask1/microblog.py @@ -0,0 +1,7 @@ +from app import app, db +from app.models import User, Post + + +@app.shell_context_processor +def make_shell_context(): + return {'db': db, 'User': User, 'Post': Post} \ No newline at end of file diff --git a/microblog-project/flask1/microblog/pyvenv.cfg b/microblog-project/flask1/microblog/pyvenv.cfg new file mode 100644 index 000000000..d2988223d --- /dev/null +++ b/microblog-project/flask1/microblog/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /opt/python/latest/bin +include-system-site-packages = false +version = 3.8.6 diff --git a/microblog/migrations/README b/microblog-project/flask1/migrations/README old mode 100755 new mode 100644 similarity index 100% rename from microblog/migrations/README rename to microblog-project/flask1/migrations/README diff --git a/microblog/migrations/alembic.ini b/microblog-project/flask1/migrations/alembic.ini similarity index 100% rename from microblog/migrations/alembic.ini rename to microblog-project/flask1/migrations/alembic.ini diff --git a/microblog-project/flask1/migrations/env.py b/microblog-project/flask1/migrations/env.py new file mode 100644 index 000000000..8b3fb3353 --- /dev/null +++ b/microblog-project/flask1/migrations/env.py @@ -0,0 +1,96 @@ +from __future__ import with_statement + +import logging +from logging.config import fileConfig + +from sqlalchemy import engine_from_config +from sqlalchemy import pool +from flask import current_app + +from alembic import context + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) +logger = logging.getLogger('alembic.env') + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +config.set_main_option( + 'sqlalchemy.url', + str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%')) +target_metadata = current_app.extensions['migrate'].db.metadata + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure( + url=url, target_metadata=target_metadata, literal_binds=True + ) + + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + + # this callback is used to prevent an auto-migration from being generated + # when there are no changes to the schema + # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html + def process_revision_directives(context, revision, directives): + if getattr(config.cmd_opts, 'autogenerate', False): + script = directives[0] + if script.upgrade_ops.is_empty(): + directives[:] = [] + logger.info('No changes in schema detected.') + + connectable = engine_from_config( + config.get_section(config.config_ini_section), + prefix='sqlalchemy.', + poolclass=pool.NullPool, + ) + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=target_metadata, + process_revision_directives=process_revision_directives, + **current_app.extensions['migrate'].configure_args + ) + + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/microblog/migrations/script.py.mako b/microblog-project/flask1/migrations/script.py.mako old mode 100755 new mode 100644 similarity index 100% rename from microblog/migrations/script.py.mako rename to microblog-project/flask1/migrations/script.py.mako diff --git a/microblog-project/flask1/migrations/versions/76c86cb9832b_followers.py b/microblog-project/flask1/migrations/versions/76c86cb9832b_followers.py new file mode 100644 index 000000000..67a4bcb2e --- /dev/null +++ b/microblog-project/flask1/migrations/versions/76c86cb9832b_followers.py @@ -0,0 +1,33 @@ +"""followers + +Revision ID: 76c86cb9832b +Revises: eb54505e6fb3 +Create Date: 2021-02-16 02:07:28.243603 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '76c86cb9832b' +down_revision = 'eb54505e6fb3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('followers', + sa.Column('follower_id', sa.Integer(), nullable=True), + sa.Column('followed_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['followed_id'], ['user.id'], ), + sa.ForeignKeyConstraint(['follower_id'], ['user.id'], ) + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('followers') + # ### end Alembic commands ### diff --git a/microblog-project/flask1/migrations/versions/eb54505e6fb3_users_table.py b/microblog-project/flask1/migrations/versions/eb54505e6fb3_users_table.py new file mode 100644 index 000000000..7fac0b74f --- /dev/null +++ b/microblog-project/flask1/migrations/versions/eb54505e6fb3_users_table.py @@ -0,0 +1,51 @@ +"""users table + +Revision ID: eb54505e6fb3 +Revises: +Create Date: 2021-02-14 04:08:38.638686 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'eb54505e6fb3' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('user', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('username', sa.String(length=64), nullable=True), + sa.Column('email', sa.String(length=120), nullable=True), + sa.Column('password_hash', sa.String(length=128), nullable=True), + sa.Column('about_me', sa.String(length=140), nullable=True), + sa.Column('last_seen', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True) + op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True) + op.create_table('post', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('body', sa.String(length=140), nullable=True), + sa.Column('timestamp', sa.DateTime(), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_post_timestamp'), 'post', ['timestamp'], unique=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_post_timestamp'), table_name='post') + op.drop_table('post') + op.drop_index(op.f('ix_user_username'), table_name='user') + op.drop_index(op.f('ix_user_email'), table_name='user') + op.drop_table('user') + # ### end Alembic commands ### diff --git a/microblog-project/flask1/tests.py b/microblog-project/flask1/tests.py new file mode 100644 index 000000000..8afaf88c1 --- /dev/null +++ b/microblog-project/flask1/tests.py @@ -0,0 +1,89 @@ +from datetime import datetime, timedelta +import unittest +from app import app, db +from app.models import User, Post + +class UserModelCase(unittest.TestCase): + def setUp(self): + app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' + db.create_all() + + def tearDown(self): + db.session.remove() + db.drop_all() + + def test_password_hashing(self): + u = User(username='susan') + u.set_password('cat') + self.assertFalse(u.check_password('dog')) + self.assertTrue(u.check_password('cat')) + + def test_avatar(self): + u = User(username='john', email='john@example.com') + self.assertEqual(u.avatar(128), ('https://www.gravatar.com/avatar/' + 'd4c74594d841139328695756648b6bd6' + '?d=identicon&s=128')) + + def test_follow(self): + u1 = User(username='john', email='john@example.com') + u2 = User(username='susan', email='susan@example.com') + db.session.add(u1) + db.session.add(u2) + db.session.commit() + self.assertEqual(u1.followed.all(), []) + self.assertEqual(u1.followers.all(), []) + + u1.follow(u2) + db.session.commit() + self.assertTrue(u1.is_following(u2)) + self.assertEqual(u1.followed.count(), 1) + self.assertEqual(u1.followed.first().username, 'susan') + self.assertEqual(u2.followers.count(), 1) + self.assertEqual(u2.followers.first().username, 'john') + + u1.unfollow(u2) + db.session.commit() + self.assertFalse(u1.is_following(u2)) + self.assertEqual(u1.followed.count(), 0) + self.assertEqual(u2.followers.count(), 0) + + def test_follow_posts(self): + # create four users + u1 = User(username='john', email='john@example.com') + u2 = User(username='susan', email='susan@example.com') + u3 = User(username='mary', email='mary@example.com') + u4 = User(username='david', email='david@example.com') + db.session.add_all([u1, u2, u3, u4]) + + # create four posts + now = datetime.utcnow() + p1 = Post(body="post from john", author=u1, + timestamp=now + timedelta(seconds=1)) + p2 = Post(body="post from susan", author=u2, + timestamp=now + timedelta(seconds=4)) + p3 = Post(body="post from mary", author=u3, + timestamp=now + timedelta(seconds=3)) + p4 = Post(body="post from david", author=u4, + timestamp=now + timedelta(seconds=2)) + db.session.add_all([p1, p2, p3, p4]) + db.session.commit() + + # setup the followers + u1.follow(u2) # john follows susan + u1.follow(u4) # john follows david + u2.follow(u3) # susan follows mary + u3.follow(u4) # mary follows david + db.session.commit() + + # check the followed posts of each user + f1 = u1.followed_posts().all() + f2 = u2.followed_posts().all() + f3 = u3.followed_posts().all() + f4 = u4.followed_posts().all() + self.assertEqual(f1, [p2, p4, p1]) + self.assertEqual(f2, [p2, p3]) + self.assertEqual(f3, [p3, p4]) + self.assertEqual(f4, [p4]) + +if __name__ == '__main__': + unittest.main(verbosity=2) \ No newline at end of file diff --git a/microblog-project/microblog-23-api/.flaskenv b/microblog-project/microblog-23-api/.flaskenv new file mode 100644 index 000000000..6006c26dc --- /dev/null +++ b/microblog-project/microblog-23-api/.flaskenv @@ -0,0 +1 @@ +FLASK_APP=microblog.py diff --git a/microblog-project/microblog-23-api/.gitattributes b/microblog-project/microblog-23-api/.gitattributes new file mode 100644 index 000000000..efdba8764 --- /dev/null +++ b/microblog-project/microblog-23-api/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.sh text eol=lf diff --git a/microblog-project/microblog-23-api/.gitignore b/microblog-project/microblog-23-api/.gitignore new file mode 100644 index 000000000..1e4f83607 --- /dev/null +++ b/microblog-project/microblog-23-api/.gitignore @@ -0,0 +1,40 @@ +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +__pycache__ + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +venv +app.db +microblog.log* diff --git a/microblog/Dockerfile b/microblog-project/microblog-23-api/Dockerfile similarity index 100% rename from microblog/Dockerfile rename to microblog-project/microblog-23-api/Dockerfile diff --git a/microblog-project/microblog-23-api/LICENSE b/microblog-project/microblog-23-api/LICENSE new file mode 100644 index 000000000..62e77cb45 --- /dev/null +++ b/microblog-project/microblog-23-api/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Miguel Grinberg + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/microblog/Procfile b/microblog-project/microblog-23-api/Procfile similarity index 100% rename from microblog/Procfile rename to microblog-project/microblog-23-api/Procfile diff --git a/microblog/README.md b/microblog-project/microblog-23-api/README.md similarity index 100% rename from microblog/README.md rename to microblog-project/microblog-23-api/README.md diff --git a/microblog/Vagrantfile b/microblog-project/microblog-23-api/Vagrantfile similarity index 100% rename from microblog/Vagrantfile rename to microblog-project/microblog-23-api/Vagrantfile diff --git a/microblog/app/__init__.py b/microblog-project/microblog-23-api/app/__init__.py similarity index 100% rename from microblog/app/__init__.py rename to microblog-project/microblog-23-api/app/__init__.py diff --git a/microblog/app/api/__init__.py b/microblog-project/microblog-23-api/app/api/__init__.py similarity index 100% rename from microblog/app/api/__init__.py rename to microblog-project/microblog-23-api/app/api/__init__.py diff --git a/microblog/app/api/auth.py b/microblog-project/microblog-23-api/app/api/auth.py similarity index 100% rename from microblog/app/api/auth.py rename to microblog-project/microblog-23-api/app/api/auth.py diff --git a/microblog/app/api/errors.py b/microblog-project/microblog-23-api/app/api/errors.py similarity index 100% rename from microblog/app/api/errors.py rename to microblog-project/microblog-23-api/app/api/errors.py diff --git a/microblog/app/api/tokens.py b/microblog-project/microblog-23-api/app/api/tokens.py similarity index 100% rename from microblog/app/api/tokens.py rename to microblog-project/microblog-23-api/app/api/tokens.py diff --git a/microblog/app/api/users.py b/microblog-project/microblog-23-api/app/api/users.py similarity index 100% rename from microblog/app/api/users.py rename to microblog-project/microblog-23-api/app/api/users.py diff --git a/microblog/app/auth/__init__.py b/microblog-project/microblog-23-api/app/auth/__init__.py similarity index 100% rename from microblog/app/auth/__init__.py rename to microblog-project/microblog-23-api/app/auth/__init__.py diff --git a/microblog/app/auth/email.py b/microblog-project/microblog-23-api/app/auth/email.py similarity index 100% rename from microblog/app/auth/email.py rename to microblog-project/microblog-23-api/app/auth/email.py diff --git a/microblog/app/auth/forms.py b/microblog-project/microblog-23-api/app/auth/forms.py similarity index 100% rename from microblog/app/auth/forms.py rename to microblog-project/microblog-23-api/app/auth/forms.py diff --git a/microblog/app/auth/routes.py b/microblog-project/microblog-23-api/app/auth/routes.py similarity index 100% rename from microblog/app/auth/routes.py rename to microblog-project/microblog-23-api/app/auth/routes.py diff --git a/microblog/app/cli.py b/microblog-project/microblog-23-api/app/cli.py similarity index 100% rename from microblog/app/cli.py rename to microblog-project/microblog-23-api/app/cli.py diff --git a/microblog/app/email.py b/microblog-project/microblog-23-api/app/email.py similarity index 100% rename from microblog/app/email.py rename to microblog-project/microblog-23-api/app/email.py diff --git a/microblog/app/errors/__init__.py b/microblog-project/microblog-23-api/app/errors/__init__.py similarity index 100% rename from microblog/app/errors/__init__.py rename to microblog-project/microblog-23-api/app/errors/__init__.py diff --git a/microblog/app/errors/handlers.py b/microblog-project/microblog-23-api/app/errors/handlers.py similarity index 100% rename from microblog/app/errors/handlers.py rename to microblog-project/microblog-23-api/app/errors/handlers.py diff --git a/microblog/app/main/__init__.py b/microblog-project/microblog-23-api/app/main/__init__.py similarity index 100% rename from microblog/app/main/__init__.py rename to microblog-project/microblog-23-api/app/main/__init__.py diff --git a/microblog/app/main/forms.py b/microblog-project/microblog-23-api/app/main/forms.py similarity index 100% rename from microblog/app/main/forms.py rename to microblog-project/microblog-23-api/app/main/forms.py diff --git a/microblog/app/main/routes.py b/microblog-project/microblog-23-api/app/main/routes.py similarity index 100% rename from microblog/app/main/routes.py rename to microblog-project/microblog-23-api/app/main/routes.py diff --git a/microblog/app/models.py b/microblog-project/microblog-23-api/app/models.py similarity index 100% rename from microblog/app/models.py rename to microblog-project/microblog-23-api/app/models.py diff --git a/microblog/app/search.py b/microblog-project/microblog-23-api/app/search.py similarity index 100% rename from microblog/app/search.py rename to microblog-project/microblog-23-api/app/search.py diff --git a/microblog/app/static/loading.gif b/microblog-project/microblog-23-api/app/static/loading.gif similarity index 100% rename from microblog/app/static/loading.gif rename to microblog-project/microblog-23-api/app/static/loading.gif diff --git a/microblog/app/static/styles.css b/microblog-project/microblog-23-api/app/static/styles.css similarity index 100% rename from microblog/app/static/styles.css rename to microblog-project/microblog-23-api/app/static/styles.css diff --git a/microblog/app/tasks.py b/microblog-project/microblog-23-api/app/tasks.py similarity index 100% rename from microblog/app/tasks.py rename to microblog-project/microblog-23-api/app/tasks.py diff --git a/microblog/app/templates/_post.html b/microblog-project/microblog-23-api/app/templates/_post.html similarity index 100% rename from microblog/app/templates/_post.html rename to microblog-project/microblog-23-api/app/templates/_post.html diff --git a/microblog/app/templates/auth/login.html b/microblog-project/microblog-23-api/app/templates/auth/login.html similarity index 100% rename from microblog/app/templates/auth/login.html rename to microblog-project/microblog-23-api/app/templates/auth/login.html diff --git a/microblog/app/templates/auth/register.html b/microblog-project/microblog-23-api/app/templates/auth/register.html similarity index 100% rename from microblog/app/templates/auth/register.html rename to microblog-project/microblog-23-api/app/templates/auth/register.html diff --git a/microblog/app/templates/auth/reset_password.html b/microblog-project/microblog-23-api/app/templates/auth/reset_password.html similarity index 100% rename from microblog/app/templates/auth/reset_password.html rename to microblog-project/microblog-23-api/app/templates/auth/reset_password.html diff --git a/microblog/app/templates/auth/reset_password_request.html b/microblog-project/microblog-23-api/app/templates/auth/reset_password_request.html similarity index 100% rename from microblog/app/templates/auth/reset_password_request.html rename to microblog-project/microblog-23-api/app/templates/auth/reset_password_request.html diff --git a/microblog/app/templates/base.html b/microblog-project/microblog-23-api/app/templates/base.html similarity index 100% rename from microblog/app/templates/base.html rename to microblog-project/microblog-23-api/app/templates/base.html diff --git a/microblog/app/templates/edit_profile.html b/microblog-project/microblog-23-api/app/templates/edit_profile.html similarity index 100% rename from microblog/app/templates/edit_profile.html rename to microblog-project/microblog-23-api/app/templates/edit_profile.html diff --git a/microblog/app/templates/email/export_posts.html b/microblog-project/microblog-23-api/app/templates/email/export_posts.html similarity index 100% rename from microblog/app/templates/email/export_posts.html rename to microblog-project/microblog-23-api/app/templates/email/export_posts.html diff --git a/microblog/app/templates/email/export_posts.txt b/microblog-project/microblog-23-api/app/templates/email/export_posts.txt similarity index 100% rename from microblog/app/templates/email/export_posts.txt rename to microblog-project/microblog-23-api/app/templates/email/export_posts.txt diff --git a/microblog/app/templates/email/reset_password.html b/microblog-project/microblog-23-api/app/templates/email/reset_password.html similarity index 100% rename from microblog/app/templates/email/reset_password.html rename to microblog-project/microblog-23-api/app/templates/email/reset_password.html diff --git a/microblog/app/templates/email/reset_password.txt b/microblog-project/microblog-23-api/app/templates/email/reset_password.txt similarity index 100% rename from microblog/app/templates/email/reset_password.txt rename to microblog-project/microblog-23-api/app/templates/email/reset_password.txt diff --git a/microblog/app/templates/errors/404.html b/microblog-project/microblog-23-api/app/templates/errors/404.html similarity index 100% rename from microblog/app/templates/errors/404.html rename to microblog-project/microblog-23-api/app/templates/errors/404.html diff --git a/microblog/app/templates/errors/500.html b/microblog-project/microblog-23-api/app/templates/errors/500.html similarity index 100% rename from microblog/app/templates/errors/500.html rename to microblog-project/microblog-23-api/app/templates/errors/500.html diff --git a/microblog/app/templates/hello.html b/microblog-project/microblog-23-api/app/templates/hello.html similarity index 100% rename from microblog/app/templates/hello.html rename to microblog-project/microblog-23-api/app/templates/hello.html diff --git a/microblog/app/templates/index.html b/microblog-project/microblog-23-api/app/templates/index.html similarity index 100% rename from microblog/app/templates/index.html rename to microblog-project/microblog-23-api/app/templates/index.html diff --git a/microblog/app/templates/messages.html b/microblog-project/microblog-23-api/app/templates/messages.html similarity index 100% rename from microblog/app/templates/messages.html rename to microblog-project/microblog-23-api/app/templates/messages.html diff --git a/microblog/app/templates/search.html b/microblog-project/microblog-23-api/app/templates/search.html similarity index 100% rename from microblog/app/templates/search.html rename to microblog-project/microblog-23-api/app/templates/search.html diff --git a/microblog/app/templates/send_message.html b/microblog-project/microblog-23-api/app/templates/send_message.html similarity index 100% rename from microblog/app/templates/send_message.html rename to microblog-project/microblog-23-api/app/templates/send_message.html diff --git a/microblog/app/templates/user.html b/microblog-project/microblog-23-api/app/templates/user.html similarity index 100% rename from microblog/app/templates/user.html rename to microblog-project/microblog-23-api/app/templates/user.html diff --git a/microblog/app/templates/user_popup.html b/microblog-project/microblog-23-api/app/templates/user_popup.html similarity index 100% rename from microblog/app/templates/user_popup.html rename to microblog-project/microblog-23-api/app/templates/user_popup.html diff --git a/microblog/app/translate.py b/microblog-project/microblog-23-api/app/translate.py similarity index 100% rename from microblog/app/translate.py rename to microblog-project/microblog-23-api/app/translate.py diff --git a/microblog/app/translations/es/LC_MESSAGES/messages.po b/microblog-project/microblog-23-api/app/translations/es/LC_MESSAGES/messages.po similarity index 100% rename from microblog/app/translations/es/LC_MESSAGES/messages.po rename to microblog-project/microblog-23-api/app/translations/es/LC_MESSAGES/messages.po diff --git a/microblog/babel.cfg b/microblog-project/microblog-23-api/babel.cfg similarity index 100% rename from microblog/babel.cfg rename to microblog-project/microblog-23-api/babel.cfg diff --git a/microblog/boot.sh b/microblog-project/microblog-23-api/boot.sh similarity index 100% rename from microblog/boot.sh rename to microblog-project/microblog-23-api/boot.sh diff --git a/microblog/config.py b/microblog-project/microblog-23-api/config.py similarity index 100% rename from microblog/config.py rename to microblog-project/microblog-23-api/config.py diff --git a/microblog/deployment/nginx/microblog b/microblog-project/microblog-23-api/deployment/nginx/microblog similarity index 100% rename from microblog/deployment/nginx/microblog rename to microblog-project/microblog-23-api/deployment/nginx/microblog diff --git a/microblog/deployment/supervisor/microblog-tasks.conf b/microblog-project/microblog-23-api/deployment/supervisor/microblog-tasks.conf similarity index 100% rename from microblog/deployment/supervisor/microblog-tasks.conf rename to microblog-project/microblog-23-api/deployment/supervisor/microblog-tasks.conf diff --git a/microblog/deployment/supervisor/microblog.conf b/microblog-project/microblog-23-api/deployment/supervisor/microblog.conf similarity index 100% rename from microblog/deployment/supervisor/microblog.conf rename to microblog-project/microblog-23-api/deployment/supervisor/microblog.conf diff --git a/microblog/microblog.py b/microblog-project/microblog-23-api/microblog.py similarity index 100% rename from microblog/microblog.py rename to microblog-project/microblog-23-api/microblog.py diff --git a/microblog/microvenv/pyvenv.cfg b/microblog-project/microblog-23-api/microvenv/pyvenv.cfg similarity index 100% rename from microblog/microvenv/pyvenv.cfg rename to microblog-project/microblog-23-api/microvenv/pyvenv.cfg diff --git a/microblog/microvenv/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/idna-2.8-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/idna-2.8-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/idna-2.8-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/idna-2.8-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/packaging-20.3-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/packaging-20.3-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/packaging-20.3-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/packaging-20.3-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/progress-1.5-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/progress-1.5-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/progress-1.5-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/progress-1.5-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/six-1.14.0-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/six-1.14.0-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/six-1.14.0-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/six-1.14.0-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl diff --git a/microblog/microvenv/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl b/microblog-project/microblog-23-api/microvenv/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl similarity index 100% rename from microblog/microvenv/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl rename to microblog-project/microblog-23-api/microvenv/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl diff --git a/microblog-project/microblog-23-api/migrations/README b/microblog-project/microblog-23-api/migrations/README new file mode 100755 index 000000000..98e4f9c44 --- /dev/null +++ b/microblog-project/microblog-23-api/migrations/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/microblog-project/microblog-23-api/migrations/alembic.ini b/microblog-project/microblog-23-api/migrations/alembic.ini new file mode 100644 index 000000000..f8ed4801f --- /dev/null +++ b/microblog-project/microblog-23-api/migrations/alembic.ini @@ -0,0 +1,45 @@ +# A generic, single database configuration. + +[alembic] +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/microblog/migrations/env.py b/microblog-project/microblog-23-api/migrations/env.py similarity index 100% rename from microblog/migrations/env.py rename to microblog-project/microblog-23-api/migrations/env.py diff --git a/microblog-project/microblog-23-api/migrations/script.py.mako b/microblog-project/microblog-23-api/migrations/script.py.mako new file mode 100755 index 000000000..2c0156303 --- /dev/null +++ b/microblog-project/microblog-23-api/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/microblog/migrations/versions/2b017edaa91f_add_language_to_posts.py b/microblog-project/microblog-23-api/migrations/versions/2b017edaa91f_add_language_to_posts.py similarity index 100% rename from microblog/migrations/versions/2b017edaa91f_add_language_to_posts.py rename to microblog-project/microblog-23-api/migrations/versions/2b017edaa91f_add_language_to_posts.py diff --git a/microblog/migrations/versions/37f06a334dbf_new_fields_in_user_model.py b/microblog-project/microblog-23-api/migrations/versions/37f06a334dbf_new_fields_in_user_model.py similarity index 100% rename from microblog/migrations/versions/37f06a334dbf_new_fields_in_user_model.py rename to microblog-project/microblog-23-api/migrations/versions/37f06a334dbf_new_fields_in_user_model.py diff --git a/microblog/migrations/versions/780739b227a7_posts_table.py b/microblog-project/microblog-23-api/migrations/versions/780739b227a7_posts_table.py similarity index 100% rename from microblog/migrations/versions/780739b227a7_posts_table.py rename to microblog-project/microblog-23-api/migrations/versions/780739b227a7_posts_table.py diff --git a/microblog/migrations/versions/834b1a697901_user_tokens.py b/microblog-project/microblog-23-api/migrations/versions/834b1a697901_user_tokens.py similarity index 100% rename from microblog/migrations/versions/834b1a697901_user_tokens.py rename to microblog-project/microblog-23-api/migrations/versions/834b1a697901_user_tokens.py diff --git a/microblog/migrations/versions/ae346256b650_followers.py b/microblog-project/microblog-23-api/migrations/versions/ae346256b650_followers.py similarity index 100% rename from microblog/migrations/versions/ae346256b650_followers.py rename to microblog-project/microblog-23-api/migrations/versions/ae346256b650_followers.py diff --git a/microblog/migrations/versions/c81bac34faab_tasks.py b/microblog-project/microblog-23-api/migrations/versions/c81bac34faab_tasks.py similarity index 100% rename from microblog/migrations/versions/c81bac34faab_tasks.py rename to microblog-project/microblog-23-api/migrations/versions/c81bac34faab_tasks.py diff --git a/microblog/migrations/versions/d049de007ccf_private_messages.py b/microblog-project/microblog-23-api/migrations/versions/d049de007ccf_private_messages.py similarity index 100% rename from microblog/migrations/versions/d049de007ccf_private_messages.py rename to microblog-project/microblog-23-api/migrations/versions/d049de007ccf_private_messages.py diff --git a/microblog/migrations/versions/e517276bb1c2_users_table.py b/microblog-project/microblog-23-api/migrations/versions/e517276bb1c2_users_table.py similarity index 100% rename from microblog/migrations/versions/e517276bb1c2_users_table.py rename to microblog-project/microblog-23-api/migrations/versions/e517276bb1c2_users_table.py diff --git a/microblog/migrations/versions/f7ac3d27bb1d_notifications.py b/microblog-project/microblog-23-api/migrations/versions/f7ac3d27bb1d_notifications.py similarity index 100% rename from microblog/migrations/versions/f7ac3d27bb1d_notifications.py rename to microblog-project/microblog-23-api/migrations/versions/f7ac3d27bb1d_notifications.py diff --git a/microblog/requirements.txt b/microblog-project/microblog-23-api/requirements.txt similarity index 100% rename from microblog/requirements.txt rename to microblog-project/microblog-23-api/requirements.txt diff --git a/microblog/tests.py b/microblog-project/microblog-23-api/tests.py similarity index 100% rename from microblog/tests.py rename to microblog-project/microblog-23-api/tests.py diff --git a/microblog/microvenv/bin/Activate.ps1 b/microblog/microvenv/bin/Activate.ps1 deleted file mode 100644 index 2fb3852c3..000000000 --- a/microblog/microvenv/bin/Activate.ps1 +++ /dev/null @@ -1,241 +0,0 @@ -<# -.Synopsis -Activate a Python virtual environment for the current PowerShell session. - -.Description -Pushes the python executable for a virtual environment to the front of the -$Env:PATH environment variable and sets the prompt to signify that you are -in a Python virtual environment. Makes use of the command line switches as -well as the `pyvenv.cfg` file values present in the virtual environment. - -.Parameter VenvDir -Path to the directory that contains the virtual environment to activate. The -default value for this is the parent of the directory that the Activate.ps1 -script is located within. - -.Parameter Prompt -The prompt prefix to display when this virtual environment is activated. By -default, this prompt is the name of the virtual environment folder (VenvDir) -surrounded by parentheses and followed by a single space (ie. '(.venv) '). - -.Example -Activate.ps1 -Activates the Python virtual environment that contains the Activate.ps1 script. - -.Example -Activate.ps1 -Verbose -Activates the Python virtual environment that contains the Activate.ps1 script, -and shows extra information about the activation as it executes. - -.Example -Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv -Activates the Python virtual environment located in the specified location. - -.Example -Activate.ps1 -Prompt "MyPython" -Activates the Python virtual environment that contains the Activate.ps1 script, -and prefixes the current prompt with the specified string (surrounded in -parentheses) while the virtual environment is active. - -.Notes -On Windows, it may be required to enable this Activate.ps1 script by setting the -execution policy for the user. You can do this by issuing the following PowerShell -command: - -PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - -For more information on Execution Policies: -https://go.microsoft.com/fwlink/?LinkID=135170 - -#> -Param( - [Parameter(Mandatory = $false)] - [String] - $VenvDir, - [Parameter(Mandatory = $false)] - [String] - $Prompt -) - -<# Function declarations --------------------------------------------------- #> - -<# -.Synopsis -Remove all shell session elements added by the Activate script, including the -addition of the virtual environment's Python executable from the beginning of -the PATH variable. - -.Parameter NonDestructive -If present, do not remove this function from the global namespace for the -session. - -#> -function global:deactivate ([switch]$NonDestructive) { - # Revert to original values - - # The prior prompt: - if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { - Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt - Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT - } - - # The prior PYTHONHOME: - if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { - Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME - Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME - } - - # The prior PATH: - if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { - Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH - Remove-Item -Path Env:_OLD_VIRTUAL_PATH - } - - # Just remove the VIRTUAL_ENV altogether: - if (Test-Path -Path Env:VIRTUAL_ENV) { - Remove-Item -Path env:VIRTUAL_ENV - } - - # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: - if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { - Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force - } - - # Leave deactivate function in the global namespace if requested: - if (-not $NonDestructive) { - Remove-Item -Path function:deactivate - } -} - -<# -.Description -Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the -given folder, and returns them in a map. - -For each line in the pyvenv.cfg file, if that line can be parsed into exactly -two strings separated by `=` (with any amount of whitespace surrounding the =) -then it is considered a `key = value` line. The left hand string is the key, -the right hand is the value. - -If the value starts with a `'` or a `"` then the first and last character is -stripped from the value before being captured. - -.Parameter ConfigDir -Path to the directory that contains the `pyvenv.cfg` file. -#> -function Get-PyVenvConfig( - [String] - $ConfigDir -) { - Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" - - # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). - $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue - - # An empty map will be returned if no config file is found. - $pyvenvConfig = @{ } - - if ($pyvenvConfigPath) { - - Write-Verbose "File exists, parse `key = value` lines" - $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath - - $pyvenvConfigContent | ForEach-Object { - $keyval = $PSItem -split "\s*=\s*", 2 - if ($keyval[0] -and $keyval[1]) { - $val = $keyval[1] - - # Remove extraneous quotations around a string value. - if ("'""".Contains($val.Substring(0, 1))) { - $val = $val.Substring(1, $val.Length - 2) - } - - $pyvenvConfig[$keyval[0]] = $val - Write-Verbose "Adding Key: '$($keyval[0])'='$val'" - } - } - } - return $pyvenvConfig -} - - -<# Begin Activate script --------------------------------------------------- #> - -# Determine the containing directory of this script -$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition -$VenvExecDir = Get-Item -Path $VenvExecPath - -Write-Verbose "Activation script is located in path: '$VenvExecPath'" -Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" -Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" - -# Set values required in priority: CmdLine, ConfigFile, Default -# First, get the location of the virtual environment, it might not be -# VenvExecDir if specified on the command line. -if ($VenvDir) { - Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" -} -else { - Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." - $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") - Write-Verbose "VenvDir=$VenvDir" -} - -# Next, read the `pyvenv.cfg` file to determine any required value such -# as `prompt`. -$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir - -# Next, set the prompt from the command line, or the config file, or -# just use the name of the virtual environment folder. -if ($Prompt) { - Write-Verbose "Prompt specified as argument, using '$Prompt'" -} -else { - Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" - if ($pyvenvCfg -and $pyvenvCfg['prompt']) { - Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" - $Prompt = $pyvenvCfg['prompt']; - } - else { - Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)" - Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" - $Prompt = Split-Path -Path $venvDir -Leaf - } -} - -Write-Verbose "Prompt = '$Prompt'" -Write-Verbose "VenvDir='$VenvDir'" - -# Deactivate any currently active virtual environment, but leave the -# deactivate function in place. -deactivate -nondestructive - -# Now set the environment variable VIRTUAL_ENV, used by many tools to determine -# that there is an activated venv. -$env:VIRTUAL_ENV = $VenvDir - -if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { - - Write-Verbose "Setting prompt to '$Prompt'" - - # Set the prompt to include the env name - # Make sure _OLD_VIRTUAL_PROMPT is global - function global:_OLD_VIRTUAL_PROMPT { "" } - Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT - New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt - - function global:prompt { - Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " - _OLD_VIRTUAL_PROMPT - } -} - -# Clear PYTHONHOME -if (Test-Path -Path Env:PYTHONHOME) { - Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME - Remove-Item -Path Env:PYTHONHOME -} - -# Add the venv to the PATH -Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH -$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/microblog/microvenv/bin/activate b/microblog/microvenv/bin/activate deleted file mode 100644 index ddd8ecd84..000000000 --- a/microblog/microvenv/bin/activate +++ /dev/null @@ -1,76 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# you cannot run it directly - -deactivate () { - # reset old environment variables - if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then - PATH="${_OLD_VIRTUAL_PATH:-}" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then - PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # This should detect bash and zsh, which have a hash command that must - # be called to get it to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then - hash -r - fi - - if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then - PS1="${_OLD_VIRTUAL_PS1:-}" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - if [ ! "${1:-}" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelevant variables -deactivate nondestructive - -VIRTUAL_ENV="/home/codespace/workspace/elearning/microblog/microvenv" -export VIRTUAL_ENV - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) -# could use `if (set -u; : $PYTHONHOME) ;` in bash -if [ -n "${PYTHONHOME:-}" ] ; then - _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" - unset PYTHONHOME -fi - -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then - _OLD_VIRTUAL_PS1="${PS1:-}" - if [ "x(microvenv) " != x ] ; then - PS1="(microvenv) ${PS1:-}" - else - if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" - else - PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" - fi - fi - export PS1 -fi - -# This should detect bash and zsh, which have a hash command that must -# be called to get it to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then - hash -r -fi diff --git a/microblog/microvenv/bin/activate.csh b/microblog/microvenv/bin/activate.csh deleted file mode 100644 index 8d62f0d35..000000000 --- a/microblog/microvenv/bin/activate.csh +++ /dev/null @@ -1,37 +0,0 @@ -# This file must be used with "source bin/activate.csh" *from csh*. -# You cannot run it directly. -# Created by Davide Di Blasi . -# Ported to Python 3.3 venv by Andrew Svetlov - -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' - -# Unset irrelevant variables. -deactivate nondestructive - -setenv VIRTUAL_ENV "/home/codespace/workspace/elearning/microblog/microvenv" - -set _OLD_VIRTUAL_PATH="$PATH" -setenv PATH "$VIRTUAL_ENV/bin:$PATH" - - -set _OLD_VIRTUAL_PROMPT="$prompt" - -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then - if ("microvenv" != "") then - set env_name = "microvenv" - else - if (`basename "VIRTUAL_ENV"` == "__") then - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - set env_name = `basename \`dirname "$VIRTUAL_ENV"\`` - else - set env_name = `basename "$VIRTUAL_ENV"` - endif - endif - set prompt = "[$env_name] $prompt" - unset env_name -endif - -alias pydoc python -m pydoc - -rehash diff --git a/microblog/microvenv/bin/activate.fish b/microblog/microvenv/bin/activate.fish deleted file mode 100644 index 479b8c71e..000000000 --- a/microblog/microvenv/bin/activate.fish +++ /dev/null @@ -1,75 +0,0 @@ -# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org) -# you cannot run it directly - -function deactivate -d "Exit virtualenv and return to normal shell environment" - # reset old environment variables - if test -n "$_OLD_VIRTUAL_PATH" - set -gx PATH $_OLD_VIRTUAL_PATH - set -e _OLD_VIRTUAL_PATH - end - if test -n "$_OLD_VIRTUAL_PYTHONHOME" - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME - set -e _OLD_VIRTUAL_PYTHONHOME - end - - if test -n "$_OLD_FISH_PROMPT_OVERRIDE" - functions -e fish_prompt - set -e _OLD_FISH_PROMPT_OVERRIDE - functions -c _old_fish_prompt fish_prompt - functions -e _old_fish_prompt - end - - set -e VIRTUAL_ENV - if test "$argv[1]" != "nondestructive" - # Self destruct! - functions -e deactivate - end -end - -# unset irrelevant variables -deactivate nondestructive - -set -gx VIRTUAL_ENV "/home/codespace/workspace/elearning/microblog/microvenv" - -set -gx _OLD_VIRTUAL_PATH $PATH -set -gx PATH "$VIRTUAL_ENV/bin" $PATH - -# unset PYTHONHOME if set -if set -q PYTHONHOME - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME - set -e PYTHONHOME -end - -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" - # fish uses a function instead of an env var to generate the prompt. - - # save the current fish_prompt function as the function _old_fish_prompt - functions -c fish_prompt _old_fish_prompt - - # with the original prompt function renamed, we can override with our own. - function fish_prompt - # Save the return status of the last command - set -l old_status $status - - # Prompt override? - if test -n "(microvenv) " - printf "%s%s" "(microvenv) " (set_color normal) - else - # ...Otherwise, prepend env - set -l _checkbase (basename "$VIRTUAL_ENV") - if test $_checkbase = "__" - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) - else - printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) - end - end - - # Restore the return status of the previous command. - echo "exit $old_status" | . - _old_fish_prompt - end - - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" -end diff --git a/microblog/microvenv/bin/alembic b/microblog/microvenv/bin/alembic deleted file mode 100755 index a79b1c444..000000000 --- a/microblog/microvenv/bin/alembic +++ /dev/null @@ -1,12 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# EASY-INSTALL-ENTRY-SCRIPT: 'alembic==0.9.6','console_scripts','alembic' -__requires__ = 'alembic==0.9.6' -import re -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit( - load_entry_point('alembic==0.9.6', 'console_scripts', 'alembic')() - ) diff --git a/microblog/microvenv/bin/chardetect b/microblog/microvenv/bin/chardetect deleted file mode 100755 index a3222b5b9..000000000 --- a/microblog/microvenv/bin/chardetect +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from chardet.cli.chardetect import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/dotenv b/microblog/microvenv/bin/dotenv deleted file mode 100755 index 2631f6020..000000000 --- a/microblog/microvenv/bin/dotenv +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from dotenv.cli import cli -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(cli()) diff --git a/microblog/microvenv/bin/easy_install b/microblog/microvenv/bin/easy_install deleted file mode 100755 index ac266f053..000000000 --- a/microblog/microvenv/bin/easy_install +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from setuptools.command.easy_install import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/easy_install-3.8 b/microblog/microvenv/bin/easy_install-3.8 deleted file mode 100755 index ac266f053..000000000 --- a/microblog/microvenv/bin/easy_install-3.8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from setuptools.command.easy_install import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/email_validator b/microblog/microvenv/bin/email_validator deleted file mode 100755 index 4fbba42d5..000000000 --- a/microblog/microvenv/bin/email_validator +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from email_validator import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/flask b/microblog/microvenv/bin/flask deleted file mode 100755 index 7fbccd436..000000000 --- a/microblog/microvenv/bin/flask +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from flask.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/mako-render b/microblog/microvenv/bin/mako-render deleted file mode 100755 index aff59eeb1..000000000 --- a/microblog/microvenv/bin/mako-render +++ /dev/null @@ -1,12 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# EASY-INSTALL-ENTRY-SCRIPT: 'Mako==1.0.7','console_scripts','mako-render' -__requires__ = 'Mako==1.0.7' -import re -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit( - load_entry_point('Mako==1.0.7', 'console_scripts', 'mako-render')() - ) diff --git a/microblog/microvenv/bin/pip b/microblog/microvenv/bin/pip deleted file mode 100755 index 303a38b35..000000000 --- a/microblog/microvenv/bin/pip +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/pip3 b/microblog/microvenv/bin/pip3 deleted file mode 100755 index 303a38b35..000000000 --- a/microblog/microvenv/bin/pip3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/pip3.8 b/microblog/microvenv/bin/pip3.8 deleted file mode 100755 index 303a38b35..000000000 --- a/microblog/microvenv/bin/pip3.8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/pybabel b/microblog/microvenv/bin/pybabel deleted file mode 100755 index c25343144..000000000 --- a/microblog/microvenv/bin/pybabel +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from babel.messages.frontend import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/pyjwt b/microblog/microvenv/bin/pyjwt deleted file mode 100755 index f3b1b935b..000000000 --- a/microblog/microvenv/bin/pyjwt +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from jwt.__main__ import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/python b/microblog/microvenv/bin/python deleted file mode 120000 index b8a0adbbb..000000000 --- a/microblog/microvenv/bin/python +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/microblog/microvenv/bin/python3 b/microblog/microvenv/bin/python3 deleted file mode 120000 index ae65fdaa1..000000000 --- a/microblog/microvenv/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/python3 \ No newline at end of file diff --git a/microblog/microvenv/bin/rq b/microblog/microvenv/bin/rq deleted file mode 100755 index 9c620a9eb..000000000 --- a/microblog/microvenv/bin/rq +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rq.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/microblog/microvenv/bin/rqinfo b/microblog/microvenv/bin/rqinfo deleted file mode 100755 index 701f3d116..000000000 --- a/microblog/microvenv/bin/rqinfo +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rq.cli import info -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(info()) diff --git a/microblog/microvenv/bin/rqworker b/microblog/microvenv/bin/rqworker deleted file mode 100755 index 26b51f686..000000000 --- a/microblog/microvenv/bin/rqworker +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/codespace/workspace/elearning/microblog/microvenv/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rq.cli import worker -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(worker()) diff --git a/microblog/microvenv/lib64 b/microblog/microvenv/lib64 deleted file mode 120000 index 7951405f8..000000000 --- a/microblog/microvenv/lib64 +++ /dev/null @@ -1 +0,0 @@ -lib \ No newline at end of file