예제 #1
0
def show_edit(show):
    if 'begin' in request.form and \
                    'description' in request.form and \
                    'duration' in request.form and \
                    'title' in request.form:
        if int(request.form['duration']) < 30:
            return emit_error(6, 'Duration too short')
        if int(request.form['duration']) > 1440:
            return emit_error(5, 'Duration too long')
        if len(request.form['title']) < 3:
            return emit_error(4, 'Title too short')
        if len(request.form['description']) == 0:
            return emit_error(3, 'Description is empty')
        show = Show.query.get(show)
        if show is None:
            return emit_error(7, 'Whoop, invalid show!')
        if show.get_usershow(current_user) is None:
            return emit_error(8, 'Trying to edit another user\'s show, eh?!')
        begin = to_utc(datetime.fromtimestamp(int(request.form['begin'])))
        begin = begin.replace(second=0)
        if begin < now():
            return jsonify({'success': False, 'error': 'You cannot enter a past date!'})
        end = begin + timedelta(minutes=int(request.form['duration']))
        if Show.query.filter(Show.end > begin, Show.begin < end, Show.show != show.show).count() > 0:
            return emit_error(1, 'Your show collides with other shows')
        show.begin = begin
        show.end = end
        _set_show_info(show, request.form)
        rfk.database.session.commit()
    else:
        return emit_error(0, 'Wait a second, are you trying to trick me again?!')
    return jsonify({'success': True, 'data': None})
예제 #2
0
def show_delete(show):
    from rfk.site import app

    app.logger.warn('hnnngggg')
    show = Show.query.get(show)
    if show is None:
        return emit_error(7, 'Whoop, invalid show!')
    if show.get_usershow(current_user) is None:
        return emit_error(8, 'Trying to delete another user\'s show, eh?!')

    app.logger.warn(rfk.database.session.delete(show))

    rfk.database.session.commit()
    return jsonify({'success': True, 'data': None})
예제 #3
0
def show_delete(show):
    from rfk.site import app

    app.logger.warn('hnnngggg');
    show = Show.query.get(show)
    if show is None:
        return emit_error(7, 'Whoop, invalid show!')
    if show.get_usershow(current_user) is None:
        return emit_error(8, 'Trying to delete another user\'s show, eh?!')

    app.logger.warn(rfk.database.session.delete(show))

    rfk.database.session.commit()
    return jsonify({'success': True, 'data': None})
예제 #4
0
def show_edit(show):
    if 'begin' in request.form and \
                    'description' in request.form and \
                    'duration' in request.form and \
                    'title' in request.form:
        if int(request.form['duration']) < 30:
            return emit_error(6, 'Duration too short')
        if int(request.form['duration']) > 1440:
            return emit_error(5, 'Duration too long')
        if len(request.form['title']) < 3:
            return emit_error(4, 'Title too short')
        if len(request.form['description']) == 0:
            return emit_error(3, 'Description is empty')
        show = Show.query.get(show)
        if show is None:
            return emit_error(7, 'Whoop, invalid show!')
        if show.get_usershow(current_user) is None:
            return emit_error(8, 'Trying to edit another user\'s show, eh?!')
        begin = to_utc(get_timezone().localize(datetime.utcfromtimestamp(int(request.form['begin']))))
        begin = begin.replace(second=0)
        if begin < now():
            return jsonify({'success': False, 'error': 'You cannot enter a past date!'})
        end = begin + timedelta(minutes=int(request.form['duration']))
        if Show.query.filter(Show.end > begin, Show.begin < end, Show.show != show.show).count() > 0:
            return emit_error(1, 'Your show collides with other shows')
        show.begin = begin
        show.end = end
        _set_show_info(show, request.form)
        rfk.database.session.commit()
    else:
        return emit_error(0, 'Wait a second, are you trying to trick me again?!')
    return jsonify({'success': True, 'data': None})
예제 #5
0
파일: tags.py 프로젝트: keios/PyRfK
def save_tag(tag):
    tag = Tag.query.get(tag)
    if tag is None:
        return emit_error(1, 'Invalid Tag')
    tag.name = request.form['name']
    tag.description = request.form['description']
    tag.icon = request.form['icon']
    rfk.database.session.commit()
    return jsonify({'success': True, 'data': None})
