Skip to content
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

fix: Add more constraints to upcoming events #7244

Merged
merged 1 commit into from
Sep 4, 2020
Merged
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
13 changes: 12 additions & 1 deletion app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flask_rest_jsonapi.exceptions import ObjectNotFound
from marshmallow_jsonapi import fields
from marshmallow_jsonapi.flask import Schema
from sqlalchemy import or_
from sqlalchemy import or_, and_
from sqlalchemy.orm.exc import NoResultFound

from app.api.bootstrap import api
Expand Down Expand Up @@ -862,9 +862,20 @@ def query(self, view_kwargs):
query_ = (
self.session.query(Event)
.filter(
Event.starts_at > current_time,
Event.ends_at > current_time,
Event.state == 'published',
Event.privacy == 'public',
or_(
Event.is_promoted,
and_(
Event.original_image_url != None,

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is not None:'

Event.logo_url != None,
Event.event_type_id != None,
Event.event_topic_id != None,
Event.event_sub_topic_id != None,
),
),
)
.order_by(Event.starts_at)
)
Expand Down