Skip to content

Commit

Permalink
PR Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Nov 11, 2024
1 parent 3646af8 commit 69bacc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions apps/geo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@


class Region(UserResource):
class Status(models.TextChoices):
INITIATED = 'initiated', 'Initiated'
PENDING = 'pending', 'Pending'
COMPLETED = 'completed', 'Completed'
FAILED = 'failed', 'Failed'
class Status(models.IntegerChoices):
INITIATED = 0, 'Initiated'
PENDING = 1, 'Pending'
COMPLETED = 2, 'Completed'
FAILED = 3, 'Failed'
"""
Region model
Expand All @@ -40,7 +40,7 @@ class Status(models.TextChoices):
cache_index = models.SmallIntegerField(default=0) # Used to track cache update.
centroid = models.PointField(blank=True, null=True) # Admin level 0 centroid
geo_options = models.JSONField(default=None, blank=True, null=True)
status = models.CharField(max_length=30, choices=Status.choices, default=Status.PENDING)
status = models.PositiveSmallIntegerField(choices=Status.choices, default=Status.PENDING)

def __init__(self, *args, **kwargs):
self.id: Union[int, None]
Expand Down
5 changes: 4 additions & 1 deletion apps/geo/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ def _load_geo_areas(region_id):
Basically, it starts with root admin level and iterate through all the
children.
"""
region = Region.objects.get(pk=region_id)
region = Region.objects.filter(pk=region_id).first()
if not region:
logger.error("Region not found", exc_info=True)
return False
try:
with reversion.create_revision():
if AdminLevel.objects.filter(region=region).count() == 0:
Expand Down

0 comments on commit 69bacc8

Please sign in to comment.