Changeset - ddc355365609
[Not reviewed]
0 1 0
Martey Dodoo - 9 years ago 2015-12-31 17:35:22
martey@mobolic.com
Remove duplicate Slot.save method.

Remove "save" method in Slot model since #107 added another "save"
method. This fixes the automated test failures in Travis CI.
1 file changed with 0 insertions and 4 deletions:
0 comments (0 inline, 0 general)
symposion/schedule/models.py
Show inline comments
...
 
@@ -45,100 +45,96 @@ class Day(models.Model):
 
        verbose_name = _("date")
 
        verbose_name_plural = _("dates")
 

	
 

	
 
@python_2_unicode_compatible
 
class Room(models.Model):
 

	
 
    schedule = models.ForeignKey(Schedule, verbose_name=_("Schedule"))
 
    name = models.CharField(max_length=65, verbose_name=_("Name"))
 
    order = models.PositiveIntegerField(verbose_name=_("Order"))
 

	
 
    def __str__(self):
 
        return self.name
 

	
 
    class Meta:
 
        verbose_name = _("Room")
 
        verbose_name_plural = _("Rooms")
 

	
 

	
 
@python_2_unicode_compatible
 
class SlotKind(models.Model):
 
    """
 
    A slot kind represents what kind a slot is. For example, a slot can be a
 
    break, lunch, or X-minute talk.
 
    """
 

	
 
    schedule = models.ForeignKey(Schedule, verbose_name=_("schedule"))
 
    label = models.CharField(max_length=50, verbose_name=_("Label"))
 

	
 
    def __str__(self):
 
        return self.label
 

	
 
    class Meta:
 
        verbose_name = _("Slot kind")
 
        verbose_name_plural = _("Slot kinds")
 

	
 

	
 
@python_2_unicode_compatible
 
class Slot(models.Model):
 

	
 
    name = models.CharField(max_length=100, editable=False)
 
    day = models.ForeignKey(Day, verbose_name=_("Day"))
 
    kind = models.ForeignKey(SlotKind, verbose_name=_("Kind"))
 
    start = models.TimeField(verbose_name=_("Start"))
 
    end = models.TimeField(verbose_name=_("End"))
 
    content_override = models.TextField(blank=True, verbose_name=_("Content override"))
 
    content_override_html = models.TextField(blank=True)
 

	
 
    def save(self, *args, **kwargs):
 
        self.content_override_html = parse(self.content_override)
 
        return super(Slot, self).save(*args, **kwargs)
 

	
 
    def assign(self, content):
 
        """
 
        Assign the given content to this slot and if a previous slot content
 
        was given we need to unlink it to avoid integrity errors.
 
        """
 
        self.unassign()
 
        content.slot = self
 
        content.save()
 

	
 
    def unassign(self):
 
        """
 
        Unassign the associated content with this slot.
 
        """
 
        content = self.content
 
        if content and content.slot_id:
 
            content.slot = None
 
            content.save()
 

	
 
    @property
 
    def content(self):
 
        """
 
        Return the content this slot represents.
 
        @@@ hard-coded for presentation for now
 
        """
 
        try:
 
            return self.content_ptr
 
        except ObjectDoesNotExist:
 
            return None
 

	
 
    @property
 
    def start_datetime(self):
 
        return datetime.datetime(
 
            self.day.date.year,
 
            self.day.date.month,
 
            self.day.date.day,
 
            self.start.hour,
 
            self.start.minute)
 

	
 
    @property
 
    def end_datetime(self):
 
        return datetime.datetime(
 
            self.day.date.year,
 
            self.day.date.month,
 
            self.day.date.day,
 
            self.end.hour,
 
            self.end.minute)
 

	
 
    @property
0 comments (0 inline, 0 general)