From 56fdc1a851cf27f1412f4de30d23d66c9c900278 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Fri, 26 Apr 2019 21:45:31 +0200 Subject: [PATCH 01/18] add a broadcastmiddleware --- bloodmallet/bloodmallet/settings/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bloodmallet/bloodmallet/settings/common.py b/bloodmallet/bloodmallet/settings/common.py index d5d393c2..bfee70d7 100644 --- a/bloodmallet/bloodmallet/settings/common.py +++ b/bloodmallet/bloodmallet/settings/common.py @@ -51,6 +51,7 @@ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'vinaigrette.middleware.VinaigretteAdminLanguageMiddleware', + 'compute_api.broadcast_middleware.BroadcastMiddleware', ] ROOT_URLCONF = 'bloodmallet.urls' From 2a4bb4c57273e0defdd101d4566375b3f5c89f9d Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:47:21 +0200 Subject: [PATCH 02/18] disable alpha-tester privileges --- bloodmallet/general_website/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bloodmallet/general_website/models.py b/bloodmallet/general_website/models.py index 45bb7b4a..6c1f3c34 100644 --- a/bloodmallet/general_website/models.py +++ b/bloodmallet/general_website/models.py @@ -31,8 +31,9 @@ def can_create_chart(self) -> bool: return True if self.is_staff: return True - if self.groups.filter(name='alpha_tester').exists(): # pylint: disable=no-member - return True + # alpha tester weekend has ended + # if self.groups.filter(name='alpha_tester').exists(): # pylint: disable=no-member + # return True return False From c971b69bc0ac9f783debeab548ebfbd13907fcd9 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:47:31 +0200 Subject: [PATCH 03/18] add comments to urls --- bloodmallet/general_website/urls.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bloodmallet/general_website/urls.py b/bloodmallet/general_website/urls.py index 27e4a4d5..76911773 100644 --- a/bloodmallet/general_website/urls.py +++ b/bloodmallet/general_website/urls.py @@ -5,11 +5,15 @@ from allauth.socialaccount.views import ConnectionsView urlpatterns = [ + + # general path('', views.index, name='index_empty'), path('index.html', views.index, name='index_long'), path('index', views.index, name='index'), path('FAQ', views.faq, name='FAQ'), path('error', views.error, name='error'), + + # charts path('my_charts', views.my_charts, name='my_charts'), path('chart/create', views.add_charts, name='add_charts'), path('chart/', views.chart, name='chart'), @@ -20,7 +24,11 @@ name='get_standard_chart_data' ), path('chart/delete', views.delete_chart, name='delete_chart'), + + # portals o_O but blizzard killed most...needs heavy data updates path('portals', views.portals, name='portals'), + + # settings path('settings/general', views.settings, name='settings'), path('settings/profile', views.profile, name='profile'), path('settings/change_password', views.change_password, name='change_password'), From 2557bddcbe35b948a7bb46b59c8b7cb97cc0e5f5 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:48:22 +0200 Subject: [PATCH 04/18] update development settings to allow local dev of frontend --- bloodmallet/bloodmallet/settings/common.py | 18 +++-- .../bloodmallet/settings/development.py | 67 ++++++++++--------- 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/bloodmallet/bloodmallet/settings/common.py b/bloodmallet/bloodmallet/settings/common.py index bfee70d7..e4e85806 100644 --- a/bloodmallet/bloodmallet/settings/common.py +++ b/bloodmallet/bloodmallet/settings/common.py @@ -95,7 +95,11 @@ }, ] -from .secrets import SECRET_KEY +try: + from .secrets import SECRET_KEY +except FileNotFoundError: + from django.core.management.utils import get_random_secret_key + SECRET_KEY = get_random_secret_key() # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ @@ -143,12 +147,16 @@ # replaces the Django standard User AUTH_USER_MODEL = 'general_website.User' -# Google cloud storage handling -DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage' - LOCALE_PATHS = (BASE_DIR + '/general_website/locale',) -from .secrets import PROJECT, ZONE, CPU_TYPE, IMAGE_FAMILY, FALLBACK_ZONE +try: + from .secrets import PROJECT, ZONE, CPU_TYPE, IMAGE_FAMILY, FALLBACK_ZONE +except FileNotFoundError: + # information is not required for local development of the frontend + pass +else: + # Google cloud storage handling + DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage' STANDARD_CHART_NAME = 'Bloodmallet Standard Chart' diff --git a/bloodmallet/bloodmallet/settings/development.py b/bloodmallet/bloodmallet/settings/development.py index f772664b..d6185e70 100644 --- a/bloodmallet/bloodmallet/settings/development.py +++ b/bloodmallet/bloodmallet/settings/development.py @@ -6,9 +6,6 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -BASE_DIR = os.path.join(BASE_DIR, '..') - ALLOWED_HOSTS = [ 'localhost', '127.0.0.1', @@ -60,40 +57,41 @@ 'level': 'DEBUG' if DEBUG else 'INFO', 'propagate': True, }, - 'allauth.socialaccount.providers.patreon': { - 'handlers': [ - 'console', - ], - 'level': 'DEBUG', - 'propagate': True - } }, } -# 'allauth.account', -# 'allauth.socialaccount', -# 'allauth.socialaccount.providers.patreon', +# don't send mails...print them to console EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases -import pymysql -pymysql.install_as_MySQLdb() -from .secrets import LIVE_DB_HOST, LIVE_DB_NAME, LIVE_DB_USER, LIVE_DB_PASSWORD +try: + from .secrets import LIVE_DB_HOST, LIVE_DB_NAME, LIVE_DB_USER, LIVE_DB_PASSWORD +except FileNotFoundError: + # pure frontend development uses a local dbs + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'mydatabase', + } + } +else: + import pymysql + pymysql.install_as_MySQLdb() -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'HOST': '127.0.0.1', - 'PORT': '3306', - 'NAME': LIVE_DB_NAME, - 'USER': LIVE_DB_USER, - 'PASSWORD': LIVE_DB_PASSWORD, - 'OPTIONS': { - 'charset': 'utf8mb4' - }, + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'HOST': '127.0.0.1', + 'PORT': '3306', + 'NAME': LIVE_DB_NAME, + 'USER': LIVE_DB_USER, + 'PASSWORD': LIVE_DB_PASSWORD, + 'OPTIONS': { + 'charset': 'utf8mb4' + }, + } } -} # used to serve files from this path in non-debug production STATIC_ROOT = 'static' @@ -103,7 +101,12 @@ SASS_PROCESSOR_ROOT = STATIC_ROOT # google cloud storage -from .secrets import DEV_BUCKET_NAME, DEV_CREDENTIALS -GS_BUCKET_NAME = DEV_BUCKET_NAME -from google.oauth2 import service_account -GS_CREDENTIALS = service_account.Credentials.from_service_account_file(DEV_CREDENTIALS) +try: + from .secrets import DEV_BUCKET_NAME, DEV_CREDENTIALS +except FileNotFoundError: + # not required for local dev + pass +else: + GS_BUCKET_NAME = DEV_BUCKET_NAME + from google.oauth2 import service_account + GS_CREDENTIALS = service_account.Credentials.from_service_account_file(DEV_CREDENTIALS) From ed4a1d219506c44849ce74d13c627ac57edf7533 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:48:37 +0200 Subject: [PATCH 05/18] move deploy scripts --- deploy.ps1 => bloodmallet/deploy.ps1 | 8 +++----- .../deploy_preparations.ps1 | 5 +---- 2 files changed, 4 insertions(+), 9 deletions(-) rename deploy.ps1 => bloodmallet/deploy.ps1 (87%) rename deploy_preparations.ps1 => bloodmallet/deploy_preparations.ps1 (85%) diff --git a/deploy.ps1 b/bloodmallet/deploy.ps1 similarity index 87% rename from deploy.ps1 rename to bloodmallet/deploy.ps1 index 7a07c6af..76d98c34 100644 --- a/deploy.ps1 +++ b/bloodmallet/deploy.ps1 @@ -4,12 +4,10 @@ Write-Host "Deploying to bloodmallet.com" $start_location = pwd Write-Host "Starting virtual environment" -NoNewline -# Activate virtual env -env/Scripts/activate -Write-Host " Done" -ForegroundColor Green -# Navigate to necessary subdirectory (which has the actual app for the appengine) -cd bloodmallet/ +# Activate virtual env (here could be a list search that looks for env, venv and .env instead) +../env/Scripts/activate +Write-Host " Done" -ForegroundColor Green Write-Host "Preparing Styles" -NoNewline # Create fresh css files diff --git a/deploy_preparations.ps1 b/bloodmallet/deploy_preparations.ps1 similarity index 85% rename from deploy_preparations.ps1 rename to bloodmallet/deploy_preparations.ps1 index 54dd2443..045e2902 100644 --- a/deploy_preparations.ps1 +++ b/bloodmallet/deploy_preparations.ps1 @@ -3,12 +3,9 @@ $start_location = pwd Write-Host "Starting virtual environment" -NoNewline # Activate virtual env -env/Scripts/activate +../env/Scripts/activate Write-Host " Done" -ForegroundColor Green -# Navigate to necessary subdirectory (which has the actual app for the appengine) -cd bloodmallet/ - Write-Host "Preparing translations" -NoNewline # collect and compile translateable texts $languages = @('cn', 'de', 'es', 'fr', 'it', 'ko', 'pt', 'ru') From 68168f3b8b64bbf9a06b641d95637e65d1b23f5a Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:48:58 +0200 Subject: [PATCH 06/18] make basic requirements more obvious --- requirements_commented.txt => requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename requirements_commented.txt => requirements.txt (83%) diff --git a/requirements_commented.txt b/requirements.txt similarity index 83% rename from requirements_commented.txt rename to requirements.txt index 121f5d45..0732b19b 100644 --- a/requirements_commented.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ -# This requirements file is a commented mirror of bloodmallet/requirements.txt, which is needed where it is for deployment. Furthermore due to the deployment the requirements file can't have comments for now. +# This requirements file is a commented mirror of bloodmallet/requirements.txt, which is needed where it is for deployment. +# Furthermore due to the deployment the requirements file can't have comments for now. +# (It would break the deployment) # Attention! # Make sure to use 'python -m pip install --upgrade pip setuptools wheel' before trying to use 'pip install -U -r requirements.txt' From 689ac72b0d31d4fefbe497b3ef9cc62f6dc895c0 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:49:11 +0200 Subject: [PATCH 07/18] fix _dev requirements file --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 5cd609b3..d339b27c 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,3 +1,3 @@ pylint>=2.1.1 yapf>=0.24.0 --r requirements_commented.txt +-r requirements.txt From 8905c1960c534490f1175f4b036961175fcd5382 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:49:20 +0200 Subject: [PATCH 08/18] add README --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..a882dcf8 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# bloodmallet.com frontend +> You're seeing the code that runs the frontend of bloodmallet.com. + +Everyone is welcome to add issues, discuss improvements and features, or create +pull requests. + +## Development setup + +1. Get or have [Python 3.6+](https://www.python.org/downloads/) (make sure to install it into PATH on windows) +1. Create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) + - `python3 -m venv env` (creates a directory "env") + - activate virtual environment + - `env/Scripts/activate` (windows) + - `source env/bin/activate` (linux) +1. Get or have [git](https://git-scm.com/downloads) installed +1. Download this repository + - `git clone https://github.com/Bloodmallet/bloodmallet_web_frontend.git bloodmallet` (creates a directory "bloodmallet") +1. Install requirements + - `cd bloodmallet` (navigate into the creates directory) + - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) + - `pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) +1. Start local django development server + - `cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") + - `python manage.py runserver` +1. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: From be32ec054a35d638bfebdbb84062fa835b397a1d Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:51:09 +0200 Subject: [PATCH 09/18] update readme list --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a882dcf8..52d3f496 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,19 @@ pull requests. ## Development setup 1. Get or have [Python 3.6+](https://www.python.org/downloads/) (make sure to install it into PATH on windows) -1. Create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) +2. Create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) - `python3 -m venv env` (creates a directory "env") - activate virtual environment - `env/Scripts/activate` (windows) - `source env/bin/activate` (linux) -1. Get or have [git](https://git-scm.com/downloads) installed -1. Download this repository +3. Get or have [git](https://git-scm.com/downloads) installed +4. Download this repository - `git clone https://github.com/Bloodmallet/bloodmallet_web_frontend.git bloodmallet` (creates a directory "bloodmallet") -1. Install requirements +5. Install requirements - `cd bloodmallet` (navigate into the creates directory) - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) - `pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) -1. Start local django development server +6. Start local django development server - `cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") - `python manage.py runserver` -1. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: +7. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: From 8456963a32a5fd5fac36a1438ce1105e74448972 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 20:51:53 +0200 Subject: [PATCH 10/18] another list update to readme --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 52d3f496..0fae720b 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,18 @@ pull requests. 1. Get or have [Python 3.6+](https://www.python.org/downloads/) (make sure to install it into PATH on windows) 2. Create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) - - `python3 -m venv env` (creates a directory "env") - - activate virtual environment - - `env/Scripts/activate` (windows) - - `source env/bin/activate` (linux) + - `python3 -m venv env` (creates a directory "env") + - activate virtual environment + - `env/Scripts/activate` (windows) + - `source env/bin/activate` (linux) 3. Get or have [git](https://git-scm.com/downloads) installed 4. Download this repository - - `git clone https://github.com/Bloodmallet/bloodmallet_web_frontend.git bloodmallet` (creates a directory "bloodmallet") + - `git clone https://github.com/Bloodmallet/bloodmallet_web_frontend.git bloodmallet` (creates a directory "bloodmallet") 5. Install requirements - - `cd bloodmallet` (navigate into the creates directory) - - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) - - `pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) + - `cd bloodmallet` (navigate into the creates directory) + - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) + - `pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) 6. Start local django development server - - `cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") - - `python manage.py runserver` + - `cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") + - `python manage.py runserver` 7. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: From eb543e719865c2013448864397f99caead8c2299 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:27:51 +0200 Subject: [PATCH 11/18] add env clarification --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0fae720b..9a3f7f96 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ pull requests. 4. Download this repository - `git clone https://github.com/Bloodmallet/bloodmallet_web_frontend.git bloodmallet` (creates a directory "bloodmallet") 5. Install requirements - - `cd bloodmallet` (navigate into the creates directory) + - `cd bloodmallet` (navigate into the created directory) - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) - - `pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) + - `(env)$ pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) 6. Start local django development server - - `cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") - - `python manage.py runserver` + - `(env)$ cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") + - `(env)$ python manage.py runserver` 7. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: From 24aa86acfb4f41af4e581f4d2f29f5c13485c437 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:28:07 +0200 Subject: [PATCH 12/18] fix local dev exceptions --- bloodmallet/bloodmallet/settings/common.py | 4 ++-- bloodmallet/bloodmallet/settings/development.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bloodmallet/bloodmallet/settings/common.py b/bloodmallet/bloodmallet/settings/common.py index e4e85806..2b939645 100644 --- a/bloodmallet/bloodmallet/settings/common.py +++ b/bloodmallet/bloodmallet/settings/common.py @@ -97,7 +97,7 @@ try: from .secrets import SECRET_KEY -except FileNotFoundError: +except ModuleNotFoundError: from django.core.management.utils import get_random_secret_key SECRET_KEY = get_random_secret_key() @@ -151,7 +151,7 @@ try: from .secrets import PROJECT, ZONE, CPU_TYPE, IMAGE_FAMILY, FALLBACK_ZONE -except FileNotFoundError: +except ModuleNotFoundError: # information is not required for local development of the frontend pass else: diff --git a/bloodmallet/bloodmallet/settings/development.py b/bloodmallet/bloodmallet/settings/development.py index d6185e70..8ca815c6 100644 --- a/bloodmallet/bloodmallet/settings/development.py +++ b/bloodmallet/bloodmallet/settings/development.py @@ -67,7 +67,7 @@ # https://docs.djangoproject.com/en/2.1/ref/settings/#databases try: from .secrets import LIVE_DB_HOST, LIVE_DB_NAME, LIVE_DB_USER, LIVE_DB_PASSWORD -except FileNotFoundError: +except ModuleNotFoundError: # pure frontend development uses a local dbs DATABASES = { 'default': { @@ -103,7 +103,7 @@ # google cloud storage try: from .secrets import DEV_BUCKET_NAME, DEV_CREDENTIALS -except FileNotFoundError: +except ModuleNotFoundError: # not required for local dev pass else: From 03ff1c41020eb8de9eec37f3de9419234e05c920 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:31:54 +0200 Subject: [PATCH 13/18] add hidden app only, if it's already present --- bloodmallet/bloodmallet/settings/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bloodmallet/bloodmallet/settings/common.py b/bloodmallet/bloodmallet/settings/common.py index 2b939645..aa3d7c81 100644 --- a/bloodmallet/bloodmallet/settings/common.py +++ b/bloodmallet/bloodmallet/settings/common.py @@ -37,8 +37,13 @@ 'crispy_forms', 'vinaigrette', 'general_website.apps.GeneralWebsiteConfig', - 'compute_api.apps.ComputeApiConfig', ] +try: + import compute_api +except ModuleNotFoundError: + pass +else: + INSTALLED_APPS.append('compute_api.apps.ComputeApiConfig') MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', From 083bdc872e1f2e18e7c509b50c43d379411704a5 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:33:45 +0200 Subject: [PATCH 14/18] add hidden app to urls only if it's present --- bloodmallet/bloodmallet/urls.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bloodmallet/bloodmallet/urls.py b/bloodmallet/bloodmallet/urls.py index 7dde77cb..4c2015da 100644 --- a/bloodmallet/bloodmallet/urls.py +++ b/bloodmallet/bloodmallet/urls.py @@ -22,9 +22,15 @@ path('', include('general_website.urls')), path('admin/login/', app_login), path('admin/', admin.site.urls), - path('compute_api/', include('compute_api.urls', namespace='compute_engine')), ] +try: + import compute_api +except ModuleNotFoundError: + pass +else: + urlpatterns.append(path('compute_api/', include('compute_api.urls', namespace='compute_engine'))) + handler400 = 'general_website.views.handler404' handler403 = 'general_website.views.handler404' handler404 = 'general_website.views.handler404' From faf93f748f72117d0251897a1b4a438c17c28b1a Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:39:35 +0200 Subject: [PATCH 15/18] specify development settings for runserver command --- bloodmallet/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bloodmallet/manage.py b/bloodmallet/manage.py index d029ab0c..5cb14754 100644 --- a/bloodmallet/manage.py +++ b/bloodmallet/manage.py @@ -3,7 +3,7 @@ import sys if __name__ == '__main__': - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bloodmallet.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bloodmallet.settings.development') try: from django.core.management import execute_from_command_line except ImportError as exc: From 87110952fcf2add90c0f2959b05c55245724bcd7 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:39:52 +0200 Subject: [PATCH 16/18] switch settings based on command, not on env --- bloodmallet/bloodmallet/settings/__init__.py | 6 ------ bloodmallet/bloodmallet/wsgi.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bloodmallet/bloodmallet/settings/__init__.py b/bloodmallet/bloodmallet/settings/__init__.py index 415542a9..e69de29b 100644 --- a/bloodmallet/bloodmallet/settings/__init__.py +++ b/bloodmallet/bloodmallet/settings/__init__.py @@ -1,6 +0,0 @@ -import os - -if os.getenv('GAE_APPLICATION', None): - from .production import * -else: - from .development import * diff --git a/bloodmallet/bloodmallet/wsgi.py b/bloodmallet/bloodmallet/wsgi.py index f70f86ac..ac463810 100644 --- a/bloodmallet/bloodmallet/wsgi.py +++ b/bloodmallet/bloodmallet/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bloodmallet.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bloodmallet.settings.production') application = get_wsgi_application() From 2ff52f08a2eab6644242a9e37dcf682d3d9c1c40 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:43:20 +0200 Subject: [PATCH 17/18] add hidden middleware only if app is present --- bloodmallet/bloodmallet/settings/common.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bloodmallet/bloodmallet/settings/common.py b/bloodmallet/bloodmallet/settings/common.py index aa3d7c81..ba13e803 100644 --- a/bloodmallet/bloodmallet/settings/common.py +++ b/bloodmallet/bloodmallet/settings/common.py @@ -38,12 +38,6 @@ 'vinaigrette', 'general_website.apps.GeneralWebsiteConfig', ] -try: - import compute_api -except ModuleNotFoundError: - pass -else: - INSTALLED_APPS.append('compute_api.apps.ComputeApiConfig') MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', @@ -56,9 +50,16 @@ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'vinaigrette.middleware.VinaigretteAdminLanguageMiddleware', - 'compute_api.broadcast_middleware.BroadcastMiddleware', ] +try: + import compute_api +except ModuleNotFoundError: + pass +else: + INSTALLED_APPS.append('compute_api.apps.ComputeApiConfig') + MIDDLEWARE.append('compute_api.broadcast_middleware.BroadcastMiddleware') + ROOT_URLCONF = 'bloodmallet.urls' TEMPLATES = [ From 48c1d91ce3dd74ec33ea5856c7198994692fe887 Mon Sep 17 00:00:00 2001 From: Bloodmallet Date: Tue, 30 Apr 2019 21:48:29 +0200 Subject: [PATCH 18/18] add full paths, add optional superuser --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9a3f7f96..c61add5e 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,13 @@ pull requests. 5. Install requirements - `cd bloodmallet` (navigate into the created directory) - `python -m pip install --upgrade pip setuptools wheel` (update all basic tools) - - `(env)$ pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) -6. Start local django development server - - `(env)$ cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") - - `(env)$ python manage.py runserver` -7. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: + - `(env)bloodmallet/$ pip install -U -r requirements.txt` (install the actual requirements, have a look at the *_dev.txt file, too) +6. Create local database and tables + - `(env)bloodmallet/$ cd bloodmallet` (so you're in "bloodmallet/bloodmallet/") + - `(env)bloodmallet/bloodmallet/$ python manage.py migrate` +7. Start local django development server + - `(env)bloodmallet/bloodmallet/$ python manage.py runserver` +8. Open `http://127.0.0.1:8000` in your browser of choice. And code away! :tada: + +### Optional: +Maybe you want to [create a superuser](https://docs.djangoproject.com/en/2.2/intro/tutorial02/#creating-an-admin-user) for local development.