本文整理汇总了Python中models.Activity.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.get_by_id方法的具体用法?Python Activity.get_by_id怎么用?Python Activity.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.get_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getActModel
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def getActModel(self):
aid, = self.urlcfg.analyze(self.request.path)
if (aid):
id = int(aid)
return Activity.get_by_id(id)
else:
return None
示例2: get_session_id_by_activity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def get_session_id_by_activity(activity_id):
"""
Get the session ID that this activity_id is a part of.
:param activity_id: ID of the activity_id.
:type activity_id: Integer
:returns: The project ID.
:rtype: Integer
"""
activity = Activity.get_by_id(activity_id)
return activity.session_id if activity else 0
示例3: update_activity_details
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def update_activity_details(aid):
logger.info('update_activity_details aid:%s' % str(aid))
activity = Activity.get_by_id(aid)
suggester_id = activity['suggester_id']
keens = activity['keens']
suggester = User.get_by_id(suggester_id)
keeners = User.get_by_ids_type(ids = [keen['user_id'] for keen in keens], extra_fields=['device_gcm_token', 'device_pns_token'])
message_store = [
'@' + suggester['first_name'] + ' ' + suggester['last_name'],
' has chucked a curve ball at ',
activity['keyword']
]
logger.info('update_activity_details aid:%s message:%s' % (str(aid), ''.join(message_store)))
title = 'Details of #' + activity.get('keyword') + ' with ' + suggester['first_name'] + ' ' + suggester['last_name']
message = 'was updated :'
if activity.get('when'):
message = message + ' ' + activity.get('when').strftime('%I:%M%p %b %d')
message = message + ' ' + activity.get('where')
pic_url = get_fb_profile_pic_link(suggester_id)
store_data = {
'uid' : suggester_id,
'aid' : str(aid),
'pic': pic_url
}
android_ids = []
apple_ids = []
badge_nums = []
for user in keeners:
#Don't send to suggester
if user['_id'] == suggester_id:
continue
android_ids.append(user.get('device_gcm_token'))
apple_ids.append(user.get('device_pns_token'))
badge_num = add_notification(user['_id'], settings.NOTIF_ACTIVITY_UPDATE, message_store, pic_url, store_data)
badge_nums.append(badge_num)
data = {
'type' : settings.NOTIF_ACTIVITY_UPDATE,
'title' : title,
'msg' : message,
'ticker' : '#' + activity.get('keyword') + ' details updated',
'aid' : aid,
}
logger.info('update_activity_details aid:%s keeners:%s' % (str(aid), str(keeners)))
if activity.get('keyword', '').lower() != settings.ACTIVITY_TEST_KEYWORD:
send(data, android_ids, apple_ids, badge_nums)
示例4: activity_invite
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def activity_invite(aid, uids):
activity = Activity.get_by_id(aid)
suggester_id = activity['suggester_id']
suggester = User.get_by_id(suggester_id, extra_fields=['gender'])
himher = 'him' if suggester.get('gender') == 'male' else 'female'
message = [
"@" + suggester.get('first_name') + ' ' + suggester.get('last_name'),
" is invited you to join " + himher + " for #" + activity.get('keyword') + ". Keen?"
]
pic_url = get_fb_profile_pic_link(suggester.get('_id'))
store_data = {
'uid' : suggester.get('_id'),
'firstName' : suggester.get('first_name'),
'lastName' : suggester.get('last_name'),
'network' : suggester.get('network'),
'pic' : pic_url
}
android_ids = []
apple_ids = []
badge_nums = []
for user_id in uids:
user = User.get_by_id(user_id, extra_fields=['device_gcm_token', 'device_pns_token', 'type'])
if user.get('type') == User.ACTIVE:
android_ids.append(user.get('device_gcm_token'))
apple_ids.append(user.get('device_pns_token'))
badge_num = add_notification(user.get('_id'), settings.NOTIF_ACTIVITY_INVITE, message, pic_url, store_data)
badge_nums.append(badge_num)
data = {
'type' : settings.NOTIF_ACTIVITY_INVITE,
'title' : suggester.get('first_name') + ' ' + suggester.get('last_name') + ' is wondering if',
'msg' : "you'd be keen for #" + activity.get('keyword'),
'ticker' : 'Activity invite',
'aid' : aid,
'uid' : suggester_id,
}
send(data, android_ids, apple_ids, badge_nums)
示例5: activities
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def activities(request):
# Function to get all activities and handle POST request to add or edit
# an activity
response_params = {}
response_params['activities'] = models.Activity.all()
response_params['activity_form'] = ActivityForm()
# If the form is submitted
if request.method == "POST":
tags = request.POST['tags'].split(',')
tag_ids = []
for tag in tags:
if tag.strip() != '':
t = models.Tag.get_or_insert(key_name=tag)
tag_ids.append(t.key())
name = request.POST['name']
price = int(request.POST['price'])
duration_min = timedelta(seconds=floatToSeconds(float(request.POST['duration_min'])))
duration_max = timedelta(seconds=floatToSeconds(float(request.POST['duration_max'])))
# If we got an activity id from the request, we do an update instead of an add
if 'activity-id' in request.POST:
logging.info('edit an existing activity')
activity = Activity.get_by_id(int(request.POST['activity-id']))
activity.name = name
activity.price = price
activity.duration_min = duration_min
activity.duration_max = duration_max
activity.tags = tag_ids
activity.put()
else:
activity = Activity(name=name,price=price,duration_min=duration_min,duration_max=duration_max,tags=tag_ids)
activity.put()
return render_to_response('activities.html', response_params)
示例6: intercom_event_nah_activity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def intercom_event_nah_activity(user_id, card_id):
logger.warning("intercom_event_nah_activity user_id:%s card_id:%s" % (user_id, card_id))
activity = Activity.get_by_id(card_id)
intercom.event_nah_activity(user_id, card_id, activity.get('text'))
示例7: activity_edit
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_id [as 别名]
def activity_edit(request, activity_id):
response_params = {}
response_params['activity'] = Activity.get_by_id(int(activity_id))
return render_to_response('activity-edit.html', response_params)