initial commit

This commit is contained in:
ronny abraham 2025-04-17 00:41:48 +03:00
commit edf0f7329a
147 changed files with 6231 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "usr/bin/fabric"]
path = usr/bin/customfabric
url = git@bitbucket.org:ronnyabraham/fabric.git

View file

Binary file not shown.

View file

@ -0,0 +1,32 @@
class DebugContainer():
_logger = None
def setLogger(self, logger):
self._logger = logger
def getLogger(self):
return self._logger
def __init__(self, logger):
self.setLogger(logger)
def debugmsg_beg(self, isdebug, msg):
logger = self.getLogger()
if isdebug and logger:
logger.debug("")
logger.debug(f"---- beg {msg} ----")
def debugmsg_end(self, isdebug, msg):
logger = self.getLogger()
if isdebug and logger:
logger.debug(f"---- end {msg} ----\n")
def debugmsg(self, isdebug, msg):
logger = self.getLogger()
if isdebug and logger:
logger.debug(msg)

View file

View file

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/share/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dvp',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['127.0.0.1', 'PROJECT_NAME.BRANCH_EXT', 'savage_lands.dvp', 'localhost']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log.debug',
'formatter': 'code'
},
'server.file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dvp/logs/django/django.log.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.log.debug',
'server.file.log.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/share/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dvp',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['127.0.0.1', 'PROJECT_NAME.BRANCH_EXT', 'savage_lands.dvp', 'localhost']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log.debug',
'formatter': 'code'
},
'server.file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dvp/logs/django/django.log.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.log.debug',
'server.file.log.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

16
code/core.old/asgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
ASGI config for core project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_asgi_application()

140
code/core.old/settings.py Normal file
View file

@ -0,0 +1,140 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
#
# add the directory that has the intialize.py module which contains the
# get_config function definition which will pull out all the configuraiton
# infomration for the settings file
sys.path.insert(0, os.path.join(
PROJECT_ROOT, 'usr', 'bin', 'fabric'))
#
# add an "apps" directory to this project, which is where all the apps
# ought to be in the first place.
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0gC!jEQ1;ng7Z~,a=J00q%jQw=9R_e[Rfn+MiaUGfGOK.ga!o!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'savage_lands.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'savage_lands.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'

View file

@ -0,0 +1,123 @@
"""
Django settings for core project.
Generated by 'django-admin startproject' using Django 5.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-s7naxkax)9-s0917np4o59+-n891hjq^f1gtap9n!inp21*a@n'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'core.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'core.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

22
code/core.old/urls.py Normal file
View file

@ -0,0 +1,22 @@
"""
URL configuration for core project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

16
code/core.old/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for estate project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "savage_lands._settings")
application = get_wsgi_application()

16
code/core.old/wsgi.py.bak Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for core project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_wsgi_application()

