Skip to content

Commit ead0880

Browse files
authored
Merge pull request #12 from joshpollara/feature/webapp-refactor
Refactor webapp: Remove authentication and simplify architecture
2 parents 55b2e2b + b90a90e commit ead0880

17 files changed

+1454
-1757
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ RUN mkdir -p /app/data
2525
RUN echo "0 */6 * * * cd /app && /usr/local/bin/python /app/bin/bridge_openings_sync.py >> /var/log/cron.log 2>&1" > /etc/cron.d/bridge-sync && \
2626
echo "0 2 * * 0 cd /app && /usr/local/bin/python /app/bin/fetch_osm_bridges.py >> /var/log/cron.log 2>&1" >> /etc/cron.d/bridge-sync && \
2727
echo "0 3 * * 0 cd /app && /usr/local/bin/python /app/bin/enhance_bridge_locations.py >> /var/log/cron.log 2>&1" >> /etc/cron.d/bridge-sync && \
28+
echo "30 3 * * 0 cd /app && /usr/local/bin/python /app/webapp/run_migration.py >> /var/log/cron.log 2>&1" >> /etc/cron.d/bridge-sync && \
29+
echo "30 */6 * * * cd /app && /usr/local/bin/python /app/webapp/run_migration.py >> /var/log/cron.log 2>&1" >> /etc/cron.d/bridge-sync && \
2830
chmod 0644 /etc/cron.d/bridge-sync && \
2931
crontab /etc/cron.d/bridge-sync && \
3032
touch /var/log/cron.log

webapp/auth.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

webapp/database.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616

1717
Base = declarative_base()
1818

19-
class User(Base):
20-
__tablename__ = "users"
19+
# URL-based watchlist models
20+
class Watchlist(Base):
21+
__tablename__ = "watchlists"
2122

2223
id = Column(Integer, primary_key=True, index=True)
23-
email = Column(String, unique=True, index=True, nullable=False)
24-
hashed_password = Column(String, nullable=False)
25-
calendar_token = Column(String, unique=True, index=True)
24+
name = Column(String, unique=True, index=True, nullable=False)
25+
created_at = Column(DateTime, default=datetime.utcnow)
2626

27-
watched_bridges = relationship("WatchedBridge", back_populates="user", cascade="all, delete-orphan")
27+
bridges = relationship("WatchlistBridge", back_populates="watchlist", cascade="all, delete-orphan")
2828

29-
class WatchedBridge(Base):
30-
__tablename__ = "watched_bridges"
29+
class WatchlistBridge(Base):
30+
__tablename__ = "watchlist_bridges"
3131

3232
id = Column(Integer, primary_key=True, index=True)
33-
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
33+
watchlist_id = Column(Integer, ForeignKey("watchlists.id"), nullable=False)
3434
bridge_name = Column(String, nullable=False)
35-
bridge_id = Column(Integer, nullable=True) # Reference to bridges table
35+
bridge_id = Column(String, nullable=True) # Reference to bridges table
3636
created_at = Column(DateTime, default=datetime.utcnow)
3737

38-
user = relationship("User", back_populates="watched_bridges")
38+
watchlist = relationship("Watchlist", back_populates="bridges")
3939

4040
def get_db():
4141
db = SessionLocal()

webapp/ical_generator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import List, Dict
33
import hashlib
44

5-
def generate_ical_feed(user_email: str, events: List[Dict]) -> str:
5+
def generate_ical_feed(events: List[Dict], calendar_name: str = "BridgePing") -> str:
66
"""Generate iCalendar feed for bridge opening events."""
77

88
# iCal header
@@ -12,8 +12,8 @@ def generate_ical_feed(user_email: str, events: List[Dict]) -> str:
1212
"PRODID:-//BridgePing//Bridge Opening Calendar//EN",
1313
"CALSCALE:GREGORIAN",
1414
"METHOD:PUBLISH",
15-
f"X-WR-CALNAME:Bridge Openings - {user_email}",
16-
"X-WR-CALDESC:Scheduled bridge openings for your watched bridges",
15+
f"X-WR-CALNAME:{calendar_name}",
16+
"X-WR-CALDESC:Scheduled bridge openings",
1717
"X-WR-TIMEZONE:Europe/Amsterdam",
1818
"REFRESH-INTERVAL;VALUE=DURATION:PT1H", # Refresh every hour
1919
]
@@ -42,7 +42,8 @@ def generate_ical_feed(user_email: str, events: List[Dict]) -> str:
4242
# Add events
4343
for event in events:
4444
# Generate unique ID for this event
45-
uid_string = f"{event['bridge_name']}-{event['start_time']}-{event['location_key']}"
45+
location_key = event.get('location_key', '')
46+
uid_string = f"{event['bridge_name']}-{event['start_time']}-{location_key}"
4647
uid = hashlib.md5(uid_string.encode()).hexdigest()
4748

4849
# Format times for iCal

0 commit comments

Comments
 (0)