Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructuring SQLForm GUI API (qualipro) #148

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b7a213f
zmssqldb.zmi_filter_form
zmsdev May 15, 2023
c88315e
zmssqldb.zmi_filter_form
zmsdev May 15, 2023
8db78fc
remove unused code
zmsdev May 15, 2023
5ea40bf
type fix, whitespace
drfho May 15, 2023
a6fee55
fixing/reconstructing ZMI
Jun 1, 2023
85ff82a
extracting main ZMI
zmsdev Jun 14, 2023
fd78085
fixed filename
Jun 14, 2023
71b4b74
request.form handling
zmsdev Jun 14, 2023
d22234e
fix eventually missing manage_lang
Jun 15, 2023
880ddc9
replace deprecated js-substr with substring
zmsdev Jun 15, 2023
1df706e
readme
zmsdev Jun 20, 2023
ef0dba1
Merge branch 'main' into fb_qualipro
drfho Jun 20, 2023
3a33491
minor changes readme
Jun 20, 2023
12cf125
zmssqldb.zmi_filter_form
zmsdev May 15, 2023
4f976c9
zmssqldb.zmi_filter_form
zmsdev May 15, 2023
c7957d8
remove unused code
zmsdev May 15, 2023
2cbc7ca
type fix, whitespace
drfho May 15, 2023
3806c34
fixing/reconstructing ZMI
Jun 1, 2023
6eaa05a
extracting main ZMI
zmsdev Jun 14, 2023
7411647
fixed filename
Jun 14, 2023
b3f79e6
request.form handling
zmsdev Jun 14, 2023
6a4eb6e
fix eventually missing manage_lang
Jun 15, 2023
e917484
replace deprecated js-substr with substring
zmsdev Jun 15, 2023
0530b25
readme
zmsdev Jun 20, 2023
c5028dc
Merge branch 'fb_qualipro' of https://github.com/zms-publishing/ZMS i…
zmsdev Jun 21, 2023
f5749b4
fixes for ZSQLiteDA
zmsdev Jun 21, 2023
8242175
update doc
zmsdev Jun 21, 2023
76e849b
update doc
zmsdev Jun 21, 2023
baced4a
update doc
zmsdev Jun 21, 2023
9f0e218
update doc
zmsdev Jun 22, 2023
a699b5d
update doc
zmsdev Jun 22, 2023
df1d3ab
Merge branch 'main' into fb_qualipro
drfho Jul 3, 2023
d91980d
fixed missing preview var in request
Jul 4, 2023
e91499a
Merge branch 'main' into fb_qualipro
drfho Aug 15, 2023
0f82ee4
Merge branch 'main' into fb_qualipro
drfho Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Products/zms/ZMSZCatalogConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def search_xml(self, q, page_index=0, page_size=10, debug=0, pretty=0, REQUEST=N
xml += '<lst name="responseHeader">'
xml += '<int name="status">%i</int>'%status
xml += '<lst name="params">'
for key in REQUEST.form.keys():
for key in REQUEST.form:
xml += '<str name="%s">%s</str>'%(key, standard.html_quote(REQUEST.form[key]))
xml += '</lst>'
xml += '</lst>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<tal:block tal:define="global zmscontext options/zmscontext">
<tal:block tal:condition="python:zmscontext.getHistory()">
<script>
<!--
function showHistory(el) {
var v = $(el).val();
var version_nr = v.substring(0,v.indexOf(" "));
Expand Down Expand Up @@ -62,7 +61,6 @@
historyselect.prop("selectedIndex", 1);
}
});
-->
</script>
<input type="hidden" id="lang" name="lang" tal:attributes="value request/lang"/>
<select onchange="showHistory(this)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $ZMI.registerReady(function(){
$change_dt.each(function() {
var $el = $(this);
var mydate = $el.attr("title");
if (typeof mydate!="undefined") {
if (typeof mydate !== "undefined") {
var myformat = getZMILangStr('DATETIME_FMT');
var dtsplit=mydate.split(/[\/ .:]/);
var dfsplit=myformat.split(/[\/ .:]/);
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def url_inherit_params(url, REQUEST, exclude=[], sep='&amp;'):
anchor = url[i:]
url = url[:i]
if REQUEST.form:
for key in REQUEST.form.keys():
for key in REQUEST.form:
if not key in exclude:
v = REQUEST.form.get( key, None )
if key is not None:
Expand Down
18 changes: 9 additions & 9 deletions Products/zms/zmssqldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class ZMSSqlDb(zmscustom.ZMSCustom):
'manage_moveObjUp', 'manage_moveObjDown', 'manage_moveObjToPos',
'manage_cutObjects', 'manage_copyObjects', 'manage_pasteObjs',
'manage_userForm', 'manage_user',
'manage_zmi_input_form',
'manage_zmi_details_grid', 'manage_zmi_details_form',
'manage_zmi_lazy_select_form',
)
Expand All @@ -116,7 +115,9 @@ class ZMSSqlDb(zmscustom.ZMSCustom):

# Management Interface.
# ---------------------
manage_zmi_input_form = PageTemplateFile('zpt/ZMSSqlDb/input_form', globals())
zmi_filter_form = PageTemplateFile('zpt/ZMSSqlDb/filter_form', globals())
zmi_input_form = PageTemplateFile('zpt/ZMSSqlDb/input_form', globals())
zmi_main = PageTemplateFile('zpt/ZMSSqlDb/main', globals())
manage_zmi_details_grid = PageTemplateFile('zpt/ZMSSqlDb/zmi_details_grid', globals())
manage_zmi_details_form = PageTemplateFile('zpt/ZMSSqlDb/zmi_details_form', globals())
manage_zmi_lazy_select_form = PageTemplateFile('zpt/ZMSSqlDb/zmi_lazy_select_form', globals())
Expand All @@ -140,6 +141,7 @@ class ZMSSqlDb(zmscustom.ZMSCustom):
'checkbox': 1,
'password': 1,
'richtext': 1,
'string': 1,
'text': 1,
'time': 1,
'url': 1,
Expand Down Expand Up @@ -903,8 +905,8 @@ def getEntities(self):
# The pattern matches digits in parenthesis.To get the digits use .group(1).
size_p = re.compile(r'\(\s*?([0-9]+)\s*?\)')
for tableBrwsr in tableBrwsrs:
tableName = str(getattr(tableBrwsr, 'Name', getattr(tableBrwsr, 'name', None))())
tableType = str(getattr(tableBrwsr, 'Type', getattr(tableBrwsr, 'type', None))())
tableName = str(getattr(tableBrwsr, 'Name', getattr(tableBrwsr, 'name', None))()).replace('"','').replace('[','').replace(']','')
tableType = str(getattr(tableBrwsr, 'Type', getattr(tableBrwsr, 'type', None))()).replace('"','').replace('[','').replace(']','')
if tableType.upper() == 'TABLE' and p.match(tableName):

# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Expand All @@ -927,9 +929,7 @@ def getEntities(self):
c += l + ' '
cl = [x for x in c.split(' ') if x.strip()]
if len(cl) >= 2:
cid = cl[0]
if cid.startswith('"') and cid.endswith('"'):
cid = cid[1:-1]
cid = cl[0].replace('"','').replace('[','').replace(']','')
ucid = cid.upper()
uctype = cl[1].upper()
if not ucid in ['CHECK', 'FOREIGN', 'PRIMARY'] and not uctype.startswith('KEY') and not uctype.startswith('(') and not ucid.startswith('\''):
Expand All @@ -940,7 +940,7 @@ def getEntities(self):
else:
for columnBrwsr in tableBrwsr.tpValues():
col = {}
col["id"] = columnBrwsr.tpId()
col["id"] = columnBrwsr.tpId().replace('"','').replace('[','').replace(']','')
col["description"] = getattr(columnBrwsr, 'Description', getattr(columnBrwsr, 'description', None))().upper()
columnBrwsrs.append(col)
for columnBrwsr in columnBrwsrs:
Expand Down Expand Up @@ -1135,7 +1135,7 @@ def recordSet_Init(self, REQUEST):
if len(tabledefs) > 0:
if tablename not in [x['id'] for x in tabledefs]:
tablename = tabledefs[0]['id']
tablename = REQUEST.form.get('qentity', tablename)
tablename = REQUEST.get('qentity', tablename)
tabledef = [x for x in tabledefs if x['id'].upper()==tablename.upper()][0]
sqlStatement.append( self.recordSet_Select( tablename))
tablecols = tabledef['columns']
Expand Down
33 changes: 16 additions & 17 deletions Products/zms/zpt/ZMS/index.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
### Initialize request.
</tal:block
><tal:block tal:define="standard modules/Products.zms/standard;
dummy0 python:request.RESPONSE.setHeader('Content-Type', 'text/html\073charset=utf-8');
dummy0 python:request.set('lang',request.get('lang',here.getLanguage(request)));
site_active python:here.getHome().content.isActive(request);
done python:[]"

dummy0 python:request.RESPONSE.setHeader('Content-Type', 'text/html\073charset=utf-8');
dummy0 python:request.set('lang',request.get('lang',here.getLanguage(request)));
site_active python:here.getHome().content.isActive(request);
done python:[]"
><tal:block tal:condition="not: site_active"
><tal:block tal:define="global
dummy0 python:standard.raiseError('NotFound','Site is not active')"
Expand All @@ -18,9 +17,9 @@
><tal:block tal:define="target python:here.getHref2IndexHtml({'lang':request['lang'],'preview':request.get('preview',None),'ZMS_INDEX_HTML':[0,1][request.get('preview',None)=='preview']},deep=here.getConfProperty('index_html.redirect.deep',0))"
><tal:block tal:condition="python:not done and here.getDeclId({'lang':request['lang']})!=here.id and not request['URL']=='%sindex_html'%target and (request['URL'].endswith('/%s/index_html'%here.getDeclId({'lang':request['lang']})) or request['URL'].endswith('/%s/index_html'%here.id))"
><tal:block tal:define="
dummy0 python:request.set('ZMS_INDEX_HTML',1);
dummy0 python:request.RESPONSE.redirect(target,301);
dummy0 python:done.append(True)"></tal:block
dummy0 python:request.set('ZMS_INDEX_HTML',1);
dummy0 python:request.RESPONSE.redirect(target,301);
dummy0 python:done.append(True)"></tal:block
></tal:block
></tal:block

Expand All @@ -30,20 +29,20 @@
><tal:block tal:condition="python:not done and not here.hasAccess(request)"
><tal:block tal:replace="nothing">--- Raise unauthorized ---</tal:block
><tal:block tal:define="
dummy0 python:request.RESPONSE.unauthorized();
dummy0 python:done.append(True)"></tal:block
dummy0 python:request.RESPONSE.unauthorized();
dummy0 python:done.append(True)"></tal:block
></tal:block

><tal:block tal:replace="nothing">
### Response status
</tal:block
><tal:block tal:define="httpResponseStatus python:here.getHttpResponseStatus()" tal:on-error="nothing"
><tal:block tal:condition="python:httpResponseStatus>0"
><tal:block tal:define="
dummy0 python:request.RESPONSE.setStatus(httpResponseStatus);
dummy0 python:done.append(True)"></tal:block
></tal:block
></tal:block
><tal:block tal:define="httpResponseStatus python:here.getHttpResponseStatus()" tal:on-error="nothing"
><tal:block tal:condition="python:httpResponseStatus>0"
><tal:block tal:define="
dummy0 python:request.RESPONSE.setStatus(httpResponseStatus);
dummy0 python:done.append(True)"></tal:block
></tal:block
></tal:block

><tal:block tal:condition="python:not done and getattr(here.getHome(),'standard_html',None)"
><tal:block tal:content="structure python:here.f_standard_html_request(here,request)">f_standard_html_request</tal:block
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/zpt/ZMSRecordSet/main_grid.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
tal:content="structure python:(here.operator_gettype(elValue) is not str) and elValue.getFilename() or elValue">filename</tal:block
></tal:block
><tal:block tal:condition="python:elType in ['date','datetime','time']"
><tal:block tal:content="python:here.getLangFmtDate(elValue,request['manage_lang'],('%s_fmt'%elType).upper())">elValue</tal:block
><tal:block tal:content="python:here.getLangFmtDate(elValue,request.get('manage_lang',request['lang']),('%s_fmt'%elType).upper())">elValue</tal:block
></tal:block
><tal:block tal:condition="python:elType in ['float','int']"
><tal:block tal:content="elValue">elValue</tal:block
Expand Down
92 changes: 92 additions & 0 deletions Products/zms/zpt/ZMSSqlDb/filter_form.zpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<tal:block tal:define="
standard modules/Products.zms/standard;
entity options/entity;
tables options/tables;
resSlctStmnt options/resSlctStmnt">

<form method="get" class="form-horizontal"
tal:define="filter_columns python:[x for x in entity['columns'] if len(standard.intersection_list(['blob','details','multiselect','multimultiselect'],list(x)))==0]">
<input tal:condition="python:'lang' in request" type="hidden" name="lang" tal:attributes="value request/lang">
<input tal:condition="python:'preview' in request" type="hidden" name="preview" tal:attributes="value request/preview">
<input tal:condition="python:'qorder' in request" type="hidden" name="qorder" tal:attributes="value request/qorder">
<input tal:condition="python:'qorderdir' in request" type="hidden" name="qorderdir" tal:attributes="value request/qorderdir">
<div class="card">

<div class="card-header attr_last_modified clearfix btn-collapse">
<a class="btn card-toggle text-left" data-toggle="collapse" href="#attrActivity" aria-expanded="false"
><i class="fas fa-caret-right"></i> <tal:block tal:content="python:here.getZMILangStr('ATTR_ACTIVITY')">Activity</tal:block
></a>
<div class="btn zmi-changes" tal:content="python:here.getZMILangStr('ATTR_LAST_MODIFIED')+' '+here.getLangFmtDate(here.attr('change_dt'))+' '+here.getZMILangStr('BY')+' '+here.attr('change_uid')">change_dt by change_uid</div>
</div><!-- .card-header -->
<div id="attrActivity" class="collapse">
<div class="card-body">
<tal:block tal:condition="python:here.attr('created_dt') and here.attr('created_uid')">
<span tal:content="python:'%s: %s %s %s'%(here.getZMILangStr('ATTR_CREATED'),here.getLangFmtDate(here.attr('created_dt')),here.getZMILangStr('BY'),here.attr('created_uid'))">Createad: %d.%m.%Y by %s</span>,
</tal:block>
<span title="This Node Contains ..." tal:content="python:'%i %s'%(len(here.getChildNodes(request)),here.getZMILangStr('ATTR_OBJECTS'))">%i Objects</span>,
<span title="Data Size" class="get_size" tal:content="python:here.getDataSizeStr(here.get_size())">%i Bytes</span>,
<span title="Unique ID" class="get_uid" tal:content="python:'ID:%s'%(here.get_uid())">unique-id</span>
</div><!-- .card-body -->
</div><!-- .collapse -->

<div class="card-header filters clearfix btn-collapse">
<a class="btn card-toggle pull-left py-2 mt-1 text-left" data-toggle="collapse" href="#attrProperties">
<i class="fas fa-caret-down"></i>
<tal:block tal:content="structure python:here.getZMILangStr('ATTR_FILTER')">the label</tal:block>
</a>
<div class="row">
<div class="col-sm-8 col-md-6 col-sm-8 col-lg-4 py-2">
<select class="form-control form-control-sm" id="qentity" name="qentity" onchange="this.form.submit()">
<tal:block tal:repeat="table tables">
<option tal:attributes="value table/id; selected python:['','selected'][int(table['id'].upper()==entity['id'].upper())]" tal:content="table/label">table</option>
</tal:block>
</select>
</div>
</div>
<input type="hidden" id="qfilters" name="qfilters:int" tal:attributes="value request/qfilters" />
</div><!-- .card-header -->

<div id="attrProperties" class="filters collapse show">
<div class="card-body">
<tal:block tal:repeat="filterIndex python:range(request.get('qfilters',1))">
<div tal:attributes="class python:' '.join(['form-row']+[[],['d-none']][int(filterIndex==request.get('qfilters',1))])">
<div class="form-group col-sm-5">
<select class="form-control form-control-sm" tal:attributes="name python:'filterattr%i'%filterIndex">
<option value="" tal:content="python:here.getZMILangStr('CAPTION_SELECT')">the option</option>
<tal:block tal:repeat="column python:[here.getEntityColumn(entity['id'],x['id']) for x in filter_columns]">
<option tal:attributes="value column/id; title column/type; selected python:['','selected'][int(column['id'].lower()==request.get('filterattr%i'%filterIndex,standard.get_session_value(here,'filterattr%i_%s'%(filterIndex,here.id),'')).lower())]" tal:content="column/label">column</option>
</tal:block>
</select>
</div>
<div class="form-group col-sm-2">
<select class="form-control form-control-sm" tal:attributes="name python:'filterop%i'%filterIndex">
<tal:block tal:repeat="op python:['LIKE','=','<','<=','>','>=','NULL','NOT NULL']">
<option tal:attributes="value python:op; selected python:['','selected'][op.lower()==request.get('filterop%i'%filterIndex, standard.get_session_value(here,'filterop%i_%s'%(filterIndex,here.id),'')).lower()]" tal:content="python:op">op</option>
</tal:block>
</select>
</div>
<div class="form-group col-sm-5">
<input class="form-control form-control-sm" type="text" tal:attributes="name python:'filtervalue%i'%filterIndex; value python:request.get('filtervalue%i'%filterIndex, standard.get_session_value(here,'filtervalue%i_%s'%(filterIndex,here.id),''))" />
</div>
</div><!-- .form-row -->
</tal:block>
<div class="controls text-left">
<button type="submit" id="btn-search" class="btn btn-primary" name="btn" value="BTN_REFRESH">
<i class="fas fa-search"></i>
<tal:block tal:content="python:here.getZMILangStr('BTN_SEARCH')">Search</tal:block>
</button>
<button type="submit" id="btn-reset" class="btn btn-secondary" name="btn" value="BTN_RESET">
<tal:block tal:content="python:here.getZMILangStr('BTN_RESET')">Reset</tal:block>
</button>
&nbsp;
<a href="javascript:;" onclick="$('#manage_main_div_sql').toggleClass('d-none')" title="Show SQL Code">
&middot;
</a>
</div><!-- .form-row -->
<div id="manage_main_div_sql" class="d-none well" style="padding:1em;margin: 1em 0 0 0;"><code tal:content="structure python:resSlctStmnt.replace('\n','<br>')">resSlctStmnt</code></div>
</div><!-- .card-body -->
</div><!-- .collapse -->
</div><!-- .card -->
</form>

</tal:block>
Loading
Loading