예제 #1
0
파일: cot.py 프로젝트: shish/commentonthis
    def DELETE(self, id):
        comment = model.get_comment(id)
        if comment:
            if session.user.name != "Anonymous" and (comment.item_user == session.user.name or comment.user_name == session.user.name):
                model.del_comment(id)
                flash("success", "Comment deleted")
            else:
                flash("error", "Permission denied")
        else:
            flash("error", "Comment not found")

        referer = web.ctx.env.get('HTTP_REFERER', 'http://www.commentonthis.net/')
        raise web.seeother(referer)
예제 #2
0
파일: cot.py 프로젝트: shish/commentonthis
 def GET(self, id=None):
     if id:
         comment = model.get_comment(id)
         return render.comment_list([comment], form)
     else:
         inp = web.input(item_host=None, item_path=None, item_name=None)
         related_pages = []
         related_items = []
         if inp.item_host and inp.item_path and inp.item_name:
             related_pages = model.db.select('cot_comment',
                 what="DISTINCT item_path AS page",
                 where="(item_host=$item_host)",
                 order="item_path",
                 limit=20,
                 vars={'item_host': inp.item_host}
             )
             related_items = model.db.select('cot_comment',
                 what="DISTINCT item_name AS item",
                 where="(item_host=$item_host) AND (item_path=$item_path)",
                 order="item_name",
                 limit=20,
                 vars={'item_host': inp.item_host, 'item_path': inp.item_path}
             )
         elif inp.item_host and inp.item_path:
             related_pages = model.db.select('cot_comment',
                 what="DISTINCT item_path AS page",
                 where="(item_host=$item_host)",
                 order="item_path",
                 limit=20,
                 vars={'item_host': inp.item_host}
             )
             related_items = model.db.select('cot_comment',
                 what="DISTINCT item_name AS item",
                 where="(item_host=$item_host) AND (item_path=$item_path)",
                 order="item_name",
                 limit=20,
                 vars={'item_host': inp.item_host, 'item_path': inp.item_path}
             )
         comments = model.get_comments(session.user.name, item_host=inp.item_host, item_path=inp.item_path, item_name=inp.item_name)
         return render.comment_list(comments, inp, related_pages, related_items)
예제 #3
0
파일: auth.py 프로젝트: aulicksah/Streamz
 def POST(self):
         data=web.data()
         vid=json.loads(data)['videoid']
         s=model.get_comment(vid)
         return s
예제 #4
0
def ajax():
    # Utility entry point for various functions that are triggered by the javascript.
    action = request.args['action']
    log_access('ajax', 'query' + request.query_string)

    # AutoSaveForm is used to recover any edits on the calls when users browser closes for an unintended reason.
    if action == 'setautosaveform':
        model.set_autosave_form(request.args['key'], json.dumps(request.form))

    elif action == 'getautosaveform':
        return model.get_autosave_form(request.args['key'])

    elif action == 'deleteautosaveform':
        model.delete_autosave_form(request.args['key'])

    # Templates are quick text blobs used for editing the calls.
    elif action == 'gettemplatelist':
        return json.dumps(model.get_template_list())

    elif action == 'addtemplate':
        id = model.add_template(request.form)
        return json.dumps(model.get_template(id))

    elif action == 'settemplate':
        model.set_template(request.form)
        return json.dumps(model.get_template(request.form['id']))

    elif action == 'deletetemplate':
        model.delete_template(request.form['id'])

    elif action == 'startemplate':
        return json.dumps(model.star_template(request.form['id']))

    elif action == 'getresidentsstarredtemplates':
        return json.dumps(model.get_residents_starred_templates())

    # Commenting related functions
    elif action == 'addcomment':
        model.add_comment(request.args['key'], request.form['comment'])
        return json.dumps(model.get_comments(request.args['key']))

    elif action == 'deletecomment':
        id = request.args['comment_id']
        comment = model.get_comment(id)
        if session['user_auth_level'] >= 10000 or comment['username'] == session['user_username']: # administrator
            model.delete_comment(id)

    elif action == 'savecomment':
        id = request.args['comment_id']
        comment = model.get_comment(id)
        if session['user_auth_level'] >= 10000 or comment['username'] == session['user_username']: # administrator
            model.edit_comment(id, request.form['comment'])

    elif action == 'getcomments':
        call_id = request.args['key']
        comments = model.get_comments(call_id)
        for comment in comments:
            comment['blob'] = text_process(comment['blob'])
        return json.dumps(comments)

    # Deletes a call record.
    elif action == 'deletecalllog':
        key = request.args['key']
        if session['user_auth_level'] >= 10000 \
                or (model.is_call_log_owner(session['user_id'], key) and model.get_call_log(key)['created'] >= datetime.today() - timedelta(days=config.DISABLE_EDIT_AGE)): #  administrator
            model.delete_call_log(key)

    # Returns calls of a specific patient by the patients hospital number.
    elif action == 'searchforpatientnumber':
        key = request.args['key']
        key = key.strip()
        return json.dumps(model.get_calls_by_patient_number(key))

    # Tag related
    elif action == 'deletetag':
        model.delete_tag(request.args['tag'])

    elif action == 'saveTagChange':
        model.save_tag_change_for_call(int(request.args['id']), request.args['tag'], int(request.args['added']))

    # Liking a call, currently there is no limit on how many times you can like a record.
    elif action == 'like':
        key = int(request.args['id'])
        model.like_call_log(key)
        call = model.get_call_log(key)
        return str(call['liked'])

    # Flags a record
    elif action == 'flag':
        key = int(request.args['id'])
        flag = int(request.args['flag'])
        flag_state = model.get_flag(request.args['id'])
        if flag_state == flag:
            model.delete_flag(request.args['id'])
        else:
            model.set_flag(key, flag)

        return str(model.get_flag(request.args['id']))

    return '1'
예제 #5
0
파일: blog.py 프로젝트: qq40660/weixin-1
 def GET(self, id):
     post_content = model.get_content(int(id))
     post_comments = model.get_comment(int(id))
     return render.view(post_content, post_comments)