本文整理汇总了Python中models.Server.get_report_days方法的典型用法代码示例。如果您正苦于以下问题:Python Server.get_report_days方法的具体用法?Python Server.get_report_days怎么用?Python Server.get_report_days使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Server
的用法示例。
在下文中一共展示了Server.get_report_days方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import get_report_days [as 别名]
def profile(request):
host = get_server_host()
port = request.get_port()
user = request.user
if not user.is_superuser:
print "ERROR"
return HttpResponseRedirect('/account/logout/')
page_num = request.GET.get('page_num', 1)
page_num = int(page_num)
page_size = 6
offset = page_size * (page_num - 1)
server = Server.objects.filter(user_id=user.id).first()
host = host + ':' + port
server.host = host
if not server.work:
server_init()
server.work = 1
server.save()
count = Room.objects.filter(host=server.host).count()
page_count = (count + page_size - 1)/ page_size
if page_count < 1:
page_count = 1
if offset > count:
offset = count
if offset + page_size > count:
page_size = count - offset
rooms = Room.objects.filter(host=server.host)[offset:(offset+page_size)]
data = []
for room in rooms:
is_service = u'服务中'
is_link = u'已连接'
if not room.service:
is_service = u'未服务'
if not room.link:
is_link = u'连接已断开'
room_mode = MODE_DICT[MODE[Server.get_attr('mode')]]
room_speed = SPEED_DICT[SPEED[room.speed]]
data.append({
'id': room.id,
'is_link': is_link,
'numbers':room.numbers,
'ip_address': room.ip_address,
'service': is_service,
'mode': room_mode,
'speed': room_speed,
'power': CostPerDay.get_power(room.id, back=Server.get_report_days()),
'room_temperature': room.room_temperature,
'setting_temperature': room.setting_temperature,
'total_cost': CostPerDay.get_cost(room.id, back=Server.get_report_days()),
'rest_cost': room.total_cost,
})
return render(request, 'center.html', {'list': data, 'page_num':page_num, 'page_count':
page_count, 'user':user, 'host': host, 'report': Server.get_report_name(), 'mode':
MODE_DICT[MODE[server.mode]]})