-
Notifications
You must be signed in to change notification settings - Fork 52
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
omrizhaki
wants to merge
8
commits into
PythonFreeCourse:develop
Choose a base branch
from
omrizhaki:feature/speedymeeting
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WIP SpeedyMeetings2 #157
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ae432a
fix: work with database
omrizhaki f7f556c
fix: flake8
omrizhaki ca896f4
fix: newfile
omrizhaki 6380fe3
fix: flake8
omrizhaki a4fd927
fix: again
omrizhaki 8fe713d
fix: again2
omrizhaki 2d04e8e
fix: again3
omrizhaki 519f5f9
fix: again4
omrizhaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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: | ||
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) | ||
|
||
|
@@ -57,6 +66,14 @@ class Event(Base): | |
|
||
participants = relationship("UserEvent", back_populates="events") | ||
|
||
def get_event_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. זה דבר נהוג להכניס פונקציות ל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) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
מה המטרה שך הפנציה הזאת? למה לקרוא לה ולא פשוט לא user.speedy_meetings_enabled?