def get(self): user = users.get_current_user() if user is None: self.return_ok({}) else: current_reader = self.find_current_reader() if current_reader is None: fields = {} proposed_readers = Reader.gql( "where proposed_email = :1", user.email()).fetch(10) if len(proposed_readers) > 0: fields['proposed_readers'] = proposed_readers self.return_ok(fields) else: if 'return_to' in self.request.GET: return_to = self.get_str('return_to') else: return_to = "/" self.return_found(return_to)
def find_current_reader(self): user = users.get_current_user() if user is None: return None else: return Reader.gql("where emails = :1", user.email()).get()