def list(self, id=None): company_name = request.params.get('company_name', '') number = request.params.get('number', '') date_from = request.params.get('invoiceDateFrom', h.today(30)) date_to = request.params.get('invoiceDateTo', h.today()) query = InvoiceCorrect.query if company_name: query = query.filter(Company.shortName.like('%' + company_name + '%') ) query = query.filter(InvoiceCorrect.created_at.between(date_from, date_to) ) query = query.filter(InvoiceCorrect.number.like('%' + number + '%') ) if id: query = InvoiceCorrect.query.filter(InvoiceCorrect.invoice_id == id) records = query.order_by(InvoiceCorrect.created_at.desc(), InvoiceCorrect.series_number.desc()) c.paginator = paginate.Page( records, page=int(request.GET.pop('page', 1)), items_per_page = int(request.GET.pop('page_size', 30)), **dict(request.GET) ) if 'partial' in request.params: return render('/corrects/list-partial.xhtml') else: return render('/corrects/list.xhtml')
def add(self, id): order = Order.query.get_or_abort(id) c.invoices = Invoice.query.filter_by(idCompany=order.idCompany, isBooked=0).all() c.form = NewInvoiceForm(request.POST) if request.method == "POST" and c.form.validate(): invoice = Invoice() element = InvoicePosition() invoice.series_year = c.form.year.data invoice.series_month = c.form.months.data invoice.issueDate = h.today() invoice.idCompany = order.idCompany invoice.tax = order.company.tax invoice.save() element.order_id = order.id element.invoice_id = invoice.id element.value = order.freight element.currency_id = order.currency.id element.tax = order.company.tax element.save() flash(u"Faktura pomyślnie dodana.") return self.redirect(url(controller="invoices", action="edit", id=invoice.id)) return render("/invoices/add.xhtml")
def list(self): records = Document.query c.paginator = paginate.Page( records, page=int(request.params.get('page', 1)), items_per_page = 30, ) return render('/documents/list.xhtml')
def list(self): records = Delegation.query.order_by(desc(Delegation.id)) c.paginator = paginate.Page( records, page=int(request.params.get('page', 1)), items_per_page = 30, ) return render('/delegations/list.xhtml')
def list(self): records = User.query c.paginator = paginate.Page( records, page=int(request.GET.pop("page", 1)), items_per_page=int(request.GET.pop("page_size", 30)), **dict(request.GET) ) return render("/users/list.xhtml")
def list(self): records = Dictionary.query c.paginator = paginate.Page( records, page=int(request.GET.pop('page', 1)), items_per_page = int(request.GET.pop('page_size', 30)), **dict(request.GET) ) return render('/dictionaries/list.xhtml')
def list(self): name = request.GET.get('name', '') nip = request.GET.get('nip', '') records = Company.query.filter(Company.shortName.like(u'%' + name + u'%')) \ .filter(Company.nip.like(u'%' + nip + u'%')) \ .order_by(Company.name).all() c.paginator = paginate.Page( records, page=int(request.GET.pop('page', 1)), items_per_page = int(request.GET.pop('page_size', 30)), **dict(request.GET) ) if 'partial' in request.params: return render('/companies/list-partial.xhtml') else: return render('/companies/list.xhtml')
def list(self): company_name = request.params.get("company_name", "") number = request.params.get("number", "") is_booked = request.params.get("is_booked", "") date_from = request.params.get("invoiceDateFrom", h.today(30)) date_to = request.params.get("invoiceDateTo", h.today()) query = Invoice.query.join(Invoice.company).options(eagerload("company"), eagerload("elements")) if company_name != "": query = query.filter(Company.shortName.like(u"%" + company_name + u"%")) if is_booked: query = query.filter(Invoice.isBooked == is_booked) query = query.filter(Invoice.created_at.between(date_from, date_to)) query = query.filter(Invoice.number.like(u"%" + number + u"%")) records = query.order_by(Invoice.created_at.desc(), Invoice.series_number.desc()) invoice = Invoice() c.actions = invoice.get_action_choices(request) if request.method == "POST": response = invoice.response_action(request, Invoice.query) if response is not None: return response c.months = h.months_list() c.year = str(datetime.datetime.now().year) c.paginator = paginate.Page( records, page=int(request.GET.pop("page", 1)), items_per_page=int(request.GET.pop("page_size", 30)), **dict(request.GET) ) if "partial" in request.params: return render("/invoices/list-partial.xhtml") else: return render("/invoices/list.xhtml")
def edit(self, id): c.document = Document.query.get_or_abort(id) c.form = DocumentForm(request.POST, obj=c.document) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(c.document) c.document.save() flash(u'Seria pomyślnie zapisana') return self.redirect(url(controller='documents', action='edit', id=id)) return render('/documents/edit.xhtml')
def add(self): c.form = CompanyForm(request.POST, prefix='company') if request.method == 'POST' and c.form.validate(): company = Company() c.form.populate_obj(company) company.save() flash(u'Kontrahent pomyślnie dodany.') return self.redirect(url(controller='companies', action='edit', id=company.id)) return render('/companies/add.xhtml')
def edit(self, id): c.delegation = Delegation.query.get_or_abort(id) c.form = DelegationForm(request.POST, obj=c.delegation) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(c.delegation) c.delegation.save() flash(u'Delegacja pomyślnie zapisana') return self.redirect(url(controller='delegations', action='edit', id=id)) return render('/delegations/edit.xhtml')
def edit_semitrailer(self, id): semitrailer = Semitrailer.query.get_or_abort(id) c.form = SemitrailerForm(request.POST, obj=semitrailer) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(semitrailer) semitrailer.save() flash(u'Pomyślnie zapisano naczepę') return self.redirect(url(controller='drivers', action='list')) return render('/drivers/edit_semitrailer.xhtml')
def add_semitrailer(self): c.form = SemitrailerForm(request.POST) if request.method == 'POST' and c.form.validate(): semitrailer = Semitrailer() c.form.populate_obj(semitrailer) semitrailer.save() flash(u'Pomyślnie dodano naczepę') return self.redirect(url(controller='drivers', action='edit_semitrailer', id=semitrailer.id)) return render('/drivers/add_semitrailer.xhtml')
def add(self): c.form = DriverForm(request.POST) if request.method == 'POST' and c.form.validate(): driver = Driver() c.form.populate_obj(driver) driver.save() flash(u'Pomyślnie dodano kierowcę') return self.redirect(url(controller='drivers', action='edit', id=driver.id)) return render('/drivers/add.xhtml')
def add(self): c.form = GroupForm(request.POST) if request.method == 'POST' and c.form.validate(): group = Group() c.form.populate_obj(group) group.save() flash(u'Dodano nową grupę.') return self.redirect(url(controller='groups', action='list')) return render('/groups/add.xhtml')
def add_truck(self): c.form = TruckForm(request.POST) if request.method == 'POST' and c.form.validate(): truck = Truck() c.form.populate_obj(truck) truck.save() flash(u'Pomyślnie dodano ciągnik') return self.redirect(url(controller='drivers', action='edit_truck', id=truck.id)) return render('/drivers/add_truck.xhtml')
def password_change(self): c.form = ChangePasswordForm(request.POST) if request.method == "POST" and c.form.validate(): user = User.query.get(h.auth.user_id()) user.password = c.form.password.data user.save() flash(u"Hasło zostało zmienione.") return self.redirect(url(controller="users", action="list")) return render("/users/password_change.xhtml")
def edit_truck(self, id): truck = Truck.query.get_or_abort(id) c.form = TruckForm(request.POST, obj=truck) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(truck) truck.save() flash(u'Pomyślnie zapisano ciągnik') return self.redirect(url(controller='drivers', action='list')) return render('/drivers/edit_truck.xhtml')
def edit(self, id): group = Group.query.get_or_abort(id) c.form = GroupForm(request.POST, obj = group) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(group, exclude=['id']) group.save() flash(u'Pomyślnie edytowano grupę.') return self.redirect(url(controller='groups', action='list')) return render('/groups/edit.xhtml')
def edit(self, id): entry = Dictionary.query.get(id) c.form = DictionaryForm(request.POST, obj=entry) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(entry) entry.save() flash(u'Słownik pomyślnie edytowany.') return self.redirect(url(controller='dictionaries', action='list')) return render('/dictionaries/edit.xhtml')
def edit(self, id): c.user = User.query.get(id) c.form = UserEditForm(request.POST, obj=c.user, groups=c.user.groups) if request.method == "POST" and c.form.validate(): user = User.query.get_or_abort(id) c.form.populate_obj(user, exclude=["id"]) user.save() flash(u"Użytkownik pomyślnie edytowany.") return redirect(url(controller="users", action="list")) return render("/users/edit.xhtml")
def edit_place(self, id): c.place = Place.query.get_or_abort(id) c.place_form = PlaceForm(request.POST, obj=c.place) if request.method == 'POST' and c.place_form.validate(): c.place_form.populate_obj(c.place) c.place.save() flash(u'Miejsce pomyślnie edytowane.') return self.redirect(url(controller='companies', action='edit', id=c.place.idCompany)) return render('/places/edit.xhtml')
def document(self): """Render the error document""" resp = request.environ.get('pylons.original_response') code = cgi.escape(request.GET.get('code', '')) content = cgi.escape(request.GET.get('message', '')) if resp: content = literal(resp.status) code = code or cgi.escape(str(resp.status_int)) if not code: raise Exception('No status code was found') c.code = code c.message = content return render('/errors/error.xhtml')
def add(self): c.form = DictionaryForm(request.POST) if request.method == 'POST' and c.form.validate(): entry = Dictionary() c.form.populate_obj(entry, exclude=['id']) try: entry.save() flash(u'Dodano nowe pole.') return self.redirect(url(controller='dictionary', action='list')) except DictionaryExistsException: flash(u'Podany klucz i wartość już istnieją.') return render('/dictionaries/add.xhtml')
def list(self): c.user = meta.Session.query(User.id, User.last_name + u' ' + User.first_name).all() company_name = request.params.get('company_name', '') number = request.params.get('number', '') is_factured = request.params.get('is_factured', '') numberTransportOrder = request.params.get('numberTransportOrder', '') date_from = request.params.get('orderDateFrom', h.today(30)) date_to = request.params.get('orderDateTo', h.today()) idCreator = request.params.get('idCreator', '') records = Order.query.options(eagerload('places'), eagerload('transport_order')) if company_name: records = records.join(Company, aliased=True).filter(Company.shortName.like('%' + company_name + '%') ) if numberTransportOrder: records = records.join(Order.transport_order).join(TransportOrder.company, aliased=True).filter(and_(Company.shortName.like('%' + numberTransportOrder + '%'))) if is_factured: records = records.filter(Order.isFactured == is_factured) if idCreator: records = records.filter(Order.idCreator == idCreator) if number: records = records.filter(Order.number.like('%' + number + '%') ) records = records.filter(Order.created_at.between(date_from, date_to) ).order_by(desc(Order.id)) c.paginator = paginate.Page( records, page=int(request.GET.pop('page', 1)), items_per_page = int(request.GET.pop('page_size', 30)), **dict(request.GET) ) if 'partial' in request.params: return render('/orders/list-partial.xhtml') else: return render('/orders/list.xhtml')
def add(self): c.form = OrderForm(request.POST) if request.method == 'POST' and c.form.validate(): order = Order() order.idCompany = c.form.idCompany.data order.freight = c.form.freight.data order.foreignOrder = c.form.foreignOrder.data order.currency = c.form.currency.data order.isCurrencyDate = c.form.isCurrencyDate.data order.save() flash(u'Zlecenie pomyślnie utworzone.') return self.redirect(url(controller='orders', action='edit', id=order.id)) return render('/orders/add.xhtml')
def edit(self, id): c.invoice = Invoice.query.get_or_abort(id) c.form = InvoiceForm(request.POST, obj=c.invoice, number=c.invoice.number) if request.method == "POST" and c.form.validate(): c.form.populate_obj(c.invoice, exclude=["company", "number", "payment_date"]) c.invoice.save() if not c.invoice.is_exported: flash(u"Faktura pomyślnie zapisana") else: flash(u"Faktura nie może być zmieniana po eksporcie do OPTIMY") return self.redirect(url(controller="invoices", action="edit", id=c.invoice.id)) return render("/invoices/edit.xhtml")
def edit(self, id): c.correct = InvoiceCorrect.query.get(id) c.form = InvoiceCorrectForm(request.POST, obj=c.correct) if request.method == 'POST' and c.form.validate(): c.form.populate_obj(c.correct, exclude=['id', 'company', 'number', 'positions']) for index, form_position in enumerate(c.form.positions): position = c.correct.positions[index] form_position.form.populate_obj(position, exclude=['id']) c.correct.save() flash(u'Korekta pomyślnie zapisana') return self.redirect(url(controller='corrects', action='edit', id=c.correct.id)) return render('/corrects/edit.xhtml')
def register(self): c.form = UserRegisterForm(request.POST) if request.method == "POST" and c.form.validate(): user = User() c.form.populate_obj(user, exclude=["id"]) try: user.save() except LoginOrEmailExistsException: flash(u"Twój email lub login istnieje już w bazie danych. Użyj innego.") else: flash(u"Użytkownik został pomyślnie dodany do bazy danych.") return redirect(url(controller="users", action="list")) return render("/users/register.xhtml")
def list(self): return temporary = g.settings if request.method == 'POST': temporary = request.POST c.form = SettingsForm(temporary) if request.method == 'POST' and c.form.validate(): for field in c.form.data.iterkeys(): option = Setting.query.filter(Setting.name == field).one() option.value = c.form.data[field] option.save() flash(u'Opcje pomyślnie zapisane.') return self.redirect(url(controller='settings', action='list')) return render('/settings/main.xhtml')