Ejemplo n.º 1
0
    def get(self):
        args = self.get_parser.parse_args()
        uuid = args.get("uuid")

        alts = []
        user_ips = PlayerIpsModel.objects(player=uuid).first()
        if user_ips:
            alt_objects = PlayerIpsModel.objects(ips__in=user_ips.ips, player__ne=uuid)
            for alt_object in alt_objects:
                alts.append({"player": {"name": alt_object.player.mcname, "uuid": alt_object.player.uuid}, "last_login": alt_object.last_login.strftime(datetime_format)})
        return {'alts': alts}
Ejemplo n.º 2
0
def view_ban(ban_uid):

    ban = Ban.objects(uid=ban_uid).first()
    if ban is None:
        abort(404)

    appeal = ban.appeal

    if ban.appeal.state == 'closed_time':
        if ban.appeal.unlock_time and ban.appeal.unlock_time < datetime.datetime.utcnow(
        ):
            ban.appeal.state = 'open'
            ban.save()

    replies = AppealReply.objects(ban=ban).order_by('+created')
    notes = Note.objects(target=ban.target, active=True)

    can_post = user_can_post(current_user, ban)

    alts = []
    if current_user.can("view alts"):
        user_ips = PlayerIpsModel.objects(player=ban.target).first()
        if user_ips:
            alts = PlayerIpsModel.objects(ips__in=user_ips.ips,
                                          player__ne=ban.target)

    unlock_time_form = AppealUnlockTimeForm()
    if appeal.unlock_time:
        unlock_time_form.date.data = appeal.unlock_time
    unban_time_form = BanUnbanTimeForm()
    if ban.removed_time:
        unban_time_form.date.data = ban.removed_time

    js_state_manager.get_manager().update(
        {'ban': {
            'watching': current_user in ban.watching,
            'id': ban.uid
        }})

    return render_template('bans_unified_view.html',
                           ban_id=ban_uid,
                           ban_object=ban,
                           appeal_object=appeal,
                           notes=notes,
                           reply_form=AppealReplyForm(),
                           edit_form=BanReasonEditForm(),
                           reply_edit_form=AppealReplyTextEditForm(),
                           unlock_time_form=unlock_time_form,
                           unban_time_form=unban_time_form,
                           replies=replies,
                           can_post=can_post,
                           alts=alts)
Ejemplo n.º 3
0
    def get(self):
        args = self.get_parser.parse_args()
        uuid = args.get("uuid")

        alts = []
        user_ips = PlayerIpsModel.objects(player=uuid).first()
        if user_ips:
            alt_objects = PlayerIpsModel.objects(ips__in=user_ips.ips,
                                                 player__ne=uuid)
            for alt_object in alt_objects:
                alts.append({
                    "player": {
                        "name": alt_object.player.mcname,
                        "uuid": alt_object.player.uuid
                    },
                    "last_login":
                    alt_object.last_login.strftime(datetime_format)
                })
        return {'alts': alts}
Ejemplo n.º 4
0
def view_ban(ban_uid):

    ban = Ban.objects(uid=ban_uid).first()
    if ban is None:
        abort(404)

    appeal = ban.appeal

    if ban.appeal.state == 'closed_time':
        if ban.appeal.unlock_time and ban.appeal.unlock_time < datetime.datetime.utcnow():
            ban.appeal.state = 'open'
            ban.save()

    replies = AppealReply.objects(ban=ban).order_by('+created')
    notes = Note.objects(target=ban.target, active=True)

    can_post = user_can_post(current_user, ban)

    alts = []
    if current_user.can("view alts"):
        user_ips = PlayerIpsModel.objects(player=ban.target).first()
        if user_ips:
            alts = PlayerIpsModel.objects(ips__in=user_ips.ips, player__ne=ban.target)

    unlock_time_form = AppealUnlockTimeForm()
    if appeal.unlock_time:
        unlock_time_form.date.data = appeal.unlock_time
    unban_time_form = BanUnbanTimeForm()
    if ban.removed_time:
        unban_time_form.date.data = ban.removed_time

    js_state_manager.get_manager().update({
        'ban': {
            'watching': current_user in ban.watching,
            'id': ban.uid
        }
    })

    return render_template('bans_unified_view.html', ban_id=ban_uid, ban_object=ban, appeal_object=appeal, notes=notes,
                           reply_form=AppealReplyForm(), edit_form=BanReasonEditForm(), reply_edit_form=AppealReplyTextEditForm(),
                           unlock_time_form=unlock_time_form, unban_time_form=unban_time_form, replies=replies,
                           can_post=can_post, alts=alts)
Ejemplo n.º 5
0
    def post(self):
        args = self.post_parser.parse_args()
        uuid = args.get("uuid")
        player = MinecraftPlayer.find_or_create_player(uuid)

        if not verify_ip_address(args["ip"].decode("ascii")):
            return {'error': [{"message": "ip is not valid"}]}
        ip = args["ip"]

        player_ips = PlayerIpsModel.objects(player=player).first()
        if not player_ips:
            player_ips = PlayerIpsModel(player=player, ips=[ip])
            player_ips.save()
        player_ips.update_last_login_and_add_entry(ip)

        ip_players = IpPlayersModel.objects(ip=ip).first()
        if not ip_players:
            ip_players = IpPlayersModel(ip=ip, players=[player])
            ip_players.save()
        ip_players.update_last_login_and_add_entry(player)

        return {"success": True}
Ejemplo n.º 6
0
    def post(self):
        args = self.post_parser.parse_args()
        uuid = args.get("uuid")
        player = MinecraftPlayer.find_or_create_player(uuid)

        if not verify_ip_address(args["ip"].decode("ascii")):
            return {'error': [{"message": "ip is not valid"}]}
        ip = args["ip"]

        player_ips = PlayerIpsModel.objects(player=player).first()
        if not player_ips:
            player_ips = PlayerIpsModel(player=player, ips=[ip])
            player_ips.save()
        player_ips.update_last_login_and_add_entry(ip)

        ip_players = IpPlayersModel.objects(ip=ip).first()
        if not ip_players:
            ip_players = IpPlayersModel(ip=ip, players=[player])
            ip_players.save()
        ip_players.update_last_login_and_add_entry(player)

        return {"success": True}