def get(self, customer_id=None): if customer_id: customer = Customer.query.options( joinedload('customer_projects'), joinedload('customer_projects.installations'), joinedload( 'customer_projects.installations.panels.panel_model'), joinedload( 'customer_projects.installations.inverters.inverter_model' ), joinedload( 'customer_projects.installations.installation_documents'), joinedload('customer_projects.installations.status'), joinedload('customer_projects.installations.financing'), joinedload('customer_projects.installations.financing.status'), joinedload( 'customer_projects.installations.financing.financial_entity' )).filter_by(id=customer_id) return Result.model(customer.first()) page = request.args.get('page', 1) total_pages = 1 q = request.args.get('query') if q: customers = Customer.query.filter( (Customer.first_name.like('%' + q + '%')) | (Customer.last_name.like('%' + q + '%')) | (Customer.primary_email.like('%' + q + '%')) | (Customer.primary_phone.like('%' + q + '%'))( Customer.identification_number.like('%' + q + '%'))).all() else: paginator = Paginator(Customer.query, int(page), request.args.get('orderBy', 'last_name'), request.args.get('orderDir', 'desc')) total_pages = paginator.total_pages customers = paginator.get_items() return Result.paginate(customers, page, total_pages)
def get(self): return Result.model(InverterModel.query.all())
def get(self): return Result.model(PanelModel.query.all())
def get(self): return Result.model(Tension.query.all())
def get(self): return Result.model(Phase.query.all())
def get(self): return Result.model(TrCapacity.query.all())
def get(self): return Result.model(Transformer.query.all())
def get(self): return Result.model(Rate.query.all())
def get(self): return Result.model(Distributor.query.all())
def get(self): return Result.model(ProjectType.query.all())
def get(self): return Result.model(SourceProject.query.all())
def get(self): return Result.model( Country.query.options(joinedload('provinces')).all())
def get(self): return Result.model(FinancialStatus.query.all())
def get(self): return Result.model(FinancialEntity.query.all())
def get(self): return Result.model(SaleType.query.all())
def get(self): return Result.model(CompanyProfile.query.first())