def fetch_equipment(self, connection):
        self._logger.debug("Fetching equipment list...")

        counter = Counter()
        foundation_equipment_ids = []
        cursor = connection.cursor()
        cursor.execute('SELECT * FROM foundation_pub.equipment ORDER BY NAME')

        for row in cursor:
            row = self._prepare_row(row, cursor)
            counter['found'] += 1
            equipment = EquipmentType.find_first(
                EquipmentType.name == row['NAME'])
            if not equipment:
                equipment = EquipmentType(name=row['NAME'])
                self._location.equipment_types.append(equipment)
                counter['added'] += 1
                self._logger.info(u"Added equipment '%s'", equipment)
            foundation_equipment_ids.append(equipment.id)

        vc_parent = self._location.get_equipment_by_name('Video conference')
        for equipment in EquipmentType.find(
                ~EquipmentType.id.in_(foundation_equipment_ids),
                EquipmentType.parent_id != vc_parent.id):
            self._logger.info(
                "Mismatch: Equipment '%s' found in Indico but not in Foundation",
                equipment.name)

        db.session.commit()
        self._logger.info("Equipment objects summary: %d found - %d new added",
                          counter['found'], counter['added'])
示例#2
0
class SearchRoomsForm(IndicoForm):
    location = QuerySelectField(_(u'Location'),
                                get_label=lambda x: x.name,
                                query_factory=Location.find,
                                allow_blank=True)
    details = StringField()
    capacity = IntegerField(_(u'Capacity'),
                            validators=[Optional(),
                                        NumberRange(min=0)])
    available_equipment = IndicoQuerySelectMultipleCheckboxField(
        _(u'Equipment'),
        get_label=u'name',
        query_factory=lambda: EquipmentType.find().order_by(EquipmentType.name
                                                            ))
    is_only_public = BooleanField(_(u'Only public rooms'), default=True)
    is_auto_confirm = BooleanField(_(u'Only rooms not requiring confirmation'),
                                   default=True)
    is_only_active = BooleanField(_(u'Only active rooms'), default=True)
    is_only_my_rooms = BooleanField(_(u'Only my rooms'))
    repeatability = StringField(
    )  # TODO: use repeat_frequency/interval with new UI
    include_pending_blockings = BooleanField(
        _(u'Check conflicts against pending blockings'), default=True)
    include_pre_bookings = BooleanField(
        _(u'Check conflicts against pre-bookings'), default=True)
示例#3
0
def get_av_capable_rooms():
    """Returns a list of rooms with AV equipment"""
    eq_types = EquipmentType.find_all(
        EquipmentType.name == 'Webcast/Recording',
        Location.name == 'CERN',
        _join=EquipmentType.location)
    return set(Room.find_with_filters({'available_equipment': eq_types}))
示例#4
0
 def _process(self):
     form = self._form
     if self._is_submitted() and form.validate():
         rooms = Room.find_with_filters(form.data, session.user)
         return WPRoomBookingSearchRoomsResults(self, self.menu_item, rooms=rooms).display()
     equipment_locations = {eq.id: eq.location_id for eq in EquipmentType.find()}
     return WPRoomBookingSearchRooms(self, form=form, errors=form.error_list, rooms=Room.find_all(),
                                     equipment_locations=equipment_locations).display()
示例#5
0
 def _process(self):
     form = self._form
     if self._is_submitted() and form.validate():
         rooms = Room.find_with_filters(form.data, session.user)
         return WPRoomBookingSearchRoomsResults(self, self.menu_item, rooms=rooms).display()
     equipment_locations = {eq.id: eq.location_id for eq in EquipmentType.find()}
     return WPRoomBookingSearchRooms(self, form=form, errors=form.error_list, rooms=Room.find_all(is_active=True),
                                     equipment_locations=equipment_locations).display()
