()
Manage Admin Messages
Manage Admin Messages
Manage Admin Messages
def admin_msgs():
    """ Manage Admin Messages """
    req = request.vars
    view_info = {}
    view_info['errors'] = []
    tot_del = 0
    if req.form_submitted:
        if req.read_b:
            for item in req:
                if item[:7] == 'msg_id_':
                    msg_id = int(req[item])
                    db(db.zf_admin_messages.id==msg_id).update(read_flag=True)
                    tot_del += 1
            messages = db(db.zf_admin_messages.read_flag==False).select(db.zf_admin_messages.ALL, orderby=~db.zf_admin_messages.creation_date)
            view_info.update({'removed': tot_del})
        elif req.purge_b:
            db(db.zf_admin_messages.read_flag == True).delete()
            messages = db(db.zf_admin_messages.read_flag==False).select(db.zf_admin_messages.ALL, orderby=~db.zf_admin_messages.creation_date)
        view_info['purge'] = db(db.zf_admin_messages.read_flag == True).count()
        return dict(request=request, messages=messages, view_info=view_info)
    else:
        view_info['purge'] = db(db.zf_admin_messages.read_flag == True).count()
        messages = db(db.zf_admin_messages.read_flag==False).select(db.zf_admin_messages.ALL, orderby=~db.zf_admin_messages.creation_date)
        return dict(request=request, messages=messages, view_info=view_info)
def admin_msgs ( ) : req = request . vars view_info = { } view_info [ 'errors' ] = [ ] tot_del = 0 if req . form_submitted : if req . read_b : for item in req : if item [ : 7 ] == 'msg_id_' : msg_id = int ( req [ item ] ) db ( db . zf_admin_messages . id == msg_id ) . update ( read_flag = True ) tot_del += 1 messages = db ( db . zf_admin_messages . read_flag == False ) . select ( db . zf_admin_messages . ALL , orderby = ~ db . zf_admin_messages . creation_date ) view_info . update ( { 'removed' : tot_del } ) elif req . purge_b : db ( db . zf_admin_messages . read_flag == True ) . delete ( ) messages = db ( db . zf_admin_messages . read_flag == False ) . select ( db . zf_admin_messages . ALL , orderby = ~ db . zf_admin_messages . creation_date ) view_info [ 'purge' ] = db ( db . zf_admin_messages . read_flag == True ) . count ( ) return dict ( request = request , messages = messages , view_info = view_info ) else : view_info [ 'purge' ] = db ( db . zf_admin_messages . read_flag == True ) . count ( ) messages = db ( db . zf_admin_messages . read_flag == False ) . select ( db . zf_admin_messages . ALL , orderby = ~ db . zf_admin_messages . creation_date ) return dict ( request = request , messages = messages , view_info = view_info )