def GET_submit(self, can_submit, url, title, tags): """Submit form.""" if not can_submit: return BoringPage(_("Not Enough Karma"), infotext="You do not have enough karma to post.", content=NotEnoughKarmaToPost()).render() if url and not request.get.get('resubmit'): # check to see if the url has already been submitted listing = link_listing_by_url(url) redirect_link = None if listing.things: # if there is only one submission, the operation is clear if len(listing.things) == 1: redirect_link = listing.things[0] # if there is more than one, check the users' subscriptions else: subscribed = [l for l in listing.things if c.user_is_loggedin and l.subreddit.is_subscriber_defaults(c.user)] #if there is only 1 link to be displayed, just go there if len(subscribed) == 1: redirect_link = subscribed[0] else: infotext = strings.multiple_submitted % \ listing.things[0].resubmit_link() res = BoringPage(_("Seen it"), content = listing, infotext = infotext).render() return res # we've found a link already. Redirect to its permalink page if redirect_link: return self.redirect(redirect_link.already_submitted_link) captcha = Captcha(tabular=False) if c.user.needs_captcha() else None srs = Subreddit.submit_sr(c.user) # Set the default sr to the user's draft when creating a new article try: sr = Subreddit._by_name(c.user.draft_sr_name) except NotFound: sr = None tab = 'article' if 'link' in request.get: tab = 'link' return FormPage(_("Submit Article"), content=NewLink(title=title or '', subreddits = srs, tags=tags, sr_id = sr._id if sr else None, tab=tab, captcha=captcha)).render()
def GET_submit(self, can_submit, url, title): """Submit form.""" if not can_submit: return BoringPage(_("Not Enough Karma"), infotext="You do not have enough karma to post.", content=NotEnoughKarmaToPost()).render() if url and not request.get.get('resubmit'): # check to see if the url has already been submitted listing = link_listing_by_url(url) redirect_link = None if listing.things: # if there is only one submission, the operation is clear if len(listing.things) == 1: redirect_link = listing.things[0] # if there is more than one, check the users' subscriptions else: subscribed = [ l for l in listing.things if c.user_is_loggedin and l.subreddit.is_subscriber_defaults(c.user) ] #if there is only 1 link to be displayed, just go there if len(subscribed) == 1: redirect_link = subscribed[0] else: infotext = strings.multiple_submitted % \ listing.things[0].resubmit_link() res = BoringPage(_("Seen it"), content=listing, infotext=infotext).render() return res # we've found a link already. Redirect to its permalink page if redirect_link: return self.redirect(redirect_link.already_submitted_link) captcha = Captcha(tabular=False) if c.user.needs_captcha() else None srs = Subreddit.submit_sr(c.user) try: sr = Subreddit._by_name(g.default_sr) except NotFound: sr = None draft_subreddit = Subreddit.draft_subreddit(c.user) main_subreddit = Subreddit.main_subreddit() return FormPage(_("Submit Article"), show_sidebar=True, content=NewLink(title=title or '', draft_subreddit=draft_subreddit, main_subreddit=main_subreddit, captcha=captcha)).render()
def GET_submit(self, url, title, tags): """Submit form.""" if url and not request.get.get('resubmit'): # check to see if the url has already been submitted listing = link_listing_by_url(url) redirect_link = None if listing.things: # if there is only one submission, the operation is clear if len(listing.things) == 1: redirect_link = listing.things[0] # if there is more than one, check the users' subscriptions else: subscribed = [ l for l in listing.things if c.user_is_loggedin and l.subreddit.is_subscriber_defaults(c.user) ] #if there is only 1 link to be displayed, just go there if len(subscribed) == 1: redirect_link = subscribed[0] else: infotext = strings.multiple_submitted % \ listing.things[0].resubmit_link() res = BoringPage(_("Seen it"), content=listing, infotext=infotext).render() return res # we've found a link already. Redirect to its permalink page if redirect_link: return self.redirect(redirect_link.already_submitted_link) captcha = Captcha() if c.user.needs_captcha() else None srs = Subreddit.submit_sr(c.user) if c.default_sr else () # Set the default sr to the user's draft when creating a new article try: sr = Subreddit._by_name(c.user.draft_sr_name) except NotFound: sr = None return FormPage(_("Submit Article"), content=NewLink(title=title or '', subreddits=srs, tags=tags, sr_id=sr._id if sr else None, captcha=captcha)).render()
def GET_submit(self, url, title): """Submit form.""" if url and not request.get.get('resubmit'): # check to see if the url has already been submitted listing = link_listing_by_url(url) redirect_link = None if listing.things: # if there is only one submission, the operation is clear if len(listing.things) == 1: redirect_link = listing.things[0] # if there is more than one, check the users' subscriptions else: subscribed = [l for l in listing.things if c.user_is_loggedin and l.subreddit.is_subscriber_defaults(c.user)] #if there is only 1 link to be displayed, just go there if len(subscribed) == 1: redirect_link = subscribed[0] else: infotext = strings.multiple_submitted % \ listing.things[0].resubmit_link() res = BoringPage(_("seen it"), content = listing, infotext = infotext).render() return res # we've found a link already. Redirect to its permalink page if redirect_link: return self.redirect(redirect_link.already_submitted_link) captcha = Captcha() if c.user.needs_captcha() else None sr_names = Subreddit.submit_sr_names(c.user) if c.default_sr else () return FormPage(_("submit"), content=NewLink(url=url or '', title=title or '', subreddits = sr_names, captcha=captcha)).render()