def get_calendars_for_object(self, obj, distinction=None):
        """
        This function allows you to get calendars for a specific object

        If distinction is set it will filter out any relation that doesnt have
        that distinction.
        """
        ct = object_content_type(obj)
        if distinction:
            dist_q = Q(calendarrelation__distinction=distinction)
        else:
            dist_q = Q()
        return self.filter(dist_q, Q(calendarrelation__object_id=obj.id, calendarrelation__content_type=ct))
Пример #2
0
    def get_calendars_for_object(self, obj, distinction=None):
        """
        This function allows you to get calendars for a specific object

        If distinction is set it will filter out any relation that doesnt have
        that distinction.
        """
        ct = object_content_type(obj)
        if distinction:
            dist_q = Q(calendarrelation__distinction=distinction)
        else:
            dist_q = Q()
        return self.filter(
            dist_q,
            Q(calendarrelation__object_id=obj.id,
              calendarrelation__content_type=ct))
 def create_relation(self, calendar, content_object, distinction=None, inheritable=True):
     """
     Creates a relation between calendar and content_object.
     See CalendarRelation for help on distinction and inheritable
     """
     ct = object_content_type(content_object)
     object_id = content_object.id
     cr = CalendarRelation(
         content_type=ct,
         object_id=object_id,
         calendar=calendar,
         distinction=distinction,
         content_object=content_object
     )
     cr.save()
     return cr
Пример #4
0
 def create_relation(self,
                     calendar,
                     content_object,
                     distinction=None,
                     inheritable=True):
     """
     Creates a relation between calendar and content_object.
     See CalendarRelation for help on distinction and inheritable
     """
     ct = object_content_type(content_object)
     object_id = content_object.id
     cr = CalendarRelation(content_type=ct,
                           object_id=object_id,
                           calendar=calendar,
                           distinction=distinction,
                           content_object=content_object)
     cr.save()
     return cr