0
code/core/__init__.py Normal file
View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from core._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from core._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,169 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from core.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/share/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dvp',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['127.0.0.1', 'savage_lands.dvp', 'PROJECT_NAME.BRANCH_EXT', 'localhost']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s:%(module)s - %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s:%(lineno)d - %(message)s"
},
'code.file': {
'format': "%(levelname)s %(module)s:%(funcName)s - %(message)s\n"
},
},
'handlers': {
'file.log': {
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log',
'formatter': 'code.file'
},
'file.log.debug': {
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log.debug',
'formatter': 'code.file'
},
'server.file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dvp/logs/django/django.log.debug',
'formatter': 'code.file'
},
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'console.code': {
'class': 'logging.StreamHandler',
'formatter': 'code',
},
'null': {
'class': 'logging.NullHandler',
}
},
'root': {
# automatically set to level WARNING
'handlers': ['console.code', 'file.log', 'server.file.log.debug' ],
'propagate': True,
},
'loggers': {
'django.info': {
'handlers':
[
'console',
'file.log'
],
'level': 'INFO',
'propagate': False,
},
'django.debug': {
'handlers':
[
'console.code',
'file.log.debug',
'server.file.log.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

View file

@ -0,0 +1,169 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from core.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/share/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dvp',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dvp/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['savage_lands.dvp', 'PROJECT_NAME.BRANCH_EXT', 'localhost', '127.0.0.1']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s:%(module)s - %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s:%(lineno)d - %(message)s"
},
'code.file': {
'format': "%(levelname)s %(module)s:%(funcName)s - %(message)s\n"
},
},
'handlers': {
'file.log': {
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log',
'formatter': 'code.file'
},
'file.log.debug': {
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.log.debug',
'formatter': 'code.file'
},
'server.file.log.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dvp/logs/django/django.log.debug',
'formatter': 'code.file'
},
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'console.code': {
'class': 'logging.StreamHandler',
'formatter': 'code',
},
'null': {
'class': 'logging.NullHandler',
}
},
'root': {
# automatically set to level WARNING
'handlers': ['console.code', 'file.log', 'server.file.log.debug' ],
'propagate': True,
},
'loggers': {
'django.info': {
'handlers':
[
'console',
'file.log'
],
'level': 'INFO',
'propagate': False,
},
'django.debug': {
'handlers':
[
'console.code',
'file.log.debug',
'server.file.log.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

16
code/core/asgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
ASGI config for core project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_asgi_application()

145
code/core/settings.py Normal file
View file

@ -0,0 +1,145 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 4.2.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
#
# add the directory that has the intialize.py module which contains the
# get_config function definition which will pull out all the configuraiton
# infomration for the settings file
sys.path.insert(0, os.path.join(
PROJECT_ROOT, 'usr/bin/customfabric'))
#
# add an "apps" directory to this project, which is where all the apps
# ought to be in the first place.
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'kkNN=6(cOI7V*xQlBMmCQ.)Iy%$-r#.OStN3.#xO=5?BEeZ)M:'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'core.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'core.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

145
code/core/settings.py.bak Normal file
View file

@ -0,0 +1,145 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 4.2.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
#
# add the directory that has the intialize.py module which contains the
# get_config function definition which will pull out all the configuraiton
# infomration for the settings file
sys.path.insert(0, os.path.join(
PROJECT_ROOT, 'usr/bin/customfabric'))
#
# add an "apps" directory to this project, which is where all the apps
# ought to be in the first place.
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '5s!PefD*Jh3e6hS+T.g;o(RIEsCN8fi\3x?@Wc6G[<$ORE@p5='
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'core.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'core.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

22
code/core/urls.py Normal file
View file

@ -0,0 +1,22 @@
"""
URL configuration for core project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

16
code/core/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for estate project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core._settings")
application = get_wsgi_application()

16
code/core/wsgi.py.bak Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for core project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_wsgi_application()

22
code/manage.py Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View file

Binary file not shown.

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dev',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': '192.168.99.100',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['savage_lands.dev', 'localhost', '127.0.0.1', 'PROJECT_NAME.BRANCH_EXT']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.debug',
'formatter': 'code'
},
'server.file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dev/logs/django/django.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.debug',
'server.file.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dev',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': '192.168.99.100',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['savage_lands.dev', 'localhost', '127.0.0.1', 'PROJECT_NAME.BRANCH_EXT']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.debug',
'formatter': 'code'
},
'server.file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dev/logs/django/django.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.debug',
'server.file.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

View file

@ -0,0 +1,16 @@
"""
ASGI config for savage_lands project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'savage_lands.settings')
application = get_asgi_application()

View file

@ -0,0 +1,140 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
#
# add the directory that has the intialize.py module which contains the
# get_config function definition which will pull out all the configuraiton
# infomration for the settings file
sys.path.insert(0, os.path.join(
PROJECT_ROOT, 'usr', 'bin', 'fabric'))
#
# add an "apps" directory to this project, which is where all the apps
# ought to be in the first place.
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'M[*NhMY>c<Y9/c+%H>TTwad]kB9d@,XUh6{#I2kNhS[/-UylLg'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'savage_lands.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'savage_lands.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'

View file

@ -0,0 +1,120 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 3.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '1va$cgriqej6n5yw50&8ujdic*#yk%o10ezer6&b27n7_$vfy_'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'savage_lands.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'savage_lands.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'

View file

@ -0,0 +1,21 @@
"""savage_lands URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

View file

@ -0,0 +1,16 @@
"""
WSGI config for estate project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "savage_lands._settings")
application = get_wsgi_application()

View file

@ -0,0 +1,16 @@
"""
WSGI config for savage_lands project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'savage_lands.settings')
application = get_wsgi_application()

View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,8 @@
LOCAL_SETTINGS = True # avoid recursive imports
from savage_lands._settings.development_generated import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dev',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': '172.17.0.2',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['savage_lands.dev', 'localhost', '127.0.0.1', 'PROJECT_NAME.BRANCH_EXT']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.debug',
'formatter': 'code'
},
'server.file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dev/logs/django/django.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.debug',
'server.file.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

View file

@ -0,0 +1,134 @@
# this file contains settings that are automatically generated
# put custom commands/ imports in a separate file!
LOCAL_SETTINGS = True # avoid recursive imports
BRANCH = 'development'
from savage_lands.settings import *
import logging
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
SITE_ID = 1
TEMPLATES[0]['DIRS'].append(
"/Users/ronny/projects/django/savage_lands.prj/templates")
#
# NOTE: a lot of the code in these local settings files are automated and you
# might be inclined to take them out and move them into the main settings.py
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
# Once I set that file, THEN all the rest of the information can be automated.
# So all these automated info needs to be here.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'savage_lands_dev',
'USER': 'ronny',
'PASSWORD': 'admin',
'HOST': '172.17.0.2',
'PORT': '49036',
}
}
#
# directory from which we serve static files
#
# NOTE: both STATIC and MEDIA roots are getting their values from the
# initialization files that are set up above. Also, MEDIA_ROOT is being set
# to something called "paths.server.media.dynamic" - the names are different,
# but it means the same thing.
#
# MEDIA_ROOT is the dynamic media information that the web server, user or
# admin # will be adding and taking out. It's why I call it "dynamic"
STATIC_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/static'
MEDIA_ROOT = '/usr/local/var/www/savage_lands.dev/public/media/dynamic'
# directories from which we search for static files to place in STATIC_ROOT
# these static files are located within the project root as opposed to the
# server root location
STATICFILES_DIRS = (
os.path.join("/Users/ronny/projects/django/savage_lands.prj", "share", "media"),
)
# debug and debug toolbar settings
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on development environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = ['savage_lands.dev', 'localhost', '127.0.0.1', 'PROJECT_NAME.BRANCH_EXT']
# -----------------------------------------
# Debug logging to the console
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
" %(thread)d %(message)s"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'code': {
'format': "%(module)s:%(funcName)s - %(message)s"
},
},
'handlers': {
'file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/Users/ronny/projects/django/savage_lands.prj/var/log/django.debug',
'formatter': 'code'
},
'server.file.debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename':
'/usr/local/var/www/savage_lands.dev/logs/django/django.debug',
'formatter': 'code'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
}
},
'loggers': {
'django.debug': {
# use the console for logging
'handlers':
[
'console',
'file.debug',
'server.file.debug',
],
'level': 'DEBUG',
'propagate': True,
},
}
}

16
code/savage_lands/asgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
ASGI config for savage_lands project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'savage_lands.settings')
application = get_asgi_application()

View file

@ -0,0 +1,140 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
#
# add the directory that has the intialize.py module which contains the
# get_config function definition which will pull out all the configuraiton
# infomration for the settings file
sys.path.insert(0, os.path.join(
PROJECT_ROOT, 'usr', 'bin', 'fabric'))
#
# add an "apps" directory to this project, which is where all the apps
# ought to be in the first place.
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'D!Pk$rGQPUx3s2:uqYWtfgS9o}BWbGzH7U]W<XDs)IUgXzgmR/'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'savage_lands.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'savage_lands.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'

View file

@ -0,0 +1,120 @@
"""
Django settings for savage_lands project.
Generated by 'django-admin startproject' using Django 3.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'obl$!v$w14w=)3=v)#vjqtptp&(wfvq=p!8!24^12!v93b+y*y'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'savage_lands.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'savage_lands.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'

21
code/savage_lands/urls.py Normal file
View file

@ -0,0 +1,21 @@
"""savage_lands URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

16
code/savage_lands/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for estate project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "savage_lands._settings")
application = get_wsgi_application()

View file

@ -0,0 +1,16 @@
"""
WSGI config for savage_lands project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'savage_lands.settings')
application = get_wsgi_application()

View file

