Пример #1
0
    def set_booking_day_schema_ids(self):
        booking_days = [b.doc for b in getAllBookingDays(holly_couch)]
        for bdy in booking_days:
            if bdy["date"] <= "2012-07-22" or bdy["date"] > "2012<07-29":
                bdy["day_schema_id"] = "day_schema.2012"
                holly_couch[bdy["_id"]] = bdy

        raise redirect("/")
Пример #2
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)
Пример #3
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)
Пример #4
0
 def overview_all(self):
     """Show an overview of all booking days"""
     return dict(booking_days=[b.doc for b in getAllBookingDays(holly_couch)], makeDate=getDateObject)