Domain management (activated, booleans)
This commit is contained in:
parent
5f45caebe4
commit
f5a7e6efaf
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -33,11 +33,13 @@
|
|||
#--------------------------
|
||||
|
||||
import sys
|
||||
import domain, langs
|
||||
import domain, langs, debug
|
||||
|
||||
|
||||
def manage(action, target):
|
||||
# Load domain configuration, update if needed, check if valid
|
||||
domain.valid_conf()
|
||||
if not domain.valid_conf():
|
||||
debug.out(105, domain.conf_name, domain.dcf_uri, True, 1, True)
|
||||
|
||||
langs.load_website_lang()
|
||||
print("check:", action, target, domain.dcf.get("DOMAIN", "name"))
|
||||
print("check:", action, target)
|
||||
|
|
|
@ -89,6 +89,7 @@ def out(nbr, var, val, show, color, stop):
|
|||
102 : langs.logs.reset_dom,
|
||||
103 : langs.logs.website_lang,
|
||||
104 : langs.logs.domains_no,
|
||||
105 : langs.logs.domain_off,
|
||||
# Great (200-255)
|
||||
200 : langs.logs.load_file,
|
||||
201 : langs.logs.lang_logs_sys,
|
||||
|
|
|
@ -184,14 +184,27 @@ def dcf_update_values(srv):
|
|||
srv_wip = os.path.join(srv_dom, "wip/")
|
||||
srv_www = os.path.join(srv_dom, "www/")
|
||||
|
||||
# Set booleans if invalid values
|
||||
try: dcf.getboolean("DOMAIN", "activated")
|
||||
except: dcf.set("DOMAIN", "activated", "no")
|
||||
try: dcf.getboolean("WEBSITE", "article_code")
|
||||
except: dcf.set("WEBSITE", "article_code", "yes")
|
||||
try: dcf.getboolean("WEBSITE", "static")
|
||||
except: dcf.set("WEBSITE", "static", "no")
|
||||
try: dcf.getboolean("WEBSITE_MODULES", "sitemaps")
|
||||
except: dcf.set("WEBSITE_MODULES", "sitemaps", "yes")
|
||||
|
||||
# Set template filenames to default if none
|
||||
favicon = dcf.get("TEMPLATE_FILENAMES", "favicon") or "favicon.png"
|
||||
logo = dcf.get("TEMPLATE_FILENAMES", "logo") or "logo.png"
|
||||
styles = dcf.get("TEMPLATE_FILENAMES", "styles") or "styles.css"
|
||||
rss = dcf.get("TEMPLATE_FILENAMES", "rss") or "rss.xml"
|
||||
stats = dcf.get("TEMPLATE_FILENAMES", "stats") or "stats.ini"
|
||||
|
||||
www_url = dcf.get("WEBSITE", "www_url")
|
||||
wip_url = dcf.get("WEBSITE", "wip_url")
|
||||
dcf.get("WEBSITE", "www_url") or \
|
||||
dcf.set("WEBSITE", "www_url", "https://%s/"%conf_name)
|
||||
dcf.get("WEBSITE", "wip_url") or \
|
||||
dcf.set("WEBSITE", "wip_url", create_wip_url())
|
||||
|
||||
usr_mods = os.path.join(dcf_dir + "modules/")
|
||||
usr_tpl = os.path.join(dcf_dir, "template/")
|
||||
|
@ -242,8 +255,6 @@ def dcf_update_values(srv):
|
|||
|
||||
# WEBSITE
|
||||
dcf.set("WEBSITE", "lang", langs.site_lang)
|
||||
www_url or dcf.set("WEBSITE", "www_url", "https://%s/"%conf_name)
|
||||
wip_url or dcf.set("WEBSITE", "wip_url", create_wip_url())
|
||||
dcf.get("WEBSITE_MODULES", "sidebar_title") or \
|
||||
dcf.set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title)
|
||||
dcf.get("WEBSITE_MODULES", "sidebar_items").isdigit() or \
|
||||
|
@ -324,24 +335,18 @@ def dcf_update_values(srv):
|
|||
# Ensure domain is valid and ready to be used #
|
||||
#---------------------------------------------#
|
||||
def valid_conf():
|
||||
dcf_load()
|
||||
global active
|
||||
|
||||
# Most importants
|
||||
dcf_load()
|
||||
# - dcf name must be config_name
|
||||
# - root server must exists
|
||||
try:
|
||||
dcf_name = dcf.get("DOMAIN", "name")
|
||||
try: dcf_name = dcf.get("DOMAIN", "name")
|
||||
except: debug.out(100, conf_name, dcf_uri, True, 2, True)
|
||||
if dcf_name != conf_name:
|
||||
debug.out(100, conf_name, dcf_uri, True, 2, True)
|
||||
except:
|
||||
debug.out(100, conf_name, dcf_uri, True, 2, True)
|
||||
|
||||
|
||||
|
||||
# Server root
|
||||
# - root server must exists
|
||||
try: dcf_srv = dcf.get("SERVER", "root")
|
||||
except: debug.out(100, "SERVER root", "?", True, 2, True)
|
||||
|
||||
if not dcf_srv or not tools.dir_exists(dcf_srv, True):
|
||||
debug.out(100, "SERVER root", "? %s"%dcf_srv, True, 2, True)
|
||||
|
||||
|
@ -366,6 +371,19 @@ def valid_conf():
|
|||
if now_dcf_hash != ult_dcf_hash:
|
||||
dcf_update_values("")
|
||||
|
||||
return is_active()
|
||||
|
||||
|
||||
#==============================#
|
||||
# Check if domain is activated #
|
||||
# Return True or False
|
||||
#------------------------------#
|
||||
def is_active():
|
||||
dcf_load()
|
||||
# Domain activated ?
|
||||
try: return dcf.getboolean("DOMAIN", "activated")
|
||||
except: return False
|
||||
|
||||
|
||||
#======#=======================================================================
|
||||
# MAIN #
|
||||
|
|
Binary file not shown.
|
@ -59,6 +59,7 @@ err_cr_file = "Fichier non créé"
|
|||
|
||||
# Warnings
|
||||
warn_no_dom = "Domaine non configuré"
|
||||
domain_off = "Domaine désactivé"
|
||||
reset_dom = "RÉINITIALISE le domaine"
|
||||
|
||||
# infos
|
||||
|
|
Loading…
Reference in New Issue