Prepare for public deployment

This commit is contained in:
R. Miles McCain
2020-04-14 15:18:45 -04:00
parent e04fbb3505
commit 73b8fc96d4
6 changed files with 52 additions and 9 deletions

View File

@@ -1,5 +1,11 @@
from django.apps import AppConfig
from django.conf import settings
class DashboardConfig(AppConfig):
name = 'dashboard'
def ready(self):
if not settings.ACCOUNT_SIGNUPS_ENABLED:
# Normally you'd do this in settings.py, but this must be done _after_ apps are enabled
from allauth.account.adapter import DefaultAccountAdapter
DefaultAccountAdapter.is_open_for_signup = lambda k, v: False

View File

@@ -8,6 +8,9 @@
{% block card %}
<form class="login" method="POST" action="{% url 'account_login' %}">
<aside class="aside ~info mb-4">
<p>Welcome to Shynet, a self-hosted analytics tool that's open source and privacy conscious. View the <a href="https://github.com/milesmcc/shynet">source code</a>.</p>
</aside>
{% csrf_token %}
{{ form|a17t }}
{% if redirect_field_value %}

View File

@@ -45,7 +45,7 @@ INSTALLED_APPS = [
"rules.apps.AutodiscoverRulesConfig",
"a17t",
"core",
"dashboard",
"dashboard.apps.DashboardConfig",
"analytics",
"allauth",
"allauth.account",
@@ -87,12 +87,24 @@ WSGI_APPLICATION = "shynet.wsgi.application"
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
if os.getenv("SQLITE", "False") == "True":
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
}
}
}
# Password validation
@@ -147,8 +159,9 @@ ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_SUBJECT_PREFIX = ""
ACCOUNT_USER_DISPLAY = lambda k: k.email
ACCOUNT_SIGNUPS_ENABLED = os.getenv("SIGNUPS_ENABLED", "False") == True
LOGIN_REDIRECT_URL = "/dash"
LOGIN_REDIRECT_URL = "/"
SITE_ID = 1