Skip to content

Commit

Permalink
overridden typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
quesadas committed Oct 17, 2023
1 parent 0af4cb6 commit 7b807c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions csm_web/scheduler/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,11 @@ class OverrideAdmin(BasePermissionModelAdmin):
fields = (
"date",
"spacetime",
"overriden_spacetime",
"overridden_spacetime",
)
autocomplete_fields = (
"spacetime",
"overriden_spacetime",
"overridden_spacetime",
)

list_filter = (
Expand All @@ -922,5 +922,5 @@ def get_old_spacetime(self, obj: Override):
def get_new_spacetime(self, obj: Override):
"""Format link to new spacetime object."""
return get_admin_link_for(
obj.overriden_spacetime, "admin:scheduler_spacetime_change"
obj.overridden_spacetime, "admin:scheduler_spacetime_change"
)
4 changes: 2 additions & 2 deletions csm_web/scheduler/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def date(self):
date = evaluate_faker(
factory.Faker(
"date_between_dates",
date_start=self.overriden_spacetime.section.mentor.course.enrollment_start.date(),
date_end=self.overriden_spacetime.section.mentor.course.valid_until,
date_start=self.overridden_spacetime.section.mentor.course.enrollment_start.date(),
date_end=self.overridden_spacetime.section.mentor.course.valid_until,
)
)
return date + timedelta(
Expand Down
6 changes: 3 additions & 3 deletions csm_web/scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,14 @@ class Override(ValidatingModel):
spacetime = models.OneToOneField(
Spacetime, on_delete=models.CASCADE, related_name="+"
)
overriden_spacetime = models.OneToOneField(
overridden_spacetime = models.OneToOneField(
Spacetime, related_name="_override", on_delete=models.CASCADE
)
date = models.DateField()

def clean(self):
super().clean()
if self.spacetime == self.overriden_spacetime:
if self.spacetime == self.overridden_spacetime:
raise ValidationError("A spacetime cannot override itself")
if self.spacetime.day_of_week != self.date.strftime("%A"):
raise ValidationError(
Expand All @@ -548,7 +548,7 @@ def is_expired(self):
return self.date < now.date()

def __str__(self):
return f"Override for {self.overriden_spacetime.section} : {self.spacetime}"
return f"Override for {self.overridden_spacetime.section} : {self.spacetime}"


class Matcher(ValidatingModel):
Expand Down
10 changes: 5 additions & 5 deletions csm_web/scheduler/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ def create(self, validated_data):
spacetime = Spacetime.objects.create(
**validated_data["spacetime"],
day_of_week=DayOfWeekField.DAYS[validated_data["date"].weekday()],
duration=validated_data["overriden_spacetime"].duration,
duration=validated_data["overridden_spacetime"].duration,
)
return Override.objects.create(
date=validated_data["date"],
overriden_spacetime=validated_data["overriden_spacetime"],
overridden_spacetime=validated_data["overridden_spacetime"],
spacetime=spacetime,
)

Expand All @@ -366,15 +366,15 @@ def update(self, instance, validated_data):
]
instance.spacetime.location = spacetime_data["location"]
instance.spacetime.start_time = spacetime_data["start_time"]
instance.spacetime.duration = instance.overriden_spacetime.duration
instance.spacetime.duration = instance.overridden_spacetime.duration
instance.spacetime.save()
instance.save()
return instance

class Meta:
model = Override
fields = ("location", "start_time", "date", "overriden_spacetime")
extra_kwargs = {"overriden_spacetime": {"required": False}}
fields = ("location", "start_time", "date", "overridden_spacetime")
extra_kwargs = {"overridden_spacetime": {"required": False}}


class MatcherSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit 7b807c3

Please sign in to comment.