예제 #1
0
파일: app.py 프로젝트: ragefire87/Week-12
def deleteentry():
    if request.method == "POST":
        counter = request.form["id"]
        model.delete_entry(counter)
    else:
        model.get_entries()
    return redirect("/admin")
예제 #2
0
 def GET(self):
     '''show info'''
     entries = model.get_entries()
     if isactived_resource():
         status = True
     else:
         status = False
     entries = model.get_entries()
     return render_ori.index(entries, status)
예제 #3
0
class opsapi:

    def GET(self):
        ''' This func is used to return server configurations from db '''
        try:
            data = web.input()
        except AttributeError, e:
            return None
        if data.getinfo == 'all':
            rst = model.get_allentries()
        elif data.getinfo == 'vhost':
            rst = model.get_entries(type='vhost')
        elif data.getinfo == 'host':
            rst = model.get_entries(type='host')
        else:
            return None
        return render_ori.rawdata(rst,None)
예제 #4
0
def quick_search(keyword, CASEIGNORE=True):
    ''' This fuction is used to fetch id number with keyword'''
    ids = []

    if CASEIGNORE:
        kw = ignore_rec(keyword)
    else:
        kw = re.compile(keyword)

    data = model.get_entries()

    for i in data:
        for item in i.itervalues():
            item = str(item)
            result = re.search(kw, item)

            if result:
                if i.id not in ids:
                    ids.append(i.id)
            #list(set(ids)) # simple way to uniq elments in the id list.
    return ids
예제 #5
0
def advance_search(kw, mode=0):
    # Advance mode for filtering record
    '''
        mode = 0 means exact matching , keyword must exact match in the string
        mode = 1 means Ambiguous , just only matched the string will be returned.
        mode = 2 means Invert-matching.
    '''
    ids = []
    data = model.get_entries()

    for i in data:
        # Load data and convert into string.
        string = " ".join([str(item) for item in i.itervalues()])

        # Print string
        for k in kw.keys():
            kw[k] = _filter(k, string)

        if mode == 0:
            # Exact matching
            if False in kw.values():
                #print kw,i.hostname
                continue
            else:
                #if i.id not in ids:
                #                print i.hostname
                #                print kw,i.hostname
                ids.append(i.id)

        elif mode == 1:
            # Ambiguous matching
            if True in kw.values():
                ids.append(i.id)

        elif mode == 2:
            # Invert matching
            if False in kw.values():
                ids.append(i.id)
    return ids
예제 #6
0
def view():
    return render_template("view.html",
                           entries=model.get_entries(),
                           title=model.get_title())
예제 #7
0
 def GET(self):
     entries = model.get_entries()
     status = isactived_resource()
     return render.index(entries, status)
예제 #8
0
def search_restaurant():
    return render_template('search.html', entries=model.get_entries())
예제 #9
0
파일: app.py 프로젝트: miscalculation/HW12
def editentry():
    i = request.form["id"]
    return render_template("edit.html", id=i, entries=model.get_entries() )
예제 #10
0
def admin():
    return render_template("admin.html", entries=model.get_entries())
예제 #11
0
def delete():
    delete_id = request.form["id"]
    model.delete_entry(delete_id)
    return render_template("admin.html", entries=model.get_entries())
def index():
    ## print the guestbook
    return render_template(
        "admin.html",
        entries=model.get_entries())  #new template "admin.html"--hw14 part1
def admin():
    #model.delete_instance()
    return render_template("admin.html", entries=model.get_entries())
예제 #14
0
 def GET(self):
     web.header('Content-type', 'text/json') 
     d = model.get_entries()
     return json.dumps(d)
예제 #15
0
def admin():
    ## print the guestbook
    return render_template("admin.html", entries=model.get_entries())
예제 #16
0
def admin():
    # print("hello")
    return render_template("admin.html", entries=model.get_entries())
예제 #17
0
파일: app.py 프로젝트: ragefire87/Week-12
def admin():
    model.init()
    ## add a guestbook entry
    return render_template("admin.html", entries=model.get_entries())
예제 #18
0
def index():
    return render_template("index.html", entries=model.get_entries())
예제 #19
0
def administrator():
    ## edit posts
    return render_template("admin.html", entries=model.get_entries())
예제 #20
0
def postentry():
    name = request.form["name"]
    message = request.form["message"]
    model.add_entry(name, message)
    return render_template("admin.html", entries=model.get_entries())
예제 #21
0
def index():
    ## print the guestbook
    return render_template("index.html", entries=model.get_entries())
def admin():
    ## print the guestbook and allow for the admin to delete entries
    return render_template("admin.html", entries=model.get_entries())