Project

General

Profile

« Previous | Next » 

Revision 98b28661

Added by Serghei Mihai about 10 years ago

agenda: handling cases when the event has no act associated

View differences:

calebasse/agenda/managers.py
100 100
        at the same time and have the same act type
101 101
        """
102 102
        date_time = date_time or datetime.now()
103
        events = events or self.today_occurrences(date_time.date())
103
        if events is None:
104
            events = self.today_occurrences(date_time.date())
104 105
        overlap = filter(lambda e: e.start_datetime <= date_time and e.end_datetime > date_time, events)
105 106
        same_type_events = []
106 107
        different_overlap = []
107 108
        for event in overlap:
108 109
            if different_overlap:
109 110
                for e in different_overlap:
110
                    if event.start_datetime == e.start_datetime and \
111
                       event.end_datetime == e.end_datetime and \
112
                       event.act_type == e.act_type:
111
                    try:
112
                        if event.start_datetime == e.start_datetime and \
113
                           event.end_datetime == e.end_datetime and \
114
                           event.act_type == e.act_type:
115
                            continue
116
                        different_overlap.append(event)
117
                    except AttributeError:
113 118
                        continue
114
                    different_overlap.append(event)
115 119
            else:
116 120
                different_overlap.append(event)
117 121
        return different_overlap

Also available in: Unified diff