feat(calendar): add EventGuest model and total_attendee_count property
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
96cb134d1f
commit
afee91e52c
32
database.py
32
database.py
@ -2205,11 +2205,17 @@ class NordaEvent(Base):
|
|||||||
speaker_company = relationship('Company')
|
speaker_company = relationship('Company')
|
||||||
creator = relationship('User', foreign_keys=[created_by])
|
creator = relationship('User', foreign_keys=[created_by])
|
||||||
attendees = relationship('EventAttendee', back_populates='event', cascade='all, delete-orphan')
|
attendees = relationship('EventAttendee', back_populates='event', cascade='all, delete-orphan')
|
||||||
|
guests = relationship('EventGuest', back_populates='event', cascade='all, delete-orphan')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def attendee_count(self):
|
def attendee_count(self):
|
||||||
return len(self.attendees)
|
return len(self.attendees)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_attendee_count(self):
|
||||||
|
"""Łączna liczba uczestników + gości (do sprawdzania limitu max_attendees)."""
|
||||||
|
return len(self.attendees) + len(self.guests)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_past(self):
|
def is_past(self):
|
||||||
from datetime import date
|
from datetime import date
|
||||||
@ -2304,6 +2310,32 @@ class EventAttendee(Base):
|
|||||||
user = relationship('User')
|
user = relationship('User')
|
||||||
|
|
||||||
|
|
||||||
|
class EventGuest(Base):
|
||||||
|
"""Osoby towarzyszące na wydarzeniach (bez konta na portalu)"""
|
||||||
|
__tablename__ = 'event_guests'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
event_id = Column(Integer, ForeignKey('norda_events.id', ondelete='CASCADE'), nullable=False, index=True)
|
||||||
|
host_user_id = Column(Integer, ForeignKey('users.id', ondelete='CASCADE'), nullable=False, index=True)
|
||||||
|
first_name = Column(String(100))
|
||||||
|
last_name = Column(String(100))
|
||||||
|
organization = Column(String(255))
|
||||||
|
created_at = Column(DateTime, default=datetime.now, nullable=False)
|
||||||
|
|
||||||
|
event = relationship('NordaEvent', back_populates='guests')
|
||||||
|
host = relationship('User')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def display_name(self):
|
||||||
|
"""Nazwa wyświetlana gościa — łączy dostępne pola."""
|
||||||
|
parts = []
|
||||||
|
if self.first_name:
|
||||||
|
parts.append(self.first_name)
|
||||||
|
if self.last_name:
|
||||||
|
parts.append(self.last_name)
|
||||||
|
return ' '.join(parts) if parts else '(brak danych)'
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# PRIVATE MESSAGES
|
# PRIVATE MESSAGES
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user