X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/9e740fe6e535570620ddda6edf6fe6398e579079..82b08f79564159d7acbcaf255ed1ac1fb4882e64:/contrib/julian/models.py?ds=inline diff --git a/contrib/julian/models.py b/contrib/julian/models.py index 0653363..5c49c7e 100644 --- a/contrib/julian/models.py +++ b/contrib/julian/models.py @@ -79,10 +79,10 @@ class TimedModel(models.Model): raise ValidationError("A %s cannot end before it starts." % self.__class__.__name__) def get_start(self): - return self.start_date + return datetime.datetime.combine(self.start_date, self.start_time) if self.start_time else self.start_date def get_end(self): - return self.end_date + return datetime.datetime.combine(self.end_date, self.end_time) if self.end_time else self.end_date class Meta: abstract = True @@ -121,12 +121,20 @@ class Event(Entity, TimedModel): created = models.DateTimeField(auto_now_add=True) last_modified = models.DateTimeField(auto_now=True) - uuid = models.TextField() # Format? + + site = models.ForeignKey(Site, default=DEFAULT_SITE) + + @property + def uuid(self): + return "%s@%s" % (self.created.isoformat(), getattr(self.site, 'domain', 'None')) objects = EventManager() def __unicode__(self): return self.name + + class Meta: + unique_together = ('site', 'created') class Calendar(Entity): @@ -141,6 +149,11 @@ class Calendar(Entity): def __unicode__(self): return self.name + @property + def fpi(self): + # See http://xml.coverpages.org/tauber-fpi.html or ISO 9070:1991 for format information. + return "-//%s//%s//%s" % (self.site.name, self.name, self.language.split('-')[0].upper()) + class Meta: unique_together = ('name', 'site', 'language') @@ -398,9 +411,7 @@ class CalendarView(FeedView): return "" def feed_guid(self, obj): - # Is this correct? Should I have a different id for different subfeeds? - # See http://xml.coverpages.org/tauber-fpi.html for format. - return "-//%s//%s %s//%s" % (obj.site.name.upper(), self.feed_type.upper(), obj.name.upper(), obj.language.upper()) + return obj.fpi def description(self, obj): return obj.description