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 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 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 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)