Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
f1b502c0
Commit
f1b502c0
authored
Feb 25, 2015
by
LE GAC Renaud
Browse files
Use alias table to deal with category and quality in selector.
parent
74b2b965
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
12 deletions
+29
-12
models/db1_categories.py
models/db1_categories.py
+7
-0
models/vt_graph_selector.py
models/vt_graph_selector.py
+9
-5
models/vt_grid_selector.py
models/vt_grid_selector.py
+7
-3
modules/selector.py
modules/selector.py
+6
-4
No files found.
models/db1_categories.py
0 → 100644
View file @
f1b502c0
# -*- coding: utf-8 -*-
""" categories
alias tables for people_categories
"""
db
.
people_categories
.
with_alias
(
'categories'
)
models/vt_graph_selector.py
View file @
f1b502c0
...
...
@@ -6,12 +6,15 @@ virtdb.define_table('graph_selector',
Field
(
'year_start'
,
'integer'
,
default
=
year
),
Field
(
'year_end'
,
'integer'
),
Field
(
'id_teams'
,
'reference teams'
,
label
=
T
(
'Team'
)),
Field
(
'
category'
,
'string'
),
Field
(
'id_
people_
categories'
,
'reference
people_
categories'
,
label
=
T
(
"
Qualit
y"
)),
Field
(
'id_p
roject
s'
,
'reference p
roject
s'
,
label
=
T
(
'Project'
)))
Field
(
'
id_projects'
,
'reference projects'
,
label
=
T
(
'Project'
)
),
Field
(
'id_categories'
,
'reference categories'
,
label
=
T
(
"
Categor
y"
)),
Field
(
'id_p
eople_categorie
s'
,
'reference p
eople_categorie
s'
,
label
=
T
(
"Quality"
)))
virtdb
.
graph_selector
.
category
.
requires
=
IS_IN_SET
(
PEOPLE_CATEGORIES
)
virtdb
.
graph_selector
.
id_people_categories
.
requires
=
IS_IN_DB
(
db
,
'people_categories.code'
)
virtdb
.
graph_selector
.
id_categories
.
requires
=
\
IS_IN_DB
(
db
,
'categories.category'
)
virtdb
.
graph_selector
.
id_people_categories
.
requires
=
\
IS_IN_DB
(
db
,
'people_categories.code'
)
virtdb
.
graph_selector
.
id_projects
.
requires
=
IS_IN_DB
(
db
,
'projects.project'
)
virtdb
.
graph_selector
.
id_teams
.
requires
=
IS_IN_DB
(
db
,
'teams.team'
)
...
...
@@ -29,6 +32,7 @@ fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype
=
'xcomboboxuserreset'
text
=
T
(
'select...'
)
fieldsModifier
.
configure_field
(
'id_categories'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_people_categories'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_teams'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_projects'
,
emptyText
=
text
,
xtype
=
mytype
)
...
...
models/vt_grid_selector.py
View file @
f1b502c0
...
...
@@ -7,11 +7,14 @@ virtdb.define_table('grid_selector',
Field
(
'year_end'
,
'integer'
),
Field
(
'id_teams'
,
'reference teams'
,
label
=
T
(
'Team'
)),
Field
(
'id_projects'
,
'reference projects'
,
label
=
T
(
'Project'
)),
Field
(
'categor
y
'
,
'
string'
),
Field
(
'
id_
categor
ies
'
,
'
reference categories'
,
label
=
T
(
"Category"
)
),
Field
(
'id_people_categories'
,
'reference people_categories'
,
label
=
T
(
"Quality"
)))
virtdb
.
grid_selector
.
category
.
requires
=
IS_IN_SET
(
PEOPLE_CATEGORIES
)
virtdb
.
grid_selector
.
id_people_categories
.
requires
=
IS_IN_DB
(
db
,
'people_categories.code'
)
virtdb
.
grid_selector
.
id_categories
.
requires
=
\
IS_IN_DB
(
db
,
'categories.category'
)
virtdb
.
grid_selector
.
id_people_categories
.
requires
=
\
IS_IN_DB
(
db
,
'people_categories.code'
)
virtdb
.
grid_selector
.
id_projects
.
requires
=
IS_IN_DB
(
db
,
'projects.project'
)
virtdb
.
grid_selector
.
id_teams
.
requires
=
IS_IN_DB
(
db
,
'teams.team'
)
...
...
@@ -29,6 +32,7 @@ fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype
=
'xcomboboxuserreset'
text
=
T
(
'select...'
)
fieldsModifier
.
configure_field
(
'id_categories'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_people_categories'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_teams'
,
emptyText
=
text
,
xtype
=
mytype
)
fieldsModifier
.
configure_field
(
'id_projects'
,
emptyText
=
text
,
xtype
=
mytype
)
...
...
modules/selector.py
View file @
f1b502c0
...
...
@@ -134,7 +134,7 @@ class MySelector(SelectorActiveItems):
and year are systematically excluded.
"""
li
=
[
'categor
y
'
,
'year_end'
,
'year_start'
]
li
=
[
'
id_
categor
ies
'
,
'year_end'
,
'year_start'
]
li
.
extend
(
exclude_fields
)
SelectorActiveItems
.
__init__
(
self
,
table
,
exclude_fields
=
li
)
...
...
@@ -309,7 +309,7 @@ class MySelector(SelectorActiveItems):
def
query
(
self
,
table
):
"""Supersede the base class method to handle
categor
y constraints.
"""Supersede the base class method to handle
qualit
y constraints.
@type table: gluon.dal.Table
@param table:
...
...
@@ -325,8 +325,10 @@ class MySelector(SelectorActiveItems):
query
=
SelectorActiveItems
.
query
(
self
,
table
)
# category constraint
if
self
.
category
:
q
=
db
.
people_categories
.
category
==
self
.
category
id_category
=
self
.
id_categories
if
id_category
:
category
=
db
.
people_categories
[
id_category
].
category
q
=
db
.
people_categories
.
category
==
category
query
=
(
query
)
&
(
q
)
return
query
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment