本文整理汇总了Python中s3.s3utils.s3_avatar_represent函数的典型用法代码示例。如果您正苦于以下问题:Python s3_avatar_represent函数的具体用法?Python s3_avatar_represent怎么用?Python s3_avatar_represent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s3_avatar_represent函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render_homepage_posts
def render_homepage_posts(rfields, record, **attr):
"""
Custom dataList item renderer for CMS Posts on the Homepage
@param rfields: the S3ResourceFields to render
@param record: the record as dict
@param attr: additional HTML attributes for the item
"""
pkey = "cms_post.id"
# Construct the item ID
listid = "datalist"
if pkey in record:
record_id = record[pkey]
item_id = "%s-%s" % (listid, record_id)
else:
# template
item_id = "%s-[id]" % listid
item_class = "thumbnail"
db = current.db
raw = record._row
series = record["cms_post.series_id"]
date = record["cms_post.created_on"]
body = record["cms_post.body"]
location = record["cms_post.location_id"]
location_id = raw["cms_post.location_id"]
location_url = URL(c="gis", f="location", args=[location_id])
# Attachment(s)?
document = raw["doc_document.file"]
if document:
doc_url = URL(c="default", f="download",
args=[document]
)
doc_link = A(I(_class="icon icon-paper-clip fright"),
_href=doc_url)
else:
doc_link = ""
if series not in ("News", "Twitter", "Ushahidi", "YouTube"):
# We expect an Author
author = record["cms_post.created_by"]
author_id = raw["cms_post.created_by"]
organisation = record["auth_user.organisation_id"]
organisation_id = raw["auth_user.organisation_id"]
org_url = URL(c="org", f="organisation", args=[organisation_id])
# @ToDo: Optimise by not doing DB lookups (especially duplicate) within render, but doing these in the bulk query
avatar = s3_avatar_represent(author_id,
_class="media-object",
_style="width:50px;padding:5px;padding-top:0px;")
s3db = current.s3db
ltable = s3db.pr_person_user
ptable = db.pr_person
query = (ltable.user_id == author_id) & \
(ltable.pe_id == ptable.pe_id)
row = db(query).select(ptable.id,
limitby=(0, 1)
).first()
if row:
person_url = URL(c="hrm", f="person", args=[row.id])
else:
person_url = "#"
author = A(author,
_href=person_url,
)
avatar = A(avatar,
_href=person_url,
_class="pull-left",
)
card_person = DIV(author,
" - ",
A(organisation,
_href=org_url,
_class="card-organisation",
),
doc_link,
_class="card-person",
)
else:
# No Author
card_person = DIV(doc_link,
_class="card-person",
)
avatar = None
if series == "News":
icon = URL(c="static", f="img",
args=["markers", "gis_marker.image.News.png"])
elif series == "Twitter":
icon = URL(c="static", f="img", args=["social", "twitter.png"])
elif series == "Ushahidi":
icon = URL(c="static", f="img",
args=["markers", "gis_marker.image.Ushahidi.png"])
elif series == "YouTube":
#icon = URL(c="static", f="img", args=["social", "YouTube.png"])
avatar = DIV(IFRAME(_width=320,
_height=180,
#.........这里部分代码省略.........
开发者ID:dvabhishek,项目名称:eden,代码行数:101,代码来源:controllers.py
示例2: render_profile_posts
def render_profile_posts(listid, resource, rfields, record, **attr):
"""
Custom dataList item renderer for CMS Posts on the Profile pages
@param listid: the HTML ID for this list
@param resource: the S3Resource to render
@param rfields: the S3ResourceFields to render
@param record: the record as dict
@param attr: additional HTML attributes for the item
"""
pkey = "cms_post.id"
# Construct the item ID
if pkey in record:
record_id = record[pkey]
item_id = "%s-%s" % (listid, record_id)
else:
# template
item_id = "%s-[id]" % listid
item_class = "thumbnail"
raw = record._row
series = record["cms_post.series_id"]
date = record["cms_post.created_on"]
body = record["cms_post.body"]
location = record["cms_post.location_id"]
location_id = raw["cms_post.location_id"]
location_url = URL(c="gis", f="location", args=[location_id])
author = record["cms_post.created_by"]
author_id = raw["cms_post.created_by"]
organisation = record["auth_user.organisation_id"]
organisation_id = raw["auth_user.organisation_id"]
org_url = URL(c="org", f="organisation", args=[organisation_id])
# @ToDo: Optimise by not doing DB lookups (especially duplicate) within render, but doing these in the bulk query
avatar = s3_avatar_represent(author_id,
_class="media-object")
db = current.db
s3db = current.s3db
ltable = s3db.pr_person_user
ptable = db.pr_person
query = (ltable.user_id == author_id) & \
(ltable.pe_id == ptable.pe_id)
row = db(query).select(ptable.id,
limitby=(0, 1)
).first()
if row:
person_url = URL(c="hrm", f="person", args=[row.id])
else:
person_url = "#"
author = A(author,
_href=person_url,
)
avatar = A(avatar,
_href=person_url,
_class="pull-left",
)
permit = current.auth.s3_has_permission
table = db.cms_post
if permit("update", table, record_id=record_id):
edit_btn = A(I(" ", _class="icon icon-edit"),
_href=URL(c="cms", f="post",
args=[record_id, "update.popup"],
vars={"refresh": listid,
"record": record_id}),
_class="s3_modal",
_title=current.response.s3.crud_strings.cms_post.title_update,
)
else:
edit_btn = ""
if permit("delete", table, record_id=record_id):
#delete_btn = A(I(" ", _class="icon icon-remove-sign"),
#_href=URL(c="cms", f="post", args=[record_id, "delete"]),
#)
delete_btn = A(I(" ", _class="icon icon-remove-sign"),
_class="dl-item-delete",
)
else:
delete_btn = ""
edit_bar = DIV(edit_btn,
delete_btn,
_class="edit-bar fright",
)
document = raw["doc_document.file"]
if document:
doc_url = URL(c="default", f="download",
args=[document]
)
doc_link = A(I(_class="icon icon-paper-clip fright"),
_href=doc_url)
else:
doc_link = ""
# Render the item
class SMALL(DIV):
tag = "small"
item = DIV(DIV(DIV(avatar,
P(SMALL(" ", author, " ",
#.........这里部分代码省略.........
开发者ID:dvabhishek,项目名称:eden,代码行数:101,代码来源:config.py
示例3: render_cms_events
def render_cms_events(listid, resource, rfields, record, **attr):
"""
Custom dataList item renderer for 'Events' on the Home page
@param listid: the HTML ID for this list
@param resource: the S3Resource to render
@param rfields: the S3ResourceFields to render
@param record: the record as dict
@param attr: additional HTML attributes for the item
"""
T = current.T
pkey = "cms_post.id"
# Construct the item ID
if pkey in record:
record_id = record[pkey]
item_id = "%s-%s" % (listid, record_id)
else:
# template
item_id = "%s-[id]" % listid
item_class = "thumbnail"
raw = record._row
series = "Event"
date = record["cms_post.date"]
body = record["cms_post.body"]
location = record["cms_post.location_id"]
location_id = raw["cms_post.location_id"]
location_url = URL(c="gis", f="location", args=[location_id])
author = record["cms_post.created_by"]
author_id = raw["cms_post.created_by"]
organisation = record["auth_user.organisation_id"]
organisation_id = raw["auth_user.organisation_id"]
org_url = URL(c="org", f="organisation", args=[organisation_id, "profile"])
# @ToDo: Optimise by not doing DB lookups (especially duplicate) within render, but doing these in the bulk query
avatar = s3_avatar_represent(author_id,
_class="media-object",
_style="width:50px;padding:5px;padding-top:0px;")
db = current.db
ltable = current.s3db.pr_person_user
ptable = db.pr_person
query = (ltable.user_id == author_id) & \
(ltable.pe_id == ptable.pe_id)
row = db(query).select(ptable.id,
limitby=(0, 1)
).first()
if row:
person_url = URL(c="hrm", f="person", args=[row.id])
else:
person_url = "#"
author = A(author,
_href=person_url,
)
avatar = A(avatar,
_href=person_url,
_class="pull-left",
)
# Edit Bar
permit = current.auth.s3_has_permission
table = db.cms_post
if permit("update", table, record_id=record_id):
edit_btn = A(I(" ", _class="icon icon-edit"),
_href=URL(c="cms", f="post",
args=[record_id, "update.popup"],
vars={"refresh": listid,
"record": record_id}),
_class="s3_modal",
_title=T("Edit Event"),
)
else:
edit_btn = ""
if permit("delete", table, record_id=record_id):
delete_btn = A(I(" ", _class="icon icon-remove-sign"),
_class="dl-item-delete",
)
else:
delete_btn = ""
edit_bar = DIV(edit_btn,
delete_btn,
_class="edit-bar fright",
)
# Dropdown of available documents
documents = raw["doc_document.file"]
if documents:
if not isinstance(documents, list):
documents = [documents]
doc_list = UL(_class="dropdown-menu",
_role="menu",
)
retrieve = db.doc_document.file.retrieve
for doc in documents:
try:
doc_name = retrieve(doc)[0]
except IOError:
doc_name = current.messages["NONE"]
doc_url = URL(c="default", f="download",
#.........这里部分代码省略.........
开发者ID:abhi12ravi,项目名称:eden,代码行数:101,代码来源:controllers.py
示例4: custom_postp
def custom_postp(r, output):
if r.representation == "plain" and \
r.method != "search":
# Map Popups - styled like dataList
auth = current.auth
db = current.db
record = r.record
record_id = record.id
item_class = "thumbnail"
item_id = "popup-%s" % record_id
table = s3db.cms_post
series = table.series_id.represent(record.series_id)
date = S3DateTime.date_represent(record.created_on, utc=True)
body = record.body
location_id = record.location_id
location = table.location_id.represent(location_id)
location_url = URL(c="gis", f="location", args=[location_id])
# Attachment(s)?
table = s3db.doc_document
row = db(table.doc_id == record.doc_id).select(table.file,
limitby=(0, 1)
).first()
if row:
doc_url = URL(c="default", f="download",
args=[row.file]
)
doc_link = A(I(_class="icon icon-paper-clip fright"),
_href=doc_url)
else:
doc_link = ""
if series not in ("News", "Twitter", "Ushahidi", "YouTube"):
# We expect an Author
author_id = record.created_by
author = table.created_by.represent(author_id)
utable = auth.settings.table_user
user = db(utable.id == author_id).select(utable.organisation_id,
limitby=(0, 1)
).first()
organisation_id = user.organisation_id
organisation = s3db.org_organisation_id.attr["represent"](organisation_id)
org_url = URL(c="org", f="organisation", args=[organisation_id])
# @ToDo: Optimise by not doing DB lookups (especially duplicate) within render, but doing these in the bulk query
avatar = s3_avatar_represent(author_id,
_class="media-object",
_style="width:50px;padding:5px;padding-top:0px;")
ltable = s3db.pr_person_user
ptable = db.pr_person
query = (ltable.user_id == author_id) & \
(ltable.pe_id == ptable.pe_id)
row = db(query).select(ptable.id,
limitby=(0, 1)
).first()
if row:
person_url = URL(c="hrm", f="person", args=[row.id])
else:
person_url = "#"
author = A(author,
_href=person_url,
)
avatar = A(avatar,
_href=person_url,
_class="pull-left",
)
card_person = DIV(author,
" - ",
A(organisation,
_href=org_url,
_class="card-organisation",
),
doc_link,
_class="card-person",
)
else:
# No Author
card_person = DIV(doc_link,
_class="card-person",
)
avatar = None
if series == "News":
icon = URL(c="static", f="img",
args=["markers", "gis_marker.image.News.png"])
elif series == "Twitter":
icon = URL(c="static", f="img", args=["social", "twitter.png"])
elif series == "Ushahidi":
icon = URL(c="static", f="img",
args=["markers", "gis_marker.image.Ushahidi.png"])
elif series == "YouTube":
#icon = URL(c="static", f="img", args=["social", "YouTube.png"])
avatar = DIV(IFRAME(_width=320,
_height=180,
_src=record.comments,
_frameborder=0),
_class="pull-left"
)
if not avatar:
avatar = DIV(IMG(_src=icon,
#.........这里部分代码省略.........
开发者ID:dmncdr,项目名称:eden,代码行数:101,代码来源:config.py
注:本文中的s3.s3utils.s3_avatar_represent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论