示例#6
0
class SearchRoomsForm(IndicoForm):
    location = QuerySelectField(_(u'Location'),
                                get_label=lambda x: x.name,
                                query_factory=Location.find,
                                allow_blank=True)
    details = StringField()
    available = RadioField(_(u'Availability'),
                           coerce=int,
                           default=-1,
                           widget=ConcatWidget(prefix_label=False),
                           choices=[(1, _(u'Available')), (0, _(u'Booked')),
                                    (-1, _(u"Don't care"))])
    capacity = IntegerField(_(u'Capacity'),
                            validators=[Optional(),
                                        NumberRange(min=0)])
    available_equipment = IndicoQuerySelectMultipleCheckboxField(
        _(u'Equipment'),
        get_label=_get_equipment_label,
        modify_object_list=_group_equipment,
        query_factory=lambda: EquipmentType.find().order_by(EquipmentType.name
                                                            ))
    is_only_public = BooleanField(_(u'Only public rooms'), default=True)
    is_auto_confirm = BooleanField(_(u'Only rooms not requiring confirmation'),
                                   default=True)
    is_only_active = BooleanField(_(u'Only active rooms'), default=True)
    is_only_my_rooms = BooleanField(_(u'Only my rooms'))
    # Period details when searching for (un-)availability
    start_dt = DateTimeField(_(u'Start date'),
                             validators=[Optional()],
                             parse_kwargs={'dayfirst': True},
                             display_format='%d/%m/%Y %H:%M',
                             widget=HiddenInput())
    end_dt = DateTimeField(_(u'End date'),
                           validators=[Optional()],
                           parse_kwargs={'dayfirst': True},
                           display_format='%d/%m/%Y %H:%M',
                           widget=HiddenInput())
    repeatability = StringField(
    )  # TODO: use repeat_frequency/interval with new UI
    include_pending_blockings = BooleanField(
        _(u'Check conflicts against pending blockings'), default=True)
    include_pre_bookings = BooleanField(
        _(u'Check conflicts against pre-bookings'), default=True)
示例#7
0
 def _create_equipment_type(name):
     eq = EquipmentType(name=name)
     db.session.add(eq)
     db.session.flush()
     return eq
示例#8
0
 def _create_equipment_type(name, **params):
     params.setdefault('location', dummy_location)
     eq = EquipmentType(name=name, **params)
     db.session.flush()
     return eq
示例#9
0
 def _process_POST(self, name, features):
     self._check_conflict(name)
     equipment_type = EquipmentType(name=name, features=features)
     db.session.add(equipment_type)
     db.session.flush()
     return self._jsonify_one(equipment_type), 201
示例#10
0
 def _process_args(self):
     id_ = request.view_args.get('equipment_type_id')
     self.equipment_type = EquipmentType.get_one(
         id_) if id_ is not None else None
