Exemple #1
0
def journal_record_trans_to_display(r):
    _findex= make_findex(r.fid)
    findex = '''<a href="/FileDetail?fid=%s">%s</a>''' % (r.fid,_findex)
    u = users.get_user_by_uid(r.by_uid)
    if u.privilege == 5:
        by = 'admin'
    elif u.privilege == 2:
        by = 'officer'
    else:
        by = 'user'
    return Storage(
        findex = findex,
        by = by,
        **r
    )
Exemple #2
0
def file_record_trans_to_display(r,acts=[]):
    _findex = make_findex(r.fid)
    findex = '''<a href="/FileDetail?fid=%s">%s</a>''' % (r.fid,_findex)
    class_ = ""
    id_ = r.fid
    brief_p = r.get('brief_p')
    actions = ''
    for act in acts:
        if act in ['accept','reject','transfer']:
            actions += '<a class="btn btn-primary btn-xs btnact" \
            data-toggle="modal fade" data-target=".modal" \
            data-fid="%s" data-findex="%s" data-act="%s" \
            data-papertitle="%s">%s</a>' \
            % (r.fid,_findex,act,r.paper_title,act)
        elif act == 'download':
            actions += '''<a class="btn btn-primary btn-xs" \
            href="/download?name=%s" download="%s">Download</a>''' \
            % (r.savename,r.paper_title+'.'+r.ext)
        elif act == 'cancel':
            actions +=  '<a class="hidden btn btn-primary btn-xs btnact"\
            data-toggle="modal fade" data-target=".modal" \
            data-fid="%s" data-findex="%s" data-act="%s" \
            data-papertitle="%s">%s</a>' \
            % (r.fid,_findex,act,r.paper_title,act)
        elif act == 'modify':
            actions +=  '<a class="btn btn-primary btn-xs btnact"\
            data-toggle="modal fade" data-target=".modal" \
            data-fid="%s" data-findex="%s" data-act="%s" \
            data-papertitle="%s">%s</a>' \
            % (r.fid,_findex,act,r.paper_title,act)
    if len(actions)>0:
        actions = '''<div class="btn-group">%s</div>''' %(actions)
    if r.status == "new":
        class_ = "success"
    if r.status == "rejected":
        class_ = "danger"
    if brief_p == 1:
        _type = "Brief"
    elif brief_p == 0:
        _type = "Extended"
    else:
        _type = ""
    return Storage(findex = findex,
                   class_ = class_,
                   id_ = id_,
                   _type = _type,
                   actions = actions,
                   **r)
Exemple #3
0
 def add_child(e):
     if e.has_child_p:
         lines = e.content.split('\n')
         child =  []
         for line in lines:
             line = line.strip()
             if len(line)==0:
                 break
             name,title = line.split(':')
             if name.startswith("#"):
                 continue
             child.append(Storage(name=name,title=title))
         e.child = child
     else:
         e.child = []
     return e
Exemple #4
0
def test_pizza_PUT():
    input = Storage()
    input.pizza = 'capricciosa'
    input.drink = 'coca'
    assert '1' == pizza_PUT(input, 'employee1')
Exemple #5
0
def test_pizza_POST():
    input = Storage()
    input.pizza = 'margherita'
    input.drink = 'sprite'
    assert None is pizza_POST(input, 'employee1')
Exemple #6
0
def test_pizzas_GET():
    '[{"employee": "employee4", "drink": "chinotto", "pizza": "diavola"}, {"employee": "employee2", "drink": "coca", "pizza": "marinara"}, {"employee": "employee3", "drink": "fanta", "pizza": "prosciutto"}]' == pizzas_GET(
        Storage())
Exemple #7
0
def test_pizza_DELETE():
    assert '1' == pizza_DELETE(Storage(), 'employee1')
Exemple #8
0
def test_pizza_PUT():
    input = Storage()
    input.pizza = 'capricciosa'
    input.drink = 'coca'
    assert '1' == pizza_PUT(input, 'employee1')
Exemple #9
0
def test_pizza_POST():
    input = Storage()
    input.pizza = 'margherita'
    input.drink = 'sprite'
    assert None is pizza_POST(input, 'employee1')
Exemple #10
0
def test_pizza_GET():
    assert '[{"employee": "employee2", "drink": "coca", "pizza": "marinara"}]'\
           == pizza_GET(Storage(), 'employee2')
Exemple #11
0
def user_record_trans_to_display(r):
    return Storage(operations='<a href="%s">%s</a>' %
                   ('/cumt/UserDetail?uid=%d' % (r.get('uid')), 'Detail'),
                   **r)