예제 #1
0
파일: views.py 프로젝트: sudo-dirk/pygal
def add_tag(item_name):
    item_name = encode(item_name)
    c = get_class_for_item(item_name)
    if c:
        tag_id = flask.request.args.get('tag_id')
        item = c(item_name)
        if item.exists() and type(item) is not itemlist:
            # TODO: Right management for tagging
            inp = collector(title='Add Tag: %s' % (item.name()), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang, tag_id=tag_id)
            rv = flask.render_template('header.html', input=inp)
            rv += flask.render_template('add_tag.html', input=inp)
            rv += flask.render_template('footer.html', input=inp)
            return rv
    flask.abort(404)
예제 #2
0
파일: views.py 프로젝트: sudo-dirk/pygal
def info(item_name):
    item_name = encode(item_name)
    if flask.request.args.get('q', None) is None:
        c = get_class_for_item(item_name)
    else:
        c = get_class_for_item(item_name, force_uncached=True, force_list=True)
    if c:
        item = c(item_name, flask.request.args)
        inp = collector(title='Info: %s' % item.name(), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang)
        rv = flask.render_template('header.html', input=inp)
        if item.exists():
            if item.user_may_view():
                rv += flask.render_template('info.html', input=inp)
            else:
                rv += lang.permission_denied
        rv += flask.render_template('footer.html', input=inp)
        return rv
    flask.abort(404)
예제 #3
0
파일: views.py 프로젝트: sudo-dirk/pygal
def delete(item_name):
    item_name = encode(item_name)
    c = get_class_for_item(item_name)
    if c:
        item = c(item_name, flask.request.args)
        if item.exists() and type(item) is not itemlist:
            inp = collector(title='Delete: %s' % (item.name()), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang)
            rv = flask.render_template('header.html', input=inp)
            if item.user_may_delete():
                if flask.request.method == 'GET':
                    rv += flask.render_template('delete.html', input=inp)
                elif flask.request.method == 'POST' and flask.request.form.get('delete_submit') == '1':
                        item.delete()
                        return flask.redirect(item.parent_url())
                else:
                    flask.abort(500)
            else:
                rv += lang.permission_denied
            rv += flask.render_template('footer.html', input=inp)
            return rv
    flask.abort(404)
예제 #4
0
파일: views.py 프로젝트: sudo-dirk/pygal
def item(item_name):
    item_name = encode(item_name)
    if flask.request.args.get('search_request', None) is None:
        c = get_class_for_item(item_name)
    else:
        c = get_class_for_item(item_name, force_uncached=True, force_list=True)
    if c:
        item = c(item_name, flask.request.args)
        #
        # Edit/ Add a tag if posted
        #
        if flask.request.method == 'POST' and flask.request.form.get('tag_submit') == '1':
            # TODO: Right management for tagging
            tag_id = flask.request.form.get('tag_id', None)
            action = flask.request.form.get('action')
            if action == 'Submit Tag':       # EDIT/ ADD
                x1 = int(flask.request.form.get('x1'))
                x2 = int(flask.request.form.get('x2'))
                y1 = int(flask.request.form.get('y1'))
                y2 = int(flask.request.form.get('y2'))
                tag_text = flask.request.form.get('tag_text')
                item.add_tag_wn_x1y1x2y2(x1, y1, x2, y2, tag_text, tag_id)
            elif action == 'Delete Tag':     # DELETE
                item.delete_tag(tag_id)
        #
        # Create Page
        #
        inp = collector(title=item.name(), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang)
        rv = flask.render_template('header.html', input=inp)
        if item.user_may_view():
            if item.exists():
                if item.user_may_view() or type(item) is itemlist:
                    rv += flask.render_template(item.template(), input=inp)
                else:
                    rv += lang.permission_denied
        rv += flask.render_template('footer.html', input=inp)
        return rv
    flask.abort(404)