def test_is_map_available(dummy_location, db): assert not dummy_location.is_map_available dummy_location.aspects.append(Aspect(name=u'Test', center_latitude=u'', center_longitude=u'', zoom_level=0, top_left_latitude=0, top_left_longitude=0, bottom_right_latitude=0, bottom_right_longitude=0)) db.session.flush() assert dummy_location.is_map_available
def test_default_on_startup(dummy_location, db): aspect = Aspect(name=u'Test', center_latitude='', center_longitude='', zoom_level=0, top_left_latitude=0, top_left_longitude=0, bottom_right_latitude=0, bottom_right_longitude=0) dummy_location.aspects.append(aspect) db.session.flush() assert not aspect.default_on_startup dummy_location.default_aspect = aspect db.session.flush() assert aspect.default_on_startup
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()
def _checkParams(self): self._location = Location.find_first(name=self._param('location')) aspect_data = self._param('aspect') try: zoom_level = int(aspect_data.get('zoom_level', '0')) except ValueError: zoom_level = 0 self._aspect = Aspect( name=aspect_data.get('name', ''), center_latitude=aspect_data.get('center_latitude', ''), center_longitude=aspect_data.get('center_longitude', ''), zoom_level=zoom_level, top_left_latitude=aspect_data.get('top_left_latitude', ''), top_left_longitude=aspect_data.get('top_left_longitude', ''), bottom_right_latitude=aspect_data.get('bottom_right_latitude', ''), bottom_right_longitude=aspect_data.get('bottom_right_longitude', '')) self._default_on_startup = aspect_data.get('DefaultOnStartup', False)