def testing(): for x in range(0, 10): org = Organization() org.name = 'Test Organization ' + str(x) org.active = True org.save() print org
def prompt_organization(prompt="Enter an organization ID: "): while True: org_id = raw_input(prompt) if org_id is not "": org = Organization.get_organization(org_id) if org is not None: return org
def multiprompt_organization(prompt="Enter org IDs, comma separated: "): org_ids = raw_input(prompt).split(",") orgs = [] for org_id in org_ids: org = Organization.get_organization(org_id) if org is not None: orgs.append(org) return orgs
def change_organization(id=None): if id is not None: # Check if user belongs to organization org = Organization.get_organization(id) if org is not None and org in g.user.organizations: session['organization'] = org._id app.logger.debug("Changed '%s' organization to '%s'" % (g.user.username, session['organization'])) else: app.logger.debug("User tried to change to non-existent organization?") if 'referer' in request.headers: return redirect(request.headers['referer']) return redirect(url_for('dashboard.index'))
def build_organization(): u = Organization() u.name = raw_input("Organization name: ") u.active = True u.save() return u
def find_organization(org): org = Organization.objects(id=ObjectID(org)) if org is None: return None else: return org