示例#11
0
    def migrate_rooms(self):
        eq = defaultdict(set)
        vc = defaultdict(set)
        for old_room_id, old_room in self.rb_root["Rooms"].iteritems():
            eq[old_room._locationName].update(e for e in old_room._equipment.split("`") if e)
            vc[old_room._locationName].update(e for e in getattr(old_room, "avaibleVC", []) if e)

        print cformat("%{white!}migrating equipment")
        for name, eqs in eq.iteritems():
            l = Location.find_first(name=name)

            if l is None:
                print cformat("%{yellow!}*** WARNING")
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped equipment: {}".format(name, eqs)
                )
                continue

            l.equipment_types.extend(EquipmentType(name=x) for x in eqs)
            print cformat("- [%{cyan}{}%{reset}] {}").format(name, eqs)
            db.session.add(l)
        db.session.commit()
        print

        print cformat("%{white!}migrating vc equipment")
        for name, vcs in vc.iteritems():
            l = Location.find_first(name=name)

            if l is None:
                print cformat("%{yellow!}*** WARNING")
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped VC equipment: {}".format(name, vcs)
                )
                continue

            pvc = l.get_equipment_by_name("Video conference")
            for vc_name in vcs:
                req = EquipmentType(name=vc_name)
                req.parent = pvc
                l.equipment_types.append(req)
                print cformat("- [%{cyan}{}%{reset}] {}").format(name, req.name)
            db.session.add(l)
        db.session.commit()
        print

        print cformat("%{white!}migrating rooms")

        for old_room_id, old_room in self.rb_root["Rooms"].iteritems():
            l = Location.find_first(name=old_room._locationName)

            if l is None:
                print cformat("%{yellow!}*** WARNING")
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped room '{}'".format(
                        old_room._locationName, old_room.id
                    )
                )
                continue

            r = Room(
                id=old_room_id,
                name=convert_to_unicode((old_room._name or "").strip() or generate_name(old_room)),
                site=convert_to_unicode(old_room.site),
                division=convert_to_unicode(old_room.division),
                building=convert_to_unicode(old_room.building),
                floor=convert_to_unicode(old_room.floor),
                number=convert_to_unicode(old_room.roomNr),
                notification_before_days=(
                    (old_room.resvStartNotificationBefore or None)
                    if getattr(old_room, "resvStartNotification", False)
                    else None
                ),
                notification_for_responsible=getattr(old_room, "resvNotificationToResponsible", False),
                notification_for_assistance=getattr(old_room, "resvNotificationAssistance", False),
                reservations_need_confirmation=old_room.resvsNeedConfirmation,
                telephone=convert_to_unicode(getattr(old_room, "telephone", None)),
                key_location=convert_to_unicode(getattr(old_room, "whereIsKey", None)),
                capacity=getattr(old_room, "capacity", None),
                surface_area=getattr(old_room, "surfaceArea", None),
                latitude=getattr(old_room, "latitude", None),
                longitude=getattr(old_room, "longitude", None),
                comments=convert_to_unicode(getattr(old_room, "comments", None)),
                owner_id=self.merged_avatars.get(old_room.responsibleId, old_room.responsibleId),
                is_active=old_room.isActive,
                is_reservable=old_room.isReservable,
                max_advance_days=int(old_room.maxAdvanceDays) if getattr(old_room, "maxAdvanceDays", None) else None,
            )

            print cformat("- [%{cyan}{}%{reset}] %{grey!}{:4}%{reset}  %{green!}{}%{reset}").format(
                l.name, r.id, r.name
            )

            for old_bookable_time in getattr(old_room, "_dailyBookablePeriods", []):
                r.bookable_hours.append(
                    BookableHours(start_time=old_bookable_time._startTime, end_time=old_bookable_time._endTime)
                )
                print cformat("  %{blue!}Bookable:%{reset} {}").format(r.bookable_hours[-1])

            for old_nonbookable_date in getattr(old_room, "_nonBookableDates", []):
                r.nonbookable_periods.append(
                    NonBookablePeriod(start_dt=old_nonbookable_date._startDate, end_dt=old_nonbookable_date._endDate)
                )
                print cformat("  %{blue!}Nonbookable:%{reset} {}").format(r.nonbookable_periods[-1])

            if self.photo_path:
                try:
                    with open(
                        os.path.join(self.photo_path, "large_photos", get_canonical_name_of(old_room) + ".jpg"), "rb"
                    ) as f:
                        large_photo = f.read()
                except Exception:
                    large_photo = None

                try:
                    with open(
                        os.path.join(self.photo_path, "small_photos", get_canonical_name_of(old_room) + ".jpg"), "rb"
                    ) as f:
                        small_photo = f.read()
                except Exception:
                    small_photo = None

                if large_photo and small_photo:
                    r.photo = Photo(data=large_photo, thumbnail=small_photo)
                    print cformat("  %{blue!}Photos")

            new_eq = []
            for old_equipment in ifilter(None, old_room._equipment.split("`") + old_room.avaibleVC):
                room_eq = l.get_equipment_by_name(old_equipment)
                new_eq.append(room_eq)
                r.available_equipment.append(room_eq)
            if new_eq:
                print cformat("  %{blue!}Equipment:%{reset} {}").format(", ".join(sorted(x.name for x in new_eq)))

            for attr_name, value in getattr(old_room, "customAtts", {}).iteritems():
                value = convert_to_unicode(value)
                if not value or ("Simba" in attr_name and value == u"Error: unknown mailing list"):
                    continue
                attr_name = attribute_map.get(attr_name, attr_name).replace(" ", "-").lower()
                ca = l.get_attribute_by_name(attr_name)
                if not ca:
                    print cformat("  %{blue!}Attribute:%{reset} {} %{red!}not found").format(attr_name)
                    continue
                attr = RoomAttributeAssociation()
                attr.value = value
                attr.attribute = ca
                r.attributes.append(attr)
                print cformat("  %{blue!}Attribute:%{reset} {} = {}").format(attr.attribute.title, attr.value)

            l.rooms.append(r)
            db.session.add(l)
            print
        db.session.commit()
