def _create_view(un, vtitle, pid=None, vname=""): if vname=="": vname="cat_"+__newid() view=__create_viewdict(un+"_"+vname, vtitle, []) core.setdoc('task-views', view) if pid: _change_view_path(pid, view['_id']) return view['_id']
def _change_view_path(pvid, cvid, called_recursive=False): new_parent=core.getdoc('task-views', pvid) child=core.getdoc('task-views', cvid) old_path=child['path'][:] new_parent['subviews'].append(cvid) child['path']=new_parent['path']+[new_parent['_id']] core.setdoc('task-views', new_parent) core.setdoc('task-views', child) if not called_recursive: toclean=[] for i in old_path: if not i in new_parent['path']: toclean.append(i) for i in child['tasks']: _del_task_from_views(toclean, i) for i in child['subviews']: _change_view_path(cvid, i, called_recursive=True)
def _new_user(un, pw): userdoc=__create_userdict(un, pw) core.setdoc('users', userdoc)
def _create_group(bossid, name): glob=core.getdoc('groups', "glob") glob['counter']=glob['counter']+1 temp=__create_group_dict(bossid, name, glob['counter']) core.setdoc('groups', glob) return core.setdoc('groups', temp)
def _add_member(uid, gid): group=core.getdoc('groups', str(gid)) group['members'].append(uid) core.setdoc('groups', group)
def _del_task_from_view(vid, tid): view=core.getdoc('task-views', vid) if tid in view['tasks']: view['tasks'].remove(tid) core.setdoc('task-views', view)
def _add_task_to_view(vid, tid, dest="tasks"): view=core.getdoc('task-views', vid) view[dest].append(tid) core.setdoc('task-views', view)
def _create_proj(un, ptitle, pid): pname="proj_"+__newid() proj=__create_projdict(un+"_"+pname, ptitle, []) core.setdoc('task-views', proj) _change_view_path(pid, proj['_id']) return proj['_id']
def _set_task(task): core.setdoc('tasks', task)
def _upd_task_order(vid, neworder): newview=core.getdoc('task-views', vid) newview['tasks']=neworder core.setdoc('task-views', newview)