|
a/bitergiametrics/main.py |
|
b/bitergiametrics/main.py |
|
... |
|
... |
34 |
|
34 |
|
35 |
class W:
|
35 |
class W:
|
36 |
thread=w.Thread(
|
36 |
thread=w.Thread(
|
37 |
page=None, limit=None, page_size=None, count=None,
|
37 |
page=None, limit=None, page_size=None, count=None,
|
38 |
style='linear')
|
38 |
style='linear')
|
39 |
pager = widgets.BlogPager()
|
39 |
# pager = widgets.BlogPager()
|
40 |
new_post_form = widgets.NewPostForm()
|
40 |
# new_post_form = widgets.NewPostForm()
|
41 |
edit_post_form = widgets.EditPostForm()
|
41 |
# edit_post_form = widgets.EditPostForm()
|
42 |
view_post_form = widgets.ViewPostForm()
|
42 |
view_metrics_form = widgets.ViewMetricsForm()
|
43 |
label_edit = ffw.LabelEdit()
|
43 |
# label_edit = ffw.LabelEdit()
|
44 |
attachment_add = ffw.AttachmentAdd()
|
|
|
45 |
attachment_list = ffw.AttachmentList()
|
|
|
46 |
preview_post_form = widgets.PreviewPostForm()
|
|
|
47 |
subscribe_form = SubscribeForm()
|
44 |
# subscribe_form = SubscribeForm()
|
48 |
|
45 |
|
49 |
class BitergiaMetricsApp(Application):
|
46 |
class BitergiaMetricsApp(Application):
|
50 |
__version__ = version.__version__
|
47 |
__version__ = version.__version__
|
51 |
tool_label='Metrics'
|
48 |
tool_label='Metrics'
|
52 |
default_mount_label='Metrics'
|
49 |
default_mount_label='Metrics'
|
|
... |
|
... |
121 |
@with_trailing_slash
|
118 |
@with_trailing_slash
|
122 |
def index(self, page=0, limit=10, **kw):
|
119 |
def index(self, page=0, limit=10, **kw):
|
123 |
query_filter = dict(app_config_id=c.app.config._id)
|
120 |
query_filter = dict(app_config_id=c.app.config._id)
|
124 |
if not has_access(c.app, 'write')():
|
121 |
if not has_access(c.app, 'write')():
|
125 |
query_filter['state'] = 'published'
|
122 |
query_filter['state'] = 'published'
|
126 |
q = BM.BlogPost.query.find(query_filter)
|
123 |
# q = BM.BlogPost.query.find(query_filter)
|
127 |
post_count = q.count()
|
124 |
# post_count = q.count()
|
128 |
limit, page = h.paging_sanitizer(limit, page, post_count)
|
125 |
# limit, page = h.paging_sanitizer(limit, page, post_count)
|
129 |
posts = q.sort('timestamp', pymongo.DESCENDING) \
|
126 |
# posts = q.sort('timestamp', pymongo.DESCENDING) \
|
130 |
.skip(page * limit).limit(limit)
|
127 |
# .skip(page * limit).limit(limit)
|
131 |
c.form = W.preview_post_form
|
128 |
c.form = W.view_metrics_form
|
132 |
c.pager = W.pager
|
129 |
# c.pager = W.pager
|
133 |
return dict(posts=posts, page=page, limit=limit, count=post_count)
|
130 |
# return dict(posts=posts, page=page, limit=limit, count=post_count)
|
|
|
131 |
return dict()
|
134 |
|
132 |
|
135 |
class MetricsAdminController(DefaultAdminController):
|
133 |
class MetricsAdminController(DefaultAdminController):
|
136 |
def __init__(self, app):
|
134 |
def __init__(self, app):
|
137 |
self.app = app
|
135 |
self.app = app
|
138 |
|
136 |
|