-
Notifications
You must be signed in to change notification settings - Fork 52
WIP Speedy Meetings #125
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
WIP Speedy Meetings #125
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,13 @@ class User(Base): | |
|
||
events = relationship("UserEvent", back_populates="participants") | ||
|
||
speedy_meetings_enabled = Column(Boolean, default=False) | ||
|
||
events = relationship( | ||
"Event", cascade="all, delete", back_populates="owner") | ||
|
||
def has_speedy_meetings_enabled(self) -> bool: | ||
return self.speedy_meetings_enabled | ||
def __repr__(self): | ||
return f'<User {self.id}>' | ||
|
||
|
@@ -48,6 +55,7 @@ class Event(Base): | |
title = Column(String, nullable=False) | ||
start = Column(DateTime, nullable=False) | ||
end = Column(DateTime, nullable=False) | ||
default_end = get_default_end_time() | ||
content = Column(String) | ||
location = Column(String) | ||
|
||
|
@@ -70,6 +78,24 @@ def __repr__(self): | |
return f'<Event {self.id}>' | ||
|
||
|
||
owner = relationship("User", back_populates="events") | ||
|
||
user = get_user_by_id(owner_id) | ||
|
||
def get_user_by_id(self, owner_id): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it needed? can't we just call user.owner? |
||
return owner | ||
|
||
def get_default_end_time(self): | ||
return start + get_event_duration() | ||
|
||
def get_event_duration(self): | ||
default_duration = get_default_duration() | ||
if user.has_speedy_meetings_enabled(): | ||
return default_duration * .75 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is 0.75? |
||
return default_duration | ||
|
||
def get_default_duration(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it's part of the table model? |
||
return 60 | ||
class PSQLEnvironmentError(Exception): | ||
pass | ||
|
||
|
@@ -116,3 +142,4 @@ class Quote(Base): | |
id = Column(Integer, primary_key=True, index=True) | ||
text = Column(String, nullable=False) | ||
author = Column(String) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is part of the ORM, it must be of type
Column
or arelationship
.You can check the SQLAlchemy docs to see how to add default value to the
end
column.