def search(request): r = request ses = r.session try: sc = request.registry.solr_conn except AttributeError: r.session['message'] = 'I could not find the search engine.' return {'code': 'ENOSOLR', 'success': False} search_term = r.params['term'] q = sc.query() for term in search_term.split(): q = q.query(term) res = q.execute() stories = [] vds = [] vote_dict = {} for r in res: stories.append(submission.get_story_by_id(r['id'])) if 'users.id' in ses: vds.append(users.get_user_votes(ses['users.id'], "on_submission", r['id'])) for vd in vds: if type(vd) == dict: vote_dict.update(vd) #queries.update_story_vote_tally(stories) return {'res': res, 'stories': stories, 'vote_dict': vote_dict}
def search(request): r = request ses = r.session try: sc = request.registry.solr_conn except AttributeError: r.session['message'] = 'I could not find the search engine.' return {'code': 'ENOSOLR', 'success': False} search_term = r.params['term'] q = sc.query() for term in search_term.split(): q = q.query(term) res = q.execute() stories = [] vds = [] vote_dict = {} for r in res: stories.append(submission.get_story_by_id(r['id'])) if 'users.id' in ses: vds.append( users.get_user_votes(ses['users.id'], "on_submission", r['id'])) for vd in vds: if type(vd) == dict: vote_dict.update(vd) #queries.update_story_vote_tally(stories) return {'res': res, 'stories': stories, 'vote_dict': vote_dict}
def find_by_id(id): # @FIXME: make these exceptions specific to the case # where they can run successfully but do not find # the thing we are looking for. This should be really # easy as I think we just need NoResultFound. from raggregate.queries import submission from raggregate.queries import users from raggregate.queries import epistle as epistle_queries try: return submission.get_story_by_id(id) except: pass if users.get_user_by_id(id): return users.get_user_by_id(id) try: return submission.get_comment_by_id(id) except: pass try: return epistle_queries.get_epistle_by_id(id) except: raise
def get_submission_identifier_for_url(s): if s.__class__ != Submission: s = submission.get_story_by_id(s) if s.slug is None or s.slug == '': return s.id else: return s.slug
def get_sublist_members(sublist_id): members = dbsession.query(SublistMember).filter( SublistMember.sublist_id == sublist_id).all() member_list = [] for m in members: member_list.append(submission_queries.get_story_by_id(m.member_id)) return member_list
def calc_hot_window_score(submission_id, hot_point_window=timedelta(hours=6)): """ Retrieve vote/score information for a given submission over hot_point_window time. Count votes received in the last hot_point_window time. If this is higher than normal, the story will be considered hot. @param submission_id: the submission to calculate @param hot_point_window: timedelta object representing acceptable vote timeframe from now """ try: story_votes = dbsession.query( Vote.submission_id, func.sum(Vote.points).label('points')).filter( Vote.added_on < general.now_in_utc(), Vote.added_on > (general.now_in_utc() - hot_point_window)).filter( Vote.submission_id == submission_id).group_by( Vote.submission_id).one() except sqlalchemy.orm.exc.NoResultFound: # no votes on this story yet return 0 from raggregate.queries import submission story = submission.get_story_by_id(submission_id) story.hot_window_score = story_votes.points story.hot_window_score_timestamp = general.now_in_utc() dbsession.add(story) return story_votes.points
def _assign_epistle_parent(e): #@TODO: REALLY need to put parent_info somewhere smarter, and/or not make this happen so much if e.parent: if e.parent_type == 'story': e.parent_info = submission.get_story_by_id(e.parent) elif e.parent_type == 'comment': e.parent_info = queries.get_comment_by_id(e.parent) elif e.parent_type == 'epistle' or e.parent_type == 'reply': e.parent_info = epistle_queries.get_epistle_by_id(e.parent) return e
def notify(request): from raggregate.queries import notify as notify_queries s = request.session p = request.session['safe_params'] u = None op = 'add' vote_dict = {} notifyd = notify_queries.get_notify_by_user_id(s['users.id']) notifyd_ids = [ str(i.target_id) for i in notify_queries.get_notify_by_user_id(s['users.id']) ] if 'target_id' in p and 'logged_in' in s: dbsession = DBSession() uid = s['users.id'] to_notify = p['target_id'] if 'op' in p: op = p['op'] if op == 'add': if to_notify not in notifyd_ids: notify_queries.create_notify(uid, to_notify, s['users.id']) s['message'] = 'Successfully notified' elif op == 'del': if to_notify in notifyd_ids: notify_queries.delete_notify(user_id=uid, target_id=to_notify) s['message'] = 'Successfully de-notified' elif 'logged_in' in s: u = users.get_user_by_id(s['users.id']) # the template expects a set of stories to render notifyd_stories = [ submission.get_story_by_id(i.target_id) for i in notifyd if i.target_type == 'submission' ] notifyd_comments = [ submission.get_comment_by_id(i.target_id) for i in notifyd if i.target_type == 'comment' ] if u: vds = [] for i in notifyd_stories: vds.append( users.get_user_votes(s['users.id'], "on_submission", i.id)) for vd in vds: if type(vd) == dict: vote_dict.update(vd) return { 'notifyd_stories': notifyd_stories, 'notifyd_comments': notifyd_comments, 'vote_dict': vote_dict, }
def fire_to_listeners(parent_id, submitter, new_id, request): parent = general.find_by_id(parent_id) if isinstance(parent, Submission): submission = parent if isinstance(parent, Comment): submission = submission_queries.get_story_by_id(parent.submission_id) submitter = user_queries.get_user_by_id(submitter).display_name() users = get_users_to_notify(parent_id) for recipient in users: if "users.id" in request.session and str(recipient.id) == request.session["users.id"]: continue if recipient.notify_by_mail: send_mail(recipient, submitter, submission, new_id, request) return True
def count_story_votes(submission_id): from raggregate.queries import submission dv_num = dbsession.query(Vote).filter(Vote.points < 0).filter(Vote.submission_id == submission_id).count() story = submission.get_story_by_id(submission_id) story.downvote_tally = dv_num story.downvote_tally_timestamp = general.now_in_utc() uv_num = dbsession.query(Vote).filter(Vote.points > 0).filter(Vote.submission_id == submission_id).count() story.upvote_tally = uv_num story.upvote_tally_timestamp = general.now_in_utc() story.total_vote_tally = uv_num + dv_num story.total_vote_timestamp = general.now_in_utc() dbsession.add(story) dbsession.flush() return [dv_num, uv_num]
def fire_to_listeners(parent_id, submitter, new_id, request): parent = general.find_by_id(parent_id) if isinstance(parent, Submission): submission = parent if isinstance(parent, Comment): submission = submission_queries.get_story_by_id(parent.submission_id) submitter = user_queries.get_user_by_id(submitter).display_name() users = get_users_to_notify(parent_id) for recipient in users: if 'users.id' in request.session and str( recipient.id) == request.session['users.id']: continue if recipient.notify_by_mail: send_mail(recipient, submitter, submission, new_id, request) return True
def count_story_votes(submission_id): from raggregate.queries import submission dv_num = dbsession.query(Vote).filter(Vote.points < 0).filter( Vote.submission_id == submission_id).count() story = submission.get_story_by_id(submission_id) story.downvote_tally = dv_num story.downvote_tally_timestamp = general.now_in_utc() uv_num = dbsession.query(Vote).filter(Vote.points > 0).filter( Vote.submission_id == submission_id).count() story.upvote_tally = uv_num story.upvote_tally_timestamp = general.now_in_utc() story.total_vote_tally = uv_num + dv_num story.total_vote_timestamp = general.now_in_utc() dbsession.add(story) dbsession.flush() return [dv_num, uv_num]
def calc_hot_window_score(submission_id, hot_point_window = timedelta(hours = 6)): """ Retrieve vote/score information for a given submission over hot_point_window time. Count votes received in the last hot_point_window time. If this is higher than normal, the story will be considered hot. @param submission_id: the submission to calculate @param hot_point_window: timedelta object representing acceptable vote timeframe from now """ try: story_votes = dbsession.query(Vote.submission_id, func.sum(Vote.points).label('points')).filter(Vote.added_on < general.now_in_utc(), Vote.added_on > (general.now_in_utc() - hot_point_window)).filter(Vote.submission_id == submission_id).group_by(Vote.submission_id).one() except sqlalchemy.orm.exc.NoResultFound: # no votes on this story yet return 0 from raggregate.queries import submission story = submission.get_story_by_id(submission_id) story.hot_window_score = story_votes.points story.hot_window_score_timestamp = general.now_in_utc() dbsession.add(story) return story_votes.points
def save(request): s = request.session p = request.session['safe_params'] u = None op = 'add' vote_dict = {} if 'story_id' in p and 'logged_in' in s: dbsession = DBSession() u = users.get_user_by_id(s['users.id']) to_save = submission.get_story_by_id(p['story_id']) if 'op' in p: op = p['op'] if op == 'add': if to_save not in u.saved: u.saved.append(to_save) dbsession.add(u) s['message'] = 'Successfully saved {0}'.format(to_save.title) elif op == 'del': if to_save in u.saved: u.saved.remove(to_save) dbsession.add(u) s['message'] = 'Successfully unsaved {0}'.format(to_save.title) elif 'logged_in' in s: u = users.get_user_by_id(s['users.id']) if u: vds = [] for i in u.saved: vds.append( users.get_user_votes(s['users.id'], "on_submission", i.id)) for vd in vds: if type(vd) == dict: vote_dict.update(vd) return { 'saved': u.saved, 'vote_dict': vote_dict, }
def test_create_submission(self): submission = self.create_submission() result = submission_queries.get_story_by_id(submission.id) assert submission.id == result.id
def list(request): from raggregate.queries import user_preference as up s = request.session p = request.session['safe_post'] r = request qs = s['safe_get'] s['message'] = "Post a story." dbsession = DBSession() stories = None filtered_section = None section_found = False sections = section_queries.get_sections() direct_link = False if s.get('users.id', None): direct_link = True if up.get_user_prefs(s['users.id']).get('link_to_story', 'off') == 'on' else False if r.params and 'op' in r.params: sub_id = r.params['sub_id'] if r.params['op'] == 'del' or r.params['op'] == 'hide': try: story_to_del = submission.get_story_by_id(sub_id) except sqlalchemy.orm.exc.NoResultFound: story_to_del = None if story_to_del: if users.is_user_allowed_admin_action(s['users.id'], str(story_to_del.id), ): if r.params['op'] == 'del': story_to_del.description = "[deleted]" story_to_del.url = "#" story_to_del.title = "[deleted]" story_to_del.deleted = True dbsession.add(story_to_del) dbsession.flush() else: print("Illegal deletion attempted on {0}".format(story_to_del.submitter.id)) if 'sort.default_order' in r.registry.settings: sort = r.registry.settings['sort.default_order'] else: # default to new sort order if server-specific setting doesn't exist # this should only be the case on old clones; do NOT remove default_order # from the ini just because you want new by default. sort = 'new' page_num = 1 per_page = 30 next_page = None prev_page = None # only pass through approved sort options if 'sort' in qs: if qs['sort'] == 'top': sort = 'top' if qs['sort'] == 'hot': sort = 'hot' if qs['sort'] == 'contro': sort = 'contro' if qs['sort'] == 'new': sort = 'new' if 'page_num' in qs: try: page_num = int(qs['page_num']) except: page_num = 1 if 'section' in qs and qs['section'] == 'all': section = 'all' else: section = None if 'section' in qs and qs['section'] != 'all' and qs['section'] != '': section = qs['section'] try: section = section_queries.get_section_by_name(section) section_found = True except sqlalchemy.orm.exc.NoResultFound: try: section = section_queries.get_section_by_id(section) section_found = True except: from pyramid_tm import transaction transaction.abort() pass # reset section variable to None if we couldn't the named section if section_found == False: section = None else: #if we did find something, set filtered_section so that we can #reference the filtered section in the template. filtered_section = section if 'subscribe' in qs and isinstance(section, Section) and 'logged_in' in s: if qs['subscribe'] == 'y': sub_way = True elif qs['subscribe'] == 'n': sub_way = False sub = sub_queries.create_subscription(s['users.id'], section.id, sub_way) s['message'] = 'Subscription to section {0} updated'.format(section.name) # @FIXME: make per_page configurable in a safe location # it is probably unwise to allow this to be set in the query string # because then a malicious user could say per_page = 10000000000 # and easily launch a DoS via that mechanism. # if 'per_page' in qs: # per_page = qs['per_page'] stories = submission.get_story_list(page_num = page_num, per_page = per_page, sort = sort, request = request, section = section) max_stories = stories['max_stories'] stories = stories['stories'] # this should be split into its own def under queries.py # as it is currently used in at least one other place if max_stories > (page_num * per_page): next_page = page_num + 1 if page_num > 1: prev_page = page_num - 1 vote_dict = {} subscribed_to_list = [] if 'logged_in' in s: vote_dict = users.get_user_votes(s['users.id'], "on_all_submissions") subscribed_to_list = sub_queries.get_subscribed_by_user_id(s['users.id']) for story in stories: #@TODO: Remember to not tally on every load once a real site deploys story.tally_votes() story.tally_comments() print "\n\nsubscribed list: {0}\n\n".format(subscribed_to_list) # Get message of the day motd = motd_queries.get_random_message() return {'stories': stories, 'success': True, 'code': 0, 'vote_dict': vote_dict, 'max_stories': max_stories, 'prev_page': prev_page, 'next_page': next_page, 'sections': sections, 'filtered_section': section, 'motd': motd, 'subscribed_to_list': subscribed_to_list, 'direct_link': direct_link}
def full(request): message = '' #@TODO: Change this to use slugs instead of literal guids sub_id = request.matchdict['sub_id'] sub_id = submission.get_story_id_from_slug(sub_id) dbsession = DBSession() p = request.session['safe_post'] prm = request.session['safe_params'] s = request.session logged_in = False if 'logged_in' in s: #return {'message': 'Sorry, please log in first.', 'story': {}, 'comments': {}, 'success': False, 'code': 'ENOLOGIN'} logged_in = True # record the comment if 'op' in prm and prm['op'] == 'del' and logged_in: if 'comment_id' in prm: c = submission.get_comment_by_id(prm['comment_id']) if users.is_user_allowed_admin_action(s['users.id'], str(c.id), ): c.deleted = True dbsession.add(c) s['message'] = 'Comment deleted.' if 'op' in prm and prm['op'] == 'edit' and logged_in: if 'comment_id' in prm: c = submission.get_comment_by_id(prm['comment_id']) if users.is_user_allowed_admin_action(s['users.id'], str(c.id), ): c.body = prm['body'] dbsession.add(c) s['message'] = 'Comment updated.' else: if 'description-textarea' in request.session['safe_post'] and logged_in: sub = submission.get_story_by_id(sub_id) if users.is_user_allowed_admin_action(s['users.id'], str(sub.id)): sub.description = prm['description-textarea'] dbsession.add(sub) s['message'] = 'Description updated.' if 'body' in request.session['safe_post'] and logged_in: if p['parent_type'] == 'story': in_reply_to = submission.get_story_by_id(p['comment_parent']).submitter.id elif p['parent_type'] == 'comment': c = submission.get_comment_by_id(p['comment_parent']) in_reply_to = c.user_id c = Comment(sub_id, s['users.id'], p['comment_parent'], prm['body'], in_reply_to = in_reply_to) dbsession.add(c) dbsession.flush() # if enabled default, subscribe user to own comment. # @TODO: make a preference for users to toggle this if general.check_notify_default(s['users.id'], request): notify_queries.create_notify(s['users.id'], c.id, s['users.id']) v = Vote(sub_id, s['users.id'], 1, "comment", c.id) v.direction = 1 dbsession.add(v) notify_queries.fire_to_listeners(p['comment_parent'], s['users.id'], c.id, request) s['message'] = 'Comment added.' #@TODO: Stop using SA queries in views, move them to individual models story = submission.get_story_by_id(sub_id) story.tally_votes() story_vote_dict = {} comment_vote_dict = {} if logged_in: # see queries.py; these two should not be separate. #@FIXME story_vote_dict = users.get_user_votes(s['users.id'], "on_submission", sub_id) comment_vote_dict = users.get_user_votes(s['users.id'], "on_submissions_comments", sub_id) page_num = 1 per_page = 30 if 'sort.comment_default_order' in request.registry.settings: sort = request.registry.settings['sort.comment_default_order'] else: # do NOT change the hardcoded default, change in the ini as above sort = 'top' next_page = None prev_page = None if 'comment_sort' in prm: sort = prm['comment_sort'] if 'page_num' in prm: try: page_num = int(prm['page_num']) except: page_num = 1 # comments returns a dict; see queries.py if 'comment_perma' not in prm: comments = submission.get_comments(sub_id, organize_parentage=True, page_num = page_num, per_page = per_page, sort = sort) else: comments = submission.get_comments(sub_id, organize_parentage=True, page_num = page_num, per_page = per_page, sort = sort, target = 'comment', target_id = prm['comment_perma']) for c in comments['comments']: #@TODO: Don't do this on every load on a real deployment c.tally_votes() if c.deleted: c.body = '[deleted]' if page_num > 1: prev_page = page_num - 1 if comments['max_comments'] > (page_num * per_page): next_page = page_num + 1 return {'story': story, 'comments': comments, 'success': True, 'code': 0, 'story_vote_dict': story_vote_dict, 'comment_vote_dict': comment_vote_dict, 'next_page': next_page, 'prev_page': prev_page, 'render_type': story.render_type, }
def full(request): message = '' #@TODO: Change this to use slugs instead of literal guids sub_id = request.matchdict['sub_id'] sub_id = submission.get_story_id_from_slug(sub_id) dbsession = DBSession() p = request.session['safe_post'] prm = request.session['safe_params'] s = request.session logged_in = False if 'logged_in' in s: #return {'message': 'Sorry, please log in first.', 'story': {}, 'comments': {}, 'success': False, 'code': 'ENOLOGIN'} logged_in = True # record the comment if 'op' in prm and prm['op'] == 'del' and logged_in: if 'comment_id' in prm: c = submission.get_comment_by_id(prm['comment_id']) if users.is_user_allowed_admin_action( s['users.id'], str(c.id), ): c.deleted = True dbsession.add(c) s['message'] = 'Comment deleted.' if 'op' in prm and prm['op'] == 'edit' and logged_in: if 'comment_id' in prm: c = submission.get_comment_by_id(prm['comment_id']) if users.is_user_allowed_admin_action( s['users.id'], str(c.id), ): c.body = prm['body'] dbsession.add(c) s['message'] = 'Comment updated.' else: if 'description-textarea' in request.session['safe_post'] and logged_in: sub = submission.get_story_by_id(sub_id) if users.is_user_allowed_admin_action(s['users.id'], str(sub.id)): sub.description = prm['description-textarea'] dbsession.add(sub) s['message'] = 'Description updated.' if 'body' in request.session['safe_post'] and logged_in: if p['parent_type'] == 'story': in_reply_to = submission.get_story_by_id( p['comment_parent']).submitter.id elif p['parent_type'] == 'comment': c = submission.get_comment_by_id(p['comment_parent']) in_reply_to = c.user_id c = Comment(sub_id, s['users.id'], p['comment_parent'], prm['body'], in_reply_to=in_reply_to) dbsession.add(c) dbsession.flush() # if enabled default, subscribe user to own comment. # @TODO: make a preference for users to toggle this if general.check_notify_default(s['users.id'], request): notify_queries.create_notify(s['users.id'], c.id, s['users.id']) v = Vote(sub_id, s['users.id'], 1, "comment", c.id) v.direction = 1 dbsession.add(v) notify_queries.fire_to_listeners(p['comment_parent'], s['users.id'], c.id, request) s['message'] = 'Comment added.' #@TODO: Stop using SA queries in views, move them to individual models story = submission.get_story_by_id(sub_id) story.tally_votes() story_vote_dict = {} comment_vote_dict = {} if logged_in: # see queries.py; these two should not be separate. #@FIXME story_vote_dict = users.get_user_votes(s['users.id'], "on_submission", sub_id) comment_vote_dict = users.get_user_votes(s['users.id'], "on_submissions_comments", sub_id) page_num = 1 per_page = 30 if 'sort.comment_default_order' in request.registry.settings: sort = request.registry.settings['sort.comment_default_order'] else: # do NOT change the hardcoded default, change in the ini as above sort = 'top' next_page = None prev_page = None if 'comment_sort' in prm: sort = prm['comment_sort'] if 'page_num' in prm: try: page_num = int(prm['page_num']) except: page_num = 1 # comments returns a dict; see queries.py if 'comment_perma' not in prm: comments = submission.get_comments(sub_id, organize_parentage=True, page_num=page_num, per_page=per_page, sort=sort) else: comments = submission.get_comments(sub_id, organize_parentage=True, page_num=page_num, per_page=per_page, sort=sort, target='comment', target_id=prm['comment_perma']) for c in comments['comments']: #@TODO: Don't do this on every load on a real deployment c.tally_votes() if c.deleted: c.body = '[deleted]' if page_num > 1: prev_page = page_num - 1 if comments['max_comments'] > (page_num * per_page): next_page = page_num + 1 return { 'story': story, 'comments': comments, 'success': True, 'code': 0, 'story_vote_dict': story_vote_dict, 'comment_vote_dict': comment_vote_dict, 'next_page': next_page, 'prev_page': prev_page, 'render_type': story.render_type, }
def list(request): from raggregate.queries import user_preference as up s = request.session p = request.session['safe_post'] r = request qs = s['safe_get'] s['message'] = "Post a story." dbsession = DBSession() stories = None filtered_section = None section_found = False sections = section_queries.get_sections() direct_link = False if s.get('users.id', None): direct_link = True if up.get_user_prefs(s['users.id']).get( 'link_to_story', 'off') == 'on' else False if r.params and 'op' in r.params: sub_id = r.params['sub_id'] if r.params['op'] == 'del' or r.params['op'] == 'hide': try: story_to_del = submission.get_story_by_id(sub_id) except sqlalchemy.orm.exc.NoResultFound: story_to_del = None if story_to_del: if users.is_user_allowed_admin_action( s['users.id'], str(story_to_del.id), ): if r.params['op'] == 'del': story_to_del.description = "[deleted]" story_to_del.url = "#" story_to_del.title = "[deleted]" story_to_del.deleted = True dbsession.add(story_to_del) dbsession.flush() else: print("Illegal deletion attempted on {0}".format( story_to_del.submitter.id)) if 'sort.default_order' in r.registry.settings: sort = r.registry.settings['sort.default_order'] else: # default to new sort order if server-specific setting doesn't exist # this should only be the case on old clones; do NOT remove default_order # from the ini just because you want new by default. sort = 'new' page_num = 1 per_page = 30 next_page = None prev_page = None # only pass through approved sort options if 'sort' in qs: if qs['sort'] == 'top': sort = 'top' if qs['sort'] == 'hot': sort = 'hot' if qs['sort'] == 'contro': sort = 'contro' if qs['sort'] == 'new': sort = 'new' if 'page_num' in qs: try: page_num = int(qs['page_num']) except: page_num = 1 if 'section' in qs and qs['section'] == 'all': section = 'all' else: section = None if 'section' in qs and qs['section'] != 'all' and qs['section'] != '': section = qs['section'] try: section = section_queries.get_section_by_name(section) section_found = True except sqlalchemy.orm.exc.NoResultFound: try: section = section_queries.get_section_by_id(section) section_found = True except: from pyramid_tm import transaction transaction.abort() pass # reset section variable to None if we couldn't the named section if section_found == False: section = None else: #if we did find something, set filtered_section so that we can #reference the filtered section in the template. filtered_section = section if 'subscribe' in qs and isinstance(section, Section) and 'logged_in' in s: if qs['subscribe'] == 'y': sub_way = True elif qs['subscribe'] == 'n': sub_way = False sub = sub_queries.create_subscription(s['users.id'], section.id, sub_way) s['message'] = 'Subscription to section {0} updated'.format( section.name) # @FIXME: make per_page configurable in a safe location # it is probably unwise to allow this to be set in the query string # because then a malicious user could say per_page = 10000000000 # and easily launch a DoS via that mechanism. # if 'per_page' in qs: # per_page = qs['per_page'] stories = submission.get_story_list(page_num=page_num, per_page=per_page, sort=sort, request=request, section=section) max_stories = stories['max_stories'] stories = stories['stories'] # this should be split into its own def under queries.py # as it is currently used in at least one other place if max_stories > (page_num * per_page): next_page = page_num + 1 if page_num > 1: prev_page = page_num - 1 vote_dict = {} subscribed_to_list = [] if 'logged_in' in s: vote_dict = users.get_user_votes(s['users.id'], "on_all_submissions") subscribed_to_list = sub_queries.get_subscribed_by_user_id( s['users.id']) for story in stories: #@TODO: Remember to not tally on every load once a real site deploys story.tally_votes() story.tally_comments() print "\n\nsubscribed list: {0}\n\n".format(subscribed_to_list) # Get message of the day motd = motd_queries.get_random_message() return { 'stories': stories, 'success': True, 'code': 0, 'vote_dict': vote_dict, 'max_stories': max_stories, 'prev_page': prev_page, 'next_page': next_page, 'sections': sections, 'filtered_section': section, 'motd': motd, 'subscribed_to_list': subscribed_to_list, 'direct_link': direct_link }
def load_submission(self): from raggregate.queries import submission return submission.get_story_by_id(self.submission_id)
def get_sublist_members(sublist_id): members = dbsession.query(SublistMember).filter(SublistMember.sublist_id == sublist_id).all() member_list = [] for m in members: member_list.append(submission_queries.get_story_by_id(m.member_id)) return member_list