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)
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')
def post_edit_item(rdb, user_id, event_id, task_id, item_id): #ensure user is logged in logged_in = account.isLoggedIn() if not logged_in: return redirect('/login') #ensure user has access to change this event if not account.accountHasAdmin(rdb, user_id, event_id): abort(401, "Sorry, access is denied!") result = item.edit_item(rdb, user_id, event_id, task_id, item_id) if result: redirect('/task/%s/%s/%s' % result) else: abort(400, "Error submiting your changes")
def show_edit_item(rdb, user_id, event_id, task_id, item_id): #ensure user is logged in logged_in = account.isLoggedIn() if not logged_in: return redirect('/login') #ensure user has access to change this event if not account.accountHasAdmin(rdb, user_id, event_id): abort(401, "Sorry, access is denied!") #get event details to feed to template item_info = rdb.hgetall('item:' + str(user_id) + ':' + str(event_id) + ':' + str(task_id) + ':' + str(item_id)) if item_info: return template('edititem.tpl', get_url=url, logged_in=logged_in, iinfo=item_info, uid=user_id, eid=event_id, tid=task_id, iid=item_id) else: return abort(404, "Sorry, there is no Item for this task")
def show_edit_event(user_id, event_id): #ensure user is logged in logged_in = account.isLoggedIn() if not logged_in: return redirect('/login') #ensure user has access to change this event if not account.accountHasAdmin(rdb, user_id, event_id): abort(401, "Sorry, access is denied!") #get event details to feed to template event_info = rdb.hgetall('event:' + str(user_id) + ':' + str(event_id)) if event_info: return template('editevent.tpl', get_url=url, logged_in=logged_in, einfo=event_info, uid=user_id, eid=event_id) else: return abort(404, "Sorry, there is no task for this user and id")