Skip to content

Commit 143f59b

Browse files
committed
Add "Order" field to community downloads and filter events from the last six months
1 parent 53f7857 commit 143f59b

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

src/api/store/download.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ def _cc_actions_download(self, community_id):
22422242

22432243
def _community_vendors_download(self, community_id):
22442244
vendors = Vendor.objects.filter(communities__id=community_id, is_deleted=False, is_published=True)
2245-
columns = ["Name", "Logo", "Description", "Website", "Key Contact", "Key Contact Email", "Communities Serviced", "Service Area"]
2245+
columns = ["Name", "Logo", "Description", "Website", "Key Contact", "Key Contact Email", "Communities Serviced", "Service Area", "Order"]
22462246
data = [columns]
22472247
for vendor in vendors:
22482248
image_url = vendor.logo.file.url if vendor.logo else ""
@@ -2257,14 +2257,16 @@ def _community_vendors_download(self, community_id):
22572257
"Key Contact Email": key_contact.get("email") if key_contact else "",
22582258
"Communities Serviced": ", ".join([community.name for community in vendor.communities.all()]),
22592259
"Service Area": vendor.service_area,
2260+
"Order":vendor.id,
22602261
})
22612262
data.append(cell)
22622263
return data
22632264

22642265

22652266
def _community_events_download(self, community_id):
2266-
events = Event.objects.filter(community__id=community_id, is_deleted=False, is_published=True)
2267-
columns = ["Title", "Description", "Start Date", "End Date", "Location", "Event Type", "Link", "Image", "Tags"]
2267+
six_months_ago = timezone.now() - datetime.timedelta(days=180)
2268+
events = Event.objects.filter(community__id=community_id, is_deleted=False, is_published=True, start_date_and_time__gte=six_months_ago)
2269+
columns = ["Title", "Description", "Start Date", "End Date", "Location", "Event Type", "Link", "Image", "Tags", "Order"]
22682270
data = [columns]
22692271

22702272
for event in events:
@@ -2279,15 +2281,16 @@ def _community_events_download(self, community_id):
22792281
"Event Type": event.event_type,
22802282
"Link": event.external_link if event.external_link else "",
22812283
"Image": compressed_image_url if event.image else "",
2282-
"Tags": ", ".join([tag.name for tag in event.tags.all()])
2284+
"Tags": ", ".join([tag.name for tag in event.tags.all()]),
2285+
"Order": event.rank if event.rank else event.id,
22832286
})
22842287
data.append(cell)
22852288
return data
22862289

22872290

22882291
def _community_testimonials_download(self, community_id):
22892292
testimonials = Testimonial.objects.filter(community__id=community_id, is_deleted=False, is_published=True)
2290-
columns = ["Title", "Body","User","Related Action", "Related Vendor", "Image", "Tags", "Email"]
2293+
columns = ["Title", "Body","User","Related Action", "Related Vendor", "Image", "Tags", "Email", "Order"]
22912294
data = [columns]
22922295

22932296
for testimonial in testimonials:
@@ -2301,14 +2304,15 @@ def _community_testimonials_download(self, community_id):
23012304
"Related Vendor": testimonial.vendor.name if testimonial.vendor else "",
23022305
"Image": compressed_image_url,
23032306
"Tags": ", ".join([f"{tag.name}:{tag.tag_collection.name if tag.tag_collection else ''}" for tag in testimonial.tags.all()]),
2304-
"Email": testimonial.user.email if testimonial.user else ""
2307+
"Email": testimonial.user.email if testimonial.user else "",
2308+
"Order": testimonial.rank if testimonial.rank else testimonial.id,
23052309
})
23062310
data.append(cell)
23072311
return data
23082312

23092313
def _export_community_actions(self, community_id):
23102314
actions = Action.objects.filter(community__id=community_id, is_deleted=False,is_published=True)
2311-
columns = ["Title", "Description", "Steps to Take", "Deep Dive", "Image", "CC Action", "Tags"]
2315+
columns = ["Title", "Description", "Steps to Take", "Deep Dive", "Image", "CC Action", "Tags", "Order" ]
23122316
data = [columns]
23132317

