|
3 | 3 | from rest_framework.permissions import AllowAny |
4 | 4 | from rest_framework.response import Response |
5 | 5 | from ratelimit.decorators import ratelimit |
6 | | -from django.http import HttpResponse |
7 | | -from django.utils import timezone |
8 | | -from django.utils.html import escape |
9 | | -from django.conf import settings |
10 | 6 |
|
11 | 7 | from services.openai_service import generate_embedding |
12 | 8 | from utils.embedding_utils import find_similar_events |
@@ -317,48 +313,3 @@ def get_google_calendar_urls(request): |
317 | 313 | {"error": f"Failed to generate Google Calendar URLs: {e!s}"}, |
318 | 314 | status=status.HTTP_500_INTERNAL_SERVER_ERROR, |
319 | 315 | ) |
320 | | - |
321 | | - |
322 | | -def rss_feed(request): |
323 | | - """ |
324 | | - Simple RSS feed of upcoming events (returns application/rss+xml). |
325 | | - """ |
326 | | - now = timezone.now() |
327 | | - items = Events.objects.filter(dtstart__gte=now).order_by("dtstart")[:50] |
328 | | - |
329 | | - site_url = getattr(settings, "SITE_URL", "https://wat2do.ca") |
330 | | - rss_items = [] |
331 | | - for ev in items: |
332 | | - title = escape(ev.title or "Untitled event") |
333 | | - link = ev.source_url or f"{site_url}/events/{ev.id}" |
334 | | - description = escape(ev.description or "") |
335 | | - pub_date = ev.dtstamp.astimezone(timezone.utc).strftime("%a, %d %b %Y %H:%M:%S GMT") |
336 | | - guid = f"{ev.id}@wat2do" |
337 | | - enclosure = "" |
338 | | - if ev.source_image_url: |
339 | | - enclosure = f'<media:content url="{escape(ev.source_image_url)}" medium="image" />' |
340 | | - |
341 | | - item_xml = f""" |
342 | | - <item> |
343 | | - <title>{title}</title> |
344 | | - <link>{escape(link)}</link> |
345 | | - <description><![CDATA[{description}]]></description> |
346 | | - <guid isPermaLink="false">{guid}</guid> |
347 | | - <pubDate>{pub_date}</pubDate> |
348 | | - {enclosure} |
349 | | - </item> |
350 | | -""" |
351 | | - rss_items.append(item_xml) |
352 | | - |
353 | | - rss = f"""<?xml version="1.0" encoding="UTF-8"?> |
354 | | -<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"> |
355 | | - <channel> |
356 | | - <title>Wat2Do — Upcoming events</title> |
357 | | - <link>{site_url}</link> |
358 | | - <atom:link href="{site_url}/rss.xml" rel="self" type="application/rss+xml" /> |
359 | | - <description>Upcoming events at the University of Waterloo</description> |
360 | | - <lastBuildDate>{timezone.now().astimezone(timezone.utc).strftime("%a, %d %b %Y %H:%M:%S GMT")}</lastBuildDate> |
361 | | - {''.join(rss_items)} |
362 | | - </channel> |
363 | | -</rss>""" |
364 | | - return HttpResponse(rss, content_type="application/rss+xml") |
0 commit comments