Skip to content

Commit 516ae2e

Browse files
committed
change event display handle to accept other_handle, and only have Instagram link if display handle is an ig_handle
1 parent 98ba70c commit 516ae2e

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

backend/services/openai_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
import json
1111
import os
12-
import time
1312
import traceback
14-
from copy import deepcopy
1513
from datetime import datetime
1614

1715
from dotenv import load_dotenv
@@ -505,10 +503,10 @@ def generate_recommended_filters(self, events_data: list[dict]) -> list[list[str
505503
return []
506504

507505

508-
509506
# Singleton instance
510507
openai_service = OpenAIService()
511508

509+
512510
# Backward compatibility - export functions that use the singleton
513511
generate_embedding = openai_service.generate_embedding
514512
extract_events_from_caption = openai_service.extract_events_from_caption

backend/utils/events_utils.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def determine_display_handle(event):
2929
"""
3030
Determine a display handle for an event.
3131
Accepts either a dict-like object (with .get) or a Django model instance (attributes).
32-
Prefers social handles in order: ig, discord, x, tiktok, fb. Prepends '@' unless already present.
33-
Falls back to event.school or "Wat2Do Event".
32+
Prefers ig_handle, then other_handle, then event.school.
3433
"""
3534

3635
def _get(key):
@@ -40,18 +39,12 @@ def _get(key):
4039
# model instance / object
4140
return getattr(event, key, None)
4241

43-
social_handles = [
44-
_get("ig_handle"),
45-
_get("discord_handle"),
46-
_get("x_handle"),
47-
_get("tiktok_handle"),
48-
_get("fb_handle"),
49-
]
50-
social_handles = [h for h in social_handles if h]
51-
52-
if social_handles:
53-
handle = social_handles[0]
54-
handle_str = str(handle)
55-
return handle_str
42+
ig_handle = _get("ig_handle")
43+
other_handle = _get("other_handle")
5644
school = _get("school")
45+
46+
if ig_handle:
47+
return str(ig_handle)
48+
if other_handle:
49+
return str(other_handle)
5750
return school or "Wat2Do Event"

frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/features/events/components/EventsGrid.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,24 @@ const OrganizationBadge = ({
9191
}) => {
9292
if (!event.display_handle) return null;
9393

94+
// Only link if display_handle is an ig_handle
95+
const isInstagram = !!event.ig_handle && event.display_handle === event.ig_handle;
96+
9497
return (
9598
<BadgeMask variant="bottom-left">
9699
<Badge
97100
onMouseDown={() => {
98-
if (!isSelectMode) {
101+
if (!isSelectMode && isInstagram) {
99102
window.open(
100103
`https://www.instagram.com/${event.display_handle}/`,
101104
"_blank"
102105
);
103106
}
104107
}}
105108
variant="outline"
106-
className="font-extrabold cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800"
109+
className={`font-extrabold${isInstagram ? " cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800" : ""}`}
107110
>
108-
@{event.display_handle}
111+
{isInstagram ? `@${event.display_handle}` : event.display_handle}
109112
</Badge>
110113
</BadgeMask>
111114
);

0 commit comments

Comments
 (0)