Repository: fossasia/open-event-server

Issue:
Fetching featured speakers, accepted sessions, public call for speaker by default
**Describe the bug**
By default, the server should only return featured speakers, accepted sessions, public speakers call when client-side make GET requests. Currently, it also returns pending sessions or private call for speaker.

**Additional context**
Discussed in: https://github.com/fossasia/open-event-android/pull/1902 (comment)


Discussion:
Except featured speakers, everything should be done as @anhanh11001 stated
@anhanh11001 I'd like to take this. 

@anhanh11001 Which endpoint are you talking about? 
@mrsaicharan1 every endpoint which returns sessions or call for speakers 
@iamareebjamal Would like to take this up.

Resolving patch:
diff --git a/app/api/sessions.py b/app/api/sessions.py
--- a/app/api/sessions.py
+++ b/app/api/sessions.py
@@ -86,7 +86,7 @@ def query(self, view_kwargs):
         :param view_kwargs:
         :return:
         """
-        query_ = self.session.query(Session)
+        query_ = self.session.query(Session).filter(Session.state == "accepted")
         if view_kwargs.get('track_id') is not None:
             track = safe_query(self, Track, 'id', view_kwargs['track_id'], 'track_id')
             query_ = query_.join(Track).filter(Track.id == track.id)
@@ -104,7 +104,7 @@ def query(self, view_kwargs):
         if view_kwargs.get('speaker_id'):
             speaker = safe_query(self, Speaker, 'id', view_kwargs['speaker_id'], 'speaker_id')
             # session-speaker :: many-to-many relationship
-            query_ = Session.query.filter(Session.speakers.any(id=speaker.id))
+            query_ = Session.query.filter(Session.speakers.any(id=speaker.id), Session.state == "accepted")
 
         return query_
 
diff --git a/app/api/speakers_calls.py b/app/api/speakers_calls.py
--- a/app/api/speakers_calls.py
+++ b/app/api/speakers_calls.py
@@ -86,20 +86,29 @@ def before_get_object(self, view_kwargs):
         """
         if view_kwargs.get('event_identifier'):
             try:
-                event = self.session.query(Event).filter_by(identifier=view_kwargs['event_identifier']).one()
+                event = self.session.query(Event).filter_by(identifier=view_kwargs['event_identifier'],
+                                                            privacy='public').one()
             except NoResultFound:
                 raise ObjectNotFound({'parameter': 'event_identifier'},
                                      "Event: {} not found".format(view_kwargs['event_identifier']))
             else:
                 view_kwargs['event_id'] = event.id
 
-        if view_kwargs.get('event_id'):
+        elif view_kwargs.get('event_id'):
             try:
-                speakers_call = self.session.query(SpeakersCall).filter_by(event_id=view_kwargs['event_id']).one()
+                speakers_call = self.session.query(SpeakersCall).filter_by(event_id=view_kwargs['event_id'],
+                                                                           privacy='public').one()
             except NoResultFound:
                 raise ObjectNotFound({'parameter': 'event_identifier'}, "Object: not found")
             view_kwargs['id'] = speakers_call.id
 
+        else:
+            try:
+                speakers_call = self.session.query(SpeakersCall).filter_by(id=view_kwargs['id'], privacy='public').one()
+            except NoResultFound:
+                raise ObjectNotFound({'parameter': 'speaker_call_id'}, "Object: not found")
+            view_kwargs['id'] = speakers_call.id
+
     decorators = (api.has_permission('is_coorganizer', fetch="event_id", fetch_as="event_id",
                                      model=SpeakersCall, methods="PATCH,DELETE"),)
     schema = SpeakersCallSchema


Test patch: