コード例 #1
0
def showBansPage(request):
    current_user = request.user
    is_authenticated = request.user.is_authenticated()
    is_op = request.user.groups.filter(name='ops').exists()
    if not is_op:
        return redirect('stats_home')
    bansList = models.get_list_of_bans()
    return render(request, 'stats/bans.html', locals())
コード例 #2
0
def apiBansIndex(request):
    bansList = models.get_list_of_bans()
    viewList = []
    for ban in bansList:
        banObject = {}
        banObject['user'] = ban.user_name
        banObject['banmask'] = ban.banmask
        banObject['banned_by'] = ban.banned_by
        banObject['timestamp'] = ban.timestamp.__str__()
        banObject['ban_length'] = ban.ban_length
        banObject['last_modified'] = ban.last_modified
        # print(ban.ban_length is None)
        if ban.unban_date is None:
            banObject['unban_date'] = None
        else:
            banObject['unban_date'] = ban.unban_date.strftime("%Y-%m-%d")
        banObject['id'] = ban.id
        banObject['reason'] = ban.reason
        viewList.append(banObject)


    return HttpResponse(json.dumps(viewList), content_type="application/json")