示例#1
0
def show_task_ajax(rdb, user_id, event_id, task_id):
    logged_in = account.isLoggedIn()
    if logged_in:
        #todo: make sure user has access to this event
        
        #get task info        
        task_info = rdb.hgetall('task:' + str(user_id) + ':' + str(event_id) + ':' + str(task_id))
        task_info['strtstatus'] = constants.getStatusStrFromInt(task_info['tstatus'])
        #get items for this task
        items = []
        for i in rdb.smembers('itemids:' + str(user_id) + ':' + str(event_id) + ':' + str(task_id)):
            item_info = rdb.hgetall('item:' + str(user_id) + ':' + str(event_id) + ':' + str(task_id) + ':' + str(i))
            item = (i,
                    item_info['iname'],
                    item_info['icost'],
                    item_info['inotes'],
                    constants.getStatusStrFromInt(item_info['istatus']) )
            items.insert(0, item)
            print item
        task_info['items'] = items

        permission = account.accountHasAdmin(rdb, user_id, event_id)
        return template('taskajax.tpl', get_url=url, logged_in=logged_in,
                                        tinfo=task_info, uid=user_id,
                                        eid=event_id, tid = task_id,
                                        perms=permission)
示例#2
0
def show_event(rdb, user_id, event_id):
    
    logged_in = account.isLoggedIn()
    if logged_in:
        #get event info
        event_info = rdb.hgetall('event:' + str(user_id) + ':' + str(event_id))
        
        #add string versions of constants
        event_info['strestatus'] = constants.getEventTypeStrFromInt(event_info['estatus'])
        event_info['stretype'] = constants.getStatusStrFromInt(event_info['etype'])
        event_info['user_id'] = user_id
        event_info['event_id'] = event_id
        
        #get tasks for this event
        tasks = []
        for i in rdb.smembers('taskids:'+ str(user_id) + ':' + str(event_id)):
            #get task
            task_info = rdb.hgetall('task:' + str(user_id) + ':' + str(event_id) + ':' + str(i))
            print task_info
            t = (   i,
                 task_info['tname'],
                 task_info['tinfo'],
                 task_info['tcost'],
                 constants.getStatusStrFromInt(task_info['tstatus']),
                 task_info['numitems'],
                 [])
            #get items for each task
            for j in rdb.smembers('itemids' + str(user_id) + ':' + str(event_id) + str(i)):
                #get task
                item_info = rdb.hgetall('item:' + str(user_id) + ':' + str(event_id) + ':' + str(i) + ':' + str(j))
                item = (j,
                        item_info['iname'],
                        item_info['icost'],
                        item_info['inotes'],
                        constants.getStatusStrFromInt(item_info['istatus']) )
                t[6].insert(0, item)
            
            tasks.insert(0,t)
            #return info to template
        event_info['tasks'] = tasks

        permission = account.accountHasAdmin(rdb, user_id, event_id)
        print permission
        return template('event.tpl', get_url=url, logged_in=logged_in,
                                     row=event_info, uid=user_id,
                                     perms=permission, eid=event_id)
    
    else:
        redirect('/userhome')