def get_or_create(self, calendar, data):
     uri = data.id.text
     try:
         result = self.get(uri = uri)
     except self.model.DoesNotExist:
         result = self.model(calendar = calendar)
     result.title = data.title.text or ''
     result.content = data.content.text or ''
     result.start_time = parse_date_w3dtf(data.when[0].start_time)
     result.end_time = parse_date_w3dtf(data.when[0].end_time)
     result.edit_uri = data.GetEditLink().href
     result.view_uri = data.GetHtmlLink().href
     return result
Beispiel #2
0
 def get_or_create(self, calendar, data):
     uri = data.id.text
     try:
         result = self.get(uri=uri)
     except self.model.DoesNotExist:
         result = self.model(calendar=calendar)
     result.title = data.title.text or ''
     result.content = data.content.text or ''
     result.start_time = parse_date_w3dtf(data.when[0].start_time)
     result.end_time = parse_date_w3dtf(data.when[0].end_time)
     result.edit_uri = data.GetEditLink().href
     result.view_uri = data.GetHtmlLink().href
     return result
Beispiel #3
0
    def from_gcal(self, calendar, data, commit=True):
        uri = data.id.text
        try:
            instance = self.get(uri = uri)
        except self.model.DoesNotExist:
            instance = self.model(calendar = calendar, uri = uri)

        instance.title = data.title.text or ''
        instance.summary = data.content.text or ''
        instance.start_time = parse_date_w3dtf(data.when[0].start_time)
        instance.end_time = parse_date_w3dtf(data.when[0].end_time)
        instance.edit_uri = data.GetEditLink().href
        instance.view_uri = data.GetHtmlLink().href

        if commit:
            instance.save()

        return instance