def get(self): """Simply returns a rendered template with an enigmatic salutation.""" upload_url = blobstore.create_upload_url('/upload') auth_session = None if 'id' in self.auth_session: auth_session = self.auth_session template_values = { 'uploadurl' : upload_url, 'auth_session': auth_session, 'current_user': self.auth_current_user, 'login_url': self.auth_login_url(), 'logout_url': self.auth_logout_url(), 'current_url': self.request.url } if self.session.get('client') is not None: template_values['client'] = ClientModel.get(self.session.get('client')) history = JobHistoryModel.all() history.filter("Client =", ClientModel.get(self.session.get('client'))) history.order("-Created") history.fetch(100); template_values['history'] = history jobs = JobModel.all() jobs.filter("Client =", ClientModel.get(self.session.get('client'))) jobs.order("-Changed") jobs.fetch(100) template_values['jobs'] = jobs logging.log(logging.INFO, "client " + ClientModel.get(self.session.get('client')).Name + " has " + str(template_values['jobs'].count()) + " jobs") return self.render_response('clientlanding.html', **template_values)
def get(self, **kwargs): auth_session = None if 'id' in self.auth_session: auth_session = self.auth_session template_values = { 'auth_session': auth_session, 'current_user': self.auth_current_user, 'login_url': self.auth_login_url(), 'logout_url': self.auth_logout_url(), 'current_url': self.request.url } try: if kwargs['view'] is not None: template_values['view'] = kwargs['view'] except: template_values['view'] = None if self.session.get('client') is not None: template_values['client'] = ClientModel.get( self.session.get('client')) history = JobHistoryModel.all() history.filter("Client =", ClientModel.get(self.session.get('client'))) history.order("-Created") history.fetch(100) template_values['history'] = history jobs = JobModel.all() jobs.filter("Client =", ClientModel.get(self.session.get('client'))) try: if kwargs['order']: jobs.order(kwargs['order']) else: jobs.order('OrderStage') except: jobs.order('OrderStage') template_values['jobs'] = jobs template_values['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages': JobStatus(), 'allOrderStages': lstOrderStages, 'allJobStages': lstJobStages } return self.render_response('clientlanding.html', **template_values)
def post(self): if self.request.form.get('jobid'): job = JobModel.get(self.request.form.get('jobid')) job.ChangedBy = self.auth_current_user job.Description = self.request.form.get('description') job.Nickname = self.request.form.get('nickname') add_history("job was updated", self.auth_current_user, job.key(), self.auth_current_user.assigned_to) job.put() else: job = JobModel() job.Approved = False job.Description = self.request.form.get('description') job.Nickname = self.request.form.get('nickname') job.ChangedBy = self.auth_current_user job.CreatedBy = self.auth_current_user job.Client = ClientModel.get(self.auth_current_user.assigned_to) job.OrderStage = OrderStatus.PendingQuote job.put() #.Created.strftime("%a, %b %d %Y - %I:%M%P") job.JobNumber = job.Created.strftime("%Y_%b_%d_") job.JobNumber += str(job.key().id()) job.put() add_history("a request for a quote was started. ", self.auth_current_user, job.key(), self.auth_current_user.assigned_to) context = {'added': True, 'key': str(job.key())} if self.request.is_xhr: return render_json_response(context) else: return render_response('hello.html', **context)
def post(self): if self.request.form.get('jobid'): job = JobModel.get(self.request.form.get('jobid')) job.ChangedBy = self.auth_current_user job.Description = self.request.form.get('description') job.Nickname = self.request.form.get('nickname') add_history("job was updated", self.auth_current_user, job.key(), self.auth_current_user.assigned_to) job.put() else: job = JobModel() job.Approved = False job.Description = self.request.form.get('description') job.Nickname = self.request.form.get('nickname') job.ChangedBy = self.auth_current_user job.CreatedBy = self.auth_current_user job.Client = ClientModel.get(self.auth_current_user.assigned_to) job.OrderStage = OrderStatus.PendingQuote job.put() #.Created.strftime("%a, %b %d %Y - %I:%M%P") job.JobNumber = job.Created.strftime("%Y_%b_%d_") job.JobNumber += str(job.key().id()) job.put() add_history("a request for a quote was started. ", self.auth_current_user, job.key(), self.auth_current_user.assigned_to) context = {'added': True, 'key' : str(job.key()) } if self.request.is_xhr: return render_json_response(context) else: return render_response('hello.html', **context)
def getClientsAndUsers(clientkey = None): if clientkey: clients = ClientModel.get(clientkey) else: clients = ClientModel.all().order("Name") context = [] for client in clients: users_query = db.Query(User).filter("assigned_to", str(client.key())) logging.log(logging.INFO, "users: " + str(users_query.count())) u = [] if users_query.count() > 0: for user in users_query: u.append({'Username' : user.username, 'Email' : user.email, 'Key': str(user.key())}) client.Users = u; context.append(client) return context;
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')) clientid = kwargs['clientid'] jobs = JobModel.all() jobs.filter("Client = ", ClientModel.get(clientid)) jobs.filter("Invoiced != " , True) context = [] if self.request.is_xhr: for job in jobs: os = None js = None if job.OrderStage and lstOrderStages[job.OrderStage]: os = lstOrderStages[job.OrderStage] if job.JobStage: js = lstJobStages[job.JobStage] context.append({ 'name' : job.Nickname, 'jobstage': js, 'orderstage': os, '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)
def getClientChoices(): clients = ClientModel.all() choices = [("admin", "Admin (all access)"), ("staff", "Staff (limited access)")]; for client in clients: choices.append((str(client.key()), client.Name)) logging.log(logging.INFO, str(len(choices)) + " choices") return choices
def get(self, **kwargs): auth_session = None if 'id' in self.auth_session: auth_session = self.auth_session template_values = { 'auth_session': auth_session, 'current_user': self.auth_current_user, 'login_url': self.auth_login_url(), 'logout_url': self.auth_logout_url(), 'current_url': self.request.url } try: if kwargs['view'] is not None: template_values['view'] = kwargs['view'] except: template_values['view'] = None if self.session.get('client') is not None: template_values['client'] = ClientModel.get(self.session.get('client')) history = JobHistoryModel.all() history.filter("Client =", ClientModel.get(self.session.get('client'))) history.order("-Created") history.fetch(100); template_values['history'] = history jobs = JobModel.all() jobs.filter("Client =", ClientModel.get(self.session.get('client'))) try: if kwargs['order']: jobs.order(kwargs['order']) else: jobs.order('OrderStage') except: jobs.order('OrderStage') template_values['jobs'] = jobs template_values['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages' : JobStatus(), 'allOrderStages' : lstOrderStages, 'allJobStages' : lstJobStages } return self.render_response('clientlanding.html', **template_values)
def post(self): if self.request.form.get('key') is not None: # logging.log(logging.INFO, "deleting client with key " + self.request.form.get('key')) c = ClientModel.get(self.request.form.get('key')) name = c.Name if c: c.delete() add_history("a client was deleted! (%s)" % name, self.auth_current_user, None, None) return render_json_response({})
def get(self): """Simply returns a rendered template with an enigmatic salutation.""" upload_url = blobstore.create_upload_url('/upload') auth_session = None if 'id' in self.auth_session: auth_session = self.auth_session template_values = { 'uploadurl': upload_url, 'auth_session': auth_session, 'current_user': self.auth_current_user, 'login_url': self.auth_login_url(), 'logout_url': self.auth_logout_url(), 'current_url': self.request.url } if self.session.get('client') is not None: template_values['client'] = ClientModel.get( self.session.get('client')) history = JobHistoryModel.all() history.filter("Client =", ClientModel.get(self.session.get('client'))) history.order("-Created") history.fetch(100) template_values['history'] = history jobs = JobModel.all() jobs.filter("Client =", ClientModel.get(self.session.get('client'))) jobs.order("-Changed") jobs.fetch(100) template_values['jobs'] = jobs logging.log( logging.INFO, "client " + ClientModel.get(self.session.get('client')).Name + " has " + str(template_values['jobs'].count()) + " jobs") return self.render_response('clientlanding.html', **template_values)
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['client'] = ClientModel.get(kwargs['clientid']) # kwargs['history'] = db.Query("SELECT * FROM JobHistoryModel WHERE Client=:client ORDER BY Created LIMIT 30", client=ClientModel.get(kwargs['clientid'])) history = JobHistoryModel.all() history.filter("Client =", ClientModel.get(kwargs['clientid'])) history.order("-Created").fetch(200) kwargs['history'] = history kwargs['stages'] = lstStages kwargs['stagesEnum'] = Stages() jobs = JobModel.all() jobs.filter("Client =", ClientModel.get(kwargs['clientid'])) try: if kwargs['order']: jobs.order(kwargs['order']) else: jobs.order('Stage') except: jobs.order('Stage') kwargs['jobs'] = jobs return self.render_response('adminclient.html', **kwargs)
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['history'] = JobHistoryModel.all().order('-Created').fetch(20) for h in kwargs['history']: h.Created = h.Created.replace(tzinfo=pytz.timezone('US/Eastern')).astimezone(timezone("US/Eastern")) kwargs['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages' : JobStatus(), 'allOrderStages' : lstOrderStages, 'allJobStages' : lstJobStages } jobs = JobModel.all() try: if kwargs['order']: jobs.order(kwargs['order']) else: jobs.order('OrderStage') except: jobs.order('OrderStage') try: if kwargs['clientid']: jobs.filter("Client = " , ClientModel.get(kwargs['clientid'])) except: pass kwargs['jobs'] = jobs kwargs['clients'] = ClientModel.all() for job in kwargs['jobs']: job.Created = job.Created.replace(tzinfo=pytz.timezone('US/Mountain')).astimezone(timezone("US/Mountain")) return self.render_response('admindashboard.html', **kwargs)
def get(self, **kwargs): if self.auth_current_user.is_admin or self.auth_current_user.is_staff: #this user is admin or staff kwargs['client'] = JobModel.get(kwargs['jobid']).Client kwargs['uploadurl'] = upload_url = blobstore.create_upload_url( '/upload') kwargs['job'] = JobModel.get(kwargs['jobid']) kwargs['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages': JobStatus(), 'allOrderStages': lstOrderStages, 'allJobStages': lstJobStages, 'allStages': lstAllStages } logging.log(logging.INFO, kwargs['StatusInfo']) kwargs['isAdmin'] = self.auth_current_user.is_admin kwargs['isStaff'] = self.auth_current_user.is_staff kwargs['isClient'] = False kwargs['files'] = getArtifacts(kwargs['jobid']) kwargs['history'] = getHistory(kwargs['jobid']) kwargs['communication'] = get_communication(kwargs['jobid']) kwargs['token'] = addConnection(JobModel.get(kwargs['jobid']), self.auth_current_user) return self.render_response('job.html', **kwargs) else: if self.session.get('client') is not None and self.session.get( 'client') == str( JobModel.get(kwargs['jobid']).Client.key()): kwargs['client'] = ClientModel.get(self.session.get('client')) kwargs['uploadurl'] = upload_url = blobstore.create_upload_url( '/upload') kwargs['job'] = JobModel.get(kwargs['jobid']) kwargs['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages': JobStatus(), 'allOrderStages': lstOrderStages, 'allJobStages': lstJobStages } logging.log(logging.INFO, kwargs['StatusInfo']) kwargs['isClient'] = True kwargs['files'] = getArtifacts(kwargs['jobid']) kwargs['history'] = getHistory(kwargs['jobid']) kwargs['communication'] = get_communication(kwargs['jobid']) kwargs['token'] = addConnection(JobModel.get(kwargs['jobid']), self.auth_current_user) return self.render_response('job.html', **kwargs) else: return self.redirect("/login")
def get(self): if not self.auth_current_user.is_admin and not self.auth_current_user.is_staff: return redirect(url_for('auth/login')) clients = ClientModel.all().order("Name") context = [] if self.request.is_xhr: for client in clients: users_query = db.Query(User).filter("assigned_to", str(client.key())) logging.log(logging.INFO, "users: " + str(users_query.count())) u = [] if users_query.count() > 0: for user in users_query: u.append({'Username' : user.username, 'Email' : user.email, 'Key': str(user.key())}) context.append({'Name' : client.Name, 'Key' : str(client.key()), 'Address': client.Address, 'Email' : client.Email, 'PhoneNumber': client.PhoneNumber, 'Users' : u}); return render_json_response(context) else: return render_response('hello.html', **context)
def get(self, **kwargs): if self.auth_current_user.is_admin or self.auth_current_user.is_staff: #this user is admin or staff kwargs['client'] = JobModel.get(kwargs['jobid']).Client kwargs['uploadurl'] = upload_url = blobstore.create_upload_url('/upload') kwargs['job'] = JobModel.get(kwargs['jobid']) kwargs['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages' : JobStatus(), 'allOrderStages' : lstOrderStages, 'allJobStages' : lstJobStages, 'allStages' : lstAllStages } logging.log(logging.INFO, kwargs['StatusInfo']) kwargs['isAdmin'] = self.auth_current_user.is_admin kwargs['isStaff'] = self.auth_current_user.is_staff kwargs['isClient'] = False kwargs['files'] = getArtifacts(kwargs['jobid']) kwargs['history'] = getHistory(kwargs['jobid']) kwargs['communication'] = get_communication(kwargs['jobid']) kwargs['token'] = addConnection(JobModel.get(kwargs['jobid']),self.auth_current_user); return self.render_response('job.html', **kwargs) else: if self.session.get('client') is not None and self.session.get('client') == str(JobModel.get(kwargs['jobid']).Client.key()): kwargs['client'] = ClientModel.get(self.session.get('client')) kwargs['uploadurl'] = upload_url = blobstore.create_upload_url('/upload') kwargs['job'] = JobModel.get(kwargs['jobid']) kwargs['StatusInfo'] = { 'OrderStages': OrderStatus(), 'JobStages' : JobStatus(), 'allOrderStages' : lstOrderStages, 'allJobStages' : lstJobStages } logging.log(logging.INFO, kwargs['StatusInfo']) kwargs['isClient'] = True kwargs['files'] = getArtifacts(kwargs['jobid']) kwargs['history'] = getHistory(kwargs['jobid']) kwargs['communication'] = get_communication(kwargs['jobid']) kwargs['token'] = addConnection(JobModel.get(kwargs['jobid']),self.auth_current_user); return self.render_response('job.html', **kwargs) else : return self.redirect("/login")
def get(self, **kwargs): if str(self.auth_current_user.key()) == kwargs['userid'] or self.auth_current_user.is_admin or self.auth_current_user.is_staff: form = self.form user = User.get(kwargs['userid']) kwargs['user'] = user history = JobHistoryModel.all() history.filter("CreatedBy =", User.get(kwargs['userid'])) history.order("-Created").fetch(20); kwargs['history'] = history if user.assigned_to: kwargs['client'] = ClientModel.get(user.assigned_to) if user: obj = { 'username' : user.username, 'key' : str(user.key()), 'email' : user.email } logging.log(logging.INFO, 'editing user: '******'form'] = form return self.render_response('edituser.html', **kwargs) else: return self.redirect_to(url_for('account/login'))
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')) #get the client or create new if new if self.request.form.get('key') is not None: c = ClientModel.get(self.request.form.get('key')) else : c = ClientModel() #set the client properties and save # c.Changed = datetime.now() c.Name = self.request.form.get('name') c.Address = self.request.form.get('address') if self.request.form.get('phone') is not None: c.PhoneNumber = self.request.form.get('phone') c.Email = self.request.form.get('email') c.CreatedBy = self.auth_current_user c.put() add_history("a client was updated", self.auth_current_user, None, c.key()) self.set_message('success', 'Successfully saved your changes. ', flash=True, life=5) #create the user username = self.request.form.get('username') password = self.request.form.get('password') context = {} if username and password: auth_id = 'own|%s' % username user = self.auth_create_user(username, auth_id, password=password, assigned_to=str(c.key()), email=self.request.form.get('email')) #create the result if user: context = {'clientadded': True, 'key': str(c.key()), 'user' : str(user.key()) } add_history("user was created", self.auth_current_user, None, c.key(), user.key()) self.set_message('success', 'The user was created. ', flash=True, life=5) else : context = {'clientadded': True, 'key' : str(c.key()) } if self.request.is_xhr: return render_json_response(context) else: return redirect(self.request.form.get('redirect'))
def get(self, **kwargs): if self.session.get('client') is not None: kwargs['client'] = ClientModel.get(self.session.get('client')) kwargs['uploadurl'] = upload_url = blobstore.create_upload_url('/upload') return self.render_response('clientjob.html', **kwargs)
def get(self, **kwargs): if self.session.get('client') is not None: kwargs['client'] = ClientModel.get(self.session.get('client')) kwargs['uploadurl'] = upload_url = blobstore.create_upload_url( '/upload') return self.render_response('clientjob.html', **kwargs)