def all_items(): """ Show user items list """ if type(request.vars.q) is list: # in the case of being loaded from a query string # use only the last valor from q request.vars.q = request.vars.q[-1] request.vars.q = None if request.vars.q == '' else request.vars.q if request.vars.q is not None: ids = Whoosh().search(request.vars.q) query = db.item.unique_id.belongs(ids) else: query = (db.item.id > 0) query &= ( auth.accessible_query('collaborator', db.item) | auth.accessible_query('owner', db.item)) grid = SQLFORM.grid( query, orderby=[~db.item.created_on], create=False, csv=False, paginate=6, ) return dict(grid=grid)
def load_items(): """Show the item list of this dashboard""" dash = db.dashboard(request.args(0)) # session.dashboard = dash.id request.vars.q = None if request.vars.q == '' else request.vars.q if request.vars.q is not None: ids = Whoosh().search(request.vars.q) query = db.item.unique_id.belongs(ids) else: query = (db.item.id > 0) query &= ( auth.accessible_query('collaborator', db.item) | auth.accessible_query('owner', db.item)) query &= db.dashboard.item_list.contains(db.item.unique_id) query &= (db.dashboard.id == dash.id) grid = SQLFORM.grid( query, args=request.args[:1], orderby=[~db.item.created_on], create=False, csv=False, paginate=6, ) response.title = dash.name response.js = "jQuery('#dashboard_cmp').get(0).reload();" return dict(grid=grid, current_dash=dash)
def index(): """ Show the user the organizations he/she can access """ query = (db.organization.id > 0) query &= (auth.accessible_query('read', db.organization) | auth.accessible_query('update', db.organization)) orgs = db(query).select(db.organization.ALL) return locals()
def index(): """ Show the user the organizations he/she can access """ query = (db.organization.id > 0) query &= ( auth.accessible_query('read', db.organization) | auth.accessible_query('update', db.organization)) orgs = db(query).select(db.organization.ALL) return locals()
def share(): """ Show the list of desk to with the item can be push """ item = application.getItemByUUID(request.args(0)) if item is None: raise HTTP(404) query = (db.desk.id != session.desk_id) query &= auth.accessible_query('push_items', db.desk) posible_desk = db(query).select() fld_to_desk = Field('to_desk', 'integer') fld_to_desk.label = T("Push to") fld_to_desk.comment = T("Select where to push the item") fld_to_desk.requires = IS_IN_SET([(desk.id, desk.name) for desk in posible_desk]) form = SQLFORM.factory(fld_to_desk, submit_button=T("Send"), table_name='share') if form.process().accepted: # send the item to the selected desk ct = application.getContentType(item.item_type) ct.shareItem(item.unique_id, session.desk_id, form.vars.to_desk) response.js = "$('#metaModal').modal('hide');" return locals()
def share(): """ Show the list of desk to with the item can be push """ item = application.getItemByUUID(request.args(0)) if item is None: raise HTTP(404) query = (db.desk.id != session.desk_id) query &= auth.accessible_query('push_items', db.desk) posible_desk = db(query).select() fld_to_desk = Field('to_desk', 'integer') fld_to_desk.label = T("Push to organization desk") fld_to_desk.comment = T("Select where to push the item") fld_to_desk.requires = IS_EMPTY_OR( IS_IN_SET([(desk.id, desk.name) for desk in posible_desk])) fld_personal_desk = Field('to_person_desk', 'integer') fld_personal_desk.label = T("Push to other person desk") fld_personal_desk.comment = T("Select a person from the list.") # list of person on orgs persons = [] # search up all the persons orgs = db(db.organization.users.contains(auth.user.id)).select() for org in orgs: x = [db.auth_user(id=y) for y in org.users if y != auth.user.id] persons.extend(x) persons = list(set(persons)) fld_personal_desk.requires = IS_EMPTY_OR( IS_IN_SET([(per.id, "{} {}".format(per.first_name, per.last_name)) for per in persons])) fld_cond = Field('cond', 'boolean', default=False) fld_cond.label = T('To other person?') form = SQLFORM.factory(fld_to_desk, fld_personal_desk, fld_cond, submit_button=T("Send"), table_name='share') if form.process().accepted: src = session.desk_id if form.vars.cond: # send the item to other user other_user = db.auth_user(form.vars.to_person_desk) target = application.getUserDesk(other_user).id else: # send the item to the selected desk target = form.vars.to_desk if target: ct = application.getContentType(item.item_type) ct.shareItem(item.unique_id, src, target) response.js = "$('#metaModal').modal('hide');" response.flash = None return locals()
def index(): """Show the item list of this dashboard""" dash = db.dashboard(request.args(0)) activeDashboard(request.args(0)) query = (db.item.id > 0) query &= ( auth.accessible_query('collaborator', db.item) | auth.accessible_query('owner', db.item)) query &= db.dashboard.item_list.contains(db.item.unique_id) query &= (db.dashboard.id == dash.id) grid = SQLFORM.grid( query, args=request.args[:1], orderby=[~db.item.created_on], create=False, csv=False, paginate=6, ) response.title = dash.name return dict(grid=grid, current_dash=dash)
def share(): """ Show the list of desk to with the item can be push """ item = application.getItemByUUID(request.args(0)) if item is None: raise HTTP(404) query = (db.desk.id != session.desk_id) query &= auth.accessible_query('push_items', db.desk) posible_desk = db(query).select() fld_to_desk = Field('to_desk', 'integer') fld_to_desk.label = T("Push to organization desk") fld_to_desk.comment = T("Select where to push the item") fld_to_desk.requires = IS_EMPTY_OR(IS_IN_SET( [(desk.id, desk.name) for desk in posible_desk] )) fld_personal_desk = Field('to_person_desk', 'integer') fld_personal_desk.label = T("Push to other person desk") fld_personal_desk.comment = T("Select a person from the list.") # list of person on orgs persons = [] # search up all the persons orgs = db(db.organization.users.contains(auth.user.id)).select() for org in orgs: x = [db.auth_user(id=y) for y in org.users if y != auth.user.id] persons.extend(x) persons = list(set(persons)) fld_personal_desk.requires = IS_EMPTY_OR(IS_IN_SET( [(per.id, "{} {}".format(per.first_name, per.last_name)) for per in persons] )) fld_cond = Field('cond', 'boolean', default=False) fld_cond.label = T('To other person?') form = SQLFORM.factory( fld_to_desk, fld_personal_desk, fld_cond, submit_button=T("Send"), table_name='share') if form.process().accepted: src = session.desk_id if form.vars.cond: # send the item to other user other_user = db.auth_user(form.vars.to_person_desk) target = application.getUserDesk(other_user).id else: # send the item to the selected desk target = form.vars.to_desk if target: ct = application.getContentType(item.item_type) ct.shareItem(item.unique_id, src, target) response.js = "$('#metaModal').modal('hide');" response.flash = None return locals()