Browse Source

multiple settings files

Roberto Berto 4 năm trước cách đây
mục cha
commit
dbe3250525

+ 4 - 1
.gitignore

@@ -135,4 +135,7 @@ dmypy.json
 db.sqlite3
 
 # visual studio
-*.code-workspace
+*.code-workspace
+
+# development config
+vycontrol/settings/development.py

+ 2 - 0
vycontrol/devstart.sh

@@ -0,0 +1,2 @@
+#https://simpleisbetterthancomplex.com/tips/2017/07/03/django-tip-20-working-with-multiple-settings-modules.html
+python manage.py runserver --settings=vycontrol.settings.development

+ 1 - 1
vycontrol/manage.py

@@ -5,7 +5,7 @@ import sys
 
 
 def main():
-    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vycontrol.settings')
+    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vycontrol.settings.production')
     try:
         from django.core.management import execute_from_command_line
     except ImportError as exc:

+ 12 - 10
vycontrol/s/main.css

@@ -1,5 +1,5 @@
 body {
-    background-color: #333;
+    background-color: #eee;
     color: white;
     font-size: 12px;    
 
@@ -12,7 +12,7 @@ body {
     color: black;
 }
 .menu { 
-    background-color: #888;
+    background-color: #eee;
     padding: 5px;
 }
 
@@ -20,27 +20,27 @@ body {
   color: #000;
 }    
 .content { 
-    background-color: #ccc;
+    background-color: #eee;
     padding: 0 10px 0 10px;
 }
 .content a {
-  color: #640000;
+  color: #101088;
 }
 #menu-logotop h1 {
   font-size: 10px;      
 }
 #menu-logotop {
-  background-color: #333;
+  background-color: #999;
   padding: 0 0px 4px 0px;
 }
 
 #menu-logotop a {
-  color:#af1d1d ;
+  color:#101088 ;
 }
 
 #menu-topline {
   padding-top: 3px;
-  background-color: #e14342;
+  background-color: #101088;
   margin-bottom: 2px;
 }
 #menu-logotop h2 {
@@ -62,7 +62,7 @@ form.instancedefault {
 }
 
 #debug {
-    background-color: #AB425E;
+    background-color: #ccccff;
     margin-top: 20px;
     margin-bottom: 20px;
 }
@@ -109,7 +109,9 @@ h4 {
 }
 
 input[type=submit] {
-  background-color: #EACD65;
+  background-color: #101088;
+  color: #fff;
+  padding: 3px 6px;
   border: 0;
   margin-bottom: 20px;
   margin-top: 20px;
@@ -152,7 +154,7 @@ input[type=submit] {
 
 #menu-username {
   margin-right: 10px;
-  color:#af1d1d ;
+  color:#101088 ;
 }
 
 .label_for_h3 {

+ 0 - 0
vycontrol/vycontrol/settings/__init__.py


+ 10 - 17
vycontrol/vycontrol/settings.py → vycontrol/vycontrol/settings/base.py

@@ -11,23 +11,23 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
 """
 import pathlib
 import os
+from pathlib import Path
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+#VYCONTROL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+BASE_DIR = str(Path(__file__).resolve().parents[2])
+
+
 
 
 # Quick-start development settings - unsuitable for production
 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
 
-# SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = '*wv2=o(o5$i2qim7yxras_7jf%n!*1rrzehv3o2f-ebsr@ba%4'
+
 
 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
 SESSION_COOKIE_AGE = 60 * 60 # 60 minutes
 
-# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
-
 # put all your hosts here
 ALLOWED_HOSTS = ['127.0.0.1']
 
@@ -84,10 +84,13 @@ SESSION_ENGINE = "django.contrib.sessions.backends.cache"
 
 ROOT_URLCONF = 'vycontrol.urls'
 
+
+TEMPLATE_DIR = os.path.join(BASE_DIR, 'vycontrol/templates')
+
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [os.path.join(BASE_DIR, 'vycontrol', 'templates')],
+        'DIRS': [TEMPLATE_DIR],
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [
@@ -173,14 +176,4 @@ STATICFILES_DIRS = [
 ]
 STATIC_URL = '/s/'
 
-# based on https://simpleisbetterthancomplex.com/tutorial/2016/09/19/how-to-create-password-reset-view.html 
-# There are many transactional email services out there. SendGrid, MailGun, Mandrill. see also https://simpleisbetterthancomplex.com/tutorial/2016/06/13/how-to-send-email.html
-# EMAIL_HOST = 'smtp.sendgrid.net'
-# EMAIL_PORT = 587
-# EMAIL_HOST_USER = 'testsite_app'
-# EMAIL_HOST_PASSWORD = 'mys3cr3tp4ssw0rd'
-# EMAIL_USE_TLS = True
-# DEFAULT_FROM_EMAIL = 'TestSite Team <noreply@example.com>'
-
-EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'  # During development only
 

+ 24 - 0
vycontrol/vycontrol/settings/production.py

@@ -0,0 +1,24 @@
+from .base import *
+
+DEBUG = False
+
+ALLOWED_HOSTS = ['vycontrol.domain.com', ]
+
+CACHES = {
+    'default': {
+        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+        'LOCATION': '127.0.0.1:11211',
+    }
+}
+
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+EMAIL_HOST = 'smtp.mailgun.org'
+EMAIL_PORT = 587
+EMAIL_HOST_USER = 'user'
+EMAIL_HOST_PASSWORD = 'password'
+EMAIL_USE_TLS = True
+
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '*wv2=o(o5$i2qim7yxras_7jf%n!*1rrzehv3o2f-ebsr@ba%4'
+

+ 1 - 1
vycontrol/vycontrol/templates/base.html

@@ -60,7 +60,7 @@
     <div class="col-3 menu">
 
       <p class="text-center">
-        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logo_minimal.png" width="100"  height="100" alt="vycontrol"></a></h1>
+        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logotxt.png?x" width="170"  height="30" alt="vycontrol"></a></h1>
       </p>
 
 

+ 1 - 1
vycontrol/vycontrol/templates/base_not_installed.html

@@ -43,7 +43,7 @@
     <div class="col-3 menu">
 
       <p class="text-center">
-        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logo_minimal.png" width="100"  height="100" alt="vycontrol"></a></h1>
+        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logotxt.png?x" width="170"  height="30" alt="vycontrol"></a></h1>
       </p>
 
 

+ 1 - 1
vycontrol/vycontrol/templates/base_not_logged.html

@@ -44,7 +44,7 @@
     <div class="col-3 menu">
 
       <p class="text-center">
-        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logo_minimal.png" width="100"  height="100" alt="vycontrol"></a></h1>
+        <h1 align="center"><a href="/"><img src="https://storage.googleapis.com/vycontrol/logos/logotxt.png?x" width="170"  height="30" alt="vycontrol"></a></h1>
       </p>