Exemplo n.º 1
0
def populate_db():
    import geoalchemy2
    import shapely

    testing.setUp()
    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    shape = shapely.geometry.Polygon([(7.23, 41.25), (7.23, 41.12),
                                      (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()
Exemplo n.º 2
0
def populate_db():
    import geoalchemy2
    import shapely

    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    shape = shapely.geometry.Polygon(
        [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()
    def create_project(self):
        import geoalchemy2
        import shapely
        import transaction
        from osmtm.models import Area, Project, DBSession

        shape = shapely.geometry.Polygon(
            [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
        geometry = geoalchemy2.shape.from_shape(shape, 4326)
        area = Area(geometry)
        project = Project(u'test project')
        project.area = area
        project.auto_fill(12)
        project.status = Project.status_published

        DBSession.add(project)
        DBSession.flush()
        project_id = project.id
        transaction.commit()

        return project_id
    def create_project(self):
        import geoalchemy2
        import shapely
        import transaction
        from osmtm.models import Area, Project, DBSession

        shape = shapely.geometry.Polygon([(7.23, 41.25), (7.23, 41.12),
                                          (7.41, 41.20)])
        geometry = geoalchemy2.shape.from_shape(shape, 4326)
        area = Area(geometry)
        project = Project(u'test project')
        project.area = area
        project.auto_fill(12)
        project.status = Project.status_published

        DBSession.add(project)
        DBSession.flush()
        project_id = project.id
        transaction.commit()

        return project_id
Exemplo n.º 5
0
        project = Project(job.title)
        project.id = job.id
        project.area = area
        project.zoom = job.zoom
        project.last_update = job.last_update
        project.description = job.description
        project.short_description = job.short_description
        project.private = job.is_private
        project.instructions = job.workflow
        project.per_task_instructions = job.task_extra
        project.imagery = job.imagery if job.imagery != 'None' else None
        project.license_id = job.license_id
        project.author_id = users[job.author.encode('utf-8')] \
            if job.author else None
        project.status = job.status
        project.josm_preset = job.josm_preset

        if job.featured:
            project.priority = 1

        session_v2.add(project)
        session_v2.flush()
        project_id = project.id

        first_history = session_v1.query(tiles_history).filter(
            and_(
                tiles_history.c.job_id == job.id,
                'tiles_history."update" IS NOT NULL',
            )).order_by('tiles_history."update"').limit(1)
Exemplo n.º 6
0
        project = Project(job.title)
        project.id = job.id
        project.area = area
        project.zoom = job.zoom
        project.last_update = job.last_update
        project.description = job.description
        project.short_description = job.short_description
        project.private = job.is_private
        project.instructions = job.workflow
        project.per_task_instructions = job.task_extra
        project.imagery = job.imagery if job.imagery != 'None' else None
        project.license_id = job.license_id
        project.author_id = users[job.author.encode('utf-8')] \
            if job.author else None
        project.status = job.status
        project.josm_preset = job.josm_preset

        if job.featured:
            project.priority = 1

        session_v2.add(project)
        session_v2.flush()
        project_id = project.id

        first_history = session_v1.query(tiles_history).filter(
            and_(
                tiles_history.c.job_id == job.id,
                'tiles_history."update" IS NOT NULL',
            )
        ).order_by('tiles_history."update"').limit(1)
Exemplo n.º 7
0
def populate_db():
    import geoalchemy2
    import shapely

    testing.setUp()
    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    user = User(VALIDATOR_ID, u'user_validator')
    user.role = User.role_validator
    DBSession.add(user)

    user = User(EXPERIENCED_MAPPER_ID, u'user_experienced_mapper')
    user.role = User.role_experienced_mapper
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    label0 = Label()
    label0.name = u'bar'
    label0.color = u'#ff0000'
    DBSession.add(label0)

    label1 = Label()
    label1.name = u'dude label'
    label1.color = u'#ff0000'
    DBSession.add(label1)

    shape = shapely.geometry.Polygon(
        [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.short_description = u'lorem ipsum description'
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    project.labels = [label0, label1]
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()