Skip to content

Commit

Permalink
POLIO-1252: remove deprecated field
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-le committed Dec 23, 2024
1 parent 6daf3e3 commit c38404d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugins/polio/api/rounds/round.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create(self, validated_data):
if started_at is not None or ended_at is not None:
reason_for_delay = ReasonForDelay.objects.filter(key_name="INITIAL_DATA").first()
datelog = RoundDateHistoryEntry.objects.create(
round=round, reason="INITIAL_DATA", reason_for_delay=reason_for_delay, modified_by=user
round=round, reason_for_delay=reason_for_delay, modified_by=user
)
if started_at is not None:
datelog.started_at = started_at
Expand Down Expand Up @@ -95,7 +95,7 @@ def update(self, instance, validated_data):
# Fallback on first reason available for account
reason_for_delay = ReasonForDelay.filter(account=account).first()
datelog = RoundDateHistoryEntry.objects.create(
round=instance, reason="INITIAL_DATA", reason_for_delay=reason_for_delay, modified_by=user
round=instance, reason_for_delay=reason_for_delay, modified_by=user
)
if datelog is not None:
# Replace instance with key_name to avoid validation error
Expand Down
8 changes: 1 addition & 7 deletions plugins/polio/api/shared_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Meta:
model = RoundDateHistoryEntry
fields = [
"created_at",
"reason",
"reason_for_delay",
"ended_at",
"started_at",
Expand Down Expand Up @@ -88,7 +87,6 @@ class Meta:
model = RoundDateHistoryEntry
fields = [
"created_at",
"reason",
"reason_for_delay",
"ended_at",
"started_at",
Expand All @@ -101,12 +99,8 @@ class Meta:
modified_by = UserSerializer(required=False, read_only=True)
round: Field = serializers.PrimaryKeyRelatedField(read_only=True, many=False)
reason_for_delay = ReasonForDelayFieldSerializer()
reason = serializers.SerializerMethodField()

@staticmethod
def get_reason(obj: RoundDateHistoryEntry):
return obj.reason_for_delay.key_name if obj.reason_for_delay else None


def validate(self, data):
if data.get("reason_for_delay", None) is None:
raise serializers.ValidationError("No reason provided")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.17 on 2024-12-23 16:18

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("polio", "0213_alter_vaccinerequestform_vaccine_type"),
]

operations = [
migrations.RemoveField(
model_name="rounddatehistoryentry",
name="reason",
),
]
2 changes: 0 additions & 2 deletions plugins/polio/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ class RoundDateHistoryEntry(models.Model):
previous_ended_at = models.DateField(null=True, blank=True)
started_at = models.DateField(null=True, blank=True)
ended_at = models.DateField(null=True, blank=True)
# Deprecated. Cannot be deleted until the PowerBI dashboards are updated to use reason_for_delay instead
reason = models.CharField(null=True, blank=True, choices=DelayReasons.choices, max_length=200)
reason_for_delay = models.ForeignKey(
"ReasonForDelay", on_delete=models.PROTECT, null=True, blank=True, related_name="round_history_entries"
)
Expand Down

0 comments on commit c38404d

Please sign in to comment.