Example #1
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)
Example #2
0
def get_local_notes(uuid=None, uid=None, active=None):
    query = dict()

    if uuid is not None:
        query['target'] = uuid
    if uid is not None:
        query['uid'] = uid
    if active is not None:
        query['active'] = active

    notes_data = Note.objects(**query)

    notes_response = []

    for note_data in notes_data:
        notes_response.append(construct_local_note_data(note_data))

    return notes_response
Example #3
0
def get_local_notes(uuid=None, uid=None, active=None):
    query = dict()

    if uuid is not None:
        query['target'] = uuid
    if uid is not None:
        query['uid'] = uid
    if active is not None:
        query['active'] = active

    notes_data = Note.objects(**query)

    notes_response = []

    for note_data in notes_data:
        notes_response.append(construct_local_note_data(note_data))

    return notes_response
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)
Example #5
0
    def post(self):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args

        issuer = request.api_user
        note = args.get("note")
        source = args.get("server")
        uuid = args.get("uuid")

        player = MinecraftPlayer.find_or_create_player(uuid)

        note = Note(issuer=issuer,
                    issuer_old=issuer.name,
                    target=player,
                    username=player.mcname,
                    note=note,
                    server=source).save()
        return {'note': construct_local_note_data(note)}