本文整理汇总了Python中models.Log.group方法的典型用法代码示例。如果您正苦于以下问题:Python Log.group方法的具体用法?Python Log.group怎么用?Python Log.group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Log
的用法示例。
在下文中一共展示了Log.group方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: click_mine_interact
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import group [as 别名]
def click_mine_interact(request):
# data_dict = {}
user = request.user;
userProfile = UserProfile.objects.get(user= user)
mine_index = request.POST.get('mine_index')
mine_index = int(mine_index)
panel_id = request.POST.get('panel_id')
panel_id = int(panel_id)
panel = Panel.objects.get(pk = panel_id)
progress = panel.progress
progress = progress[0:mine_index] + '1' + progress[mine_index+1:]
panel.progress = progress
panel.save()
rows = panel.game.columns
log = Log()
log.game = panel.game
log.group = panel.group
log.panel = panel
log.action = '\"Click (%d, %d)\"' % (mine_index/rows, mine_index % rows)
log.action_time = datetime.now()
log.user_profile = userProfile
log.save()
response_data={}
game = panel.game
response_data['rowses'] = game.rows
response_data['columns'] = game.columns
response_data['progress'] = panel.progress
response_data['wait_time'] = game.wait_time
return HttpResponse(json.dumps(response_data), mimetype="application/json")
示例2: switch_view
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import group [as 别名]
def switch_view(request, panel_id):
data_dict = {}
user = request.user;
userProfile = UserProfile.objects.get(user= user)
panel_id = int(panel_id)
panel = Panel.objects.get(pk = panel_id)
session_id = panel.session
group_id = panel.group.id
group_name = panel.group.name
panel_name = panel.name
game = panel.game
count = 0
for tmp in panel.progress:
if tmp == '1':
count += 1
cost = utils.cost(game.switch_cost)
if count < cost:
#cannot switch
log = Log()
log.game = game
log.group = panel.group
log.panel = panel
log.user_profile = userProfile
log.action = '\"Switch failed, Not enough credit\"'
log.action_time = datetime.now()
log.save()
data_dict['panel_id'] = panel_id
nextUrl = reverse('mine.views.mine_field_view', args=(panel_id,))
return HttpResponseRedirect(nextUrl)
else:
log = Log()
log.game = game
log.group = panel.group
log.panel = panel
log.user_profile = userProfile
log.action = '\"Go to Switch page, cost %s\"' % cost
log.action_time = datetime.now()
log.save()
#cost
index = 0
for s in panel.progress:
if cost == 0:
break
if s == '1':
cost -= 1
index += 1
panel.progress = '0'*(index+1) + panel.progress[index+1:]
panel.save()
panels = Panel.objects.filter(group__id = group_id, session = session_id)
panel_id_status_dict={}
for panel in panels:
progress = panel.progress
count = 0
for s in progress:
if s == '1':
count +=1
panel_id_status_dict[panel.id] = {'current': count, 'total': len(progress), 'panel_name': panel.name}
panel_id_status_json = json.dumps(panel_id_status_dict)
data_dict['panel_id_status_json'] = panel_id_status_json
data_dict['panel_id'] = panel_id
data_dict['group_name'] = group_name
data_dict['panel_name'] = panel_name
return render(request, 'switch.html', data_dict)