From 20becdbd27dae828a94350f0d6bdbca1368885e7 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Mon, 7 Dec 2015 04:52:33 +0100 Subject: [PATCH] Added standard templates --- citoplasma/mtemplates.py | 6 +- citoplasma/templates/admin/content.html | 4 ++ citoplasma/templates/admin/home.html | 45 ++++++++++++++ citoplasma/templates/admin/index.html | 9 +++ citoplasma/templates/admin/login.phtml | 66 +++++++++++++++++++++ citoplasma/templates/admin/register.phtml | 60 +++++++++++++++++++ citoplasma/templates/forms/modelform.html | 5 ++ citoplasma/templates/forms/modelform.phtml | 14 +++++ citoplasma/templates/utils/admin.phtml | 4 ++ citoplasma/templates/utils/insertform.phtml | 13 ++++ citoplasma/templates/utils/list.phtml | 53 +++++++++++++++++ index.py | 10 +--- modules/admin/index.py | 16 ++--- modules/admin/models/admin.py | 12 ++-- 14 files changed, 293 insertions(+), 24 deletions(-) create mode 100644 citoplasma/templates/admin/content.html create mode 100644 citoplasma/templates/admin/home.html create mode 100644 citoplasma/templates/admin/index.html create mode 100644 citoplasma/templates/admin/login.phtml create mode 100644 citoplasma/templates/admin/register.phtml create mode 100644 citoplasma/templates/forms/modelform.html create mode 100644 citoplasma/templates/forms/modelform.phtml create mode 100644 citoplasma/templates/utils/admin.phtml create mode 100644 citoplasma/templates/utils/insertform.phtml create mode 100644 citoplasma/templates/utils/list.phtml diff --git a/citoplasma/mtemplates.py b/citoplasma/mtemplates.py index 01d3ad2..8b16022 100644 --- a/citoplasma/mtemplates.py +++ b/citoplasma/mtemplates.py @@ -77,8 +77,12 @@ class ptemplate: theme_templates='themes/'+config.theme+'/templates' module_templates=module+'/templates' + + #Standard templates + + standard_templates=path.dirname(__name__)+'/templates' - return TemplateLookup(directories=[theme_templates, module_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace') + return TemplateLookup(directories=[theme_templates, module_templates, standard_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace') #return Environment(autoescape=self.guess_autoescape, auto_reload=True, loader=FileSystemLoader([theme_templates, module_templates])) diff --git a/citoplasma/templates/admin/content.html b/citoplasma/templates/admin/content.html new file mode 100644 index 0000000..9cdc6f1 --- /dev/null +++ b/citoplasma/templates/admin/content.html @@ -0,0 +1,4 @@ +<%inherit file="home.html" /> +<%block name="content"> +${content_index|n} + diff --git a/citoplasma/templates/admin/home.html b/citoplasma/templates/admin/home.html new file mode 100644 index 0000000..c53ff91 --- /dev/null +++ b/citoplasma/templates/admin/home.html @@ -0,0 +1,45 @@ + + + + +${title} + +${add_css_home('admin/admin.css')} +${add_css_home('font-awesome.min.css')} +${HeaderHTML.css_home()|n} +${add_js_home('jquery.min.js')} +${HeaderHTML.js_home()|n} +${HeaderHTML.header_home()|n} + + +
+
+
+Logout +
+ +
+ +
+ +
+

${title}

+ <%block name="content"> + +
+
+
+
+
+ + \ No newline at end of file diff --git a/citoplasma/templates/admin/index.html b/citoplasma/templates/admin/index.html new file mode 100644 index 0000000..9c5d07c --- /dev/null +++ b/citoplasma/templates/admin/index.html @@ -0,0 +1,9 @@ +<%inherit file="home.html"/> +<%block name="content"> +
+Bienvenido al administrador +
+
+Desde aquí podrá administrar su site +
+ diff --git a/citoplasma/templates/admin/login.phtml b/citoplasma/templates/admin/login.phtml new file mode 100644 index 0000000..446455c --- /dev/null +++ b/citoplasma/templates/admin/login.phtml @@ -0,0 +1,66 @@ + + + + <%block name="title">${lang('admin', 'login', 'Paramecio Login')}</%block> + + + ${add_js_home('jquery.min.js')} + ${add_css_home('admin/login.css')} + ${add_css_home('font-awesome.min.css')} + ${HeaderHTML.css_home()|n} + ${HeaderHTML.js_home()|n} + <%block name="ajax"> + + + + + <%block name="content"> +
+
+ ${lang('admin', 'login', 'Paramecio Login')} +
+ ${forms|n} +
+ +   +
+
+ + + diff --git a/citoplasma/templates/admin/register.phtml b/citoplasma/templates/admin/register.phtml new file mode 100644 index 0000000..3642dbe --- /dev/null +++ b/citoplasma/templates/admin/register.phtml @@ -0,0 +1,60 @@ +<%inherit file="login.phtml"/> +<%block name="ajax"> + + +<%block name="title">${lang('admin', 'sign_up', 'Paramecio Sign up')} +<%block name="content"> +
+
+ ${lang('admin', 'sign_up', 'Paramecio Sign up')} +
+ ${forms|n} +
+
+ +   +
+
+ diff --git a/citoplasma/templates/forms/modelform.html b/citoplasma/templates/forms/modelform.html new file mode 100644 index 0000000..ace42d8 --- /dev/null +++ b/citoplasma/templates/forms/modelform.html @@ -0,0 +1,5 @@ +
+ {% for form in forms.values() %} +

{{form.form()}}