23142318
for action in actions:
@@ -2323,15 +2327,15 @@ def _export_community_actions(self, community_id):
23232327
"Image": compressed_image_url,
23242328
"CC Action": action.calculator_action.name if action.calculator_action else "",
23252329
"Tags": ", ".join([f"{tag.name}:{tag.tag_collection.name if tag.tag_collection else ''}" for tag in action.tags.all()]),
2326-
"order":action.rank if action.rank else action.id,
2330+
"Order":action.rank if action.rank else action.id
23272331
})
23282332
data.append(cell)
23292333
return data
23302334

23312335

23322336
def _export_all_actions(self):
23332337
actions = Action.objects.filter(is_deleted=False,is_published=True)
2334-
columns = ["Title", "Description", "Steps to Take", "Deep Dive", "Image", "CC Action", "Tags", "Community"]
2338+
columns = ["Title", "Description", "Steps to Take", "Deep Dive", "Image", "CC Action", "Tags", "Community", "Order"]
23352339
data = [columns]
23362340

23372341
for action in actions:
@@ -2347,15 +2351,15 @@ def _export_all_actions(self):
23472351
"CC Action": action.calculator_action.name if action.calculator_action else "",
23482352
"Tags": ", ".join([f"{tag.name}:{tag.tag_collection.name if tag.tag_collection else ''}" for tag in action.tags.all()]),
23492353
"Community": action.community.name if action.community else "",
2350-
"order":action.rank if action.rank else action.id,
2354+
"Order":action.rank if action.rank else action.id,
23512355
})
23522356
data.append(cell)
23532357
return data
23542358

23552359

23562360
def _export_all_testimonials(self):
23572361
testimonials = Testimonial.objects.filter(is_deleted=False,is_published=True)
2358-
columns = ["Title", "Body", "User", "Related Action", "Related Vendor", "Image", "Tags", "Email", "Community"]
2362+
columns = ["Title", "Body", "User", "Related Action", "Related Vendor", "Image", "Tags", "Email", "Community", "Order"]
23592363
data = [columns]
23602364

23612365
for testimonial in testimonials:
@@ -2369,15 +2373,15 @@ def _export_all_testimonials(self):
23692373
"Tags": ", ".join([f"{tag.name}:{tag.tag_collection.name if tag.tag_collection else ''}" for tag in testimonial.tags.all()]),
23702374
"Email": testimonial.user.email if testimonial.user else "",
23712375
"Community": testimonial.community.name if testimonial.community else "",
2372-
"order":testimonial.rank if testimonial.rank else testimonial.id,
2376+
"Order":testimonial.rank if testimonial.rank else testimonial.id,
23732377
})
23742378
data.append(cell)
23752379
return data
23762380

23772381
def _export_all_events(self):
23782382
six_months_ago = timezone.now() - datetime.timedelta(days=180)
23792383
events = Event.objects.filter(is_deleted=False,is_published=True, start_date_and_time__gte=six_months_ago)
2380-
columns = ["Title", "Description", "Start Date", "End Date", "Location", "Event Type", "Link", "Image", "Tags", "Community"]
2384+
columns = ["Title", "Description", "Start Date", "End Date", "Location", "Event Type", "Link", "Image", "Tags", "Community", "Order"]
23812385
data = [columns]
23822386

23832387
for event in events:
@@ -2394,7 +2398,7 @@ def _export_all_events(self):
23942398
"Image": event.image.file.url if event.image else "",
23952399
"Tags": ", ".join([f"{tag.name}:{tag.tag_collection.name if tag.tag_collection else ''}" for tag in event.tags.all()]),
23962400
"Community": event.community.name if event.community else "",
2397-
"order":event.id,
2401+
"Order":event.id,
23982402
})
23992403
data.append(cell)
24002404
return data

0 commit comments

Comments
 (0)