예제 #6
0
파일: tags.py 프로젝트: keios/PyRfK
def save_tag(tag):
    tag = Tag.query.get(tag)
    if tag is None:
        return emit_error(1, "Invalid Tag")
    tag.name = request.form["name"]
    tag.description = request.form["description"]
    tag.icon = request.form["icon"]
    rfk.database.session.commit()
    return jsonify({"success": True, "data": None})
예제 #7
0
def save_tag(tag):
    tag = Tag.query.get(tag)
    if tag is None:
        return emit_error(1, 'Invalid Tag')
    tag.name = request.form['name']
    tag.description = request.form['description']
    tag.icon = request.form['icon']
    rfk.database.session.commit()
    return jsonify({'success': True, 'data': None})
예제 #8
0
def show_add():
    try:
        if 'begin' in request.form and \
                        'description' in request.form and \
                        'duration' in request.form and \
                        'title' in request.form:
            if int(request.form['duration']) < 30:
                return emit_error(6, 'Duration too short')
            if int(request.form['duration']) > 1440:
                return emit_error(5, 'Duration too long')
            if len(request.form['title']) < 3:
                return emit_error(4, 'Title too short')
            if len(request.form['description']) == 0:
                return emit_error(3, 'Description is empty')

            begin = to_utc(get_timezone().localize(
                datetime.utcfromtimestamp(int(request.form['begin']))))
            begin = begin.replace(second=0)
            end = begin + timedelta(minutes=int(request.form['duration']))
            if begin < now():
                return emit_error(2, 'You cannot enter a past date!')
            if Show.query.filter(Show.end > begin,
                                 Show.begin < end).count() > 0:
                return emit_error(1, 'Your show collides with other shows')
            show = Show(begin=begin,
                        end=end,
                        name=request.form['title'],
                        description=request.form['description'],
                        flags=Show.FLAGS.PLANNED)
            rfk.database.session.add(show)
            show.add_user(current_user)
            _set_show_info(show, request.form)
            rfk.database.session.commit()
            return jsonify({'success': True, 'data': None})
        else:
            return emit_error(
                0, 'Wait a second, are you trying to trick me again?!')
    except Exception as e:
        from rfk.site import app

        app.logger.error(e)
        return emit_error(0, 'something went horribly wrong')
예제 #9
0
def show_add():
    try:
        if 'begin' in request.form and \
                        'description' in request.form and \
                        'duration' in request.form and \
                        'title' in request.form:
            if int(request.form['duration']) < 30:
                return emit_error(6, 'Duration too short')
            if int(request.form['duration']) > 1440:
                return emit_error(5, 'Duration too long')
            if len(request.form['title']) < 3:
                return emit_error(4, 'Title too short')
            if len(request.form['description']) == 0:
                return emit_error(3, 'Description is empty')

            begin = to_utc(datetime.fromtimestamp(int(request.form['begin'])))
            begin = begin.replace(second=0)
            end = begin + timedelta(minutes=int(request.form['duration']))
            if begin < now():
                return emit_error(2, 'You cannot enter a past date!')
            if Show.query.filter(Show.end > begin, Show.begin < end).count() > 0:
                return emit_error(1, 'Your show collides with other shows')
            show = Show(begin=begin,
                        end=end,
                        name=request.form['title'],
                        description=request.form['description'],
                        flags=Show.FLAGS.PLANNED)
            rfk.database.session.add(show)
            show.add_user(current_user)
            _set_show_info(show, request.form)
            rfk.database.session.commit()
            return jsonify({'success': True, 'data': None})
        else:
            return emit_error(0, 'Wait a second, are you trying to trick me again?!')
    except Exception as e:
        from rfk.site import app

        app.logger.error(e)
        return emit_error(0, 'something went horribly wrong')
예제 #10
0
 def get_new_address():
     emit_error(1, 'Bitcoin is not available')
예제 #11
0
 def get_new_address():
     emit_error(1, 'Bitcoin is not available')
예제 #12
0
파일: site.py 프로젝트: alphabernd/PyRfK
def show_delete(show):
    show = Show.query.get(show)
    if show.get_usershow(current_user) is None:
        return emit_error(8, 'Trying to delete another user\'s show, eh?!' )
    show.delete()