Skip to content

Commit

Permalink
DBC22-1483: added subtype default, parse location before update queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd committed Jan 8, 2024
1 parent e4481ad commit 84f9ef9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.3 on 2024-01-08 23:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('event', '0011_event_closed'),
]

operations = [
migrations.AlterField(
model_name='event',
name='event_sub_type',
field=models.CharField(blank=True, default='', max_length=32),
),
]
2 changes: 1 addition & 1 deletion src/backend/apps/event/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Event(BaseModel):
# Description
description = models.CharField(max_length=1024)
event_type = models.CharField(max_length=32)
event_sub_type = models.CharField(max_length=32, blank=True)
event_sub_type = models.CharField(max_length=32, blank=True, default='')

# General status
status = models.CharField(max_length=32)
Expand Down
8 changes: 7 additions & 1 deletion src/backend/apps/event/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ def build_data_diff(current_obj, new_obj_data):
current_field_data = getattr(current_obj, field)
new_field_data = new_obj_data[field] if field in new_obj_data else None
if not compare_data(current_field_data, new_field_data):
data_diff[field] = new_field_data
if field == 'location':
# {'coordinates': [-122.601346, 49.143921], 'type': 'Point'}
locationCls = Point if new_field_data['type'] == 'Point' else LineString
data_diff[field] = locationCls(new_field_data['coordinates'])

else:
data_diff[field] = new_field_data

return data_diff

Expand Down

0 comments on commit 84f9ef9

Please sign in to comment.