示例#12
0
    def migrate_rooms(self):
        eq = defaultdict(set)
        vc = defaultdict(set)
        for old_room_id, old_room in self.rb_root['Rooms'].iteritems():
            eq[old_room._locationName].update(
                e for e in old_room._equipment.split('`') if e)
            vc[old_room._locationName].update(
                e for e in getattr(old_room, 'avaibleVC', []) if e)

        print cformat('%{white!}migrating equipment')
        for name, eqs in eq.iteritems():
            l = Location.find_first(name=name)

            if l is None:
                print cformat('%{yellow!}*** WARNING')
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped equipment: {}"
                    .format(name, eqs))
                continue

            l.equipment_types.extend(EquipmentType(name=x) for x in eqs)
            print cformat('- [%{cyan}{}%{reset}] {}').format(name, eqs)
            db.session.add(l)
        db.session.commit()
        print

        print cformat('%{white!}migrating vc equipment')
        for name, vcs in vc.iteritems():
            l = Location.find_first(name=name)

            if l is None:
                print cformat('%{yellow!}*** WARNING')
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped VC equipment: {}"
                    .format(name, vcs))
                continue

            pvc = l.get_equipment_by_name('Video conference')
            for vc_name in vcs:
                req = EquipmentType(name=vc_name)
                req.parent = pvc
                l.equipment_types.append(req)
                print cformat('- [%{cyan}{}%{reset}] {}').format(
                    name, req.name)
            db.session.add(l)
        db.session.commit()
        print

        print cformat('%{white!}migrating rooms')

        for old_room_id, old_room in self.rb_root['Rooms'].iteritems():
            l = Location.find_first(name=old_room._locationName)

            if l is None:
                print cformat('%{yellow!}*** WARNING')
                print cformat(
                    "%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped room '{}'"
                    .format(old_room._locationName, old_room.id))
                continue

            r = Room(
                id=old_room_id,
                name=convert_to_unicode((old_room._name or '').strip()
                                        or generate_name(old_room)),
                site=convert_to_unicode(old_room.site),
                division=convert_to_unicode(old_room.division),
                building=convert_to_unicode(old_room.building),
                floor=convert_to_unicode(old_room.floor),
                number=convert_to_unicode(old_room.roomNr),
                notification_before_days=((
                    old_room.resvStartNotificationBefore or None) if getattr(
                        old_room, 'resvStartNotification', False) else None),
                notification_for_responsible=getattr(
                    old_room, 'resvNotificationToResponsible', False),
                notification_for_assistance=getattr(
                    old_room, 'resvNotificationAssistance', False),
                reservations_need_confirmation=old_room.resvsNeedConfirmation,
                telephone=convert_to_unicode(
                    getattr(old_room, 'telephone', None)),
                key_location=convert_to_unicode(
                    getattr(old_room, 'whereIsKey', None)),
                capacity=getattr(old_room, 'capacity', None),
                surface_area=getattr(old_room, 'surfaceArea', None),
                latitude=getattr(old_room, 'latitude', None),
                longitude=getattr(old_room, 'longitude', None),
                comments=convert_to_unicode(getattr(old_room, 'comments',
                                                    None)),
                owner_id=self.merged_avatars.get(old_room.responsibleId,
                                                 old_room.responsibleId),
                is_active=old_room.isActive,
                is_reservable=old_room.isReservable,
                max_advance_days=int(old_room.maxAdvanceDays) if getattr(
                    old_room, 'maxAdvanceDays', None) else None)

            print cformat(
                '- [%{cyan}{}%{reset}] %{grey!}{:4}%{reset}  %{green!}{}%{reset}'
            ).format(l.name, r.id, r.name)

            for old_bookable_time in getattr(old_room, '_dailyBookablePeriods',
                                             []):
                r.bookable_hours.append(
                    BookableHours(start_time=old_bookable_time._startTime,
                                  end_time=old_bookable_time._endTime))
                print cformat('  %{blue!}Bookable:%{reset} {}').format(
                    r.bookable_hours[-1])

            for old_nonbookable_date in getattr(old_room, '_nonBookableDates',
                                                []):
                r.nonbookable_periods.append(
                    NonBookablePeriod(start_dt=old_nonbookable_date._startDate,
                                      end_dt=old_nonbookable_date._endDate))
                print cformat('  %{blue!}Nonbookable:%{reset} {}').format(
                    r.nonbookable_periods[-1])

            if self.photo_path:
                try:
                    with open(
                            os.path.join(
                                self.photo_path, 'large_photos',
                                get_canonical_name_of(old_room) + '.jpg'),
                            'rb') as f:
                        large_photo = f.read()
                except Exception:
                    large_photo = None

                try:
                    with open(
                            os.path.join(
                                self.photo_path, 'small_photos',
                                get_canonical_name_of(old_room) + '.jpg'),
                            'rb') as f:
                        small_photo = f.read()
                except Exception:
                    small_photo = None

                if large_photo and small_photo:
                    r.photo = Photo(data=large_photo, thumbnail=small_photo)
                    print cformat('  %{blue!}Photos')

            new_eq = []
            for old_equipment in ifilter(
                    None,
                    old_room._equipment.split('`') + old_room.avaibleVC):
                room_eq = l.get_equipment_by_name(old_equipment)
                new_eq.append(room_eq)
                r.available_equipment.append(room_eq)
            if new_eq:
                print cformat('  %{blue!}Equipment:%{reset} {}').format(
                    ', '.join(sorted(x.name for x in new_eq)))

            for attr_name, value in getattr(old_room, 'customAtts',
                                            {}).iteritems():
                value = convert_to_unicode(value)
                if not value or ('Simba' in attr_name
                                 and value == u'Error: unknown mailing list'):
                    continue
                attr_name = attribute_map.get(attr_name,
                                              attr_name).replace(' ',
                                                                 '-').lower()
                ca = l.get_attribute_by_name(attr_name)
                if not ca:
                    print cformat(
                        '  %{blue!}Attribute:%{reset} {} %{red!}not found'
                    ).format(attr_name)
                    continue
                attr = RoomAttributeAssociation()
                attr.value = value
                attr.attribute = ca
                r.attributes.append(attr)
                print cformat('  %{blue!}Attribute:%{reset} {} = {}').format(
                    attr.attribute.title, attr.value)

            l.rooms.append(r)
            db.session.add(l)
            print
        db.session.commit()
