From f63765c066b48fa8cb45dd19436fc01b3523de14 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Sun, 3 Jan 2016 23:22:44 +0100 Subject: [PATCH] Many fixes and features --- paramecio/citoplasma/lists.py | 6 +++++- paramecio/citoplasma/templates/utils/list.phtml | 6 +++++- paramecio/cromosoma/corefields.py | 4 ++-- paramecio/cromosoma/coreforms.py | 2 +- paramecio/cromosoma/extraforms/dateform.py | 4 +--- paramecio/cromosoma/webmodel.py | 10 ++++++++-- paramecio/modules/admin/index.py | 5 ++--- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/paramecio/citoplasma/lists.py b/paramecio/citoplasma/lists.py index e474c2b..7f23d3a 100644 --- a/paramecio/citoplasma/lists.py +++ b/paramecio/citoplasma/lists.py @@ -137,7 +137,7 @@ class SimpleList: if self.search_field!='' and self.search_text!='': self.model.conditions[0]+=' AND '+self.search_field+' LIKE %s' - self.model.conditions[1]=['%'+self.search_text+'%'] + self.model.conditions[1].append('%'+self.search_text+'%') pass @@ -158,6 +158,8 @@ class SimpleList: self.obtain_field_search() + self.model.yes_reset_conditions=False + self.search() total_elements=self.model.select_count() @@ -178,5 +180,7 @@ class SimpleList: self.begin_page=str(self.begin_page) + self.model.yes_reset_conditions=True + return self.t.load_template('utils/list.phtml', simplelist=self, list=list_items, pages=pages) diff --git a/paramecio/citoplasma/templates/utils/list.phtml b/paramecio/citoplasma/templates/utils/list.phtml index 4c88077..50c9b48 100644 --- a/paramecio/citoplasma/templates/utils/list.phtml +++ b/paramecio/citoplasma/templates/utils/list.phtml @@ -39,7 +39,11 @@ % for row in list: % for field in simplelist.fields_showed: - ${simplelist.model.fields[field].show_formatted(row[field])} + % if simplelist.model.fields[field].escape==True: + ${simplelist.model.fields[field].show_formatted(row[field])} + % else: + ${simplelist.model.fields[field].show_formatted(row[field])|n} + % endif % endfor % for extra_field_func in simplelist.arr_extra_options: diff --git a/paramecio/cromosoma/corefields.py b/paramecio/cromosoma/corefields.py index 5dee813..ac8b41a 100644 --- a/paramecio/cromosoma/corefields.py +++ b/paramecio/cromosoma/corefields.py @@ -72,8 +72,8 @@ class BooleanField(IntegerField): required=False - self.yes=I18n.lang('common', 'yes', 'Yes') - self.no=I18n.lang('common', 'no', 'No') + self.yes_text=I18n.lang('common', 'yes', 'Yes') + self.no_text=I18n.lang('common', 'no', 'No') super(IntegerField, self).__init__(name, size, required) diff --git a/paramecio/cromosoma/coreforms.py b/paramecio/cromosoma/coreforms.py index 407a12c..508ddbc 100644 --- a/paramecio/cromosoma/coreforms.py +++ b/paramecio/cromosoma/coreforms.py @@ -72,7 +72,7 @@ class SelectForm(BaseForm): for k,v in self.arr_select.items(): arr_selected[k]=arr_selected.get(k, '') - the_form+="" + the_form+="" the_form+='\n' diff --git a/paramecio/cromosoma/extraforms/dateform.py b/paramecio/cromosoma/extraforms/dateform.py index 8bacb0c..2f90ec0 100644 --- a/paramecio/cromosoma/extraforms/dateform.py +++ b/paramecio/cromosoma/extraforms/dateform.py @@ -30,9 +30,7 @@ class DateForm(BaseForm): h=int(time[3]) min=int(time[4]) s=int(time[5]) - - - + return standard_t.load_template('forms/dateform.phtml', yes_time=self.yes_time, form=self.name, y=y, m=m, d=d, h=h, min=min, s=s) #def diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py index 147c358..d0ac664 100644 --- a/paramecio/cromosoma/webmodel.py +++ b/paramecio/cromosoma/webmodel.py @@ -98,6 +98,8 @@ class WebModel: self.valid_fields=[] self.last_id=0 + + self.distinct='' # A method where create the new fields of this model @@ -310,7 +312,7 @@ class WebModel: self.query_error="Error: without fields to search" return False - sql= ("select "+", ".join(final_fields)+extra_sql_field+" from "+", ".join(tables_to_select)+' '+conditions[0]+' '+self.order_by+' '+self.limit).strip() + sql= ("select "+" "+self.distinct+", ".join(final_fields)+extra_sql_field+" from "+", ".join(tables_to_select)+' '+conditions[0]+' '+self.order_by+' '+self.limit).strip() self.last_query=sql @@ -398,7 +400,7 @@ class WebModel: cursor=self.select(fields_selected, raw_query) - results={} + results=OrderedDict() for row in cursor: @@ -844,6 +846,10 @@ class PhangoField: # Define the form, when is created forms with create_forms you can change the properties of this class self.name_form=BaseForm + + # Property that define if make escape in show_formatted + + self.escape=True # This method is used for describe the new field in a sql language format. diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index d9d3265..b72af0e 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -7,6 +7,7 @@ from paramecio.citoplasma.urls import make_url, add_get_parameters from paramecio.citoplasma.sessions import get_session from bottle import get,post,response,request from settings import config +from settings import config_admin from paramecio.citoplasma.lists import SimpleList from paramecio.citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.httputils import GetPostFiles @@ -40,9 +41,7 @@ def home(module='', submodule=''): if submodule!='': module+='/'+submodule - from settings import config_admin - - t.clean_header_cache() + #t.clean_header_cache() #check if login