当前位置: 首页>>代码示例>>Python>>正文


Python locations.Location类代码示例

本文整理汇总了Python中indico.modules.rb.models.locations.Location的典型用法代码示例。如果您正苦于以下问题:Python Location类的具体用法?Python Location怎么用?Python Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testRemoveLocationByName

    def testRemoveLocationByName(self):
        test_location_name = 'test_location'
        db.session.add(Location(name=test_location_name))
        db.session.commit()

        assert Location.getLocationByName(test_location_name) is not None
        Location.removeLocationByName(test_location_name)
        db.session.commit()
        assert Location.getLocationByName(test_location_name) is None
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:9,代码来源:locations_test.py

示例2: migrate_locations

    def migrate_locations(self):
        print cformat("%{white!}migrating locations")
        default_location_name = self.zodb_root["DefaultRoomBookingLocation"]
        custom_attributes_dict = self.rb_root["CustomAttributesList"]

        for old_location in self.zodb_root["RoomBookingLocationList"]:
            # create location
            l = Location(
                name=convert_to_unicode(old_location.friendlyName),
                is_default=(old_location.friendlyName == default_location_name),
            )

            print cformat("- %{cyan}{}").format(l.name)

            # add aspects
            for old_aspect in old_location._aspects.values():
                a = Aspect(
                    name=convert_to_unicode(old_aspect.name),
                    center_latitude=old_aspect.centerLatitude,
                    center_longitude=old_aspect.centerLongitude,
                    zoom_level=old_aspect.zoomLevel,
                    top_left_latitude=old_aspect.topLeftLatitude,
                    top_left_longitude=old_aspect.topLeftLongitude,
                    bottom_right_latitude=old_aspect.bottomRightLatitude,
                    bottom_right_longitude=old_aspect.bottomRightLongitude,
                )

                print cformat("  %{blue!}Aspect:%{reset} {}").format(a.name)

                l.aspects.append(a)
                if old_aspect.defaultOnStartup:
                    l.default_aspect = a

            # add custom attributes
            for ca in custom_attributes_dict.get(l.name, []):
                if ca["type"] != "str":
                    raise RuntimeError("Non-str custom attributes are unsupported: {}".format(ca))
                attr_name = attribute_map.get(ca["name"], ca["name"])
                attr = RoomAttribute(
                    name=attr_name.replace(" ", "-").lower(),
                    title=attr_name,
                    type=ca["type"],
                    is_required=ca["required"],
                    is_hidden=ca["hidden"],
                )
                l.attributes.append(attr)
                print cformat("  %{blue!}Attribute:%{reset} {}").format(attr.title)

            # add new created location
            db.session.add(l)
            print
            print
        db.session.commit()
开发者ID:jacquesd,项目名称:indico,代码行数:53,代码来源:roombooking.py

示例3: migrate_locations

def migrate_locations(main_root, rb_root):
    print cformat('%{white!}migrating locations')
    default_location_name = main_root['DefaultRoomBookingLocation']
    custom_attributes_dict = rb_root['CustomAttributesList']

    for old_location in main_root['RoomBookingLocationList']:
        # create location
        l = Location(
            name=convert_to_unicode(old_location.friendlyName),
            is_default=(old_location.friendlyName == default_location_name)
        )

        print cformat('- %{cyan}{}').format(l.name)

        # add aspects
        for old_aspect in old_location._aspects.values():
            a = Aspect(
                name=convert_to_unicode(old_aspect.name),
                center_latitude=old_aspect.centerLatitude,
                center_longitude=old_aspect.centerLongitude,
                zoom_level=old_aspect.zoomLevel,
                top_left_latitude=old_aspect.topLeftLatitude,
                top_left_longitude=old_aspect.topLeftLongitude,
                bottom_right_latitude=old_aspect.bottomRightLatitude,
                bottom_right_longitude=old_aspect.bottomRightLongitude
            )

            print cformat('  %{blue!}Aspect:%{reset} {}').format(a.name)

            l.aspects.append(a)
            if old_aspect.defaultOnStartup:
                l.default_aspect = a

        # add custom attributes
        for ca in custom_attributes_dict.get(l.name, []):
            if ca['type'] != 'str':
                raise RuntimeError('Non-str custom attributes are unsupported: {}'.format(ca))
            attr_name = attribute_map.get(ca['name'], ca['name'])
            attr = RoomAttribute(name=attr_name.replace(' ', '-').lower(), title=attr_name, type=ca['type'],
                                 is_required=ca['required'], is_hidden=ca['hidden'])
            l.attributes.append(attr)
            print cformat('  %{blue!}Attribute:%{reset} {}').format(attr.title)

        # add new created location
        db.session.add(l)
        print
        print
    db.session.commit()
