Commit 1bcca4e8 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

More readable code for the views haverters and check & validate.

parent 07d4d57d
<!--
The python controller return:
- collection_logs (list of MsgCollection) one for each collection
- harvester (Storage)
- logs (list of MSg) one for each publication
- selector (Selector)
-->
{{
#--------------------------------------------------------------------------
# The python controller return:
# - collection_logs (list of MsgCollection) one for each collection
# - harvester (Storage)
# - logs (list of MSg) one for each publication
# - selector (Selector)
#--------------------------------------------------------------------------
#
# prepare the data
# prepare the data:
# - configure the Ext.data.Array for the statistics
# - configure the Ext.data.Array for the logs
# - build unique DIV identifier
# - write the title
# - the title of the page
# - the DIV block
# - the HTML page footer
# - export python variable to the javascript
#
#--------------------------------------------------------------------------
import json
from datetime import datetime
#
# configure the Ext.data.Array for the statistics
......@@ -88,12 +89,8 @@
cfg_logsStore = json.dumps(cfg)
#
# unique identifier for each DIV block associated to a grid
# Write the Title on the HTML page
#
divstat = abs(hash(cfg_statStore))
divlogs = abs(hash(cfg_logsStore))
# the title
period = ""
if selector.year_start and selector.year_end:
period = T("from %s to %s") % (selector.year_start, selector.year_end)
......@@ -103,9 +100,6 @@
pass
#
# Write the Title on the HTML page
#
project = ""
if selector.id_projects:
project = db.projects[selector.id_projects].project
......@@ -120,51 +114,52 @@
"margin-top: 2ex;"]
response.write(P(title, _style="".join(style)))
}}
<!--
The two DIV blocks to hook the Ext JS grid
#
# the DIV blocks, one for each grid
#
divstat = id(cfg_statStore)
divlogs = id(cfg_logsStore)
-->
<div id="grid-{{=divstat}}"></div>
<div id="grid-{{=divlogs}}"></div>
<!--
response.write(DIV(_id="grid-%s" % divstat))
response.write(DIV(_id="grid-%s" % divlogs))
Inline javascript to instantiate and render the Ext JS grid
#
# the footer, processing time of the request
#
delta = (datetime.now()-request.now).total_seconds()
delta = T('Harvester took %s seconds') % round(delta, 2)
-->
<script type="text/javascript">
/**
* Display the results of the harvester.
* The report is built around two Ext.grid.Panel.
* The first one summarize the static while the second one
* shows what happen for each publication found in the store.
*/
style = ["font-size: 10px;",
"margin-left: 10px;",
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
//
// bind the python and javascript variables
// use the internationalization of web2py to translate grid header
// MANDATORY: escape false to convert properly the quotes
//
{{
def write(value):
return response.write("\n%s" % value, escape=False)
write("var cfgStatStore = %s," % cfg_statStore)
write(" cfgLogsStore = %s," % cfg_logsStore)
write(" trAction = '%s'," % T('Action'))
write(" trAdded = '%s'," % T('Added'))
write(" trCollection = '%s'," % T('Collection'))
write(" trError = '%s'," % T('Error'))
write(" trExisting = '%s'," % T('Existing'))
write(" trFound = '%s'," % T('Found'))
write(" trLost = '%s'," % T('Lost'))
write(" trModified = '%s'," % T('Modified'))
write(" trRejected = '%s'," % T('Rejected'))
write(" trTitle = '%s'," % T('Title'))
write(" trStatistics = '%s'," % T('Statistics'))
write(" trYear = '%s';" % T('Year'))
}}
response.write(P(delta, _style="".join(style)))
#
# Export python variables to the javascript
#
jsvars = ["cfgStatStore = %s" % cfg_statStore,
"cfgLogsStore = %s" % cfg_logsStore,
"trAction = '%s'" % T('Action'),
"trAdded = '%s'" % T('Added'),
"trCollection = '%s'" % T('Collection'),
"trError = '%s'" % T('Error'),
"trExisting = '%s'" % T('Existing'),
"trFound = '%s'" % T('Found'),
"trLost = '%s'" % T('Lost'),
"trModified = '%s'" % T('Modified'),
"trRejected = '%s'" % T('Rejected'),
"trTitle = '%s'" % T('Title'),
"trStatistics = '%s'" % T('Statistics'),
"trYear = '%s'" % T('Year')]
jsvars = " var %s;" % ',\n'.join(jsvars)
response.write(SCRIPT(jsvars), escape=False)
}}
<script type="text/javascript">
/**
* Renderer functions
......@@ -199,7 +194,7 @@
}
//
// instantiate the grids for the STAT
// instantiate the grid for the STAT
//
var gridStat = Ext.create('Ext.grid.Panel', {
title: trStatistics,
......@@ -229,7 +224,7 @@
});
//
// instantiate the grids for the LOGs
// instantiate the grid for the LOGs
// The row are group per database action and sorted by title.
// Each title is rendered as an URL pointing to the publication
// in the harvester repository
......@@ -251,18 +246,4 @@
renderTo: 'grid-{{=divlogs}}'
});
</script>
{{
# processing time of the request
from datetime import datetime
delta = (datetime.now()-request.now).total_seconds()
delta = T('Harvester took %s seconds') % round(delta, 2)
style = ["font-size: 10px;",
"margin-left: 10px;",
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
response.write(P(delta, _style="".join(style)))
}}
</script>
\ No newline at end of file
<!--
The python controller return:
- logs (List of Storage)
- selector (Selector)
- counters (dict of Storage) the key are the project
The storage keys are: found, ok, validated
-->
{{
#--------------------------------------------------------------------------
# The python controller return:
# - logs (List of Storage)
# - selector (Selector)
# - counters (dict of Storage) the key are the project
# The storage keys are: found, ok, validated
#
#--------------------------------------------------------------------------
#
# prepare the data
# - create URL for id, ids and title
# - configure the Ext.data.Array for the statistics
# - configure the Ext.data.Array for the logs
# - build unique DIV identifier
# - Modify the encoding of the field name for the form
# - write the title
# - configure the field name for the Ext.form.Panel
# - the title of the HTML page
# - the DIV blocks
# - the HTML page footer
# - export python variables to the javascript
#
#--------------------------------------------------------------------------
import json
from datetime import datetime
#
# create the URL to compare id and ids
......@@ -53,7 +57,6 @@
row.id = str(A(row.id, _href=script))
pass
#
# configure the Ext.data.Array for the statistics
#
......@@ -106,14 +109,9 @@
cfg_logsStore = json.dumps(cfg)
#
# unique identifier for each DIV block associated to a grid
#
divlogs = abs(hash(cfg_logsStore))
divstat = abs(hash(cfg_statStore))
#
# HACK
# configure the field name for the Ext.form.Panel
#
# HACK:
# simplify the encoding of the field name for the form (TableField → field)
# NOTE: for publication fields are organized in tabPanel
# FIXME: awfull piece of code. Have to solve it in plugin_dbbui
......@@ -137,7 +135,7 @@
publications_fields = json.dumps(items)
#
# Write the Title on the HTML page
# the title of the HTML page
#
period = ""
if selector.year:
......@@ -170,58 +168,57 @@
response.write(P(title, _style="".join(style)))
}}
<!--
#
# the DIV block, one for each grid
#
divlogs = id(cfg_logsStore)
divstat = id(cfg_statStore)
The two DIV blocks to hook the Ext JS grid
response.write(DIV(_id="grid-%s" % divstat))
response.write(DIV(_id="grid-%s" % divlogs))
-->
<div id="grid-{{=divstat}}"></div>
<div id="grid-{{=divlogs}}"></div>
#
# the HTML page footer: processing time of the request
#
delta = (datetime.now()-request.now).total_seconds()
delta = T('Check and validate took %s seconds') % round(delta, 2)
<!--
style = ["font-size: 10px;",
"margin-left: 10px;",
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
Inline javascript to instantiate and render the Ext JS Grids
response.write(P(delta, _style="".join(style)))
-->
<script type="text/javascript">
/**
* Display the results of the Check and validate controller.
* The report is built around two Ext.grid.Panels.
* The first one summarizes the static while the second one
* shows what happen for each publication found in the store.
*/
#
# export python variables to the javascript
#
jsvars = ["cfgLogsStore = %s" % cfg_logsStore,
"cfgStatStore = %s" % cfg_statStore,
"fields = %s" % publications_fields,
"trCategory = '%s'" % T('Category'),
"trCollection = '%s'" % T('Collection'),
"trDuplicate = '%s'" % T('Duplicate'),
"trError = '%s'" % T('Error'),
"trId = '%s'" % T('Id'),
"trInvalid = '%s'" % T('Invalid'),
"trProject = '%s'" % T('Project'),
"trRecord = '%s'" % T('Record'),
"trRecords = '%s'" % T('Records'),
"trStatistics = '%s'" % T('Statistics'),
"trStatusOK = '%s'" % T('Status OK'),
"trTitle = '%s'" % T('Title'),
"trUpdate = '%s'" % T('Update'),
"trValidated = '%s'" % T('Validated'),
"trYear = '%s'" % T('Year'),
"urlRead = '%s'" % URL('publications', 'read'),
"urlUpdate = '%s'" % URL('publications', 'update')]
jsvars = " var %s;" % ',\n'.join(jsvars)
response.write(SCRIPT(jsvars), escape=False)
//
// bind the python and javascript variables
// use the internationalization of web2py to translate grid header
// MANDATORY: escape false to convert properly the quotes
//
{{
def write(value):
return response.write("\n%s" % value, escape=False)
write("var cfgLogsStore = %s," % cfg_logsStore)
write(" cfgStatStore = %s," % cfg_statStore)
write(" fields = %s," % publications_fields)
write(" trCategory = '%s'," % T('Category'))
write(" trCollection = '%s'," % T('Collection'))
write(" trDuplicate = '%s'," % T('Duplicate'))
write(" trError = '%s'," % T('Error'))
write(" trId = '%s'," % T('Id'))
write(" trInvalid = '%s'," % T('Invalid'))
write(" trProject = '%s'," % T('Project'))
write(" trRecord = '%s'," % T('Record'))
write(" trRecords = '%s'," % T('Records'))
write(" trStatistics = '%s'," % T('Statistics'))
write(" trStatusOK = '%s'," % T('Status OK'))
write(" trTitle = '%s'," % T('Title'))
write(" trUpdate = '%s'," % T('Update'))
write(" trValidated = '%s'," % T('Validated'))
write(" trYear = '%s'," % T('Year'))
write(" urlRead = '%s'," % URL('publications', 'read'))
write(" urlUpdate = '%s';" % URL('publications', 'update'))
}}
}}
<script type="text/javascript">
var gridLog,
gridStat;
......@@ -355,19 +352,4 @@
renderTo: 'grid-{{=divlogs}}'
});
</script>
{{
# processing time of the request
from datetime import datetime
delta = (datetime.now()-request.now).total_seconds()
delta = T('Check and validate took %s seconds') % round(delta, 2)
style = ["font-size: 10px;",
"margin-left: 10px;",
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
response.write(P(delta, _style="".join(style)))
}}
\ No newline at end of file
</script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment