예제 #1
0
파일: users.py 프로젝트: rafal-kos/pytis
    def authenticate(self):
        user = User()
        user.login = request.POST["login"]
        user.password = request.POST["password"]

        try:
            user.exists()
        except UserDoesntExistsException:
            flash(u"Niepoprawne dane autoryzacyjne. Sprawdź swój login i hasło.", "error")
            return redirect(url(controller="users", action="login"))

        user = User.query.filter(User.login == request.POST["login"]).first()
        flash(u"Witamy w systemie")
        try:
            session["user"] = {"id": user.id, "login": user.login}

            groups = []
            for group in user.groups:
                groups.append(str(group.name).lower())
            session["user"].update({"groups": groups})
        except KeyError:
            pass
        else:
            session.save()
            return redirect(url("/"))
예제 #2
0
파일: users.py 프로젝트: rafal-kos/pytis
    def delete(self, id):
        user = User.query.get_or_abort(id)
        meta.Session.delete(user)
        meta.Session.commit()

        flash(u"Użytkownik pomyślnie usunięty.")
        return redirect(url(controller="users", action="list"))
예제 #3
0
파일: invoices.py 프로젝트: rafal-kos/pytis
    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")
예제 #4
0
파일: invoices.py 프로젝트: rafal-kos/pytis
    def delete_invoice_element(self, id):
        element = InvoicePosition.query.get_or_abort(id)

        invoice_id = element.invoice_id

        element.delete()

        flash(u"Pozycja pomyślnie usunięta.")
        return self.redirect(url(controller="invoices", action="edit", id=invoice_id))
예제 #5
0
파일: orders.py 프로젝트: rafal-kos/pytis
 def delete(self, id=None):               
     order = Order.query.get_or_abort(id)
     
     try:
         order.delete()            
         
         flash(u'Zlecenie pomyślnie usunięte.')
     except Exception,e:            
         flash(unicode(e.message))
예제 #6
0
파일: invoice.py 프로젝트: rafal-kos/pytis
 def print_demand_payment(self, request, queryset):        
     if len(set([invoice.company.id for invoice in queryset])) != 1:
         flash(u'Faktury nie należą do jednego kontrahenta')
         return
     
     c.config = app_globals
     c.invoices = queryset        
     c.sum = sum([round(invoice.brutto_value, 2) for invoice in c.invoices])        
     
     return h.generate_pdf('/prints/demand_payment.html', 'wezwanie_do_zaplaty')        
예제 #7
0
 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')    
예제 #8
0
    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')   
예제 #9
0
 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')
예제 #10
0
파일: drivers.py 프로젝트: rafal-kos/pytis
 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')
예제 #11
0
파일: groups.py 프로젝트: rafal-kos/pytis
 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')
예제 #12
0
파일: drivers.py 프로젝트: rafal-kos/pytis
 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')               
예제 #13
0
파일: drivers.py 프로젝트: rafal-kos/pytis
 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') 
예제 #14
0
파일: drivers.py 프로젝트: rafal-kos/pytis
 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')
예제 #15
0
파일: drivers.py 프로젝트: rafal-kos/pytis
 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') 
예제 #16
0
파일: groups.py 프로젝트: rafal-kos/pytis
 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')
예제 #17
0
파일: users.py 프로젝트: rafal-kos/pytis
    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")
예제 #18
0
 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')    
예제 #19
0
 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')
예제 #20
0
파일: invoices.py 프로젝트: rafal-kos/pytis
    def delete(self, id=None):
        invoice = Invoice.query.get_or_abort(id)

        try:
            invoice.delete()

            response.status_int = 302
            response.headers["location"] = url(controller="invoices", action="list")
            flash(u"Faktura pomyślnie usunięta.")
        except Exception, e:
            response.status_int = 302
            response.headers["location"] = url(controller="invoices", action="edit", id=id)
            flash(unicode(e.message))
예제 #21
0
파일: users.py 프로젝트: rafal-kos/pytis
    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")
예제 #22
0
 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')              
예제 #23
0
파일: orders.py 프로젝트: rafal-kos/pytis
 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')
예제 #24
0
파일: corrects.py 프로젝트: rafal-kos/pytis
 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')
예제 #25
0
파일: invoices.py 프로젝트: rafal-kos/pytis
    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")
예제 #26
0
파일: users.py 프로젝트: rafal-kos/pytis
    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")
예제 #27
0
파일: settings.py 프로젝트: rafal-kos/pytis
 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')
예제 #28
0
파일: invoices.py 프로젝트: rafal-kos/pytis
    def add_invoice_element(self, id, idInvoice):
        if id is None or idInvoice is None:
            abort(404)

        invoice = Invoice.query.get_or_abort(idInvoice)
        order = Order.query.get_or_abort(id)

        element = InvoicePosition()
        element.order_id = order.id
        element.invoice_id = invoice.id
        element.value = order.freight
        element.currency = order.currency
        element.tax = order.company.tax
        element.save()

        response.status_int = 302
        response.headers["location"] = url(controller="invoices", action="edit", id=idInvoice)
        flash(u"Pomyślnie dodano.")
예제 #29
0
    def edit(self, id):                                                       
        c.company = Company.query.get_or_abort(id)               
        c.form = EditCompanyForm(request.POST, obj=c.company, prefix='company')
        c.place_form = PlaceForm(request.POST, prefix='place', idCompany=c.company.id)

        if request.method == 'POST' and 'action' in request.POST:
            
            if request.POST['action'] == 'company' and c.form.validate(c.company):
                c.form.populate_obj(c.company)
                c.company.save()
                
                flash(u'Kontrahent pomyślnie edytowany.')
                return self.redirect(url(controller='companies', action='edit', id=c.company.id))                
            if request.POST['action'] == 'place' and c.place_form.validate():
                place = Place()
                c.place_form.populate_obj(place)
                place.save()
                
                flash(u'Miejsce pomyślnie dodane.')
                return self.redirect(url(controller='companies', action='edit', id=c.company.id))
                
        return render('/companies/edit.xhtml')
예제 #30
0
파일: corrects.py 프로젝트: rafal-kos/pytis
 def add(self, id):
     c.invoice = Invoice.query.get(id)               
     
     c.form = InvoiceCorrectForm(request.POST,
                                 correct_date = h.today(),
                                 sell_date = c.invoice.sellDate,                                    
                                 company=c.invoice.company.name,                                    
                                 payment_form=c.invoice.company.payment,
                                 payment_date=c.invoice.payment_date,
                                 positions=c.invoice.elements)
     
     for index, position in enumerate(c.form.positions):                       
         position.tax.value = c.invoice.elements[index].tax.id            
     
     if request.method == 'POST' and c.form.validate():
         correct = InvoiceCorrect()            
         correct.company = c.invoice.company
         correct.currency = c.invoice.elements[0].currency
         correct.invoice = c.invoice
         correct.series_year = str(datetime.datetime.now().year)
         correct.series_month = str(datetime.datetime.now().month)
         correct.currency_symbol = c.invoice.currencySymbol
         correct.currency_date = c.invoice.currencyDate
         correct.currency_value = c.invoice.currencyValue
         correct.currency_table_number = c.invoice.currencyTableNumber
         
         c.form.populate_obj(correct, exclude = ['id', 'company', 'number', 'positions'])
         for form_position in c.form.positions:
             position = InvoicePositionCorrect()                
             form_position.form.populate_obj(position, exclude=['id'])                                              
             correct.positions.append(position)                      
             
         correct.save()
         
         flash(u'Korekta pomyślnie dodana.')
         return self.redirect(url(controller='corrects', action='edit', id=correct.id))
     
     return render('/corrects/add.xhtml')