开发者ID:pferreir,项目名称:indico-backup,代码行数:48,代码来源:migrate_to_sqlalchemy.py

示例4: get_location_data

 def get_location_data(params):
     location_data = json.loads(params['location_data'])
     if location_data.get('room_id'):
         location_data['room'] = Room.get_one(location_data['room_id'])
     if location_data.get('venue_id'):
         location_data['venue'] = Location.get_one(location_data['venue_id'])
     return location_data
开发者ID:fph,项目名称:indico,代码行数:7,代码来源:categoryDisplay.py

示例5: testClone

    def testClone(self):
        original = Location.getDefaultLocation()
        cloned = utils.clone(Location, original)

        assert cloned.id != original.id
        assert cloned.name == original.name
        assert cloned.default_aspect.id == original.default_aspect.id
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:7,代码来源:utils_test.py

示例6: wrapper

 def wrapper(*args, **kw):
     location_name = getattr(request, request_attribute).get(parameter_name, None)
     location = Location.find_first(name=location_name)
     if not location:
         raise NotFound(_('There is no location named: {0}').format(location_name))
     setattr(args[0], attribute_name, location)
     return f(*args, **kw)
开发者ID:bkolobara,项目名称:indico,代码行数:7,代码来源:decorators.py

示例7: main

def main(main_uri, rb_uri, sqla_uri, photo_path, drop, merged_avatars):
    update_session_options(db)  # get rid of the zope transaction extension
    main_root, rb_root, app = setup(main_uri, rb_uri, sqla_uri)
    global tz
    try:
        tz = pytz.timezone(main_root['MaKaCInfo']['main'].getTimezone())
    except KeyError:
        tz = pytz.utc

    start = time.clock()
    with app.app_context():
        if drop:
            print cformat('%{yellow!}*** DANGER')
            print cformat('%{yellow!}***%{reset} '
                          '%{red!}ALL DATA%{reset} in your database %{yellow!}{!r}%{reset} will be '
                          '%{red!}PERMANENTLY ERASED%{reset}!').format(db.engine.url)
            if raw_input(cformat('%{yellow!}***%{reset} To confirm this, enter %{yellow!}YES%{reset}: ')) != 'YES':
                print 'Aborting'
                sys.exit(1)
            delete_all_tables(db)
        stamp()
        db.create_all()
        if Location.find().count():
            # Usually there's no good reason to migrate with data in the DB. However, during development one might
            # comment out some migration tasks and run the migration anyway.
            print cformat('%{yellow!}*** WARNING')
            print cformat('%{yellow!}***%{reset} Your database is not empty, migration will most likely fail!')
            if raw_input(cformat('%{yellow!}***%{reset} To confirm this, enter %{yellow!}YES%{reset}: ')) != 'YES':
                print 'Aborting'
                sys.exit(1)
        migrate(main_root, rb_root, photo_path, merged_avatars)
    print 'migration took {} seconds'.format((time.clock() - start))
开发者ID:pferreir,项目名称:indico-backup,代码行数:32,代码来源:migrate_to_sqlalchemy.py

示例8: export_reservation

    def export_reservation(self, aw):
        locations = Location.find_all(Location.name.in_(self._locations))
        if not locations:
            return

        for room_id, reservation in _export_reservations(self, False, True):
            yield reservation
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:7,代码来源:api.py

