Exemple #1
0
 def post(self, *args, **kwargs):
     recipient_form = RequisitesForm(self.request.arguments)
     bill_content_form = BillContentForm(self.request.arguments)
     if not (recipient_form.validate() and bill_content_form.validate()):
         if not recipient_form.validate():
             logging.debug(u'Форма получателя не валидна.')
         if not bill_content_form.validate():
             logging.debug(u'Форма содержимого не валидна.')
         self.context.update({'title': u'Создание счёта',
                              'module_name': url_base,
                              'sender': RequisitesDB.get_one({'inn': '772160030650'}),
                              'recipient': recipient_form,
                              'bill_content': bill_content_form,
                              'bill_num': Counter.next_key('bill'),
                              'date': datetime.now(),
                              })
         self.render(tmpl('create'))
     else:
         req = RequisitesDB.create_from_data(recipient_form.data)
         contr = ContactorDB.create(self.user_id, req['_id'])['_id']
         items_from_form = bill_content_form.data['items']
         items = []
         for i in items_from_form:
             if i['count'] > 0.0 and i['name']:
                 items.append(i)
         cont = ContentDB.create(items)['_id']
         bill_num = Counter.next_key('bill')
         date = datetime.now()
         sender_user = UserDB.get_one({'id': 1})
         bill = BillDB.create_simple(sender_user['_id'], contr, cont, bill_num, date)
         logging.debug(u'Счёт сохранен.')
         self.redirect('/%s/full/%s' % (url_base, bill['_id']))
Exemple #2
0
 def post(self, _id):
     bill = BillDB.get_by_id(_id)
     context = create_context_by_bill(bill)
     action = self.get_argument('action')
     
     if action == 'pdf':
         create_pdf_bill(context, 'media/bills/%s.pdf' % _id)
         self.redirect('/media/bills/%s.pdf' % _id)
         return
     elif action == 'email':
         email = self.get_argument('email_send_to')
         send_mail_by_queue(email, u'Счёт № %s' % bill['number'], u'Привет. А вот и счёт!', ['/media/bills/%s.pdf' % _id])
     else:
         logging.error(u'Неизвестный экшн в создании счёта.')
     
     self.redirect('/%s/full/%s' % (url_base, bill['_id']))
     
     
     """
Exemple #3
0
    def post(self, _id):
        bill = BillDB.get_by_id(_id)
        context = create_context_by_bill(bill)
        action = self.get_argument('action')

        if action == 'pdf':
            create_pdf_bill(context, 'media/bills/%s.pdf' % _id)
            self.redirect('/media/bills/%s.pdf' % _id)
            return
        elif action == 'email':
            email = self.get_argument('email_send_to')
            send_mail_by_queue(email, u'Счёт № %s' % bill['number'],
                               u'Привет. А вот и счёт!',
                               ['/media/bills/%s.pdf' % _id])
        else:
            logging.error(u'Неизвестный экшн в создании счёта.')

        self.redirect('/%s/full/%s' % (url_base, bill['_id']))
        """
Exemple #4
0
 def post(self, *args, **kwargs):
     recipient_form = RequisitesForm(self.request.arguments)
     bill_content_form = BillContentForm(self.request.arguments)
     if not (recipient_form.validate() and bill_content_form.validate()):
         if not recipient_form.validate():
             logging.debug(u'Форма получателя не валидна.')
         if not bill_content_form.validate():
             logging.debug(u'Форма содержимого не валидна.')
         self.context.update({
             'title':
             u'Создание счёта',
             'module_name':
             url_base,
             'sender':
             RequisitesDB.get_one({'inn': '772160030650'}),
             'recipient':
             recipient_form,
             'bill_content':
             bill_content_form,
             'bill_num':
             Counter.next_key('bill'),
             'date':
             datetime.now(),
         })
         self.render(tmpl('create'))
     else:
         req = RequisitesDB.create_from_data(recipient_form.data)
         contr = ContactorDB.create(self.user_id, req['_id'])['_id']
         items_from_form = bill_content_form.data['items']
         items = []
         for i in items_from_form:
             if i['count'] > 0.0 and i['name']:
                 items.append(i)
         cont = ContentDB.create(items)['_id']
         bill_num = Counter.next_key('bill')
         date = datetime.now()
         sender_user = UserDB.get_one({'id': 1})
         bill = BillDB.create_simple(sender_user['_id'], contr, cont,
                                     bill_num, date)
         logging.debug(u'Счёт сохранен.')
         self.redirect('/%s/full/%s' % (url_base, bill['_id']))
Exemple #5
0
 def get(self, _id):
     self.context.update(create_context_by_bill(BillDB.get_by_id(_id)))
     self.render('documents/bill.html')
Exemple #6
0
 def get(self, _id):
     self.context.update(create_context_by_bill(BillDB.get_by_id(_id)))
     self.render('documents/bill.html')