Skip to content

WIP SpeedyMeetings2 #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion app/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from app.config import PSQL_ENVIRONMENT
from app.database.database import Base
from sqlalchemy import (DDL, Boolean, Column, DateTime, ForeignKey, Index,
Integer, String, event)
func, Integer, String, event)
from sqlalchemy.dialects.postgresql import TSVECTOR
from sqlalchemy.orm import relationship

Expand Down Expand Up @@ -37,17 +37,26 @@ class User(Base):

events = relationship("UserEvent", back_populates="participants")

speedy_meetings_enabled = Column(Boolean, default=False)

def has_speedy_meetings_enabled(self) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

מה המטרה שך הפנציה הזאת? למה לקרוא לה ולא פשוט לא user.speedy_meetings_enabled?

return self.speedy_meetings_enabled

def __repr__(self):
return f'<User {self.id}>'


class Event(Base):
__tablename__ = "events"

DEFAULT_DURATION = 60
SHORT_MEETING = 0.75

id = Column(Integer, primary_key=True, index=True)
title = Column(String, nullable=False)
start = Column(DateTime, nullable=False)
end = Column(DateTime, nullable=False)
default_end = Column(Integer, default=func.get_default_end_time())
content = Column(String)
location = Column(String)

Expand All @@ -57,6 +66,14 @@ class Event(Base):

participants = relationship("UserEvent", back_populates="events")

def get_event_duration(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

זה דבר נהוג להכניס פונקציות לModels ולא להוציא את זה לקבצים בinternal?
בדקת את זה לפני?

שואל באמת כי זה פעם ראשונה שאני רואה

if self.owner.has_speedy_meetings_enabled():
return self.DEFAULT_DURATION * self.SHORT_MEETING
return self.DEFAULT_DURATION

def get_default_end_time(self):
return self.start + self.get_event_duration()

# PostgreSQL
if PSQL_ENVIRONMENT:
events_tsv = Column(TSVECTOR)
Expand Down