示例9: _checkParams

 def _checkParams(self):
     self._with_kpi = request.args.get('withKPI', type=bool)
     self._actionSucceeded = request.args.get('actionSucceeded', default=False, type=bool)
     location_name = request.view_args.get('locationId')
     self._location = Location.find_first(name=location_name)
     if not self._location:
         raise IndicoError('Unknown Location: {0}'.format(location_name))
开发者ID:NIIF,项目名称:indico,代码行数:7,代码来源:locations.py

示例10: _process_args

 def _process_args(self):
     self._locationName = request.form.get('newLocationName').strip()
     if not self._locationName:
         raise BadRequest(_('Location name may not be empty'))
     if '/' in self._locationName:
         raise BadRequest(_('Location name may not contain slashes'))
     if Location.find_first(name=self._locationName):
         raise BadRequest(_('Location "{0}" already exists').format(self._locationName))
开发者ID:bkolobara,项目名称:indico,代码行数:8,代码来源:locations.py

示例11: export_roomName

    def export_roomName(self, aw):
        loc = Location.find_first(name=self._location)
        if loc is None:
            return

        search_str = '%{}%'.format(self._room_name)
        rooms_data = Room.get_with_data('vc_equipment', 'non_vc_equipment',
                                        filters=[Room.location_id == loc.id, Room.name.ilike(search_str)])
        for result in rooms_data:
            yield _serializable_room(result)
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:10,代码来源:api.py

示例12: wrapper

    def wrapper(*args, **kw):
        if not args:
            raise IndicoError(_("Wrong usage of location decorator"))

        location_name = getattr(request, request_attribute).get(parameter_name, None)
        location = Location.find_first(name=location_name)
        if not location:
            raise NotFoundError(_("There is no location named: {0}").format(location_name))
        setattr(args[0], attribute_name, location)
        return f(*args, **kw)
开发者ID:florv,项目名称:indico,代码行数:10,代码来源:decorators.py

示例13: _process_args

    def _process_args(self):
        name = request.view_args.get('locationId')
        self._location = Location.find_one(name=name)
        self._new_attr = None
        attr_title = request.form.get('newCustomAttributeName', default='').strip()
        if attr_title:
            attr_name = attr_title.replace(' ', '-').lower()
            if RoomAttribute.query.filter_by(name=attr_name).first():
                raise BadRequest(_('There is already an attribute named: {0}').format(attr_name))

            self._new_attr = RoomAttribute(name=attr_name, title=attr_title,
                                           is_hidden=request.form.get('newCustomAttributeIsHidden') == 'on')
开发者ID:mic4ael,项目名称:indico,代码行数:12,代码来源:locations.py

示例14: export_roomName

    def export_roomName(self, user):
        loc = Location.find_first(name=self._location)
        if loc is None:
            return

        search_str = '%{}%'.format(self._room_name)
        rooms_data = Room.get_with_data(
            filters=[
                Room.location_id == loc.id,
                or_(Room.name.ilike(search_str),
                    Room.verbose_name.ilike(search_str))
            ])

        for result in rooms_data:
            yield _serializable_room(result)
开发者ID:mic4ael,项目名称:indico,代码行数:15,代码来源:api.py

示例15: export_room

    def export_room(self, user):
        loc = Location.find_first(name=self._location)
        if loc is None:
            return

        # Retrieve rooms
        rooms_data = list(Room.get_with_data(filters=[Room.id.in_(self._ids), Room.location_id == loc.id]))

        # Retrieve reservations
        reservations = None
        if self._detail == 'reservations':
            reservations = OrderedMultiDict(_export_reservations(self, True, False, [
                Reservation.room_id.in_(x['room'].id for x in rooms_data)
            ]))

        for result in rooms_data:
            yield _serializable_room(result, reservations)
开发者ID:mic4ael,项目名称:indico,代码行数:17,代码来源:api.py


注:本文中的indico.modules.rb.models.locations.Location类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。