forked from gergely/calendar-social
Connect events with profiles instead of local users
This commit is contained in:
parent
89605538c2
commit
4cbebb9c5a
@ -199,12 +199,13 @@ class GregorianCalendar(CalendarSystem):
|
|||||||
"""Returns all events for a given day
|
"""Returns all events for a given day
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..models import Event
|
from ..models import Event, Profile
|
||||||
|
|
||||||
events = Event.query
|
events = Event.query
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
events = events.filter(Event.user == user)
|
events = events.join(Profile) \
|
||||||
|
.filter(Profile.user == user)
|
||||||
|
|
||||||
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
|
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
end_timestamp = start_timestamp + timedelta(days=1)
|
end_timestamp = start_timestamp + timedelta(days=1)
|
||||||
|
@ -206,10 +206,10 @@ class Event(db.Model):
|
|||||||
#: The UUID of the event. This is what is presented to the users and used in federation.
|
#: The UUID of the event. This is what is presented to the users and used in federation.
|
||||||
event_uuid = db.Column(db.String(length=40), unique=True, nullable=False, default=generate_uuid)
|
event_uuid = db.Column(db.String(length=40), unique=True, nullable=False, default=generate_uuid)
|
||||||
|
|
||||||
#: The ID of the user who created the event
|
#: The ID of the profile who created the event
|
||||||
user_id = db.Column(db.Integer(), db.ForeignKey('users.id'), nullable=False)
|
profile_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), nullable=False)
|
||||||
|
|
||||||
user = db.relationship('User', backref=db.backref('events', lazy='dynamic'))
|
profile = db.relationship('Profile', backref=db.backref('events', lazy='dynamic'))
|
||||||
|
|
||||||
#: The title of the event
|
#: The title of the event
|
||||||
title = db.Column(db.Unicode(length=200), nullable=False)
|
title = db.Column(db.Unicode(length=200), nullable=False)
|
||||||
@ -263,7 +263,7 @@ class Event(db.Model):
|
|||||||
return self.__as_tz(self.end_time, as_timezone=user.timezone)
|
return self.__as_tz(self.end_time, as_timezone=user.timezone)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<Event {self.id} ({self.title}) of {self.user}>'
|
return f'<Event {self.id} ({self.title}) of {self.profile}>'
|
||||||
|
|
||||||
|
|
||||||
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
|
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
|
||||||
|
Loading…
Reference in New Issue
Block a user