Ejemplo n.º 1
0
 def overview(self):
     """Show an overview of all bookings"""
     scheduled_bookings = [b.doc for b in getAllScheduledBookings(holly_couch)]
     unscheduled_bookings = [b.doc for b in getAllUnscheduledBookings(holly_couch)]
     
     #...I need a map from booking_day_id to booking day date and from [booking_day_i, slot_id] to time.
     #   actually, I do thin couch could create such a view, it's just going to be very messy 
     # TODO: in the future we cant use a hard coded day schema, we will need one map for each day schema that exists.
     return dict(scheduled_bookings=scheduled_bookings,  unscheduled_bookings=unscheduled_bookings,  workflow_map=workflow_map,  activity_map=getActivityTitleMap(holly_couch),  booking_date_map=getBookingDayInfoMap(holly_couch),  user_name_map=getUserNameMap(holly_couch), slot_map=getSchemaSlotActivityMap(holly_couch, 'day_schema.1'),  workflow_submenu=workflow_submenu)
Ejemplo n.º 2
0
    def sanity_check_property_usage(self):

        # ...iterate through all bookings, we are only interested in scheduled bookings
        bookings = getAllScheduledBookings(holly_couch, limit=1000000)
        booking_days_map = dict()
        for bd in getAllBookingDays(holly_couch):
            booking_days_map[bd.doc["_id"]] = bd.doc

        visiting_group_map = dict()
        for vg in getAllVisitingGroups(holly_couch):
            visiting_group_map[vg.key[1]] = vg.doc

        # activity_map = dict()
        activity_title_map = getActivityTitleMap(holly_couch)

        problems = list()
        for tmp_bx in bookings:
            tmp_b = tmp_bx.doc
            tmp_b_day_id = tmp_b["booking_day_id"]
            tmp_b_day = booking_days_map[tmp_b_day_id]

            #    if not activity_map.has_key(tmp_b_day['day_schema_id']):
            #        activity_map[tmp_b_day['day_schema_id']] = getSchemaSlotActivityMap(holly_couch, tmp_b_day['day_schema_id'])

            #    tmp_activity_map = activity_map[tmp_b_day['day_schema_id']]

            if None != tmp_b_day:  # and tmp_b_day.date >= datetime.date.today():
                if tmp_b["visiting_group_id"] != "" and (False == tmp_b.get("hide_warn_on_suspect_booking", False)):
                    tmp_date = tmp_b_day["date"]
                    tmp_content = activity_title_map[tmp_b["activity_id"]] + " " + tmp_b["content"]
                    tmp_b_visiting_group = visiting_group_map[tmp_b["visiting_group_id"]]

                    if not tmp_b_visiting_group.has_key("from_date"):
                        problems.append(
                            dict(
                                booking=tmp_b,
                                msg="visiting group %s has no from_date" % tmp_b_visiting_group["visiting_group_name"],
                                severity=100,
                            )
                        )
                    else:
                        if tmp_b_visiting_group["from_date"] > tmp_date:
                            problems.append(
                                dict(
                                    booking=tmp_b,
                                    msg="arrives at %s but booking %s is at %s"
                                    % (str(tmp_b_visiting_group["from_date"]), tmp_content, str(tmp_date)),
                                    severity=10,
                                )
                            )

                        if tmp_b_visiting_group["from_date"] == tmp_date:
                            problems.append(
                                dict(
                                    booking=tmp_b,
                                    msg="arrives same day as booking %s, at %s"
                                    % (tmp_content, str(tmp_b_visiting_group["from_date"])),
                                    severity=self.get_severity(tmp_b_visiting_group, 1),
                                )
                            )

                    if tmp_b_visiting_group["to_date"] < tmp_date:
                        problems.append(
                            dict(
                                booking=tmp_b,
                                msg="leves at %s but booking %s is at %s"
                                % (str(tmp_b_visiting_group["to_date"]), tmp_content, str(tmp_date)),
                                severity=10,
                            )
                        )

                    if tmp_b_visiting_group["to_date"] == tmp_date:
                        problems.append(
                            dict(
                                booking=tmp_b,
                                msg="leves same day as booking %s, at %s"
                                % (tmp_content, str(tmp_b_visiting_group["to_date"])),
                                severity=self.get_severity(tmp_b_visiting_group, 1),
                            )
                        )

                    tmp_content = tmp_b["content"]
                    for tmp_prop in tmp_b_visiting_group["visiting_group_properties"].values():
                        checks = [x + tmp_prop["property"] for x in ["$$", "$", "$#", "#"]]

                        for check in checks:
                            if check in tmp_content:
                                if tmp_prop["from_date"] > tmp_date:
                                    problems.append(
                                        dict(
                                            booking=tmp_b,
                                            msg="property $"
                                            + tmp_prop["property"]
                                            + " usable from "
                                            + str(tmp_prop["from_date"])
                                            + " but booking is at "
                                            + str(tmp_date),
                                            severity=10,
                                        )
                                    )

                                if tmp_prop["from_date"] == tmp_date:
                                    problems.append(
                                        dict(
                                            booking=tmp_b,
                                            msg="property $"
                                            + tmp_prop["property"]
                                            + " arrives at "
                                            + str(tmp_prop["from_date"])
                                            + " and booking is the same day",
                                            severity=self.get_severity(tmp_b_visiting_group, 1),
                                        )
                                    )

                                if tmp_prop["to_date"] < tmp_date:
                                    problems.append(
                                        dict(
                                            booking=tmp_b,
                                            msg="property $"
                                            + tmp_prop["property"]
                                            + " usable to "
                                            + str(tmp_prop["to_date"])
                                            + " but booking is at "
                                            + str(tmp_date),
                                            severity=10,
                                        )
                                    )

                                if tmp_prop["to_date"] == tmp_date:
                                    problems.append(
                                        dict(
                                            booking=tmp_b,
                                            msg="property $"
                                            + tmp_prop["property"]
                                            + " leavs at "
                                            + str(tmp_prop["to_date"])
                                            + " and booking is the same day ",
                                            severity=self.get_severity(tmp_b_visiting_group, 1),
                                        )
                                    )

                                break  # there can be more than one match in checks
        problems.sort(self.fn_sort_problems_by_severity)
        return dict(problems=problems, visiting_group_map=visiting_group_map)
