示例#1
0
def basedetails(request, nation_id, manager, pcheck, var):
    nation = request.user.nation
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    context = {'target': target}
    utils.pagecheck(nation, target, pcheck)
    query = getattr(target, manager).all().order_by('-pk')
    paginator, actionlist = utils.paginate_me(query, 50, page)
    context.update({
        'pages': utils.pagination(paginator, actionlist),
        var: actionlist,
    })
    return context
示例#2
0
def nation_logins(request, nation_id):
    nation = request.user.nation
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    context = {'target': target}
    page = (request.GET['page'] if 'page' in request.GET else 1)
    utils.pagecheck(nation, target, "all wars")
    query = target.login_times.all().order_by('-pk')
    paginator, actionlist = utils.paginate_me(query, 50, page)
    context.update({
        'pages': utils.pagination(paginator, actionlist),
        'logins': actionlist,
    })
    return details(request, nation_id, page, 'logins')
示例#3
0
def nation_allaid(request, nation_id):
    nation = request.user.nation
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    context = {'target': target}
    page = (request.GET['page'] if 'page' in request.GET else 1)
    utils.pagecheck(nation, target, "all aid")
    query = Aidlog.objects.filter(Q(sender=target)
                                  | Q(reciever=target)).order_by('-pk')
    paginator, actionlist = utils.paginate_me(query, 50, page)
    context.update({
        'pages': utils.pagination(paginator, actionlist),
        'aidlist': actionlist,
    })
    return render(request, 'mod/allaid.html', context)
示例#4
0
def nation_wars(request, nation_id):
    nation = request.user.nation
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    context = {'target': target}
    page = (request.GET['page'] if 'page' in request.GET else 1)
    utils.pagecheck(nation, target, "all wars")
    query = War.objects.filter(Q(attacker=target)
                               | Q(defender=target)).order_by('-pk')
    paginator, actionlist = utils.paginate_me(query, 50,
                                              request.GET.get('page', 1))
    context.update({
        'pages': utils.pagination(paginator, actionlist),
        'reports': actionlist,
    })
    return render(request, 'mod/wars.html', context)
示例#5
0
def nation_outgoing(request, nation_id):
    nation = request.user.nation
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    page = (request.GET['page'] if 'page' in request.GET else 1)
    context = {
        'target': target,
        'title': 'All outgoing aid',
        'direction': 'out'
    }
    utils.pagecheck(nation, target, "outgoing aid")
    query = target.outgoing_aid.all().order_by('-pk')
    paginator, actionlist = utils.paginate_me(query, 50, page)
    context.update({
        'pages': utils.pagination(paginator, actionlist),
        'aidlist': actionlist,
    })
    return render(request, 'mod/aid.html', context)
示例#6
0
文件: views.py 项目: argiepras/Coco
def nation_page(request, nation_id):
    nation = request.user.nation
    context = {}
    pagename = "overview"
    result = False
    target = utils.get_player(nation_id)
    if target == False:
        return render(request, 'mod/not_found.html')
    utils.pagecheck(nation, target, pagename)
    if request.method == "POST":
        form = reasonform(request.POST)
        if form.is_valid():
            if 'delete' in request.POST:
                delete_nation(target)
                nation.mod_actions.create(
                    action="Deleted %s" % target.name,
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = "%s has been deleted" % target.name

            elif 'reportban' in request.POST:
                delall = (True if 'killreports' in request.POST else False)
                report_ban(target, delall)
                nation.mod_actions.create(
                    action="Report banned %s" % target.name,
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = "%s has banned from reporting" % target.name

            elif 'ban' in request.POST:
                act = "Deleted and banned %s" % target.name
                delete_nation(target)
                ips = []
                if 'banall' in request.POST:
                    act += " and banned all associated IPs"
                    for ip in target.IPs.all():
                        if not Ban.objects.filter(IP=ip.IP).exists():
                            Ban.objects.create(IP=ip.IP)
                            ips.append(ip.IP)
                else:
                    latest = target.IPs.all().latest('pk')
                    if not Ban.objects.filter(IP=latest.IP).exists():
                        Ban.objects.create(IP=latest.IP)
                        ips.append(latest.IP)

                nation.mod_actions.create(
                    action=act,
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = act

            elif 'deletewar' in request.POST:
                result, otherguy = delete_war(request, target)
                nation.mod_actions.create(
                    action="Deleted war between %s and %s" %
                    (target.name, otherguy),
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = "War between %s and %s has been deleted" % (
                    target.name, otherguy)

            elif 'force' in request.POST:
                target.vacation = True
                target.save(update_fields=["vacation"])
                nation.mod_actions.create(
                    action="Placed %s into vacation mode" % target.name,
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = "%s has been placed into vacation mode" % target.name

            elif 'remove' in request.POST:
                target.vacation = False
                target.save(update_fields=["vacation"])
                nation.mod_actions.create(
                    action="Removed %s from vacation mode" % target.name,
                    reason=form.cleaned_data['reason'],
                    reversible=True,
                    reverse="not yet implemented",
                )
                result = "%s has been removed from vacation mode" % target.name

        else:
            result = 'invalid reason (did you forget it?)'

    #set a variable that determines whether mod can see sensitive data
    #like logs of pretty much everything
    can_see = True
    #nation.investigated.all().filter(reported=target).exists()

    if can_see:
        context.update({
            'warlogs':
            War.objects.filter(Q(attacker=target) | Q(defender=target))[0:10],
            'aids':
            Aidlog.objects.filter(Q(sender=target) | Q(reciever=target))[0:10],
            'actionlogs':
            target.actionlogs.all()[0:10],
            'login_times':
            target.login_times.all()[0:10],
            'associated_IPs':
            target.IPs.all(),
        })
    context.update({
        'result':
        result,
        'can_see':
        can_see,
        'reasonform':
        reasonform(),
        'target':
        target,
        'reports_made':
        Report.objects.filter(reporter=target),
        'reports_made_count':
        Report.objects.filter(reporter=target).count(),
        'reports_dismissed_count':
        Report.objects.filter(reporter=target, guilty=False).count(),
    })

    return render(request, 'mod/nation.html', context)