Exemple #1
0
def folder_resource(db_session):
    """A basic folder Resource called '/folder'."""

    folder_resource = Resource(name='folder', type=Resource.BASIC_FOLDER)
    db_session.add(folder_resource)
    db_session.flush()
    folder_resource.permissions = json.dumps(
        [[ACCESS_TYPE_PUBLIC, folder_resource.id, ACCESS_LEVEL_WRITE]])

    return folder_resource
Exemple #2
0
def create_organization(full_name, folder_name):
    r = Resource()
    r.name = folder_name
    r.type = Resource.ORGANIZATION_FOLDER
    r.creation_timestamp = datetime.datetime.utcnow()
    r.modification_timestamp = r.creation_timestamp
    r.system_attributes = json.dumps({
        'full_name': full_name,
        'timezone': 'US/Pacific',
    })
    db.session.add(r)
    db.session.commit()
    r.permissions = json.dumps([[ACCESS_TYPE_ORG_USERS, r.id, ACCESS_LEVEL_WRITE], [ACCESS_TYPE_ORG_CONTROLLERS, r.id, ACCESS_LEVEL_WRITE]])
    r.organization_id = r.id  # the organization record has its own id as its organization
    db.session.commit()
    return r.id