+ {% endfor %} +
\ No newline at end of file diff --git a/citoplasma/templates/forms/modelform.phtml b/citoplasma/templates/forms/modelform.phtml new file mode 100644 index 0000000..ce4f195 --- /dev/null +++ b/citoplasma/templates/forms/modelform.phtml @@ -0,0 +1,14 @@ +<%def name="check_required(required)"> + % if required: + ${'*'} + % endif + +
+ % for form in forms.values(): + % if form.type!='hidden': +

${form.form()|n} ${form.txt_error}

+ % else: + ${form.form()|n} + % endif + % endfor +
diff --git a/citoplasma/templates/utils/admin.phtml b/citoplasma/templates/utils/admin.phtml new file mode 100644 index 0000000..8d2b954 --- /dev/null +++ b/citoplasma/templates/utils/admin.phtml @@ -0,0 +1,4 @@ +${show_flash_message()|n} +

${admin.title}

+${lang('common', 'add_item', 'Add new item')} +${admin.list.show()|n} \ No newline at end of file diff --git a/citoplasma/templates/utils/insertform.phtml b/citoplasma/templates/utils/insertform.phtml new file mode 100644 index 0000000..532a7ea --- /dev/null +++ b/citoplasma/templates/utils/insertform.phtml @@ -0,0 +1,13 @@ +

${lang('common', 'home', 'Home')} >> +% if id!='0': + ${title_edit} +%else: + ${title_edit} +%endif +

+
+

${title_edit}

+ ${model.query_error} + ${ form|n } +

+
\ No newline at end of file diff --git a/citoplasma/templates/utils/list.phtml b/citoplasma/templates/utils/list.phtml new file mode 100644 index 0000000..4c88077 --- /dev/null +++ b/citoplasma/templates/utils/list.phtml @@ -0,0 +1,53 @@ + +<%def name="select_field()"> + % if simplelist.search_field==field: + selected + % endif + +<%def name="set_css_arrow(simplelist, field)"> + % if simplelist.order_field==field: + fa fa-arrow-circle-${simplelist.order_class[simplelist.s['order']]} + % endif + +% if simplelist.yes_search: +
+
+ ${lang('common','search', 'Search')}: + + +
+
+% endif + + + % for field in simplelist.fields_showed: + + % endfor + % for extra_field in simplelist.arr_extra_fields: + + % endfor + + % for row in list: + + % for field in simplelist.fields_showed: + + % endfor + + % for extra_field_func in simplelist.arr_extra_options: + + % endfor + + % endfor +
${simplelist.model.fields[field].label}${ extra_field }
${simplelist.model.fields[field].show_formatted(row[field])}${ simplelist.set_options(extra_field_func, row)|n }
+

+${pages|n} +

\ No newline at end of file diff --git a/index.py b/index.py index 45f4ec8..b5c58d1 100644 --- a/index.py +++ b/index.py @@ -48,14 +48,6 @@ def create_app(): try: - #dir_controllers=os.listdir(config.base_modules.replace('.', '/')+'/'+module) - - #arr_views=[x for x in dir_modules if x.find('.py')!=-1 and x.find('__init__')==-1] - """ - for controller in config.base_modules: - if controller.find('.py')!=-1 and controller.find('__init__')==-1: - controller=controller.replace('.py', '') - """ controller_path=import_module(module) controller_base=os.path.dirname(controller_path.__file__) @@ -67,7 +59,7 @@ def create_app(): if controller.find('.py')!=-1 and controller.find('__init__')==-1: controller_py=controller.replace('.py', '') - print(controller_py) + import_module(module+'.'+controller_py) add_func_static_module(controller_base) diff --git a/modules/admin/index.py b/modules/admin/index.py index 6605b7d..7580eb6 100644 --- a/modules/admin/index.py +++ b/modules/admin/index.py @@ -1,16 +1,16 @@ #!/usr/bin/python3 -from citoplasma.mtemplates import ptemplate -from modules.admin.models.admin import UserAdmin -from citoplasma.i18n import load_lang, I18n -from citoplasma.urls import make_url, add_get_parameters -from citoplasma.sessions import get_session +from paramecio.citoplasma.mtemplates import ptemplate +from paramecio.modules.admin.models.admin import UserAdmin +from paramecio.citoplasma.i18n import load_lang, I18n +from paramecio.citoplasma.urls import make_url, add_get_parameters +from paramecio.citoplasma.sessions import get_session from bottle import get,post from settings import config from settings import config_admin -from citoplasma.lists import SimpleList -from citoplasma.generate_admin_class import GenerateAdminClass -from citoplasma.httputils import GetPostFiles +from paramecio.citoplasma.lists import SimpleList +from paramecio.citoplasma.generate_admin_class import GenerateAdminClass +from paramecio.citoplasma.httputils import GetPostFiles from cromosoma.formsutils import show_form, pass_values_to_form from cromosoma.coreforms import PasswordForm from importlib import import_module, reload diff --git a/modules/admin/models/admin.py b/modules/admin/models/admin.py index 4cc709d..e968941 100644 --- a/modules/admin/models/admin.py +++ b/modules/admin/models/admin.py @@ -1,11 +1,11 @@ #!/usr/bin/python3 -from citoplasma.i18n import I18n -from cromosoma.webmodel import WebModel -from cromosoma.usermodel import UserModel -from cromosoma import corefields -from cromosoma.extrafields.emailfield import EmailField -from cromosoma.extrafields.passwordfield import PasswordField +from paramecio.citoplasma.i18n import I18n +from paramecio.cromosoma.webmodel import WebModel +from paramecio.cromosoma.usermodel import UserModel +from paramecio.cromosoma import corefields +from paramecio.cromosoma.extrafields.emailfield import EmailField +from paramecio.cromosoma.extrafields.passwordfield import PasswordField class PrivilegesField(corefields.IntegerField): pass