Beispiel #1
0
 def post(self, job_id):
     job = Job.get_by_key_name(job_id)
     # make sure the job is recent
     if not(job.active):
         self.error(404)
     email = job.email
     email.enable = False
     email.updated_at = datetime.datetime.now()
     email.put()
     # find the email-club join
     join_query = EmailToClub.all()
     join_query.filter("email =", email)
     joins = join_query.fetch(20)
     # do the delete
     for join in joins:
         join.enable = False
         join.updated_at = datetime.now()
         join.put()
     # mark all the jobs inactive
     job_query = Job.all()
     job_query.filter("email =", email)
     job_query.filter("active =", True)
     jobs = job_query.fetch(20)
     for job in jobs:
         job.active = False
         job.put()
     self.response.out.write(template.render("templates/sorry.html", {}))
Beispiel #2
0
    def get(self, job_id):
        job = Job.get_by_key_name(job_id)

        if job and job.state != DONE and job.active == True:
            job.updated_at = datetime.now()
            job.state = DONE
            job.put()
            # update the email
            email = job.email
            email.updated_at = datetime.now()
            email.put()
            # count the number of jobs attached to this flyer
            job_query = Job.all()
            job_query.filter("flyer =", job.flyer)
            job_query.filter("active =", True)
            total_jobs = job_query.count()
            # count the number of jobs done so far
            job_query = Job.all()
            job_query.filter("flyer =", job.flyer)
            job_query.filter("active =", True)
            job_query.filter("state =", DONE)
            done_jobs = job_query.count()
            # write out
            self.response.out.write(template.render("templates/finish.html",
                                                    {"total": total_jobs,
                                                     "done": done_jobs}))
        else:
            self.error(404)
Beispiel #3
0
 def post(self, job_id):
     job = Job.get_by_key_name(job_id)
     # make sure the job is recent
     if not(job.active):
         self.error(404)
     club = job.flyer.club
     email = job.email
     # update the email
     email.updated_at = datetime.now()
     email.put()
     # find the email-club join
     join_query = EmailToClub.all()
     join_query.filter("email =", email)
     join_query.filter("club =", club)
     join = join_query.get()
     # do the delete
     join.enable = False
     join.updated_at = datetime.now()
     join.put()
     # mark all the jobs inactive
     flyer_query = Flyer.all()
     flyer_query.filter("club =", club)
     flyer_query.filter("active =", True)
     flyers = flyer_query.fetch(20)
     for flyer in flyers:
         job_query = Job.all()
         job_query.filter("email =", email)
         job_query.filter("flyer =", flyer)
         job_query.filter("active =", True)
         job = job_query.get()
         if job:
             job.active = False
             job.put()
     self.response.out.write(template.render("templates/sorry.html",
                                             {}))
Beispiel #4
0
    def get(self, job_id):
        job = Job.get_by_key_name(job_id)
        # make sure the job is recent
        if not(job):
            self.error(404)
            return
        if not(job.active):
            self.error(404)
            return

        # display the "are you sure?" page
        self.response.out.write(template.render("templates/stop_certain.html",
                                                {}))
Beispiel #5
0
 def get(self, job_id):
     job = Job.get_by_key_name(job_id)
     if not job:
         self.error(404)
     flyer = job.flyer
     email = job.email
     # update the email
     email.updated_at = datetime.now()
     email.put()
     if flyer.flyer:
         if job.state == INIT:
             job.updated_at = datetime.now()
             job.state = DOWNLOADED
             job.put()
         # get the blobstore key, send it off
         resource = flyer.flyer.key()
         blob_info = blobstore.BlobInfo.get(resource)
         self.send_blob(blob_info, save_as=flyer.name+".pdf")
     else:
         self.error(404)