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),
                     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))
Example #3
0
def run():

    STEP = 100
    thing = Account
    max_id = max_thing_id(thing)
    id_start = 0

    for id_low in xrange(id_start, max_id + 1, STEP):
        users = list(query_thing_id_range(thing, id_low, id_low + STEP))

        for user in users:
            if not user._loaded:
                user._load()
            if hasattr(user, 'email'):
                data = {'name' : user.name, 'password' : None, 'email' : user.email, 'attempt' : 0}
                PendingJob.store(None, 'create_wiki_account', data)
Example #4
0
    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 run(self):
        jobs = PendingJob._query(data=True)

        for job in jobs:
            self.process_job(job)