本文整理汇总了Python中pyasm.search.Search.get_count方法的典型用法代码示例。如果您正苦于以下问题:Python Search.get_count方法的具体用法?Python Search.get_count怎么用?Python Search.get_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.get_count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_count
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_count(cls, where=None, category=None):
search = Search(Clipboard)
search.add_user_filter()
if not category:
search.add_filter("category","select")
if where:
search.add_where(where)
return search.get_count()
示例2: get_notes_and_stypes_counts
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_notes_and_stypes_counts(process, search_key, stypes_list):
# getting notes by search_type process and count of stypes from stypes_list
from pyasm.search import Search
search_type, search_code = server.split_search_key(search_key)
cnt = {
'notes': {},
'stypes': {},
}
for p in process:
search = Search('sthpw/note')
search.add_op_filters([('process', p), ('search_type', search_type), ('search_code', search_code)])
cnt['notes'][p] = search.get_count()
for stype in stypes_list:
search = Search(stype)
search.add_parent_filter(search_key)
cnt['stypes'][stype] = search.get_count()
return cnt
示例3: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_display(self):
# set up the self refresh event for other widgets or callbacks to call
event_container = WebContainer.get_event_container()
script = ClipboardWdg.get_self_refresh_script(show_progress=False)
event_container.add_listener(self.EVENT_ID, script, replace=True )
if self.is_from_ajax():
div = Widget()
else:
div = DivWdg()
div.set_id(self.ID)
div.add_style("display: block")
div.add_class("background_box")
div.add_style("padding-left: 3px")
div.add_style("padding-right: 3px")
div.add_style("height: 1.5em")
div.add_style("width: 150px")
# handle the ajax
self.set_ajax_top_id(self.ID)
self.register_cmd(ClipboardClearCbk)
refresh_script = self.get_refresh_script()
search = Search("sthpw/clipboard")
search.add_user_filter()
search.add_filter("category", "select")
count = search.get_count()
div.add("Clipboard: %s items: " % count)
web = WebContainer.get_web()
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", "pyasm.widget.ClipboardListWdg")
ref = url.to_string()
iframe = WebContainer.get_iframe()
iframe.set_width(64)
action = iframe.get_on_script(ref)
button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
button.add_event("onclick", action)
div.add(button)
# add the clear clipboard icon
clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
clear_icon.add_event("onclick", refresh_script)
div.add(clear_icon)
return div
示例4: get_sobject_history_wdg
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_sobject_history_wdg(self, sobject):
search_type = sobject.get_search_type()
search_id = sobject.get_id()
content_id ='summary_sobject_history_%s' %sobject.get_id()
title_id = 'sobject_history_head_%s' %sobject.get_id()
head = DivWdg()
head.add_style('height','1.8em')
title = self._get_title_span()
dyn_load = AjaxLoader(display_id=content_id)
args_dict = {'search_type': sobject.get_search_type()}
args_dict['search_id'] = sobject.get_id()
dyn_load.set_load_method('_get_sobject_history_wdg')
dyn_load.set_load_class('pyasm.prod.web.AssetDetailWdg', load_args=args_dict)
on_script = dyn_load.get_on_script(load_once=True)
swap_wdg = self._get_swap_wdg(title_id)
swap_wdg.add_action_script(on_script, "toggle_display('%s')" %content_id)
head.add(swap_wdg)
head.add(title)
title.add("Transaction History")
search = Search("sthpw/sobject_log")
search.add_filter("search_type", search_type)
search.add_filter("search_id", search_id)
count = search.get_count()
title.add( " ( %s )" % count )
self.add_title_style(title, title_id, swap_wdg)
div = DivWdg(id=content_id)
div.add_style("width: 100%")
div.add_style("margin-left: auto")
div.add_style('display','none')
return head, div
示例5: get_dailies_wdg
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_dailies_wdg(my, sobject):
search_type = sobject.get_search_type()
search_id = sobject.get_id()
dailies_head = DivWdg()
dailies_head.add_style('height','1.8em')
dailies_title = my._get_title_span()
content_id ='summary_dailies_%s' %sobject.get_id()
title_id = 'dailies_head_%s' %sobject.get_id()
args_dict = {'search_type': sobject.get_search_type()}
args_dict['search_id'] = sobject.get_id()
dyn_load = AjaxLoader(display_id=content_id)
dyn_load.set_load_method('_get_dailies_wdg')
dyn_load.set_load_class('pyasm.prod.web.AssetDetailWdg', load_args=args_dict)
on_script = dyn_load.get_on_script(load_once=True)
swap_wdg = my._get_swap_wdg(title_id)
swap_wdg.add_action_script(on_script, "toggle_display('%s')" %content_id)
dailies_head.add(swap_wdg)
dailies_head.add(dailies_title)
dailies_title.add("Dailies")
search = Search("prod/submission")
search.add_filter("search_type", search_type)
search.add_filter("search_id", search_id)
count = search.get_count()
dailies_title.add( " ( %s )" % count )
my.add_title_style(dailies_title, title_id, swap_wdg)
dailies_div = DivWdg(id=content_id)
dailies_div.add_style("width: 98%")
dailies_div.add_style("margin-left: auto")
dailies_div.add_style('display','none')
return dailies_head, dailies_div
示例6: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def execute(self):
web = WebContainer.get_web()
search_type = web.get_form_value("search_type")
search_id = web.get_form_value("search_id")
# check if item is already in the clipboard
search = Search("sthpw/clipboard")
search.add_filter("search_type", search_type)
search.add_filter("search_id", search_id)
search.add_filter("category", "select")
if search.get_count():
# if is already selected then remove.
item = search.get_sobject()
item.delete()
search = Search(search_type)
search.add_id_filter(search_id)
sobject = search.get_sobject()
search_type_obj = sobject.get_search_type_obj()
self.description = "Removed %s '%s' from clipboard" % (search_type_obj.get_title(), sobject.get_code() )
else:
search = Search(search_type)
search.add_id_filter(search_id)
sobject = search.get_sobject()
search_type_obj = sobject.get_search_type_obj()
clipboard = SearchType.create("sthpw/clipboard")
clipboard.set_value("search_type", search_type)
clipboard.set_value("search_id", search_id)
#TODO: set project_code as well
clipboard.set_value("category", "select")
clipboard.set_user()
clipboard.commit()
self.description = "Added %s '%s' to clipboard" % (search_type_obj.get_title(), sobject.get_code() )
示例7: create
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def create(src_sobject, dst_sobject, context="reference", direction="both"):
project_code = Project.get_project_code()
if not context:
context = "reference"
# ensure that the connection doesn't already exist
search = Search("sthpw/connection")
search.add_sobject_filter(src_sobject, prefix="src_")
search.add_sobject_filter(dst_sobject, prefix="dst_")
if search.get_count():
Environment.add_warning("Already connected", "%s is already connected to %s" % (src_sobject.get_code(), dst_sobject.get_code() ) )
return
connection = SearchType.create("sthpw/connection")
connection.set_value("src_search_type", src_sobject.get_search_type() )
connection.set_value("dst_search_type", dst_sobject.get_search_type() )
connection.set_value("src_search_id", src_sobject.get_id() )
connection.set_value("dst_search_id", dst_sobject.get_id() )
connection.set_value("context", context)
connection.set_value("project_code", project_code)
connection.commit()
if direction == "both":
connection = SearchType.create("sthpw/connection")
connection.set_value("src_search_type", dst_sobject.get_search_type() )
connection.set_value("dst_search_type", src_sobject.get_search_type() )
connection.set_value("src_search_id", dst_sobject.get_id() )
connection.set_value("dst_search_id", src_sobject.get_id() )
connection.set_value("context", context)
connection.set_value("project_code", project_code)
connection.commit()
return connection
示例8: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
#.........这里部分代码省略.........
title_wdg.add_style("font-weight: bold")
title_wdg.add_style("font-size: 14px")
content = DivWdg()
top.add(content)
content.add_style("padding: 10px")
if not search_key:
warning_msg = "Projects must be deleted individually"
content.add(DivWdg(warning_msg, css='warning'))
content.add("<br/>")
return top
warning_msg = "Deleting a project will delete the database associated with this project. All data and files will be lost. Please consider carefully before proceeding."
if warning_msg:
warning_wdg = DivWdg(warning_msg, css='warning')
content.add(warning_wdg)
warning_wdg.add_style("margin: 20 10px")
content.add("<br/>")
if not project_code:
content.add("This project [%s] has been deleted."%search_key)
return top
elif not project:
content.add("This project [%s] has been deleted."%project_code)
return top
assert project_code
assert project
content.add("<br/>")
content.add("<b>NOTE: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> ")
content.add("<br/>")
content.add("<br/>")
total_items_wdg = DivWdg()
total_items = 0
content.add(total_items_wdg)
# find all of the sTypes
details_wdg = DivWdg()
content.add(details_wdg)
details_wdg.add_style("max-height: 300px")
details_wdg.add_style("overflow-y: auto")
details_wdg.add_style("padding-left: 15px")
details_wdg.add_border()
search_types = project.get_search_types()
related_types = []
for search_type_obj in search_types:
search_type_wdg = DivWdg()
title = search_type_obj.get_title()
search_type = search_type_obj.get_value("search_type")
search_type_wdg.add_style("margin-top: 5px")
search_type_wdg.add_style("margin-bottom: 5px")
details_wdg.add(search_type_wdg)
search_type_wdg.add(title)
search_type_wdg.add(" (%s)" % search_type )
search = Search( search_type, project_code=project_code )
count = search.get_count()
total_items += count
search_type_wdg.add(" - %s item(s)" % count)
# TODO: this is similar to SearchType.get_related_types(). streamline at some point.
related_types = my.get_related_types(search_type)
for related_type in related_types:
try:
search = Search(related_type)
except Exception, e:
print "WARNING: ", e
continue
full_search_type = "%s?project=%s" % (search_type, project_code)
if related_type.startswith("sthpw/"):
search.add_filter("search_type", full_search_type)
count = search.get_count()
if count == 0:
continue
total_items += count
related_wdg = DivWdg()
related_wdg.add_style('padding-left: 25px')
search_type_wdg.add(related_wdg)
related_wdg.add(related_type)
related_wdg.add(" - %s item(s)" % count)
示例9: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_display(my):
top = my.top
top.add_color("background", "background")
top.add_color("color", "color")
top.add_style("padding: 10px")
top.add_style("min-width: 400px")
from tactic.ui.app import HelpButtonWdg
help_wdg = HelpButtonWdg(alias="exporting-csv-data")
top.add(help_wdg)
help_wdg.add_style("float: right")
help_wdg.add_style("margin-top: -3px")
if not my.check():
top.add(DivWdg('Error: %s' %my.error_msg))
top.add(HtmlElement.br(2))
return super(CsvExportWdg, my).get_display()
if my.search_type_list and my.search_type_list[0] != my.search_type:
st = SearchType.get(my.search_type_list[0])
title_div =DivWdg('Exporting related items [%s]' % st.get_title())
top.add(title_div)
top.add(HtmlElement.br())
my.search_type = my.search_type_list[0]
my.view = my.related_view
if my.mode != 'export_all':
num = len(my.selected_search_keys)
else:
search = Search(my.search_type)
num = search.get_count()
msg_div = DivWdg('Total: %s items to export'% num)
msg_div.add_style("font-size: 12px")
msg_div.add_style("font-weight: bold")
msg_div.add_style('margin-left: 4px')
top.add(msg_div)
if num > 300:
msg_div.add_behavior({'type':'load',
'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
top.add(HtmlElement.br())
div = DivWdg(css='spt_csv_export', id='csv_export_action')
div.add_color("background", "background", -10)
div.add_style("padding: 10px")
div.add_style("margin: 5px")
div.add_styles('max-height: 350px; overflow: auto')
table = Table( css='minimal')
table.add_color("color", "color")
div.add(table)
table.set_id('csv_export_table')
table.center()
cb_name = 'csv_column_name'
master_cb = CheckboxWdg('master_control')
master_cb.set_checked()
master_cb.add_behavior({'type': 'click_up',
'propagate_evt': True,
'cbjs_action': '''
var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
for (var i = 0; i < inputs.length; i++)
inputs[i].checked = !inputs[i].checked;
''' %cb_name})
span = SpanWdg('Select Columns To Export')
span.add_style('font-weight','600')
table.add_row_cell(span)
table.add_row_cell(HtmlElement.br())
tr = table.add_row()
tr.add_style('border-bottom: 1px groove #777')
td = table.add_cell(master_cb)
label = HtmlElement.i('toggle all')
label.add_style('color: #888')
table.add_cell(label)
col1 = table.add_col()
col1.add_style('width: 35px')
col2 = table.add_col()
if not my.search_type or not my.view:
return table
# use overriding element names and derived titles if available
config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
if my.element_names and config:
filtered_columns = my.element_names
titles = []
for name in my.element_names:
title = config.get_element_title(name)
titles.append(title)
else:
#.........这里部分代码省略.........
示例10: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
#.........这里部分代码省略.........
content.add("<br/>")
total_items_wdg = DivWdg()
total_items = 0
content.add(total_items_wdg)
# find all of the sTypes
details_wdg = DivWdg()
content.add(details_wdg)
details_wdg.add_style("max-height: 300px")
details_wdg.add_style("overflow-y: auto")
details_wdg.add_style("padding-left: 15px")
details_wdg.add_border()
search_types = project.get_search_types()
related_types = []
for search_type_obj in search_types:
search_type_wdg = DivWdg()
title = search_type_obj.get_title()
search_type = search_type_obj.get_value("search_type")
search_type_wdg.add_style("margin-top: 5px")
search_type_wdg.add_style("margin-bottom: 5px")
details_wdg.add(search_type_wdg)
search_type_wdg.add(title)
search_type_wdg.add(" (%s)" % search_type )
search = Search( search_type, project_code=project_code )
count = search.get_count()
total_items += count
search_type_wdg.add(" - %s item(s)" % count)
# TODO: this is similar to SearchType.get_related_types(). streamline at some point.
related_types = self.get_related_types(search_type)
for related_type in related_types:
try:
search = Search(related_type)
except Exception as e:
print("WARNING: ", e)
continue
full_search_type = "%s?project=%s" % (search_type, project_code)
if related_type.startswith("sthpw/"):
search.add_filter("search_type", full_search_type)
count = search.get_count()
if count == 0:
continue
total_items += count
related_wdg = DivWdg()
related_wdg.add_style('padding-left: 25px')
search_type_wdg.add(related_wdg)
related_wdg.add(related_type)
related_wdg.add(" - %s item(s)" % count)
if total_items:
total_items_wdg.add("Total # of items to be deleted: ")
total_items_wdg.add(total_items)
total_items_wdg.add_style("font-size: 14px")
示例11: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def execute(self):
from pyasm.search import DbContainer
from pyasm.security import Security
delete_group = "admin"
security = Environment.get_security()
if not security.is_in_group(delete_group):
raise Exception("Only users in [%s] can delete projects"%delete_group)
project_code = self.kwargs.get("project_code")
if project_code:
project = Project.get_by_code(project_code)
else:
search_key = self.kwargs.get("search_key")
project = Search.get_by_search_key(search_key)
project_code = project.get_code()
assert project_code
assert project
# dump the database
# remove all dependencies the sthpw database
related_types = self.kwargs.get("related_types")
if related_types:
for related_type in related_types:
search = Search(related_type)
if related_type == "sthpw/schema":
search.add_filter("code", project_code)
else:
search.add_filter("project_code", project_code)
count = search.get_count()
sobjects = search.get_sobjects()
for sobject in sobjects:
if related_type == 'sthpw/snapshot':
self.delete_snapshot(sobject)
else:
sobject.delete()
sthpw_project = Project.get_by_code('sthpw')
# delete the database
sthpw_db_resource = sthpw_project.get_project_db_resource()
db_resource = project.get_project_db_resource()
impl = sthpw_db_resource.get_database_impl()
deleted_impl = db_resource.get_database_impl()
if not impl.database_exists(db_resource):
# remove the project entry
project.delete()
return
# close this connection to the project to be deleted
sql = DbContainer.get(db_resource)
sql.close()
if sql.get_database_type() == 'Sqlite':
DbContainer.release_thread_sql()
result = impl.drop_database(db_resource)
# this is just extra check
if result and "failed" in result:
raise TacticException(result)
Container.put("Sql:database_exists:%s"%db_resource.get_key(), None)
sql = DbContainer.get(db_resource, connect=True)
if sql:
try:
if sql.get_database_type() != 'Sqlite':
if sql.get_connection() and sql.connect():
raise TacticException("Database [%s] still exists. There could still be connections to it."%project_code)
except SqlException as e:
pass
# remove the project entry
project.delete(triggers=False)
schema = Schema.get_by_code(project_code)
if schema:
schema.delete()
# Delete project specific login group and login in group entries
expr = "@SOBJECT(sthpw/login_group['project_code','%s'])"%project_code
expr2 = "@SOBJECT(sthpw/login_group['project_code','%s'].sthpw/login_in_group)"%project_code
sobjs = Search.eval(expr2)
for sobj in sobjs:
sobj.delete()
sobjs = Search.eval(expr)
#.........这里部分代码省略.........
示例12: handle_search
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def handle_search(my):
login = my.kwargs.get("login")
project_code = my.kwargs.get("project")
my.start_date = datetime(my.year, my.month, 1)
next_month = my.month+1
next_year = my.year
if next_month > 12:
next_month = 1
next_year += 1
my.end_date = datetime(next_year, next_month, 1)
search = Search("sthpw/task")
if login:
search.add_filter("assigned", login)
if project_code:
if project_code == "$PROJECT":
search.add_project_filter()
else:
search.add_filter("project_code", project_code)
search.add_filter("bid_end_date", my.start_date, op=">")
search.add_filter("bid_end_date", my.end_date, op="<")
my.task_count = search.get_count()
my.tasks = search.get_sobjects()
my.tasks_count = {}
for task in my.tasks:
date = task.get_value("bid_end_date")
date = parser.parse(date)
date = datetime(date.year, date.month, date.day)
count = my.tasks_count.get(str(date))
if not count:
count = 0
count += 1
my.tasks_count[str(date)] = count
search = Search("sthpw/snapshot")
if login:
search.add_filter("login", login)
if project_code:
if project_code == "$PROJECT":
search.add_project_filter()
else:
search.add_filter("project_code", project_code)
search.add_filter("timestamp", my.start_date, op=">")
search.add_filter("timestamp", my.end_date, op="<")
my.snapshot_count = search.get_count()
my.snapshots = search.get_sobjects()
my.snapshots_count = {}
for snapshot in my.snapshots:
date = snapshot.get_value("timestamp")
date = parser.parse(date)
date = datetime(date.year, date.month, date.day)
count = my.snapshots_count.get(str(date))
if not count:
count = 0
count += 1
my.snapshots_count[str(date)] = count
search = Search("sthpw/task")
if login:
search.add_filter("assigned", login)
if project_code:
if project_code == "$PROJECT":
search.add_project_filter()
else:
search.add_filter("project_code", project_code)
search.add_filter("timestamp", my.start_date, op=">")
search.add_filter("timestamp", my.end_date, op="<")
my.task_count = search.get_count()
search = Search("sthpw/note")
if login:
search.add_filter("login", login)
if project_code:
if project_code == "$PROJECT":
search.add_project_filter()
else:
search.add_filter("project_code", project_code)
search.add_filter("timestamp", my.start_date, op=">")
search.add_filter("timestamp", my.end_date, op="<")
my.note_count = search.get_count()
#.........这里部分代码省略.........
示例13: _get_next_num
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def _get_next_num(sobject, column):
from pyasm.search import Search
# assumptions: a code would look something like this asset_001
# the only numbers that we care about are the trailing ones
'''
To get the next number, first do a search for
Order code by desc (code starts with asset_)
get a count of the search
grab the first result of the search. Get it's trailing number
the number to be returned will is whichever is bigger of the count or the trailing number
if ther is a number for neither, then return 1.
'''
# set the default start value
code_num = Common._get_start_code()
# get the highest number, extract the number and increase by 1
search_type = sobject.get_search_type()
search = Search(search_type)
search.set_show_retired_flag(True)
value = sobject.get_value(column)
startswith_value = value.rstrip("0123456789")
# if column is code, then value is the code
'''
There are two cases in which startswith_value would be an empty string
either there was no code to begin with, or the code is all numbers
if there is no code, don't do a search.
if there are only numbers, go off of the numbers
ie: if the code is 403. The return code should be 403_001
'''
do_search = True
if not startswith_value:
# if there is no code
if not value:
do_search = False
# if code is all numbers
else:
startswith_value = value
if do_search:
search.add_filter(column, "%s%%" % (startswith_value), op='LIKE')
else:
return None
# order by descending codes
search.add_order_by("code desc")
last_sobject = search.get_sobject()
count = search.get_count()
# grab the first result of the search. Get it's trailing number
if last_sobject != None:
last_sobject_code = last_sobject.get_value("code")
last_sobject_code_num = last_sobject_code.lstrip(startswith_value)
last_sobject_code_num = re.sub("[^0-9]", "", last_sobject_code_num)
# if last_sobject_code_num doesn't exist, then set it to 0
# if it does, make sure that it's an int
if not last_sobject_code_num:
last_sobject_code_num = 0
else:
last_sobject_code_num = int(last_sobject_code_num)
# the number to be returned will is whichever is bigger of the count or the trailing number
if int(count) > int(last_sobject_code_num):
code_num = int(count) - 1
'''
count is subtracted by 1 because there are two cases
either the code starts with something like asset, or asset_001
if it starts off as asset, then it's the same as starting from 0
if it starts with 001 though, then it's fine, because it'll take the 001 instead
'''
else:
code_num = last_sobject_code_num
# increase the larger number by 1
code_num = code_num + 1
return code_num
示例14: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_display(self):
top = DivWdg()
name = self.get_name()
top.add_class("spt_note_input_top")
context = self.get_option("context")
if not context:
context = name
sobject = self.get_option("sobject")
if not sobject:
search_key = self.get_option("search_key")
sobject = Search.get_by_search_key(search_key)
else:
search_key = sobject.get_search_key()
if search_key or (sobject and not sobject.is_insert()):
search = Search("sthpw/note")
#search.add_relationship_filters(self.filtered_parents, type='hierarchy')
search.add_parent_filter(sobject)
search.add_filter("context", context)
search.add_order_by("process")
search.add_order_by("context")
search.add_order_by("timestamp desc")
search.add_filter("context", context)
count = search.get_count()
last_note = search.get_sobject()
else:
last_note = None
count = 0
#if not last_note:
# last_note = SearchType.create("sthpw/note")
# last_note.set_value("login", "")
# last_note.set_value("timestamp", "")
# last_note.set_value("note", "")
if last_note:
last_div = DivWdg()
top.add(last_div)
table = Table()
table.add_style("width: 100%")
table.add_attr("cellpadding", "0px")
table.add_attr("cellspacing", "0px")
last_div.add(table)
table.add_row()
td = table.add_cell()
td.add_style("vertical-align: top")
td.add_style("padding: 5px 15px 10px 5px")
table.add_border()
table.add_color("background", "background", -5)
note_str = last_note.get_value("note")
login = last_note.get_value("login")
if not login:
login = "unknown"
date = last_note.get_datetime_value("timestamp")
if date:
date_str = "<i style='font-size: 0.8em'>%s</i>" % date.strftime("%Y-%m-%d")
else:
date_str = ""
login = "<i style='opacity: 0.3'>%s</i>" % login
td.add("%s - %s<br/>" % (date_str, login))
note_str_div = DivWdg()
note_str_div.add(note_str)
note_str_div.add_style("padding: 10px 15px 10px 10px")
#td = table.add_cell( note_str_div )
td.add( note_str_div )
#td.add_style("vertical-align: top")
#td.add_style("padding: 10px 15px 10px 10px")
"""
td.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_note_input_top");
var text_el = top.getElement(".spt_add_entry");
text_el.setStyle("display", "");
'''
} )
"""
# log
if count == 0:
td = table.add_cell( "" )
elif count == 1:
td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entry)</i>" % count )
else:
td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entries)</i>" % count )
#.........这里部分代码省略.........
示例15: get_count
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_count [as 别名]
def get_count(self, status):
search = Search(self.search_type)
search.add_filter("project_code", self.project_code)
search.add_filter(self.column, status)
count = search.get_count()
return count