def post(self, **kwargs): if not self.auth_current_user.is_admin and not self.auth_current_user.is_staff: return redirect(url_for('auth/login')) ids = self.request.form.get('jobids').split(',') logging.log(logging.INFO, " ids: %s" % self.request.form.get('jobids') ) if len(ids) > 0: invoice = InvoiceModel() invoice.CreatedBy = self.auth_current_user upload_files = self.get_uploads('invoice') blob_info = upload_files[0] invoice.File = str(blob_info.key()) logging.log(logging.INFO, "set uploaded file as %s" % blob_info.key()) invoice.Client = ClientModel.get(self.request.form.get('clientid')) invoice.put() for id in self.request.form.get('jobids').split(','): job = JobModel.get(id) job.Invoiced = True job.Invoice = invoice job.OrderStage = OrderStatus.Invoiced job.put() self.set_message('success', 'Successfully created invoice. ', flash=True, life=5) response = redirect_to('admin-invoices') # Clear the response body. response.data = '' return response
def get(self, **kwargs): if not self.auth_current_user.is_admin and not self.auth_current_user.is_staff: return redirect(url_for('auth/login')) #kwargs['stages'] = lstStages #kwargs['stagesEnum'] = Stages() invoices = InvoiceModel.all(); invoices.order('Client') kwargs['invoices'] = invoices return self.render_response('admininvoices.html', **kwargs)
def post(self, **kwargs): if not self.auth_current_user.is_admin and not self.auth_current_user.is_staff: return redirect(url_for('auth/login')) if self.request.form.get('invoiceid'): invoice = InvoiceModel.get(self.request.form.get('invoiceid')) invoice.Paid = True invoice.put() jobs = JobModel.all() jobs.filter("Invoice = ", invoice) for job in jobs: job.OrderStage = OrderStatus.Paid job.put() context = {'invoiced': True } if self.request.is_xhr: return render_json_response(context)
def get(self, **kwargs): if not self.auth_current_user.is_admin and not self.auth_current_user.is_staff: return redirect(url_for('auth/login')) invoiceid = kwargs['invoiceid'] jobs = JobModel.all() jobs.filter("Invoice = ", InvoiceModel.get(invoiceid)) context = [] if self.request.is_xhr: for job in jobs: context.append({ 'name' : job.Nickname, 'jobstage': lstJobStages[job.JobStage], 'orderstage': lstOrderStages[job.OrderStage], 'id' : str(job.key()), 'created': job.Created.strftime("%b %d %Y"), 'quote' : job.Quote }); return render_json_response(context) else: return render_response('hello.html', **context)