def job_send_meetup_email_to_user(meetup_id, username): meetup = Meetup._byID(meetup_id, data=True) try: user = Account._by_name(username) notify.email_user_about_meetup(user, meetup) except NotFound: # Users can get deleted so ignore if not found pass
def job_process_new_meetup(meetup_id): # Find all users near the meetup who opted to be notified, and add a child # job for each of them, so that the scope of any problems is limited. # These child jobs will run on the next run-through of this script. meetup = Meetup._byID(meetup_id, data=True) users = notify.get_users_to_notify_for_meetup(meetup.coords) for user in users: data = {'username': user.name, 'meetup_id': meetup._id} PendingJob.store(None, 'send_meetup_email_to_user', data)
def POST_create(self, res, title, description, location, latitude, longitude, timestamp, tzoffset, ip): if res._chk_error(errors.NO_TITLE): res._chk_error(errors.TITLE_TOO_LONG) res._focus('title') res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.INVALID_DATE, errors.NO_DATE)) if res.error: return meetup = Meetup(author_id=c.user._id, title=title, description=description, location=location, latitude=latitude, longitude=longitude, timestamp=timestamp, tzoffset=tzoffset) # Expire all meetups in the render cache g.rendercache.invalidate_key_group(Meetup.group_cache_key()) meetup._commit() l = Link._submit(meetup_article_title(meetup), meetup_article_text(meetup), 'self', c.user, Subreddit._by_name('meetups'), ip, []) l.meetup = meetup._id36 l._commit() meetup.assoc_link = l._id meetup._commit() when = datetime.now(g.tz) + timedelta( 0, 3600) # Leave a short window of time before notification, in case # the meetup is edited/deleted soon after its creation PendingJob.store(when, 'process_new_meetup', {'meetup_id': meetup._id}) #update the queries if g.write_query_queue: queries.new_link(l) res._redirect(url_for(action='show', id=meetup._id36))
def POST_create(self, res, title, description, location, latitude, longitude, timestamp, tzoffset, ip): if res._chk_error(errors.NO_TITLE): res._chk_error(errors.TITLE_TOO_LONG) res._focus('title') res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.INVALID_DATE, errors.NO_DATE)) if res.error: return meetup = Meetup( author_id = c.user._id, title = title, description = description, location = location, latitude = latitude, longitude = longitude, timestamp = timestamp, tzoffset = tzoffset ) # Expire all meetups in the render cache g.rendercache.invalidate_key_group(Meetup.group_cache_key()) meetup._commit() l = Link._submit(meetup_article_title(meetup), meetup_article_text(meetup), c.user, Subreddit._by_name('meetups'),ip, []) l.meetup = meetup._id36 l._commit() meetup.assoc_link = l._id meetup._commit() when = datetime.now(g.tz) + timedelta(0, 3600) # Leave a short window of time before notification, in case # the meetup is edited/deleted soon after its creation PendingJob.store(when, 'process_new_meetup', {'meetup_id': meetup._id}) #update the queries if g.write_query_queue: queries.new_link(l) res._redirect(url_for(action='show', id=meetup._id36))
def POST_create(self, res, title, description, location, latitude, longitude, timestamp, tzoffset, ip): if res._chk_error(errors.NO_TITLE): res._chk_error(errors.TITLE_TOO_LONG) res._focus('title') res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.INVALID_DATE, errors.NO_DATE)) if res.error: return meetup = Meetup( author_id=c.user._id, title=title, description=description, location=location, latitude=latitude, longitude=longitude, timestamp=timestamp / 1000, # Value from form is in ms UTC tzoffset=tzoffset) # Expire all meetups in the render cache g.rendercache.invalidate_key_group(Meetup.group_cache_key()) meetup._commit() l = Link._submit(meetup_article_title(meetup), meetup_article_text(meetup), c.user, Subreddit._by_name('discussion'), ip, []) l.meetup = meetup._id36 l._commit() meetup.assoc_link = l._id meetup._commit() #update the queries if g.write_query_queue: queries.new_link(l) res._redirect(url_for(action='show', id=meetup._id36))
def POST_create(self, res, title, description, location, latitude, longitude, timestamp, tzoffset, ip): if res._chk_error(errors.NO_TITLE): res._chk_error(errors.TITLE_TOO_LONG) res._focus('title') res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.INVALID_DATE, errors.NO_DATE)) if res.error: return meetup = Meetup( author_id = c.user._id, title = title, description = description, location = location, latitude = latitude, longitude = longitude, timestamp = timestamp, tzoffset = tzoffset ) # Expire all meetups in the render cache g.rendercache.invalidate_key_group(Meetup.group_cache_key()) meetup._commit() l = Link._submit(meetup_article_title(meetup), meetup_article_text(meetup), c.user, Subreddit._by_name('discussion'),ip, []) l.meetup = meetup._id36 l._commit() meetup.assoc_link = l._id meetup._commit() #update the queries if g.write_query_queue: queries.new_link(l) res._redirect(url_for(action='show', id=meetup._id36))
def POST_update(self, res, meetup, title, description, location, latitude, longitude, timestamp, tzoffset): if res._chk_error(errors.NO_TITLE): res._chk_error(errors.TITLE_TOO_LONG) res._focus('title') res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.INVALID_DATE, errors.NO_DATE)) if res.error: return meetup.title = title meetup.description = description meetup.location = location meetup.latitude = latitude meetup.longitude = longitude meetup.timestamp = timestamp meetup.tzoffset = tzoffset # Expire all meetups in the render cache g.rendercache.invalidate_key_group(Meetup.group_cache_key()) meetup._commit() # Update the linked article article = Link._byID(meetup.assoc_link) article._load() article_old_url = article.url article.title = meetup_article_title(meetup) article.article = meetup_article_text(meetup) article._commit() article.update_url_cache(article_old_url) res._redirect(url_for(action='show', id=meetup._id36))