本文整理汇总了Python中webapp.models.card.Card类的典型用法代码示例。如果您正苦于以下问题:Python Card类的具体用法?Python Card怎么用?Python Card使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Card类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: tag
def tag(req):
r = {
'err':'invalid'
}
tags = req.get_form_var('tags', '').strip()
if len(tags) > 0:
tags = tags.split()
else:
tags = []
if req.get_method() == "POST":
cate = req.get_form_var('cate', '')
card_id = req.get_form_var('cid', '')
#print 'j tags', card_id, tags
card = Card.get(card_id)
if card and req.user and tags:
card.tag(req.user.id, tags)
card = Card.get(card.id)
tmpl_func = 'card_tags'
if cate == 'small':
tmpl_func = 'small_card_tags'
r = {
'err':'ok',
'inner_html': stf('/card/utils.html', tmpl_func, card=card, req=req)
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:25,代码来源:__init__.py
示例2: get_taggers
def get_taggers(cls, uid, tag):
from webapp.models.card import Card
d = Card.get(uid)
t = cls.get_by_name(tag)
if t and d:
rs = store.execute("select tagger_id from me_user_tag where user_id=%s"
" and tag_id=%s", (d.id, t.id))
return [Card.get(str(r[0])) for r in rs]
return []
开发者ID:fordream,项目名称:me,代码行数:9,代码来源:tag.py
示例3: add_member
def add_member(self, req):
group = self.group
q = req.get_form_var('q', None)
if q and req.get_method() == 'POST':
card = Card.get(q)
if not card:
card = Card.get_by_ldap(q)
if card:
group.add_member(card.id, req.user.id)
return req.redirect(group.path)
开发者ID:fordream,项目名称:me,代码行数:10,代码来源:__init__.py
示例4: like
def like(req):
r = {
'err':'invalid'
}
if req.get_method() == "POST":
card_id = req.get_form_var('cid', '')
card = Card.get(card_id)
if card and req.user and not card.is_liked(req.user.id):
card.like(req.user.id)
card = Card.get(card.id)
r = {
'err':'ok',
'inner_html': stf("/card/card.html", "card_likers", card=card, req=req),
'like_num': card.like_num,
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:16,代码来源:__init__.py
示例5: add_photo_tag
def add_photo_tag(req):
r = { 'result':False }
photo_id = req.get_form_var('image_id', None)
photo = photo_id and EventPhoto.get(photo_id)
if photo and req.user:
left = req.get_form_var('left', None)
top = req.get_form_var('top', None)
width = req.get_form_var('width', None)
height = req.get_form_var('height', None)
name = req.get_form_var('name', None)
uid = req.get_form_var('name_id', None)
if name and not uid:
user_dict = get_users_dict()
uid = user_dict.get(name.cstrip().lower(), None)
if uid:
card = Card.get(uid)
if card:
tid = PhotoTag.new(photo_id, card.id, req.user.id, left, top, width, height)
tag = PhotoTag.get(tid)
if tag:
r = {
"result":True,
"tag": tag.json_dict(req.user)
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:25,代码来源:__init__.py
示例6: _q_lookup
def _q_lookup(req, id):
card = Card.get(id)
if card:
if card.is_hide:
return st('/misc/hide.html', **locals())
return CardUI(req, card)
return TraversalError("no such card")
开发者ID:fordream,项目名称:me,代码行数:7,代码来源:__init__.py
示例7: search
def search(self, req):
req.nav = '/'
q = req.get_form_var("q", None)
cards = []
if q:
cards = Card.search(q)
return st('/search.html', **locals())
开发者ID:leonsim,项目名称:me,代码行数:7,代码来源:__init__.py
示例8: gossip_result
def gossip_result(cls):
ret = {}
r = store.execute("select user_id from me_card where join_time > '2006-01-09'"
" and flag=%s order by join_time limit 1", Card.FLAG_NORMAL)
if r and r[0]:
ret['first_employee'] = Card.get(r[0][0])
r = store.execute("select user_id from me_card where user_id > 1000001"
" and flag=%s order by user_id limit 1", Card.FLAG_NORMAL)
if r and r[0]:
ret['first_register'] = Card.get(r[0][0])
r = store.execute("select user_id from (select user_id, count(user_id) as c from me_like"
" group by user_id) as s order by s.c desc limit 1")
if r and r[0]:
ret['likest_card'] = Card.get(r[0][0])
r = store.execute("select user_id from (select user_id, count(user_id) as c from me_question"
" group by user_id) as s order by s.c desc limit 1")
if r and r[0]:
ret['question_card'] = Card.get(r[0][0])
r = store.execute("select user_id from (select user_id, count(user_id) as c from me_comment"
" group by user_id) as s order by s.c desc limit 1")
if r and r[0]:
ret['commentest_card'] = Card.get(r[0][0])
r = store.execute("select user_id from (select user_id, count(tag_id) as c from me_user_tag"
" group by user_id) as s order by s.c desc limit 1")
if r and r[0]:
ret['taggest_card'] = Card.get(r[0][0])
rs = store.execute("select s.name, s.c from (select name, count(tag_id) as c from me_tag as t, me_user_tag as ut"
" where t.id=ut.tag_id group by t.id) as s order by s.c desc limit 5")
ret['hotest_tags'] = rs
r = store.execute("select user_id from (select user_id, count(user_id) as c from me_user_badage"
" group by user_id) as s order by s.c desc limit 1")
if r and r[0]:
ret['badagest_card'] = Card.get(r[0][0])
r = store.execute("select user_id, s.c from (select user_id, count(user_id) as c from me_notify"
" where ntype=%s group by user_id) as s order by s.c desc limit 1", Notify.TYPE_REQUEST_PHOTO)
if r and r[0]:
ret['most_request_photo_card'] = (Card.get(r[0][0]), r[0][1])
r = store.execute("select user_id, s.c from (select user_id, count(user_id) as c from me_notify"
" where ntype=%s group by user_id) as s order by s.c desc limit 1", Notify.TYPE_REQUEST_CHANGE_PHOTO)
if r and r[0]:
ret['most_request_change_photo_card'] = (Card.get(r[0][0]), r[0][1])
return ret
开发者ID:fordream,项目名称:me,代码行数:52,代码来源:dig.py
示例9: dig
def dig(self, req):
req.nav = '/dig'
basic_result = Dig.basic_result()
gossip_result = Dig.gossip_result()
hometowns = Dig.all_hometowns()
hot_tags = Tag.gets(count=3)
score_cards = Card.gets_by_score()
return st('/dig.html', **locals())
开发者ID:leonsim,项目名称:me,代码行数:8,代码来源:__init__.py
示例10: cardcase
def cardcase(self, req):
req.nav = '/cardcase'
start = req.get_form_var('start')
start = start and start.isdigit() and int(start) or 0
card = req.card
limit = DEVELOP_MODE and 2 or 16
total, cards = Card.gets_by_card(req.user.id, start, limit)
return st('/cardcase.html', **locals())
开发者ID:leonsim,项目名称:me,代码行数:8,代码来源:__init__.py
示例11: comment
def comment(req):
r = {
'err':'invalid'
}
if req.get_method() == "POST":
card_id = req.get_form_var('cid', '')
card = Card.get(card_id)
content = req.get_form_var('content', '').strip()
#print 'j comment', card_id, content
if card and req.user and content:
card.comment(req.user.id, content)
card = Card.get(card.id)
r = {
'err':'ok',
'html': stf("/card/card.html", "card_comments", card=card, req=req),
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:17,代码来源:__init__.py
示例12: ask
def ask(req):
r = {
'err':'invalid'
}
if req.get_method() == "POST":
card_id = req.get_form_var('cid', '')
card = Card.get(card_id)
content = req.get_form_var('content', '').strip()
anonymous = req.get_form_var('anonymous', None)
if card and req.user and content and req.user.id != card.id:
qid = Question.new(card.id, req.user.id, content, anonymous == '1')
card = Card.get(card.id)
r = {
'err':'ok',
'html': stf("/card/card.html", "card_answers", card=card, req=req),
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:17,代码来源:__init__.py
示例13: uncomment
def uncomment(req):
r = {
'err':'invalid'
}
if req.get_method() == "POST":
card_id = req.get_form_var('cid', '')
comment_id = req.get_form_var('comment_id', '')
card = Card.get(card_id)
#print 'j uncomment', comment_id
if req.user and card:
Comment.remove(req.user.id, comment_id)
card = Card.get(card.id)
r = {
'err':'ok',
'html': stf("/card/card.html", "card_comments", card=card, req=req),
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:17,代码来源:__init__.py
示例14: admin
def admin(self, req):
if req.user and req.user.id in ADMINS:
if req.get_method() == "POST":
hide_id = req.get_form_var("hide_id", "")
card = Card.get(hide_id)
if card:
Card.hide(card.id, req.user.id)
badage_id = req.get_form_var("badage_id", "")
badage_name = req.get_form_var("badage_name", "")
badage_intro = req.get_form_var("badage_intro", "")
badage_icon = req.get_form_var("badage_icon", "")
badage = None
if badage_id:
badage = Badage.get(badage_id)
if badage_name and badage_intro and badage_icon:
if badage:
badage.update(badage_name, badage_intro, badage_icon)
else:
Badage.new(badage_name, badage_intro, badage_icon)
badage_name = req.get_form_var("add_badage_name", "")
badage = Badage.get_by_name(badage_name)
if badage:
badage_user_ids = req.get_form_var("badage_user_ids", "").strip().split()
for u in badage_user_ids:
card = Card.get(u)
if card:
Badage.add(card.id, badage.id, req.user.id)
award_badage_name = req.get_form_var("award_badage_name", "")
award_sponsor = req.get_form_var("award_sponsor", "")
award_num = req.get_form_var("award_num", "")
award_vote_days = req.get_form_var("award_vote_days", "")
if award_badage_name and award_num and award_vote_days:
award_num = award_num.isdigit() and int(award_num) or 5
award_vote_days = award_vote_days.isdigit() and int(award_vote_days) or 7
Award.new(award_badage_name, award_sponsor, award_num, award_vote_days)
badages = Badage.gets()
awards = Award.gets()
q_card = req.get_form_var("q_card", "")
q_tag = req.get_form_var("q_tag", "")
if q_card and q_tag:
taggers = Tag.get_taggers(q_card, q_tag)
return st('/misc/admin.html', **locals())
raise AccessError("need admin")
开发者ID:leonsim,项目名称:me,代码行数:44,代码来源:__init__.py
示例15: names
def names(req):
q = req.get_form_var('term', None)
q = q.strip()
r = []
if q:
user_dict = get_users_dict()
ids = set([v for k, v in user_dict.iteritems() if k.startswith(q)])
for i in list(ids):
card = Card.get(i)
r.append({ "id": card.id, "label":card.screen_name , "value": card.uid})
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:11,代码来源:__init__.py
示例16: timeline
def timeline(self, req):
req.nav = '/timeline'
years = xrange(datetime.now().year - 1, 2005, -1)
now_year = str(datetime.now().year)
year = req.get_form_var("year", now_year)
start = req.get_form_var('start')
limit = req.get_form_var('count', 20)
start = start and str(start).isdigit() and int(start) or 0
limit = limit and str(limit).isdigit() and int(limit) or 0
n, cards = Card.gets_by_time(year, start, 200)
return st('/timeline.html', **locals())
开发者ID:leonsim,项目名称:me,代码行数:11,代码来源:__init__.py
示例17: girl_chart
def girl_chart(cls):
ids = {}
for d in Card.gets_by_tag('萌'):
ids[d.id] = 1
for d in Card.gets_by_tag('单身'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag('妹子'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag('萝莉'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag(''):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
rs = store.execute("select user_id from me_profile where flag=N and sex=2 and marriage in (1, 2, 12)")
for r in rs:
i = str(r[0])
n = ids.get(i, 0)
ids[i] = n + 2
love_cards = [Card.get(i) for i, n in ids.iteritems() if n > 1]
love_cards = [d for d in love_cards if ('汉子' not in ' '.join(d.ptag_names) and d.profile.sex != 1)]
love_cards = sorted(love_cards, key=attrgetter('score'), reverse=True)
return love_cards
开发者ID:fordream,项目名称:me,代码行数:25,代码来源:dig.py
示例18: boy_chart
def boy_chart(cls):
ids = {}
for d in Card.gets_by_tag('萌'):
ids[d.id] = 1
for d in Card.gets_by_tag('单身'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag('少年'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag('gay'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
for d in Card.gets_by_tag('娘'):
n = ids.get(d.id, 0)
ids[d.id] = n + 1
rs = store.execute("select user_id from me_profile where flag=N and sex=1 and marriage in (1, 2, 12)")
for r in rs:
i = str(r[0])
n = ids.get(i, 0)
ids[i] = n + 2
love_cards = [Card.get(i) for i, n in ids.iteritems() if n > 1]
love_cards = [d for d in love_cards if d.profile.sex != 2]
love_cards = sorted(love_cards, key=attrgetter('score'), reverse=True)
return love_cards
开发者ID:fordream,项目名称:me,代码行数:25,代码来源:dig.py
示例19: request_change_photo
def request_change_photo(req):
r = {
'err':'invalid'
}
if req.get_method() == "POST":
card_id = req.get_form_var('cid', '')
card = Card.get(card_id)
if card and req.user:
Notify.new(card.id, req.user.id, Notify.TYPE_REQUEST_CHANGE_PHOTO)
r = {
'err':'ok',
}
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:13,代码来源:__init__.py
示例20: read_notify
def read_notify(req):
r = {
'err':'ok'
}
if req.get_method() == "POST":
if req.user:
blog_id = req.get_form_var('bid', None)
if blog_id:
Notify.read_by_blog(req.user.id, blog_id)
else:
Notify.read_by_card(req.user.id)
card = Card.get(req.user.id)
r['num'] = card and card.notify_num or 0
return json.dumps(r)
开发者ID:fordream,项目名称:me,代码行数:14,代码来源:__init__.py
注:本文中的webapp.models.card.Card类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论