示例#13
0
 def _process(self):
     if self._eq:
         self._location.equipment_types.append(EquipmentType(name=self._eq))
         flash(_(u'Equipment added'), 'success')
     return redirect(
         url_for('rooms_admin.roomBooking-adminLocation', self._location))
示例#14
0
 def _process(self):
     if self._eq:
         self._location.equipment_types.append(EquipmentType(name=self._eq))
         flash(_(u'Equipment added'), 'success')
     self._redirect(urlHandlers.UHRoomBookingAdminLocation.getURL(self._location))
示例#15
0
文件: admin.py 项目: mic4ael/indico
 def _process_args(self):
     id_ = request.view_args.get('equipment_type_id')
     self.equipment_type = EquipmentType.get_one(id_) if id_ is not None else None
def migrate_rooms(rb_root, photo_path, avatar_id_map):
    eq = defaultdict(set)
    vc = defaultdict(set)
    for old_room_id, old_room in rb_root['Rooms'].iteritems():
        eq[old_room._locationName].update(e for e in old_room._equipment.split('`') if e)
        vc[old_room._locationName].update(e for e in getattr(old_room, 'avaibleVC', []) if e)

    print cformat('%{white!}migrating equipment')
    for name, eqs in eq.iteritems():
        l = Location.find_first(name=name)
        l.equipment_types.extend(EquipmentType(name=x) for x in eqs)
        print cformat('- [%{cyan}{}%{reset}] {}').format(name, eqs)
        db.session.add(l)
    db.session.commit()
    print

    print cformat('%{white!}migrating vc equipment')
    for name, vcs in vc.iteritems():
        l = Location.find_first(name=name)
        pvc = l.get_equipment_by_name('Video conference')
        for vc_name in vcs:
            req = EquipmentType(name=vc_name)
            req.parent = pvc
            l.equipment_types.append(req)
            print cformat('- [%{cyan}{}%{reset}] {}').format(name, req.name)
        db.session.add(l)
    db.session.commit()
    print

    print cformat('%{white!}migrating rooms')
    for old_room_id, old_room in rb_root['Rooms'].iteritems():
        l = Location.find_first(name=old_room._locationName)
        r = Room(
            id=old_room_id,
            name=convert_to_unicode((old_room._name or '').strip() or generate_name(old_room)),
            site=convert_to_unicode(old_room.site),
            division=convert_to_unicode(old_room.division),
            building=convert_to_unicode(old_room.building),
            floor=convert_to_unicode(old_room.floor),
            number=convert_to_unicode(old_room.roomNr),

            notification_before_days=((old_room.resvStartNotificationBefore or None)
                                      if getattr(old_room, 'resvStartNotification', False)
                                      else None),
            notification_for_responsible=getattr(old_room, 'resvNotificationToResponsible', False),
            notification_for_assistance=getattr(old_room, 'resvNotificationAssistance', False),

            reservations_need_confirmation=old_room.resvsNeedConfirmation,

            telephone=old_room.telephone,
            key_location=convert_to_unicode(old_room.whereIsKey),

            capacity=old_room.capacity,
            surface_area=getattr(old_room, 'surfaceArea', None),
            latitude=getattr(old_room, 'latitude', None),
            longitude=getattr(old_room, 'longitude', None),

            comments=convert_to_unicode(old_room.comments),

            owner_id=avatar_id_map.get(old_room.responsibleId, old_room.responsibleId),

            is_active=old_room.isActive,
            is_reservable=old_room.isReservable,
            max_advance_days=int(old_room.maxAdvanceDays) if getattr(old_room, 'maxAdvanceDays', None) else None
        )

        print cformat('- [%{cyan}{}%{reset}] %{grey!}{:4}%{reset}  %{green!}{}%{reset}').format(l.name, r.id, r.name)

        for old_bookable_time in getattr(old_room, '_dailyBookablePeriods', []):
            r.bookable_hours.append(
                BookableHours(
                    start_time=old_bookable_time._startTime,
                    end_time=old_bookable_time._endTime
                )
            )
            print cformat('  %{blue!}Bookable:%{reset} {}').format(r.bookable_hours[-1])

        for old_nonbookable_date in getattr(old_room, '_nonBookableDates', []):
            r.nonbookable_periods.append(
                NonBookablePeriod(
                    start_dt=old_nonbookable_date._startDate,
                    end_dt=old_nonbookable_date._endDate
                )
            )
            print cformat('  %{blue!}Nonbookable:%{reset} {}').format(r.nonbookable_periods[-1])

        if photo_path:
            try:
                with open(os.path.join(photo_path, 'large_photos',
                          get_canonical_name_of(old_room) + '.jpg'), 'rb') as f:
                    large_photo = f.read()
            except Exception:
                large_photo = None

            try:
                with open(os.path.join(photo_path, 'small_photos',
                          get_canonical_name_of(old_room) + '.jpg'), 'rb') as f:
                    small_photo = f.read()
            except Exception:
                small_photo = None

            if large_photo and small_photo:
                r.photo = Photo(data=large_photo, thumbnail=small_photo)
                print cformat('  %{blue!}Photos')

        new_eq = []
        for old_equipment in ifilter(None, old_room._equipment.split('`') + old_room.avaibleVC):
            room_eq = l.get_equipment_by_name(old_equipment)
            new_eq.append(room_eq)
            r.available_equipment.append(room_eq)
        if new_eq:
            print cformat('  %{blue!}Equipment:%{reset} {}').format(', '.join(sorted(x.name for x in new_eq)))

        for attr_name, value in getattr(old_room, 'customAtts', {}).iteritems():
            value = convert_to_unicode(value)
            if not value or ('Simba' in attr_name and value == u'Error: unknown mailing list'):
                continue
            attr_name = attribute_map.get(attr_name, attr_name).replace(' ', '-').lower()
            ca = l.get_attribute_by_name(attr_name)
            if not ca:
                print cformat('  %{blue!}Attribute:%{reset} {} %{red!}not found').format(attr_name)
                continue
            attr = RoomAttributeAssociation()
            attr.value = value
            attr.attribute = ca
            r.attributes.append(attr)
            print cformat('  %{blue!}Attribute:%{reset} {} = {}').format(attr.attribute.title, attr.value)

        l.rooms.append(r)
        db.session.add(l)
        print
    db.session.commit()