def inject_global_vars(): # theme_dir = os.path.join( # app.config["BASE_DIR"], "themes", get_setting("ACTIVE_FRONT_THEME") # ) # info_path = os.path.join(theme_dir, "info.json") # with open(info_path) as f: # info_data = json.load(f) APP_NAME = get_setting("APP_NAME") SECTION_NAME = get_setting("SECTION_NAME") SECTION_ITEMS = get_setting("SECTION_ITEMS") # ACTIVE_FRONT_THEME = get_setting("ACTIVE_FRONT_THEME") # ACTIVE_FRONT_THEME_VERSION = info_data["version"] # ACTIVE_FRONT_THEME_STYLES_URL = url_for( # "resource.active_theme_css", # active_theme=ACTIVE_FRONT_THEME, # v=ACTIVE_FRONT_THEME_VERSION, # ) base_context = { "APP_NAME": APP_NAME, "SECTION_NAME": SECTION_NAME, "SECTION_ITEMS": SECTION_ITEMS, # "ACTIVE_FRONT_THEME": ACTIVE_FRONT_THEME, # "ACTIVE_FRONT_THEME_VERSION": ACTIVE_FRONT_THEME_VERSION, # "ACTIVE_FRONT_THEME_STYLES_URL": ACTIVE_FRONT_THEME_STYLES_URL, "len": len, "current_user": current_user, } base_context.update(available_everywhere_entities) # print('\nav everywhere entities\n', available_everywhere_entities) return base_context
def get_active_theme_dir(): active_theme_dir = os.path.join( current_app.config["BASE_DIR"], "themes", get_setting("ACTIVE_FRONT_THEME"), ) return active_theme_dir
def index(): # cant be defined above but must be manually set each time # active_theme_dir = os.path.join( # dirpath, "..", "..", "themes", get_setting("ACTIVE_FRONT_THEME") # ) # module_blueprint.template_folder = active_theme_dir # return str(module_blueprint.template_folder) return render_template(get_setting("ACTIVE_FRONT_THEME") + "/index.html")
def inject_global_vars(): APP_NAME = get_setting("APP_NAME") base_context = { "APP_NAME": APP_NAME, "len": len, "current_user": current_user, } base_context.update(available_everywhere_entities) return base_context
def get_currency_symbol(): curr_code = get_setting("CURRENCY") with open(os.path.join( box_path, "shopman", "data", "currency.json", )) as f: currencies = json.load(f) for curr in currencies: if curr["cc"] == curr_code: return curr["symbol"]
def base_context(): """ Used to define global template values Returns ------- dict copy of dictionary """ theme_dir = os.path.join( current_app.config["BASE_DIR"], "themes", get_setting("ACTIVE_FRONT_THEME"), ) info_path = os.path.join(theme_dir, "info.json") with open(info_path) as f: info_data = json.load(f) APP_NAME = get_setting("APP_NAME") SECTION_NAME = get_setting("SECTION_NAME") SECTION_ITEMS = get_setting("SECTION_ITEMS") ACTIVE_FRONT_THEME = get_setting("ACTIVE_FRONT_THEME") ACTIVE_FRONT_THEME_VERSION = info_data["version"] ACTIVE_FRONT_THEME_STYLES_URL = url_for( "resource.active_theme_css", active_theme=ACTIVE_FRONT_THEME, v=ACTIVE_FRONT_THEME_VERSION, ) base_context = { "APP_NAME": APP_NAME, "SECTION_NAME": SECTION_NAME, "SECTION_ITEMS": SECTION_ITEMS, "ACTIVE_FRONT_THEME": ACTIVE_FRONT_THEME, "ACTIVE_FRONT_THEME_VERSION": ACTIVE_FRONT_THEME_VERSION, "ACTIVE_FRONT_THEME_STYLES_URL": ACTIVE_FRONT_THEME_STYLES_URL, } return base_context.copy()
def dashboard(): context = mhelp.context() form = CurrencyForm() with open(os.path.join( mhelp.dirpath, "data", "currency.json", )) as f: currencies = json.load(f) currency_choices = [(c["cc"], c["name"]) for c in currencies] form.currency.choices = currency_choices context.update({"form": form, "current_currency": get_setting("CURRENCY")}) return mhelp.render("dashboard.html", **context)
def index(): context = {} front_themes_path = os.path.join(current_app.config["BASE_DIR"], "static", "themes", "front") all_front_info = {} front_theme_folders = get_folders(front_themes_path) for folder in front_theme_folders: theme_path = os.path.join(front_themes_path, folder) info_path = os.path.join(theme_path, "info.json") with open(info_path) as f: all_front_info[folder] = json.load(f) back_themes_path = os.path.join(current_app.config["BASE_DIR"], "static", "themes", "back") all_back_info = {} back_theme_folders = get_folders(back_themes_path) for folder in back_theme_folders: theme_path = os.path.join(back_themes_path, folder) info_path = os.path.join(theme_path, "info.json") with open(info_path) as f: all_back_info[folder] = json.load(f) active_front_theme = get_setting("ACTIVE_FRONT_THEME") active_back_theme = get_setting("ACTIVE_BACK_THEME") context.update({ "all_front_info": all_front_info, "all_back_info": all_back_info, "active_front_theme": active_front_theme, "active_back_theme": active_back_theme, }) context.update(module_settings) return render_template("{}/index.html".format(module_info["module_name"]), **context)
def dashboard(): context = {} context["categorys"] = Category.query.all() context["active_page"] = get_setting("SECTION_NAME") return render_template("category/dashboard.html", **context)
def get_front_theme_dir(): theme_dir = os.path.join(themes_path, "front", get_setting("ACTIVE_FRONT_THEME")) return theme_dir
def get_active_back_theme(): return get_setting("ACTIVE_BACK_THEME")
def get_back_theme_dir(): theme_dir = os.path.join(themes_path, "back", get_setting("ACTIVE_BACK_THEME")) return theme_dir
def get_active_front_theme(): return get_setting("ACTIVE_FRONT_THEME")