diff --git a/paramecio/citoplasma/generate_admin_class.py b/paramecio/citoplasma/generate_admin_class.py index 85fa0aa..772478c 100644 --- a/paramecio/citoplasma/generate_admin_class.py +++ b/paramecio/citoplasma/generate_admin_class.py @@ -18,7 +18,9 @@ class GenerateAdminClass: self.list=SimpleList(model, url, t) - self.arr_fields_edit=model.fields.keys() + self.arr_fields_edit=list(model.fields.keys()) + + del self.arr_fields_edit[self.arr_fields_edit.index(model.name_field_id)] self.url=url @@ -55,7 +57,7 @@ class GenerateAdminClass: post=None if len(self.model.forms)==0: - self.model.create_forms(self.arr_fields_edit) + self.model.create_forms() title_edit=I18n.lang('common', 'add_new_item', 'Add new item') @@ -66,7 +68,12 @@ class GenerateAdminClass: if post==None: post={} - form=show_form(post, self.model.forms, self.t, False) + edit_forms={} + + for key_form in self.arr_fields_edit: + edit_forms[key_form]=self.model.forms[key_form] + + form=show_form(post, edit_forms, self.t, False) return self.t.load_template(self.template_insert, admin=self, title_edit=title_edit, form=form, model=self.model, id=GetPostFiles.get['id']) diff --git a/paramecio/citoplasma/lists.py b/paramecio/citoplasma/lists.py index e9aca85..e474c2b 100644 --- a/paramecio/citoplasma/lists.py +++ b/paramecio/citoplasma/lists.py @@ -33,7 +33,11 @@ class SimpleList: self.s=get_session() - #self.s['order']=self.s.get('order', 0) + #clean session + + self.s['order']=0 + + self.s['order_field']=self.model.name_field_id self.order_by=self.order_defaults[0] diff --git a/paramecio/cromosoma/dbadmin.py b/paramecio/cromosoma/dbadmin.py index 82a8d0c..d2fbcc6 100644 --- a/paramecio/cromosoma/dbadmin.py +++ b/paramecio/cromosoma/dbadmin.py @@ -158,6 +158,9 @@ def start(): old_table='old_'+table + if not old_table in WebModel.model: + WebModel.model[old_table]=WebModel.model[table] + for f, v in WebModel.model[table].fields.items(): if not f in WebModel.model[old_table].fields: diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py index 0e4ad10..3457bb7 100644 --- a/paramecio/cromosoma/webmodel.py +++ b/paramecio/cromosoma/webmodel.py @@ -107,13 +107,15 @@ class WebModel: # A method for register the fields - def register(self, field_model): + def register(self, field_model, required=False): #self.fields_required[field_model]=field_model.required self.fields[field_model.name]=field_model self.fields[field_model.name].model=self + + self.fields[field_model.name].required=required # A method for create the id field. diff --git a/paramecio/modules/admin/admin/ausers.py b/paramecio/modules/admin/admin/ausers.py index 2301da2..ef8926d 100644 --- a/paramecio/modules/admin/admin/ausers.py +++ b/paramecio/modules/admin/admin/ausers.py @@ -5,6 +5,7 @@ from paramecio.citoplasma.urls import make_url from paramecio.citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.i18n import I18n from paramecio.cromosoma.coreforms import SelectForm +from settings import config def admin(t): diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 69b84fc..e1c1fb5 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -33,7 +33,12 @@ t=ptemplate(__file__) @get('/'+config.admin_folder) @get('/'+config.admin_folder+'/') @post('/'+config.admin_folder+'/') -def home(module=''): +@get('/'+config.admin_folder+'//') +@post('/'+config.admin_folder+'//') +def home(module='', submodule=''): + + if submodule!='': + module+='/'+submodule from settings import config_admin @@ -84,15 +89,23 @@ def home(module=''): #Load module - new_module=import_module(menu[module][1]) - if config.reloader: - reload(new_module) + try: + new_module=import_module(menu[module][1]) + + if config.reloader: + reload(new_module) + + except ImportError: + + return "No exists admin module" + + return t.load_template('admin/content.html', title=menu[module][0], content_index=new_module.admin(t), menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n) else: - return t.load_template('admin/index.html', title=I18n.lang('admin', 'welcome_to_paramecio', 'Welcome to Paramecio Admin!!!'), menu=menu, lang=lang, arr_i18n=I18n.dict_i18n) + return t.load_template('admin/index.html', title=I18n.lang('admin', 'welcome_to_paramecio', 'Welcome to Paramecio Admin!!!'), menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n) else: diff --git a/paramecio/modules/admin/media/fonts/FontAwesome.otf b/paramecio/modules/admin/media/fonts/FontAwesome.otf new file mode 100644 index 0000000..681bdd4 Binary files /dev/null and b/paramecio/modules/admin/media/fonts/FontAwesome.otf differ diff --git a/paramecio/modules/admin/media/fonts/fontawesome-webfont.eot b/paramecio/modules/admin/media/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..a30335d Binary files /dev/null and b/paramecio/modules/admin/media/fonts/fontawesome-webfont.eot differ diff --git a/paramecio/modules/admin/media/fonts/fontawesome-webfont.svg b/paramecio/modules/admin/media/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..6fd19ab --- /dev/null +++ b/paramecio/modules/admin/media/fonts/fontawesome-webfont.svg @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/paramecio/modules/admin/media/fonts/fontawesome-webfont.ttf b/paramecio/modules/admin/media/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..d7994e1 Binary files /dev/null and b/paramecio/modules/admin/media/fonts/fontawesome-webfont.ttf differ diff --git a/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff b/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..6fd4ede Binary files /dev/null and b/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff differ diff --git a/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff2 b/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff2 new file mode 100644 index 0000000..5560193 Binary files /dev/null and b/paramecio/modules/admin/media/fonts/fontawesome-webfont.woff2 differ diff --git a/paramecio/modules/lang/__init__.py b/paramecio/modules/lang/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/paramecio/modules/lang/index.py b/paramecio/modules/lang/index.py new file mode 100644 index 0000000..02e36ad --- /dev/null +++ b/paramecio/modules/lang/index.py @@ -0,0 +1,23 @@ +from paramecio.citoplasma.i18n import I18n +from bottle import get,response,request, redirect +from paramecio.citoplasma.sessions import get_session +import re + +@get('/change_lang/') +def index(lang): + + if lang in I18n.dict_i18n: + + s=get_session() + + s['lang']=lang + + redirect_url=request.headers.get('Referer') + + if redirect_url!=None: + + #if not re.match('.*\/change_lang\/.*', request.path): + + redirect(redirect_url) + + return "" \ No newline at end of file