Commit bb94ea28 authored by legac's avatar legac
Browse files

Modify the table schema for the lists tools. Splitting can be done along

the axes category, team, project and year in any order.
parent e20bff40
......@@ -14,6 +14,7 @@ from list_tools import (category_article,
from plugin_dbui import decode_field
MSG_NO_LIST = T("Please select a list....")
MSG_NO_SECTIONS = T('Please, define sections for the list "%s"')
......@@ -26,13 +27,13 @@ def index():
# protection
if not id_list:
return "Please select a list...."
return MSG_NO_LIST
# retrieve the list data
list = db.lists[id_list]
# get the basic query for a diplomas or publications
# taking into account the user wishes
# taking into account foreign keys and user requirements
tool = Diplomas(db)
tool.decode_request()
q_diplomas = tool.query()
......@@ -79,14 +80,16 @@ def index():
for section in sections:
orderby = []
for i in range(1,4):
fieldname = 'split_section_%i' % i
direction = 'dir_%i' % i
for i in range(1,5):
fieldname = 'split_%i' % i
if list[fieldname] == 'category':
continue
if list[fieldname]:
field = db[section.tablename][list[fieldname]]
if list[direction] == 'DESC':
field = ~field
if list[fieldname] == 'year' and list['dir_year'] == 'DESC':
field = ~field
orderby.append(field)
if section.sort_field:
......@@ -98,20 +101,29 @@ def index():
section.orderby = tuple(orderby)
# get the splitting parameters defined at the list level
split_fields = [list.split_section_1, list.split_section_2, list.split_section_3]
split_tables = [section.tablename]*3
for i in range(3):
if split_fields[i] == 'id_projects':
split_fields[i] = 'project'
split_tables[i] = 'projects'
split_fields, split_tables = [], []
for i in range(1, 5):
fieldname = list['split_%i' % i]
if not fieldname:
break
if fieldname == 'id_projects':
fld, tbl = 'project', 'projects'
elif fieldname == 'id_teams':
fld, tbl = 'team', 'teams'
else:
fld, tbl = fieldname, section.tablename
elif split_fields[i] == 'id_teams':
split_fields[i] = 'team'
split_tables[i] = 'teams'
split_fields.append(fld)
split_tables.append(tbl)
# retrieve the publications for each section
# split them according to user requirements
# organize them according to splits requirements, for example
# category
# category/team
# category/team/year → list
# format each record according to user requirements
paths_keys = []
paths_data = {}
......@@ -120,18 +132,26 @@ def index():
for record in db(section.query).select(orderby=section.orderby):
paths = [section.section]
for i in range(3):
paths = []
for i in range(len(split_fields)):
fieldname = split_fields[i]
tablename = split_tables[i]
if fieldname == 'category':
node = section.section
else:
node = record[tablename][fieldname]
node = str(node)
if fieldname:
p = "%s/%s" % (paths[-1], record[tablename][fieldname])
paths.append(p)
if paths:
p = "%s/%s" % (paths[-1], node)
else:
p = node
paths.append(p)
for el in paths:
if el not in paths_keys:
paths_keys.append(el)
for p in paths:
if p not in paths_keys:
paths_keys.append(p)
last = paths[-1]
if last not in paths_data:
......
doc/database.png

120 KB | W: | H:

doc/database.png

134 KB | W: | H:

doc/database.png
doc/database.png
doc/database.png
doc/database.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
......@@ -54,6 +54,7 @@
'Dir 1': 'Dir 1',
'Dir 2': 'Dir 2',
'Dir 3': 'Dir 3',
'Dir Year': 'Dir Year',
'Direct access to the table: ': 'Accès direct à la table : ',
'Directors': 'Directeurs',
'E-mail': 'E-mail',
......@@ -121,8 +122,10 @@
"Password fields don't match": "Password fields don't match",
'Password reset': 'Password reset',
'PhDs': 'PhDs',
'Please select a list....': 'Please select a list....',
'Please, define sections for the list "%s"': 'définissez des sections pour la liste "%s"',
'Position': 'Position',
'Postprocessing': 'Postprocessing',
'Preprint': 'Preprint',
'Preprint identifier separated by comma: arXiv:0906.1516': 'Numéro(s) du preprint séparé par des virgules: arXiv:0906.1516',
'Preprints': 'Preprints',
......@@ -164,6 +167,10 @@
'Sort field': 'Sort field',
'Sort the publications list associated to the section according to the database field. The field has to belong to the table tabelanme. The publications of this section will be sort according to this field': 'Sort the publications list associated to the section according to the database field. The field has to belong to the table tabelanme. The publications of this section will be sort according to this field',
'Speaker': 'Orateur',
'Split 1': 'Split 1',
'Split 2': 'Split 2',
'Split 3': 'Split 3',
'Split 4': 'Split 4',
'Split Section 1': 'Split Section 1',
'Split Section 2': 'Split Section 2',
'Split Section 3': 'Split Section 3',
......
......@@ -73,16 +73,15 @@ IS_FLOAT_IN_RANGE(0., 1.0)
#
#-------------------------------------------------------------------------------
dirs = ['ASC', 'DESC']
splits = ['', 'id_projects', 'id_teams', 'year']
splits = ['', 'category', 'id_projects', 'id_teams', 'year']
db.define_table("lists",
Field("list", "string", notnull=True),
Field("split_section_1", "string", default='', requires=IS_IN_SET(splits)),
Field("split_section_2", "string", default='', requires=IS_IN_SET(splits)),
Field("split_section_3", "string", default='', requires=IS_IN_SET(splits)),
Field("dir_1", "string", default='ASC', requires=IS_IN_SET(dirs)),
Field("dir_2", "string", default='ASC', requires=IS_IN_SET(dirs)),
Field("dir_3", "string", default='ASC', requires=IS_IN_SET(dirs)),
Field("split_1", "string", default='category', requires=IS_IN_SET(splits)),
Field("split_2", "string", default='', requires=IS_IN_SET(splits)),
Field("split_3", "string", default='', requires=IS_IN_SET(splits)),
Field("split_4", "string", default='', requires=IS_IN_SET(splits)),
Field("dir_year", "string", default='ASC', requires=IS_IN_SET(dirs)),
Field("header_flag", "boolean", default=True, label='Header'),
Field("footer_flag", "boolean", default=True, label='Footer'),
Field("note", "text"),
......@@ -108,14 +107,14 @@ T("Name of the database table containing the publications shown in this section.
db.define_table("sections",
Field("id_lists", db.lists, default=undef_id, notnull=True, label='List'),
Field("section", "string", notnull=True, comment=tp_section),
Field("categories", "text", notnull=True, comment=tp_categories),
Field("position", "integer", notnull=True, requires=IS_INT_IN_RANGE(1, 999)),
Field("tablename", "string", notnull=True, comment=tp_tablename),
Field("template", "text", notnull=True),
Field("categories", "text", notnull=True, comment=tp_categories),
Field("conditions", "text"),
Field("sort_field", "string", comment=tp_sort_field),
Field("dir", "string", default='ASC', requires=IS_IN_SET(dirs)),
Field("formattor", "string"),
Field("postprocessing", "string"),
Field("note", "text"),
migrate="sections.table")
......
......@@ -11,25 +11,17 @@ fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Year'))
#
# Merge fields for the lists forms
# merge fields for the list selector
#
fieldsModifier = dbui.FieldsModifier('lists')
fieldsModifier.configure_field('split_section_1', flex=2)
fieldsModifier.configure_field('dir_1', flex=1)
fieldsModifier.merge_fields('split_section_1', 'dir_1', fieldLabel=T('Split section #1'))
fieldsModifier.configure_field('split_section_2', flex=2)
fieldsModifier.configure_field('dir_2', flex=1)
fieldsModifier.merge_fields('split_section_2', 'dir_2', fieldLabel=T('Split section #2'))
fieldsModifier.configure_field('split_section_3', flex=2)
fieldsModifier.configure_field('dir_3', flex=1)
fieldsModifier.merge_fields('split_section_3', 'dir_3', fieldLabel=T('Split section #3'))
fieldsModifier = dbui.FieldsModifier('list_selector')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Year'))
#
# merge fields for the list selector
# merge fields for the list selector_2
#
fieldsModifier = dbui.FieldsModifier('list_selector')
fieldsModifier = dbui.FieldsModifier('list_selector_2')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Year'))
......
......@@ -65,7 +65,11 @@ def get_selector(*fields):
# keep in mind that the field are encode ad TablenameFieldName
# where tablename is the name of the selector
for key in current.request.vars:
t = decode_field(key)
if len(t) != 2:
continue
if t[1] in fields:
di[t[1]] = current.request.vars[key]
......
......@@ -3,7 +3,7 @@
if key.count('/') == 0:
response.write(H2(key.title(), _class='my-h2'))
response.write(H2(key, _class='my-h2'))
else:
margin = 3 + 3*key.count('/')
......
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