@ -0,0 +1,60 @@
## main info
https://medium.com/scalereal/the-ultimate-guide-to-using-social-login-in-django-f0abe0022ab0
### facebook settings
#### these settings are needed for csrf to work
ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'
[source for account default setting](https://stackoverflow.com/questions/55666103/django-allauth-facebook-integration-login-failure)
CSRF_TRUSTED_ORIGINS = ['https://oauth.drftesting.net']
ALLOWED_HOSTS = ['https://oauth.drftesting.net']
#### settings in facebook developer apps
##### in app settings / basic
app settings->basic
###### app domains
add the top level domain and the full domain. should look like
drftesting.net
oauth.drftesting.net
go a little further down and click on the button that says "add platform"
###### Site URL
put the full site url in with "https"
https://oauth.drftesting.net/
##### under products
products->facebook login->configure (dropdown) -> settings
set Embedded Browser OAuth Login to yes
##### in Valid OAuth Redirect URIs add the callback url:
example url:
https://oauth.drftesting.net/accounts/facebook/login/callback/
######source on creating and setting up a facebook app
[configure facebook login](https://help.sharetribe.com/en/articles/666072-configure-facebook-login)
######django alluth doc on how to configure callback
[django allauth callback](https://django-allauth.readthedocs.io/en/latest/socialaccount/providers/index.html?highlight=callback)
## how to get a test authentication token
https://developers.facebook.com/docs/marketing-apis/overview/authentication/

View file

@ -0,0 +1,32 @@
in order to use the facebook login with our DRF we need to first get an access token from facebook
then we must login to an OAuth2 application to get an authorization token from our system
so we must have an OAuth Application set up before we can use the facebook token with the DRF
1. install [Django OAuth Toolkit](https://django-oauth-toolkit.readthedocs.io/en/latest/)
2. read and apply [Step 3: Register an application](https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/getting_started.html#step-3-register-an-application)
note: step 2 can be done in the admin under Django OAuth Toolkit > Application
1. install the [Django rest-framework Social OAuth2](https://github.com/RealmTeam/django-rest-framework-social-oauth2) package
2. go to the facebook developers [debug access token](https://developers.facebook.com/tools/accesstoken/) page, and get a fake user access token
3. test it using the shell script *facebook_convert.sh* which is located in **/opt/shell-commands/social_rest**
4. or just run the command
`curl -X POST -d "grant_type=convert_token`
`&client_id=$CLIENT_ID`
`&client_secret=$CLIENT_SECRET`
`&backend=facebook`
`&token=$FACEBOOK_USER_TOKEN"`
` $baseurl/auth/convert-token`
where CLIENT\_ID, CLIENT\_SECRET, AND FACEBOOK\_USER\_TOKEN are all either variables or direct values put in the proper places
CLIENT\_ID and CLIENT_SECRET you get from the OAuth application you created before. That application manages authorized user tokens to let users make DRF requests on authorization only parts of the system
FACEBOOK\_USER\_TOKEN is a value you get **AFTER** you've logged into facebook. at the facebook developers [debug access token page](https://developers.facebook.com/tools/accesstoken/) you look up the Facebook app you are trying to log into, and get a debug user access token.
In production, this means that you ahve to log into facebook **only** via web or by ios, you **absolutely cannot** log into facebook by the command line. No way.
So in production you will have to retrieve the access token facebook provides after login, *then* make the call to retrieve *yet another* access token from the Django OAuth Application you set up on your web server.

View file

@ -0,0 +1,103 @@
# getting testing authorization tokens for the django rest framework
The purpose of this readme is to explain how to retrieve testing tokens that can be passed into the django rest framework's oauth authorization to retrieve a user token
currently, this document will list how to get testing tokens for the following platforms:
- facebook
- google
## facebook
### getting an access token for testing
to get a testing token, go to graph api explorer
1. under "meta app", select the application you want a token for
2. under "user or page", select "user token" from the dropdown
3. under "add a permission", select "email" from the dropdown
4. then hit "generate access token" button, and you're good to go
[graph api explorer](https://developers.facebook.com/tools/explorer/)
#### sources
[configure facebook login](https://help.sharetribe.com/en/articles/666072-configure-facebook-login)
[getting a testing token for authentication](https://developers.facebook.com/docs/marketing-apis/overview/authentication/)
## google
### notes
in the case of the google provider we don't actually want the
access token what we want is the ID TOKEN that is returned
#### setting up credentials
To use OAuth playground to get the id token, you have to first set
the Authorized Redirect URLs in the oauth credential section to at least have:
https://developers.google.com/oauthplayground
#### oauth playground
next in OAuth Playground, set it up to use your client
1. click the settings wheel in the upper left corner
2. click on 'use your own OAUTH credentials'
3. enter the client id and client secret
##### Step1
go to Step1 Select & authorize APIs
1. find Google OAuth2 API v2
2. select unserinfo.email and userinfo.profile
3. click Authorize APIs
##### Step2
go to Step 2 Exchange authorization code for tokens
1. click Exchange authorization code for tokens
2. IGNORE access and refresh token!!! they are not relevant!
3. go to the right panel Request / Response
- in the json data, find 'id_token'
4. paste the id token in the field for auth_token in swagger
#### sources
[Using OAuth 2.0 to access Google APIs](https://medium.com/@anupama.pathirage/using-oauth-2-0-to-access-google-apis-1dbd01edea9a#:~:text=In%20a%20separate%20browser%20window,obtained%20in%20the%20previous%20step.)
[django allauth callback](https://django-allauth.readthedocs.io/en/latest/socialaccount/providers/index.html?highlight=callback)
# old info in this page
### Notes
facebook authorization requests are different than straight user/pass requests. One requires the user and pass registered with the django app when they signed in, etc. The other is via the users facebook account.
So the user must paas in his facebook account name and password
#### try using standard api get token method
Unlike the facebook request,this one passes the username and password that is already stored in Django
http http://127.0.0.1:8026/api-token-auth/ username=someuser1 password=testpass1
got to [facebook dev apps](https://developers.facebook.com/apps/)
get the
facebook test user name/pass
get client id and client secret from settings
apply:
`curl -X POST -d "client_id=<client_id>&client_secret=<client_secret>&grant_type=password&username=<user_name>&password=<password>" http://localhost:8000/auth/token

386
share/readmes/aws.md Normal file
View file

@ -0,0 +1,386 @@
## links
#### visudo
[configuring visudo](http://askubuntu.com/questions/539243/how-to-change-visudo-editor-from-nano-to-vim)
#### users
[tecmint.com complete guide to users](http://www.tecmint.com/add-users-in-linux/)
[How To Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server)
#### postgres
[ubuntu community postgres docs](https://help.ubuntu.com/community/PostgreSQL)
#### certbot
[certbot webpage to install ssl certificates](https://certbot.eff.org)
#### docker
[ubuntu docker ce install](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
[ubuntu docker compose install](https://docs.docker.com/compose/install/)
## adding/deleting users
#### adding a user:
*("www-data" is the group name for website stuff on gandi)*
> *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
***-G group*** adds the groups in a comma separated
***-d /home/username*** specifies the home directory to be created (necessary on ubuntu)
***-m*** flag to create scripts (necessary)
***-s /bin/bash*** what shell is to be used (default is none)
#### deleting a user
userdel -r {username}
## IMPORTANT
### set users primary group
**this is critical**
sudo usermod <username> -g www-data
### setting up ssh authentication
cat ~/.ssh/id\_rsa.pub | ssh **username@remote\_host** "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized\_keys"
## apt-get commands
**to see the package version:**
dpkg -s postgresql | grep Version
# setting up aws server
## creating the server instance
[aws instance](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html)
1. Open the [amazon EC2 console](https://console.aws.amazon.com/ec2/)
2. Choose **Launch Instance**
3. The *Choose an Amazon Machine Image (AMI)* page has basic configuration, so pick the first *ubuntu* configuration
4. This will take you to the *Choose an Instance Type* page, this chooses the hardware configuration, you want to pick **t2.micro**
5. Hit **Review and Launch**
6. This will take you to *Review Instance Launch* page, and that has an option for **Security Groups**, hit **Edit security groups**, on the page that pops up, pick the options you want to allow for your instance
7. When finished, hit "done" or whatever and you'll be taken back to the *Review Instance Launch* page, from here hit the **Launch** key
8. this will prompt you for a key pair. There are a few options. Create a new Pair and choose an existing key pair
####key pair info:
[aws info on key pairs](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)
[importing id_rsa](http://www.admin-magazine.com/CloudAge/Blogs/Dan-Frost-s-Blog/Importing-SSH-keys-on-AWS)
[add_ssh](http://stackoverflow.com/questions/8193768/trying-to-ssh-into-an-amazon-ec2-instance-permission-error)
1. mv /path/to/myname.pem ~/.ssh
2. ssh-add ~/.ssh/myname.pem
3. ssh ubuntu@INSTANCE_IP_ADDRESS
Remember that the IP ADDRESS changes whenever you restart the instance
on your computer
1. vim /etc/hosts
2. add a line with the server name and IP ADDRESS for that insntace
3. ssh ubuntu@SERVERNAME
## updating the hostname
[aws ubuntu hostname](https://aws.amazon.com/premiumsupport/knowledge-center/linux-static-hostname/)
[scroll down to find the "echo" comment](https://forums.aws.amazon.com/message.jspa?messageID=495274)
there is an issue with ubuntu instances on AWS, the name given in /etc/hostname doesn't match what exist in /etc/hosts. So if you try using sudo you'll get an error.
To fix this, you need to change those files, to get into sudo type in:
sudo su -
echo "127.0.0.1 $(hostname)" >> /etc/hosts
This will update /etc/hosts with the default hostname generated by amazon. Alternatively you can do what it says in the first link [aws ubuntu hostname](https://aws.amazon.com/premiumsupport/knowledge-center/linux-static-hostname/)
### setup visudo
sudo update-alternatives --config editor
su -c 'visudo'
find this line:
USERNAME ALL=(ALL) NOPASSWD: ALL
replace it with:
admin ALL=(ALL) ALL
## add new user
[adding a user on linux AWS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html)
[how to get an add the public key to the new user](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#retrieving-the-public-key)
1. *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
2. *mkdir projectdir*
### set users primary group
**this is critical**
- The primary group is the group applied to you when you log in using the usual methods (TTYs, GUI, SSH, etc.).
sudo usermod <username> -g www-data
### set password
sudo passwd <username>
### setting up ssh authentication
1. get the public key:
ssh-keygen -y -f /path/to/myinstance.pem
2. copy the above results
3. log in to the ubuntu instance using default ubuntu user
4. change users to the custom username
sudo su - username
5. create the ssh directory and auth file
cd /home/username
mkdir .ssh
touch .ssh/authorized_keys
vim ~/.ssh/authorized_keys
6. change the permissions
chown -R username:username_gropus .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
7. now paste in the public_key you got in step 1
8. log out and test with the username
ssh username@instance.domain
### add username to the sudo group
AWS has a sudo group that allows a user sudo priveleges
usermod -a -G sudo username
### apt-get setup
sudo apt-get update
sudo apt-get install aptitude
## postgres
### note:
if you are using docker for postgres, skip this and go to the docker section. It is completely unnecessary and you don't even need to install postgres
#### links fix locale error with postgres
[could not connect to server solution](http://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432)
[locale solution](http://ubuntuforums.org/showthread.php?t=1346581)
[remote connecting](http://www.railszilla.com/postgresql-tcpip-connections-port-5432/coffee-break)
sudo apt-get install postgresql
sudo apt-get install postgresql-contrib
sudo locale-gen en_US en_US.UTF-8 hu_HU hu_HU.UTF-8
sudo dpkg-reconfigure locales
sudo service postgresql restart
sudo -u postgres psql postgres
sudo -u postgres createdb **website_dbname**
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install postgresql-server-dev-9.3
#### change password for db user "postgres"
sudo -u postgres psql postgres
ALTER USER Postgres WITH PASSWORD '<newpassword>';
#### set up postgresql to remote access
######(see "remote connecting" link above)
#####Note: be careful with this, because **anyone** will be able to mess around with it
1. sudo vim /etc/postgresql/9.3/main/postgresql.conf
2. find **listen\_addresses** and change it to **listen\_addresses = '\*'**
3. sudo vim /etc/postgresql/9.3/main/pg_hba.conf
4. find **host all all 127.0.0.1/32 trust** and change **127.0.0.1/32** to **0.0.0.0/0**
5. sudo service postgresql restart
6. test it by running: *psql -h* ***ip\_address*** *-U* ***username*** *-d* ***database***
7. e.g. psql -h 173.246.107.96 -U postgres postgres
## setup the /var/www directory
cd /var
sudo mkdir www
sudo chgrp www-data www -R
sudo chmod g+w www -R
## install python packages
sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install libjpeg-dev
## install and set up supervisor
sudo apt-get install supervisor
make sure www-data is a group for the main user
vim /etc/supervisor/supervisord.conf
add the following:
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0770
chown=nobody:www-data
[supervisorctl]
serverurl=unix:///var/run//supervisor.sock
chmod=0770
chown=nobody:www-data
#### run the following commands:
sudo service supervisor stop
sudo service supervisor start
### install pip and virtualenv
[virtualenv install](http://roundhere.net/journal/virtualenv-ubuntu-12-10/)
sudo apt-get install python-pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
echo "WORKON_HOME=~/.virtualenvs" >> .bashrc
echo ". /usr/local/bin/virtualenvwrapper.sh" >> .bashrc
## Docker
### docker
##### uninstall old (if necessary)
sudo apt-get remove docker docker-engine docker.io containerd runc
##### set up apt-get
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
##### verify install
check that fingerprint key "9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88" is the same
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
##### install repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
##### install docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
### docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
## nginx
sudo apt-get install nginx
## certbot
In order to use ssl/https it is necessary to install a certificate. This is especially true if the nginx config file has *already* been set up to use ssl. (for example, you are reinstalling an environment, or creating production based on staging, etc)
[certbot.eff.org](certbot.eff.org) allows you to install a free certificate
#### add certbot ppa
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
#### install certbot
sudo apt-get install certbot python-certbot-nginx
#### Choose how you'd like to run certbot
##### OPTION1: get and install your certificates
sudo apt-get install certbot python-certbot-nginx
##### OPTION2: just get the certificate (already configured)
sudo certbot --nginx
Use Option1 when you are just starting a project, but you know you are going to be using SSL
Use Option2 when you have already set up nginx to work with https, for example, you are reinstalling an existing project, etc.
## set up vim remote editing
this just means adding the server pem file location to .ssh/config
in ~/.ssh/config add the following info
Host minionfinder.com
HostName minionfinder.com
IdentityFile /Users/ronny/projects/django/minyanfinder.prj/share/ssh/minionfinder.pem
where *minionfinder.com* refers to the host name
and the **IdentityFile** section is the fully qualified pathname of the pem file
# bootstrap server
fab (prod|rel) deploy.bootstrap

1
share/readmes/certbot.md Normal file
View file

@ -0,0 +1 @@
certbot looks through all configuration files and modifies them for ssl

46
share/readmes/curl.md Normal file
View file

@ -0,0 +1,46 @@
## Multiple header values
when you have more than one header value, ie you want to pass the authentication token **and** you want to pass json values
simply state each header value separately while preceeding it with the -H/--header prefix
e.g.
`-H "Authentication: Bearer 2342343" \`
`-H "Content-Type: application/json" `
note the forward slash \ is used to separate between lines for readability
## Passing the Authentication token
get an authentication token from the server
then pass it in through the header
`--header "Authorization: Bearer <token>`
## Passing Json Values Through Curl
##### step 1 - set the header
`--header "Content-Type: application/json"`
##### step 2 - encode the values
`-d "{\"name\":\"$2\", \"code\":\"$3\"}"`
the bracketed area must be enclose with double quotes (single could work, but we need to change the parameters into strings, and bash does not seem to do that with singles)
the parameter names and values must also be enclosed in **backslashed** double quotes
`\"`
this means the entire string has to be enclosed in normal doubles instead of singles to interpolate the values
## various
[how can i set the request header for curl](https://stackoverflow.com/questions/4212503/how-can-i-set-the-request-header-for-curl/45313572)
[curl snippets](https://gist.github.com/subfuzion/08c5d85437d5d4f00e58)
###### interpolate
*insert (something of a different nature) into something else.*

View file

@ -0,0 +1,23 @@
## Notes
facebook authorization requests are different than straight user/pass requests. One requires the user and pass registered with the django app when they signed in, etc. The other is via the users facebook account.
So the user must paas in his facebook account name and password
### try using standard api get token method
Unlike the facebook request,this one passes the username and password that is already stored in Django
http http://127.0.0.1:8026/api-token-auth/ username=someuser1 password=testpass1
got to [facebook dev apps](https://developers.facebook.com/apps/)
get the
facebook test user name/pass
get client id and client secret from settings
apply:
`curl -X POST -d "client_id=<client_id>&client_secret=<client_secret>&grant_type=password&username=<user_name>&password=<password>" http://localhost:8000/auth/token

View file

@ -0,0 +1,35 @@
###specify the font path to the "webfonts directory"
$fa-font-path: "../node_modules/@fortawesome/fontawesome-free/webfonts" !default;
###when importing from an app-local installation:
in this case "coffesshop" is the name of the app
`@import 'coffeeshop/node_modules/\@fortawesome/fontawesome-free/scss/fontawesome'`
`@import 'coffeeshop/node_modules/\@fortawesome/fontawesome-free/scss/solid'`
`@import 'coffeeshop/node_modules/\@fortawesome/fontawesome-free/scss/brands'`
### when importing from a shared directory
#### set the location in static and sass
`STATICFILES_DIRS = [
os.path.join(
PROJECT_ROOT,
'share/media/node_modules/@fortawesome'),
]`
`SASS_PROCESSOR_INCLUDE_DIRS = [
os.path.join(
PROJECT_ROOT,
'share/media/node_modules/@fortawesome'),
]`
#### now import directly from where you set loc above
`@import 'fontawesome-free/scss/fontawesome'`
`@import 'fontawesome-free/scss/solid'`
`@import 'fontawesome-free/scss/brands'`

132
share/readmes/foundation.md Normal file
View file

@ -0,0 +1,132 @@
# How to install Foundation Zurb
## Resources
* [node js](https://nodejs.org/en/download/)
* [foundation zurb](foundation.zurb.com)
## install nodeenv
[how to install nodeenv](https://calvinx.com/2013/07/11/python-virtualenv-with-node-environment-via-nodeenv/)
1. mkvirtualenv myproject1
2. pip install nodeenv
3. nodeenv -p
4. deactivate; workon myproject1
5. npm install -g foundation-cli
6. npm install -g autoprefixer
7. npm install -g generate
8. npm install -g postcss-cli
## install django sass processor
github url [django sass processor](https://github.com/jrief/django-sass-processor)
pip install django-sass-processor
### add to installed apps
sass_processor
### additional configuration settings
#### set extensions to look for
sass processor searches template files to find links to sass stylesheets. If using templates with a .django extension, you have to set the ext types you want the processor to search
SASS_TEMPLATE_EXTS = ['.django', '.html']
#### file search root directory
set the root value for which sass processor will search for sass files (set to the same value as static root)
SASS_PROCESSOR_ROOT = STATIC_ROOT
#### add cssfinder to static file finders
we need to tell the static finders thingie to use sass_processor
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
#### directories to look through
you must tell django wher eto find static files that you want to look through if you want to use them in a template
you must also tell the sass processor where those files are if you want the sass processor to be able to do anything with it
STATICFILES_DIRS = [
('node_modules',
os.path.join(
PROJECT_ROOT,
'share/media/node_modules/')),
os.path.join(
PROJECT_ROOT,
'share/media/node_modules/foundation-sites/scss'),
]
SASS_PROCESSOR_INCLUDE_DIRS = [
os.path.join(PROJECT_ROOT, 'share/media/node_modules'),
os.path.join(PROJECT_ROOT,
'share/media/node_modules/foundation-sites/scss'),
]
Notice how "node modules" is attached without a prefix.
also, I add direct links to the scss of the underlying packages so I can import them with a direct command
@import foundation
_instead of_
@import foundation-sites/scss/foundation
When you want to import sass modules underneath the "node_modules" directory you must refer to the directory structure _underneath_ the node modules structure:
@import foundation-sites/scss/foundation
however, to directly import the foundation sass library, you must do so through the "assets" directory referenced in static.
so foundation-sites/assets refers to what will be used in static, and foundation-sites/scss/foundation refers to compiling
### Usage
{% load sass_tags %}
<link href="{% sass_src 'myapp/css/mystyle.scss' %}"
rel="stylesheet" type="text/css" />
## installing Zurb Foundation Template
[how to install foundation with django](https://www.physics.utoronto.ca/~icom/workshop/django-install/foundation.html)
either open up the virtualenv that contains foundation-cli or create one, or just install foundation-cli
create a new template
foundation new
## installing via foundation-sites
npm install foundation-sites
# Alternate way of loading Foundation
install foundation-sites
link to foundation-sites parent directory
ln -s /pathto/node_modules/foundation-sites /pathto/sass/foundation-sites
inside the sass file import foundation as
@import foundation-sites/scss

233
share/readmes/gandi.md Normal file
View file

@ -0,0 +1,233 @@
## links
#### gandi
[connecting to gandi server](https://wiki.gandi.net/en/hosting/using-linux/how_to_connect_ai)
[accessing the server via ssh](https://wiki.gandi.net/en/hosting/using-linux/server-access)
[first steps with gandi server](https://wiki.gandi.net/en/hosting/gandi-expert/setup)
#### visudo
[configuring visudo](http://askubuntu.com/questions/539243/how-to-change-visudo-editor-from-nano-to-vim)
#### users
[tecmint.com complete guide to users](http://www.tecmint.com/add-users-in-linux/)
[How To Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server)
#### postgres
[ubuntu community postgres docs](https://help.ubuntu.com/community/PostgreSQL)
## adding/deleting users
#### adding a user:
*("www-data" is the group name for website stuff on gandi)*
> *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
***-G group*** adds the groups in a comma separated
***-d /home/username*** specifies the home directory to be created (necessary on ubuntu)
***-m*** flag to create scripts (necessary)
***-s /bin/bash*** what shell is to be used (default is none)
#### deleting a user
userdel -r {username}
## IMPORTANT
### set users primary group
**this is critical**
sudo usermod <username> -g www-data
### setting up ssh authentication
cat ~/.ssh/id\_rsa.pub | ssh **username@remote\_host** "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized\_keys"
## apt-get commands
**to see the package version:**
dpkg -s postgresql | grep Version
# setting up gandi server
## creating the server instance
after logging in, go to the virtual machine setup tab under *services* -> *servers*
[virtual machine](https://www.gandi.net/admin/iaas/vm)
under "servers" click "create a server". At the setup page you will have the option of either using an public ssh key, a password, or both. Pick both.
1. generate a password
2. go to ~/.ssh and look for something like *id_rsa.pub*
3. to put in on the clipboard, on OSX type *cat ~/.ssh/id_rsa.pub | pbcopy*
4. paste what's in the clipboard into the ssh input section
5. copy all this information down and start it up
## first steps with server
next follow the links under "gandi"
while you are doing the commands link *"first steps with gandi server"* you may want to do this command:
su -c 'apt-get install sudo'
su -c 'apt-get install vim'
after setting up "first steps with gandi server" above, you will want to configure visudo to use vim
### setup visudo
su -c 'update-alternatives --config editor'
su -c 'visudo'
find this line:
USERNAME ALL=(ALL) NOPASSWD: ALL
replace it with:
admin ALL=(ALL) ALL
(or whatever user name you are mainly using)
## add new user
1. *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
2. *mkdir projectdir*
### set users primary group
**this is critical**
sudo usermod <username> -g www-data
### set password
sudo passwd <username>
### setting up ssh authentication
cat ~/.ssh/id\_rsa.pub | ssh **username@remote\_host** "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized\_keys"
### apt-get setup
sudo apt-get update
sudo apt-get install aptitude
## postgres
#### links fix locale error with postgres
[could not connect to server solution](http://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432)
[locale solution](http://ubuntuforums.org/showthread.php?t=1346581)
[remote connecting](http://www.railszilla.com/postgresql-tcpip-connections-port-5432/coffee-break)
sudo apt-get install postgresql
sudo apt-get install postgresql-contrib
sudo locale-gen en_US en_US.UTF-8 hu_HU hu_HU.UTF-8
sudo dpkg-reconfigure locales
sudo service postgresql restart
sudo -u postgres psql postgres
sudo -u postgres createdb **website_dbname**
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install postgresql-server-dev-9.3
#### change password for db user "postgres"
sudo -u postgres psql postgres
ALTER USER Postgres WITH PASSWORD '<newpassword>';
#### set up postgresql to remote access
######(see "remote connecting" link above)
#####Note: be careful with this, because **anyone** will be able to mess around with it
1. sudo vim /etc/postgresql/9.3/main/postgresql.conf
2. find **listen\_addresses** and change it to **listen\_addresses = '\*'**
3. sudo vim /etc/postgresql/9.3/main/pg_hba.conf
4. find **host all all 127.0.0.1/32 trust** and change **127.0.0.1/32** to **0.0.0.0/0**
5. sudo service postgresql restart
6. test it by running: *psql -h* ***ip\_address*** *-U* ***username*** *-d* ***database***
7. e.g. psql -h 173.246.107.96 -U postgres postgres
### setup the /var/www directory
cd /var
sudo mkdir www
sudo chgrp www-data www -R
sudo chmod g+w www -R
### install python packages
sudo apt-get install python-dev
sudo apt-get install libjpeg-dev
## install and set up supervisor
sudo apt-get install supervisor
make sure www-data is a group for the main user
vim /etc/supervisor/supervisord.conf
add the following:
[unix_http_server]
file=/var/run//supervisor.sock
chmod=0770
chown=nobody:www-data
[supervisorctl]
serverurl=unix:///var/run//supervisor.sock
chmod=0770
chown=nobody:www-data
#### run the following commands:
sudo service supervisor stop
sudo service supervisor start
### install pip and virtualenv
[virtualenv install](http://roundhere.net/journal/virtualenv-ubuntu-12-10/)
sudo apt-get install python-pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
### install nginx
sudo apt-get install nginx
# bootstrap server
fab (prod|rel) deploy.bootstrap

25
share/readmes/geo.md Normal file
View file

@ -0,0 +1,25 @@
##if you get the following error:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
you must install on the host machine the following packages:
`sudo apt-get install binutils libproj-dev gdal-bin`
next you must update POstgres to use POSTGIS
[https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/postgis/](https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/postgis/)
## update postgres
### the following packages must be installed:
(x.x matching the PostgreSQL version you want to install)
postgresql-x.x
postgresql-x.x-postgis
postgresql-server-dev-x.x
python-psycopg2
find out the postgres server number:
`apt list --installed | grep 'post'`

View file

@ -0,0 +1,9 @@
## important gunicorn error
https://stackoverflow.com/questions/53570850/djangogunicorn-operation-not-permitted;
the problem is that if supervisor sets both user and group, and then gunicvorn does it, you can
get a blow up.
so comment it out in one conf or the other

6
share/readmes/nginx.md Normal file
View file

@ -0,0 +1,6 @@
if you get a Django ERROR (EXTERNAL IP): Invalid HTTP_HOST header: '*.domain.com'
https://notabela.hashnode.dev/how-to-solve-the-domain-name-provided-is-not-valid-according-to-rfc-10341035-in-django-during-development

View file

@ -0,0 +1 @@
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

36
share/readmes/postgis.md Normal file
View file

@ -0,0 +1,36 @@
## how to set up postgis
use [docker-postgis](https://github.com/kartoza/docker-postgis)
#### setting docker-postgis to use django unit testing
1. get into the running docker shell
2. open postgresql client as postgres user (you have to do this from the command line in the container as you cannot do it remotely)
3. ALTER ROLE \<user_name\> SUPERUSER;
4. set \<user_name> as admin
now the admin can run the tests
`sudo docker exec -it minyanfinder_development_db bash`
#### another more elegant solution to the problem
[create extension without superuser role](https://stackoverflow.com/questions/16527806/cannot-create-extension-without-superuser-role)
[potential problem if it's not working](https://stackoverflow.com/questions/39556719/django-test-error-creating-the-test-database-permission-denied-to-copy-databas)
createdb template_postgis; # create a new database
psql -U postgres -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';" # make it a template psql -U postpsql -U postgres -d template_postgis -c "CREATE EXTENSION postgis;" # install postgis in it
example:
createdb -h localhost -p 49032 -U admin template_postgis
psql -h localhost -p 49032 -U admin minyanfinder_dev -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';"
psql -h localhost -p 49032 -U admin -d template_gis -c "CREATE EXTENSION postgis;"
in local settings file:
DATABASES['default']['TEST'] = dict()
DATABASES['default']['TEST']['TEMPLATE'] = 'template_postgis'

View file

@ -0,0 +1 @@
xcode-select --install

9
share/readmes/regex.md Normal file
View file

@ -0,0 +1,9 @@
# useful regex commands
## convert href to static
`.s/href="\([^"]\+\)"/href="{% static '\1' %}"`
use when **href="/some/link/file.css"** if the
quotes are single quotes, then convert them to double

View file

@ -0,0 +1,49 @@
I try different commands and some of the answers help me. Only this sequence in my case fixed both broken dependencies in migrations in MYAPP and clean all past migrations starting from scratch.
Before doing this ensure that database is already synced (e.g. do not add a new Model field here or change Meta options).
rm -Rf MYAPP/migrations/*
python manage.py makemigrations --empty MYAPP
python manage.py makemigrations
python manage.py migrate --fake MYAPP 0002
Where 0002 is the migration number returned by the last makemigrations command.
Now you can run makemigrations / migrate again normally because migration 0002 is stored but not reflected in the already-synced database.
if you really want to go crazy delete all the tables in teh database related to the app and then
DELETE FROM django_migrations WHERE app='registry'
-------
this is what I do
first I clear out everything:
rm -Rf appname/migrations
fab database.drop_all
fab database.init
fab django.manage:migrate
fab django.manage:syncdb
then I re-add the app
fab django.manage:"makemigrations appname"
fab django.manage:migrate
at that point I have working table
so again
rm -Rf {ON HOST}/appname/migrations
fab ONHOST database.drop_all
fab ONHOST database.init
fab ONHOST deploy.sync <--- CRITICAL STEP DO NOT FORGET
fab ONHOST django.manage:migrate
fab ONHOST django.manage:syncdb

22
share/readmes/sass.md Normal file
View file

@ -0,0 +1,22 @@
##Sass
### How to set up sass watch with multiple directories
````
sass -I share/media/projectwide_sass_files
--watch code/apps/sassdir:code/apps/cssdir
````
### How to get vim to work with a sass file include
````
let g:syntastic_sass_sass_args="
-I /Full/share/media/projectwide_sass_files"
````
you can also add multiple directories to the -I directive. Separate them with a space
[fixing syntastic check args](http://stackoverflow.com/questions/29041876/fixing-syntasticcheck-bootstrap-error-vim-syntastic-plugin)
[syntastic manual](https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt)

View file

@ -0,0 +1,15 @@
`Host **my-remote-server**` *a symbolic name of your choice*
`Hostname **server-IP-or-DNS**` *the real name*
`User **username**` *the username you use for login*
`IdentityFile ~/.ssh/a_suitable_ssh_key_if_any` *for authentication purposes*
`ControlMaster auto`
`ControlPath ~/.ssh/%C`
*or* `~/.ssh/%h-%p-%r` *for older versions*
`ControlPersist 5m` *or* `yes` *for never expiring persistent connection*

View file

@ -0,0 +1,32 @@
in order to use the facebook login with our DRF we need to first get an access token from facebook
then we must login to an OAuth2 application to get an authorization token from our system
so we must have an OAuth Application set up before we can use the facebook token with the DRF
1. install [Django OAuth Toolkit](https://django-oauth-toolkit.readthedocs.io/en/latest/)
2. read and apply [Step 3: Register an application](https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/getting_started.html#step-3-register-an-application)
note: step 2 can be done in the admin under Django OAuth Toolkit > Application
1. install the [Django rest-framework Social OAuth2](https://github.com/RealmTeam/django-rest-framework-social-oauth2) package
2. go to the facebook developers [debug access token](https://developers.facebook.com/tools/accesstoken/) page, and get a fake user access token
3. test it using the shell script *facebook_convert.sh* which is located in **/opt/shell-commands/social_rest**
4. or just run the command
`curl -X POST -d "grant_type=convert_token`
`&client_id=$CLIENT_ID`
`&client_secret=$CLIENT_SECRET`
`&backend=facebook`
`&token=$FACEBOOK_USER_TOKEN"`
` $baseurl/auth/convert-token`
where CLIENT\_ID, CLIENT\_SECRET, AND FACEBOOK\_USER\_TOKEN are all either variables or direct values put in the proper places
CLIENT\_ID and CLIENT_SECRET you get from the OAuth application you created before. That application manages authorized user tokens to let users make DRF requests on authorization only parts of the system
FACEBOOK\_USER\_TOKEN is a value you get **AFTER** you've logged into facebook. at the facebook developers [debug access token page](https://developers.facebook.com/tools/accesstoken/) you look up the Facebook app you are trying to log into, and get a debug user access token.
In production, this means that you ahve to log into facebook **only** via web or by ios, you **absolutely cannot** log into facebook by the command line. No way.
So in production you will have to retrieve the access token facebook provides after login, *then* make the call to retrieve *yet another* access token from the Django OAuth Application you set up on your web server.

View file

@ -0,0 +1,2 @@
node.js
https://lincolnloop.com/blog/installing-nodejs-and-npm-python-virtualenv/

View file

@ -0,0 +1,54 @@
* set up using docker
## setup the /var/www directory
cd /var
sudo mkdir www
sudo chgrp www-data www -R
sudo chmod g+w www -R
## install python packages
sudo apt-get install python-dev
sudo apt-get install libjpeg-dev
## install supervisor
sudo apt-get install supervisor
make sure www-data is a group for *user*
modify /etc/supervisor/supervisord.conf
add the following:
[unix_http_server]
file=/var/run//supervisor.sock ; (the path to the socket file)
chmod=0770 ; sockef file mode (default 0700)
chown=nobody:www-data
[supervisorctl]
serverurl=unix:///var/run//supervisor.sock ; use a unix:// URL for a unix socket
chmod=0770
chown=nobody:www-data
#### run the following commands:
sudo service supervisor stop
sudo service supervisor start
## install postgres
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install postgresql-server-dev-9.1
## install pip and virtualenv
http://roundhere.net/journal/virtualenv-ubuntu-12-10/
sudo apt-get install python-pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
1. setup scripts/meta/configuration/branch.yml
1. setup scripts/meta/virtualenv/branch.txt

View file

@ -0,0 +1,96 @@
# Social Auth notes
## basic python_social_auth
### How to Add Social Login to Django
[How to Add Social Login to Django](https://simpleisbetterthancomplex.com/tutorial/2016/10/24/how-to-add-social-login-to-django.html)
#### pre test notes
1. disable 'test_social.middleware.ForwardHQMiddleware'
2. reset LOGIN_REDIRECT_URL = '/tsoc' or to wherever you want it to land
3. set SOCIAL_AUTH_URL_NAMESPACE = 'social'
4. DON'T use localhost if you plan on using twitter, twitter doesn't like it
#### error in login
[stackoverflow desc](https://stackoverflow.com/questions/46975657/attributeerror-module-django-contrib-auth-views-has-no-attribute-login)
change:
`path('login/', views.login, name='login')`
`path('login/', views.LoginView.as_view(template_name="registration/login.django"), name='login')`
#### when making callback urls
- you can use localhost
- you can also specify a port on localhost, e.g. http://localhost:8026
- you can also use minyanfinder.stg or any .stg
- make sure to specify the "u" letter in oauth
- make sure to add the final forward slash "/" at the end of the callback url
`minyanfinder.stg/oauth/complete/twitter/`
## global variables
global variables should be in settings.py
local info like the specific client id/secret key, etc, should be in the local setting sfiles
test_social should only be activated in the local setting files
### twitter notes
1. you want to either use http or https, be specific
2. twitter does not use localhost and forwardhq is buggy
3. twitter DOES register 127.0.0.1:8026 as a callback
### facebook notes
1. can use localhost
2. minaynfinder.stg is not working, need a certificate of some kind
3. forwardhq also not working
#### using a domain
##### create registered users
Go to Roles->Test Users
##### create the ssl
1. set a registered domain name to point at the ip address (ie ronnyabraham.com)
2. create a [https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs#generating-ssl-certificates](crt certificate)
3. `Settings->Basic-> App Domains` add `ronnyabraham.com`
4. `Settings->Basic->Website/Site URL` add `https://ronnyabraham.com`
5. in Products->FacebookLogin->Settings add the following to "VAlid OAuth Redirect URIs"
- https://ronnyabraham.com
- https://ronnyabraham.com/oauth/complete/facebook/
6. use letsencrypt to create ssl keys
### setting up facebook
1. if used for testing make sure you set the app FOR TESTING you have to do this in the create app stage
2. [select create test app from the app you like](https://imgur.com/RzK3pS3)
3. go to settings->basic get the app-id and app-secret
4. go to Settings-Basic-App Domains and add your FQDN (ie. mycrustyass.com)
5. go to Settings-Basic-Website (it's near the bottom, add website if it isn't there), add the site URL with it's prefix ie http or https.
Step 5 is VERY IMPORTANT b/c facebook doesn't recognize http prefix.
You must have SSL set up. But this is NOT the caes with localhost!
6. in Settings-Products add Facebook Login then set Web OAuth Login to true
7. Settings-Products-Facebook Login add Valid OAuth redirect calls.
Important! You must find out what the specific redirect call looks like. Once again, facebook doesn't require this for localhost, but for a named host it does
e.g. https://mycrustyass.com/oauth/complete/facebook/
8. test this URL in the Settings-Products-FAcebook Login-Redirect URL Validator

51
share/readmes/sphinx.md Normal file
View file

@ -0,0 +1,51 @@
## to set up a project for documentation
assuming we are using someproject:
sphinx-apidoc -o /PATH-TO/someproject/docs/source/ /PATH-TO/someproject/
sphinx-build -b html /PATH-TO/someproject/docs/source /PATH-TO/someproject/docs/build/html
cd /PATH-TO/someproject/docs
make html
/PATH-TO/someproject - contains all the source files that we are looking at
/PATH-TO/someproject/docs - wherever the sphinx doc files, build, conf, etc are located
/PATH-TO/someproject/docs/source - contains the SPHINX configuration info for how to read the source
### when setting up sphinx for use with a django app
if you get an error that looks like:
sphinx raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
from https://stackoverflow.com/questions/34461088/sphinx-apidoc-on-django-build-html-failure-on-django-core-exceptions-appregistr
import django
sys.path.insert(0, os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
django.setup()
what I did in the drfcryce project for apps.todos:
import os
import sys
import django
sys.path.insert(0, os.path.abspath('../../../'))
sys.path.insert(0, os.path.abspath('../../../../'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'drfcryce._settings.development'
django.setup()
the first two sys.path fixes are to add the apps/todos to do the python path, and
to add the drfcryce settings directory to the python path
### to set up vim
let g:syntastic_rst_checkers=['sphinx']
let g:syntastic_rst_sphinx_source_dir="/path/to/docs/source"
let g:syntastic_rst_sphinx_config_dir="/path/to/docs/source"
the first path must lead to where ever index.rst is located
the second path must lead to where ever conf.py is located

View file

@ -0,0 +1,32 @@
# how to do django translation
[https://docs.djangoproject.com/es/1.9/topics/i18n/translation/]()
#### translation for templates
[https://docs.djangoproject.com/es/1.9/topics/i18n/translation/#translator-comments-in-templates]()
#### language switching
[https://docs.djangoproject.com/es/1.9/topics/i18n/translation/#switching-language-in-templates]()
#### how to create language files
[https://docs.djangoproject.com/es/1.9/topics/i18n/translation/#localization-how-to-create-language-files]()
you have to set the -e extension to specify files you want to use. e.g.
`django-admin makemessages -e django`
`fab django.admin:"makemessages -l en -e django"`
after creating the .po files you have to compile them for use
`django-admin compilemessages`
`fab django.admin:"compilemessages"`
### set langauge redirect
[https://docs.djangoproject.com/es/1.9/topics/i18n/translation/#the-set-language-redirect-view]()

View file

@ -0,0 +1,20 @@
in order to update the images
1. make fixtures - fab django.create_fixtures:appname
2. copy fixtures - cp extras/backups/fixtures/appname/appname.json
code/app/appname/fixtures/appname.json
3. deploy - fab <branch> deploy.sync
4. copy images - cp extras/path/to/images/* /var/www/project.branch/public/media/dynamic
5. check pip - make sure virtualenv txt is updated to development
6. syncdb - fab <branch> django.manage:syncdb
5. ?flush - fab <branch> django.manage:flush
6. ?superuser - fab <branch> django.manage:createsuperuser
7. load fixture - fab <branch> django.manage:"loaddata fixture appname"
if first time:
-? fab <branch> django.manage:"makemigrations thumbnail"
-? fab <branch> django.manage:migrate
8. ?clear thumbs - fab <branch> django.manage:"thumbnail clear"

View file

@ -0,0 +1,23 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAvEr+QT7IA6V4JwElXuOV1mHdLcakErLh1M/dtpd+oiXzj5MjXeZrnYlgyGtv
yOVIEw+K3t0d0jIAXCh8/OzRq8euzAah4GXS3Q9T+9zFhvcf6XvSDQh88Ho06WtxTjTuTZ9xgFEF
x9iOqKxkr6kn0OH+26bCl92SysDrld2s0FK6Qv0Z8hBHI8yrDG1ENNQOOMoVsgLkjg3E4UGpQ/KJ
XkBR/vFCez9YWj1EFwTGaP26Y+RAHY4E57TDuhDU9/xBUeFoZ7GLfuRxxJo6hK1oLfJrPs0yfYVX
dA1yQ8qi+X/MzLk09TTN65aDoeWW7gNppGZSINgtxG4mvtSXKhUxcwIDAQABAoIBAE+ZQFzipnls
JRwQDvVLLpefbXohhFDnUDK/4RGEf6MaehlS8VuLwiip38E6MdpymwJ7ypAmV6n5O0+6SgQ+NPDy
jEFx+FK9mOOczDsn/FTu+Y2hq42Y7gBXGTEoG5EdLTShV8EP/2qZcM17e2ELGGrkbvH6UD8VCy4t
WipTuO+jnv55mQC5OrE2/Otqu5qCRX/iLY51+zpK197YNIHX4vL7eXzGIpEIG+BcVA+ErTfcr7ib
htZp2gERcwqMz/zmy5zaJmzzcNSgSaN8zS3171dEZiYcbf9gj6BCTLHbyqaLy4/U3O4RxDF1HJdF
KqJzqZEqahX8BxoQxWAx7tE0Z+kCgYEA8AHt/0TkPpAhS6/Y6TSk/aKxIkiNqHl5rAhDpimVpw8M
W+/3pe93TY7p4bKBnckXaxV75GorB/qR5Ag+DQSw6MD2KG0hKRJyRoHyePExmW9yM/CjswYTVjCk
eOK4unJ1DzcHNtU2P19enGpmfuAlraEhIJSsZfHa6AHG89Mt5S0CgYEAyNbpR5S2Bd/lFeqtvPaT
Pz95NhVZPV8ZopNpqqMDPMgPnXYI2s4VOfrKcMfy21WjEDraYzRPFwfYcWKP7FTrTGjDYDeIOjWo
4LjAFrVWtJLx5P0je0X31LMPaMJbCjR3oqvlRNAuJDf0PvVSAKu0ZL/0ndktiQ/sDtGvDh441R8C
gYEA10Izzj5go8grRLHbzxV7YUy4qDIAc3k36lajLfWgFmyFvjOUnswO6Y3jMJ0kaXsBOPbU3oFm
RMq0bJwD4zMw5CCk5o8yLZ8wxRIpgdV5kc8F05XhjGBHmYcZDJ7z5a1gVhwZqVFDTUVhGtLHSMYK
pRaeGpWdpfVsS6fEY80lHaUCgYEAlVlzij5lCYNQmPa2EgIOx4bM/VHs1b2Fk6cpebHVM3rWWdKv
jP6ZPE9qAWo/B6nsI6KQShtZARhddRvFSQpxG5YAS+mfzSGgHtRkS7635norlYxEuWPzguFRASce
ij0wBfDsAjsJRPezEqpdO5B0CkPQhR0+RmFnujFliwsgWiMCgYEAn0BHCVO0kuT2QlKc2TjdewsQ
uLe0SbWIAuIQJLu9XJMCInktYPbXwrNKjpIRnsx1xbDYBpYfratDDoO9aXdhgrMqOJmUzkNlfmPl
bT9Vk1sh99iIrsiiaxCTqoccDmB/kY2onkw7JVtGRJIgZ+6FRFDF3mtN1vipl1yfASo0AM0=
-----END RSA PRIVATE KEY-----

Some files were not shown because too many files have changed in this diff Show more