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
050c63d6
Commit
050c63d6
authored
Apr 01, 2017
by
LE GAC Renaud
Browse files
Update the class Event to add the methods get_source and get_sources.
parent
421aaf3c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
11 deletions
+63
-11
modules/plugin_event/__init__.py
modules/plugin_event/__init__.py
+2
-1
modules/plugin_event/callbacks.py
modules/plugin_event/callbacks.py
+2
-1
modules/plugin_event/event.py
modules/plugin_event/event.py
+54
-0
modules/plugin_event/model_report.py
modules/plugin_event/model_report.py
+3
-6
modules/plugin_event/report_tools.py
modules/plugin_event/report_tools.py
+2
-3
No files found.
modules/plugin_event/__init__.py
View file @
050c63d6
...
...
@@ -30,7 +30,8 @@ from dataframes import (active_period,
to_extjs_gridcolumns
,
to_items_per_year
)
from
event
import
Event
from
event
import
(
Event
,
EventException
)
from
matplotlib_tools
import
(
bicolor
,
create_pdf
,
...
...
modules/plugin_event/callbacks.py
View file @
050c63d6
...
...
@@ -7,6 +7,7 @@ import json
from
dataframes
import
to_extjs_gridcolumns
from
event
import
Event
from
gluon
import
current
from
gluon.tools
import
PluginManager
from
plugin_dbui
import
CALLBACK_ERRORS
,
get_where_query
...
...
@@ -90,7 +91,7 @@ def ON_CREATE_LISTS2(values):
year_start
=
year
,
year_end
=
year
)
func
=
PluginManager
(
"event"
).
event
.
source
s
[
values
[
"source"
]
]
.
func
func
=
Event
.
get_
source
(
values
[
"source"
]
)
.
func
df
=
func
(
**
criteria
)
...
...
modules/plugin_event/event.py
View file @
050c63d6
...
...
@@ -15,6 +15,10 @@ from dataframes import (get_items,
get_people_per_year
)
class
EventException
(
BaseException
):
pass
class
Event
(
object
):
"""Initialise the plugin event.
...
...
@@ -43,6 +47,56 @@ class Event(object):
"lg"
:
"static/plugin_event/locale/event-lang-%s.js"
%
lg
,
"libmin"
:
"static/plugin_event/event-min.js"
}
@
staticmethod
def
get_source
(
name
):
"""Get the source identified by its name.
Raised:
EventException
Args:
name (str): name of the source to be used in the UI.
Returns:
reference:
the function to generate the DataFrame.
"""
event
=
PluginManager
(
"event"
).
event
if
event
is
None
:
raise
EventException
(
"Plugin event is not configured."
)
sources
=
event
.
sources
if
sources
is
None
:
raise
EventException
(
"Plugin event sources are not configured."
)
if
name
not
in
sources
:
raise
EventException
(
"The source % is not registered"
%
name
)
return
sources
[
name
].
func
@
staticmethod
def
get_sources
():
"""Return the list of registered sources.
Raises:
EventException
Returns:
iterator:
names of the registered sources.
"""
event
=
PluginManager
(
"event"
).
event
if
event
is
None
:
raise
EventException
(
"Plugin event is not configured."
)
sources
=
event
.
sources
if
sources
is
None
:
raise
EventException
(
"Sources are not configured."
)
return
sources
.
iterkeys
()
@
staticmethod
def
register_source
(
name
,
func
):
"""Register sources which are used in the reporting section.
...
...
modules/plugin_event/model_report.py
View file @
050c63d6
...
...
@@ -6,8 +6,8 @@ import numpy as np
from
callbacks
import
ON_CREATE_LISTS2
,
ON_UPDATE_LISTS2
from
event
import
Event
from
gluon
import
current
,
IS_IN_SET
from
gluon.tools
import
PluginManager
from
pydal
import
Field
...
...
@@ -256,8 +256,7 @@ class Report(object):
migrate
=
"lists2.table"
)
sources
=
PluginManager
(
"event"
).
event
.
sources
.
keys
()
sources
.
sort
()
sources
=
sorted
(
Event
.
get_sources
())
db
.
lists2
.
source
.
requires
=
IS_IN_SET
(
sources
)
db
.
lists2
.
_before_insert
.
append
(
ON_CREATE_LISTS2
)
...
...
@@ -416,9 +415,7 @@ class Report(object):
migrate
=
"metrics2d2.table"
)
sources
=
PluginManager
(
"event"
).
event
.
sources
.
keys
()
sources
.
sort
()
sources
=
sorted
(
Event
.
get_sources
())
table
.
source
.
requires
=
IS_IN_SET
(
sources
)
funcs
=
AGGREGATE_FUNCS
.
keys
()
...
...
modules/plugin_event/report_tools.py
View file @
050c63d6
...
...
@@ -6,9 +6,9 @@ import json
import
matplotlib
as
mpl
import
pandas
as
pd
from
event
import
Event
from
gluon
import
current
from
gluon.storage
import
Storage
from
gluon.tools
import
PluginManager
from
model_report
import
AGGREGATE_FUNCS
from
matplotlib_tools
import
ticks_and_labels
from
plugin_dbui
import
Selector
,
Store
...
...
@@ -56,7 +56,6 @@ class BaseReport(object):
def
__init__
(
self
,
table
,
id_report
):
virtdb
=
current
.
globalenv
[
"virtdb"
]
plgevt
=
PluginManager
(
"event"
).
event
# ....................................................................
#
...
...
@@ -77,7 +76,7 @@ class BaseReport(object):
criteria
=
selector
.
as_dict
()
criteria
[
"id_events"
]
=
config
.
id_events
func
=
plgevt
.
source
s
[
config
.
source
].
func
func
=
Event
.
get_
source
(
config
.
source
)
self
.
df
=
df
=
func
(
**
criteria
)
...
...
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