Skip to content

Commit 41be0d4

Browse files
committed
Add surge_alert_id to serializers of Personnel
1 parent e6a7b38 commit 41be0d4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

deployments/drf_views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def get_renderer_context(self):
222222
"deployment.event_deployed_to.countries.region",
223223
"role",
224224
"type",
225+
"surge_alert_id",
225226
]
226227
if not self.request.user.is_anonymous:
227228
context["header"] += ["name"]
@@ -275,6 +276,7 @@ def get_renderer_context(self):
275276
context["labels"]["country_from.iso3"] = "deployed_from_iso3"
276277
context["labels"]["country_from.society_name"] = "deployed_from_nationalsociety"
277278
context["labels"]["country_from.region"] = "deployed_from_regionname"
279+
context["labels"]["surge_alert_id"] = "surge_alert_id"
278280

279281
# https://github.com/mjumbewu/django-rest-framework-csv/blob/master/rest_framework_csv/renderers.py#L226-L229 uses bom when required:
280282
context["bom"] = True

deployments/serializers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class Meta:
144144
fields = (
145145
'start_date', 'end_date', 'role', 'type', 'country_from', 'country_to',
146146
'deployment', 'molnix_id', 'molnix_tags', 'is_active', 'id',
147+
'surge_alert_id',
147148
'name', # plus
148149
)
149150

@@ -160,6 +161,7 @@ class Meta:
160161
fields = (
161162
'start_date', 'end_date', 'role', 'type', 'country_from', 'country_to',
162163
'deployment', 'molnix_id', 'molnix_tags', 'is_active', 'id',
164+
'surge_alert_id',
163165
)
164166

165167

@@ -175,10 +177,12 @@ class Meta:
175177
fields = (
176178
'start_date', 'end_date', 'role', 'type', 'country_from', 'country_to',
177179
'deployment', 'molnix_id', 'molnix_tags', 'is_active', 'id',
180+
'surge_alert_id',
178181
'name', 'molnix_status', # 2 plus
179182
)
180183

181184

185+
# Don't forget to adapt drf_views::get_renderer_context if you change this:
182186
class PersonnelCsvSerializerBase(ModelSerializer):
183187
country_from = NanoCountrySerializer()
184188
country_to = NanoCountrySerializer()
@@ -194,6 +198,7 @@ class PersonnelCsvSerializerBase(ModelSerializer):
194198
inactive_status = serializers.SerializerMethodField()
195199
start_date = serializers.SerializerMethodField()
196200
end_date = serializers.SerializerMethodField()
201+
surge_alert_id = serializers.SerializerMethodField()
197202

198203
@staticmethod
199204
def get_start_date(obj):
@@ -242,6 +247,10 @@ def get_ongoing(obj):
242247
end = obj.end_date if obj.end_date else today
243248
return start <= today <= end
244249

250+
@staticmethod
251+
def get_surge_alert_id(obj):
252+
return obj.surge_alert_id
253+
245254

246255
# 3 versions: a "regular", an Anon(yme) and a Super(user) class:
247256
class PersonnelCsvSerializer(PersonnelCsvSerializerBase):
@@ -256,6 +265,7 @@ class Meta:
256265
'deployment', 'id', 'is_active', 'molnix_sector', 'molnix_id',
257266
'molnix_role_profile', 'molnix_language', 'molnix_region', 'molnix_scope',
258267
'molnix_modality', 'molnix_operation', 'ongoing', 'inactive_status',
268+
'surge_alert_id',
259269
)
260270

261271

@@ -270,6 +280,7 @@ class Meta:
270280
'deployment', 'id', 'is_active', 'molnix_sector', 'molnix_id',
271281
'molnix_role_profile', 'molnix_language', 'molnix_region', 'molnix_scope',
272282
'molnix_modality', 'molnix_operation', 'ongoing', 'inactive_status',
283+
'surge_alert_id',
273284
)
274285

275286

@@ -286,6 +297,7 @@ class Meta:
286297
'molnix_status', # plus
287298
'molnix_role_profile', 'molnix_language', 'molnix_region', 'molnix_scope',
288299
'molnix_modality', 'molnix_operation', 'ongoing', 'inactive_status',
300+
'surge_alert_id',
289301
)
290302

291303

0 commit comments

Comments
 (0)