prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Schedule Editor does not clear extra fields on existing items
  When replacing an existing item in the schedule editor, the notes, css_class and details fields are not replaced or cleared.
  
  While this can be useful to leave css_class untouched, it is surprising behaviour and usually the wrong thing to do for notes  and details. 
  
  I think we must clear notes and details when this happens.
  
  We should probably clear all extra fields when replacing an item, for the sake of predictablity,
  
  
  </issue>
  <code>
  [start of wafer/schedule/serializers.py]
  1 from rest_framework import serializers
  2 
  3 from wafer.talks.models import Talk
  4 from wafer.pages.models import Page
  5 from wafer.schedule.models import ScheduleItem, Venue, Slot
  6 
  7 
  8 class ScheduleItemSerializer(serializers.HyperlinkedModelSerializer):
  9     page = serializers.PrimaryKeyRelatedField(
  10         allow_null=True, queryset=Page.objects.all())
  11     talk = serializers.PrimaryKeyRelatedField(
  12         allow_null=True, queryset=Talk.objects.all())
  13     venue = serializers.PrimaryKeyRelatedField(
  14         allow_null=True, queryset=Venue.objects.all())
  15     slots = serializers.PrimaryKeyRelatedField(
  16         allow_null=True, many=True, queryset=Slot.objects.all())
  17 
  18     class Meta:
  19         model = ScheduleItem
  20         fields = ('id', 'talk', 'page', 'venue', 'slots')
  21 
  22     def create(self, validated_data):
  23         venue_id = validated_data['venue']
  24         slots = validated_data['slots']
  25         talk = validated_data.get('talk')
  26         page = validated_data.get('page')
  27 
  28         try:
  29             existing_schedule_item = ScheduleItem.objects.get(
  30                 venue_id=venue_id, slots__in=slots)
  31         except ScheduleItem.DoesNotExist:
  32             pass
  33         else:
  34             existing_schedule_item.talk = talk
  35             existing_schedule_item.page = page
  36             existing_schedule_item.slots = slots
  37             existing_schedule_item.save()
  38             return existing_schedule_item
  39         return super(ScheduleItemSerializer, self).create(validated_data)
  40 
  41 
  42
  [end of wafer/schedule/serializers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/wafer/schedule/serializers.py b/wafer/schedule/serializers.py
  --- a/wafer/schedule/serializers.py
  +++ b/wafer/schedule/serializers.py
  @@ -34,6 +34,12 @@
               existing_schedule_item.talk = talk
               existing_schedule_item.page = page
               existing_schedule_item.slots = slots
  +            # Clear any existing details that aren't editable by the
  +            # schedule edit view
  +            existing_schedule_item.details = ''
  +            existing_schedule_item.notes = ''
  +            existing_schedule_item.css_class = ''
  +            existing_schedule_item.expand = False
               existing_schedule_item.save()
               return existing_schedule_item
           return super(ScheduleItemSerializer, self).create(validated_data)
  
verification_info: {"golden_diff": "diff --git a/wafer/schedule/serializers.py b/wafer/schedule/serializers.py\n--- a/wafer/schedule/serializers.py\n+++ b/wafer/schedule/serializers.py\n@@ -34,6 +34,12 @@\n             existing_schedule_item.talk = talk\n             existing_schedule_item.page = page\n             existing_schedule_item.slots = slots\n+            # Clear any existing details that aren't editable by the\n+            # schedule edit view\n+            existing_schedule_item.details = ''\n+            existing_schedule_item.notes = ''\n+            existing_schedule_item.css_class = ''\n+            existing_schedule_item.expand = False\n             existing_schedule_item.save()\n             return existing_schedule_item\n         return super(ScheduleItemSerializer, self).create(validated_data)\n", "issue": "Schedule Editor does not clear extra fields on existing items\nWhen replacing an existing item in the schedule editor, the notes, css_class and details fields are not replaced or cleared.\n\nWhile this can be useful to leave css_class untouched, it is surprising behaviour and usually the wrong thing to do for notes  and details. \n\nI think we must clear notes and details when this happens.\n\nWe should probably clear all extra fields when replacing an item, for the sake of predictablity,\n\n", "before_files": [{"content": "from rest_framework import serializers\n\nfrom wafer.talks.models import Talk\nfrom wafer.pages.models import Page\nfrom wafer.schedule.models import ScheduleItem, Venue, Slot\n\n\nclass ScheduleItemSerializer(serializers.HyperlinkedModelSerializer):\n    page = serializers.PrimaryKeyRelatedField(\n        allow_null=True, queryset=Page.objects.all())\n    talk = serializers.PrimaryKeyRelatedField(\n        allow_null=True, queryset=Talk.objects.all())\n    venue = serializers.PrimaryKeyRelatedField(\n        allow_null=True, queryset=Venue.objects.all())\n    slots = serializers.PrimaryKeyRelatedField(\n        allow_null=True, many=True, queryset=Slot.objects.all())\n\n    class Meta:\n        model = ScheduleItem\n        fields = ('id', 'talk', 'page', 'venue', 'slots')\n\n    def create(self, validated_data):\n        venue_id = validated_data['venue']\n        slots = validated_data['slots']\n        talk = validated_data.get('talk')\n        page = validated_data.get('page')\n\n        try:\n            existing_schedule_item = ScheduleItem.objects.get(\n                venue_id=venue_id, slots__in=slots)\n        except ScheduleItem.DoesNotExist:\n            pass\n        else:\n            existing_schedule_item.talk = talk\n            existing_schedule_item.page = page\n            existing_schedule_item.slots = slots\n            existing_schedule_item.save()\n            return existing_schedule_item\n        return super(ScheduleItemSerializer, self).create(validated_data)\n\n\n", "path": "wafer/schedule/serializers.py"}]}