-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcontrollers.py
68 lines (56 loc) · 2.33 KB
/
controllers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
This file defines actions, i.e. functions the URLs are mapped into
The @action(path) decorator exposed the function at URL:
http://127.0.0.1:8000/{app_name}/{path}
If app_name == '_default' then simply
http://127.0.0.1:8000/{path}
If path == 'index' it can be omitted:
http://127.0.0.1:8000/
The path follows the bottlepy syntax.
@action.uses('generic.html') indicates that the action uses the generic.html template
@action.uses(session) indicates that the action uses the session
@action.uses(db) indicates that the action uses the db
@action.uses(T) indicates that the action uses the i18n & pluralization
@action.uses(auth.user) indicates that the action requires a logged in user
@action.uses(auth) indicates that the action requires the auth object
session, db, T, auth, and tempates are examples of Fixtures.
Warning: Fixtures MUST be declared with @action.uses({fixtures}) else your app will result in undefined behavior
"""
from py4web import action, request, abort, redirect, URL
from yatl.helpers import A
from .common import db, session, T, cache, auth, logger, authenticated, unauthenticated, flash
@action("index", method=['GET', 'POST'])
@action.uses(db, session, auth, flash, "index.html")
def index():
tot_imos = 0
tot_imts = 0
tot_grps = 0
tot_users = 0
tot_filters = 0
tot_smppcons = 0
tot_httpcons = 0
tot_mtroutes = 0
tot_moroutes = 0
tot_gateways = 0
tot_imos = db(db.j_imo).count()
tot_imts = db(db.j_imt).count()
tot_grps = db(db.j_group).count()
tot_users = db(db.j_user).count()
tot_filters = db(db.mt_filter).count()
tot_smppcons = db(db.connector).count()
tot_httpcons = db(db.http_cons).count()
tot_mtroutes = db(db.mtroute).count()
tot_moroutes = db(db.moroute).count()
return dict(tot_imos = tot_imos,
tot_imts = tot_imts,
tot_grps = tot_grps,
tot_users = tot_users,
tot_filters = tot_filters,
tot_smppcons = tot_smppcons,
tot_httpcons = tot_httpcons,
tot_mtroutes = tot_mtroutes,
tot_moroutes = tot_moroutes,
)
user = auth.get_user()
message = T("Hello {first_name}".format(**user) if user else "Hello")
return dict(message=message)