Ejemplo n.º 3
0
    def sanity_check_property_usage(self):
        log.info("sanity_check_property_usage()")
        ##ensurePostRequest(request, __name__)
        #...iterate through all bookings, we are only interested in scheduled bookings
        bookings = getAllScheduledBookings(holly_couch, limit=1000000)
        booking_days_map = dict()
        for bd in getAllBookingDays(holly_couch):
            booking_days_map[bd.doc['_id']] = bd.doc

        visiting_group_map = dict()
        for vg in getAllVisitingGroups(holly_couch):
            visiting_group_map[vg.key[1]] = vg.doc

        #activity_map = dict()
        activity_title_map = getActivityTitleMap(holly_couch)

        problems = list()
        for tmp_bx in bookings:
            tmp_b = tmp_bx.doc
            tmp_b_day_id = tmp_b['booking_day_id']
            tmp_b_day = booking_days_map[tmp_b_day_id]

        #    if not activity_map.has_key(tmp_b_day['day_schema_id']):
        #        activity_map[tmp_b_day['day_schema_id']] = getSchemaSlotActivityMap(holly_couch, tmp_b_day['day_schema_id'])

        #    tmp_activity_map = activity_map[tmp_b_day['day_schema_id']]

            if None != tmp_b_day: # and tmp_b_day.date >= datetime.date.today():
                if tmp_b['visiting_group_id'] != '' and (False == tmp_b.get('hide_warn_on_suspect_booking',  False)):
                    tmp_date = tmp_b_day['date']
                    tmp_content = activity_title_map[tmp_b['activity_id']] + ' ' + tmp_b['content']
                    tmp_b_visiting_group = visiting_group_map[tmp_b['visiting_group_id']]


                    if not tmp_b_visiting_group.has_key('from_date'):
                        problems.append(dict(booking=tmp_b, msg='visiting group %s has no from_date' % tmp_b_visiting_group['visiting_group_name'], severity=100))
                    else:
                        if tmp_b_visiting_group['from_date'] > tmp_date:
                            problems.append(dict(booking=tmp_b, msg='arrives at %s but booking %s is at %s' %(str(tmp_b_visiting_group['from_date']), tmp_content ,str(tmp_date)), severity=10))

                        if tmp_b_visiting_group['from_date'] == tmp_date:
                            problems.append(dict(booking=tmp_b, msg='arrives same day as booking %s, at %s' % (tmp_content, str(tmp_b_visiting_group['from_date'])), severity=self.get_severity(tmp_b_visiting_group, 1)))

                    if tmp_b_visiting_group['to_date'] < tmp_date:
                        problems.append(dict(booking=tmp_b, msg='leves at %s but booking %s is at %s' % (str(tmp_b_visiting_group['to_date']), tmp_content , str(tmp_date)), severity=10))

                    if tmp_b_visiting_group['to_date'] == tmp_date:
                        problems.append(dict(booking=tmp_b, msg='leves same day as booking %s, at %s' % (tmp_content, str(tmp_b_visiting_group['to_date'])), severity=self.get_severity(tmp_b_visiting_group, 1)))

                    tmp_content = tmp_b['content']
                    for tmp_prop in tmp_b_visiting_group['visiting_group_properties'].values():
                        checks = [x+tmp_prop['property'] for x in ['$$','$',  '$#','#']]

                        for check in checks:
                            if check in tmp_content:
                                if tmp_prop['from_date'] > tmp_date:
                                    problems.append(dict(booking=tmp_b, msg='property $' + tmp_prop['property'] + ' usable from ' + str(tmp_prop['from_date']) + ' but booking is at ' + str(tmp_date), severity=10))

                                if tmp_prop['from_date'] == tmp_date:
                                    problems.append(dict(booking=tmp_b, msg='property $' + tmp_prop['property'] + ' arrives at ' + str(tmp_prop['from_date']) + ' and booking is the same day', severity=self.get_severity(tmp_b_visiting_group, 1)))

                                if tmp_prop['to_date'] < tmp_date:
                                    problems.append(dict(booking=tmp_b, msg='property $' + tmp_prop['property'] + ' usable to ' + str(tmp_prop['to_date']) + ' but booking is at ' + str(tmp_date), severity=10))

                                if tmp_prop['to_date'] == tmp_date:
                                    problems.append(dict(booking=tmp_b, msg='property $' + tmp_prop['property'] + ' leavs at ' + str(tmp_prop['to_date']) + ' and booking is the same day ', severity=self.get_severity(tmp_b_visiting_group, 1)))

                                break # there can be more than one match in checks
        problems.sort(self.fn_sort_problems_by_severity)
        return dict (problems=problems,  visiting_group_map=visiting_group_map)
Ejemplo n.º 4
0
 def view_scheduled(self):
     scheduled_bookings = [b.doc for b in getAllScheduledBookings(holly_couch)] 
     return dict(scheduled_bookings=scheduled_bookings, workflow_map=workflow_map, result_title='Schedueld bookings',  activity_map=getActivityTitleMap(holly_couch), booking_date_map=getBookingDayInfoMap(holly_couch), user_name_map=getUserNameMap(holly_couch), slot_map=getSchemaSlotActivityMap(holly_couch, 'day_schema.1'), workflow_submenu=workflow_submenu)