Beispiel #1
0
 def post(self, *args, **kwargs):
     requisites_form = RequisitesForm(self.request.arguments)
     
     if not requisites_form.validate():
         """ Не валидна форма реквизитов """
         if not requisites_form.validate():
             logging.debug(u'Форма реквизитов контрагента не валидна.')
         self.context.update({'title': u'Создание контрагента',
                             'module_name': url_base,
                             'requisites_form': requisites_form,
                             'contractor_form': ContractorForm(self.request.arguments),
                                 })
         self.render(tmpl('create'))
     else:
         req = RequisitesDB.create_from_data(requisites_form.data)
         contractor_data = self.request.arguments
         contractor_data.update({'user': [str(self.user_id)],
                                 'requisites': [str(req['_id'])]})
         
         contractor_form = ContractorForm(contractor_data)
         
         if not contractor_form.validate():
             logging.error(u'С какого-то хуя форма контрагента не валидна: %s' % contractor_form.errors)
         
         con = ContactorDB.create_from_data(contractor_form.data)
         logging.debug(u'Контрагент сохранен.')
         self.redirect('/%s/full/%s' % (url_base, con['_id']))
Beispiel #2
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']))
Beispiel #3
0
 def get(self, _id):
     con = ContactorDB.get_full(_id)
     self.context.update({'title': u'Контрагент: %s' % 'asdf',
                          'module_name': url_base,
                          'item': con, 
                          'requisites': RequisitesDB.get_full(con['requisites']), })
     self.render(tmpl('full'))
     
Beispiel #4
0
def create_context_by_bill(bill):
    sender_req = RequisitesDB.get_by_id(
        UserDB.get_by_id(bill['user'])['requisites'])
    recipient_req = RequisitesDB.get_by_id(
        ContactorDB.get_by_id(bill['contractor'])['requisites'])
    items = ContentDB.get_by_id(bill['content'])['items']
    return create_context(sender_req, recipient_req, bill['number'],
                          bill['date_created'], items)
Beispiel #5
0
class TaskForm(Form):
    user = SelectField(u'Юзер',
                       choices=UserDB.get_for_select(),
                       validators=[REQ])
    name = StringField(u'Название', validators=[REQ])
    comment = TextAreaField(u'Комментарий')
    contractors = SelectMultipleField(u'Контрагенты',
                                      choices=ContactorDB.get_for_select(),
                                      validators=[REQ])
    periodic = SelectField(u'Периодичность',
                           choices=PeriodicDB.get_for_select(),
                           validators=[REQ])
    template = SelectField(u'Шаблон',
                           choices=TemplateDB.get_for_select(),
                           validators=[REQ])
Beispiel #6
0
class BillForm(Form):
    user = SelectField(u'Юзер',
                       choices=UserDB.get_for_select(),
                       validators=[REQ])
    contractor = SelectField(u'Контрагент',
                             choices=ContactorDB.get_for_select(),
                             validators=[REQ])
    template = SelectField(u'Шаблон', choices=TemplateDB.get_for_select())
    task = SelectField(u'Задание', choices=TaskDB.get_for_select())
    content = SelectField(u'Контент',
                          choices=ContentDB.get_for_select(),
                          validators=[REQ])
    name = StringField(u'Название', validators=[REQ])
    send = BooleanField(u'Отправлен')
    paid = BooleanField(u'Оплачен')
Beispiel #7
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']))
Beispiel #8
0
def create_context_by_bill(bill):
    sender_req = RequisitesDB.get_by_id(UserDB.get_by_id(bill['user'])['requisites'])
    recipient_req = RequisitesDB.get_by_id(ContactorDB.get_by_id(bill['contractor'])['requisites'])
    items = ContentDB.get_by_id(bill['content'])['items']
    return create_context(sender_req, recipient_req, bill['number'], bill['date_created'], items)