예제 #1
0
    def before(self, form):
        BaseFormView.before(self, form)
        self.request.actionmenu.add(
            ViewLink(
                label=u"Revenir à la facture",
                path="/invoices/{id}.html",
                id=self.context.id,
                _anchor="payment",
            )
        )

        appstruct = []
        for tva_value, value in self.context.topay_by_tvas().items():
            tva = Tva.by_value(tva_value)
            appstruct.append(
                {
                    'tva_id': tva.id,
                    'amount': floor_to_precision(
                        value,
                        precision=2,
                        dialect_precision=5
                    )
                }
            )

        if len(appstruct) == 1:
            form.set_appstruct(appstruct[0])
        else:
            form.set_appstruct({'tvas': appstruct})
def test_more_vars_called(get_csrf_request_with_db):
    req = get_csrf_request_with_db()
    form = BaseFormView(req)
    form.schema = DummySchema()
    form.add_template_vars = ('arg',)
    form.arg = u"Test arg"
    result = form.__call__()
    assert(result['arg'] == u"Test arg")
예제 #3
0
    def submit_failure(self, e):
        errors = e.error.asdict()
        if 'month' in errors and 'year' in errors:
            appstruct = self.request.POST
            sheet = self._find_existing(appstruct)
            if sheet is not None:
                return self.redirect(sheet)

        BaseFormView.submit_failure(self, e)
예제 #4
0
    def __init__(self, context, request):
        BaseFormView.__init__(self, request)
        self.model_type = self.request.GET['model_type']
        self.quotechar = self.request.GET['quotechar']
        self.delimiter = self.request.GET['delimiter']

        if self.model_type not in self.model_types:
            raise HTTPForbidden()

        # We first count the number of elements in the file
        self.filepath = get_current_csv_filepath(self.request)

        # We build a field - model attr associator
        self.associator = get_csv_import_associator(self.model_type)
        _csv_obj = get_current_csv(self.filepath, self.delimiter, self.quotechar)
        self.headers = [header for header in _csv_obj.fieldnames if header]
예제 #5
0
    def submit_failure(self, e):
        errors = e.error.asdict()
        if 'month' in errors and 'year' in errors:
            appstruct = self.request.POST
            sheet = self._find_existing(appstruct)
            if sheet is not None:
                sheet = self.context
                self.request.session.flash(
                    u"Impossible de dupliquer cette note de dépenses."
                    u"Une note de dépense existe déjà pour la période "
                    u"de {0} {1}.".format(
                        strings.month_name(appstruct['month']),
                        appstruct['year'],
                    ), 'error')
                return self.redirect(self.context)

        BaseFormView.submit_failure(self, e)
예제 #6
0
    def submit_failure(self, e):
        errors = e.error.asdict()
        if 'month' in errors and 'year' in errors:
            appstruct = self.request.POST
            sheet = self._find_existing(appstruct)
            if sheet is not None:
                sheet = self.context
                self.request.session.flash(
                    u"Impossible de dupliquer cette note de dépenses."
                    u"Une note de dépense existe déjà pour la période "
                    u"de {0} {1}.".format(
                        strings.month_name(appstruct['month']),
                        appstruct['year'],
                    ),
                    'error'
                )
                return self.redirect(self.context)

        BaseFormView.submit_failure(self, e)
예제 #7
0
 def _more_template_vars(self):
     """
     Add template vars to the response dict
     List the attributes configured in the add_template_vars attribute
     and add them
     """
     result = BaseFormView._more_template_vars(self)
     result['title'] = self.title
     result['company'] = self.company
     result['tvas'] = self.tvas
     result['load_options_url'] = self.load_options_url
     result['load_catalog_url'] = self.load_catalog_url
     return result
예제 #8
0
 def _more_template_vars(self):
     """
     Add template vars to the response dict
     List the attributes configured in the add_template_vars attribute
     and add them
     """
     result = BaseFormView._more_template_vars(self)
     result['title'] = self.title
     result['company'] = self.company
     result['tvas'] = self.tvas
     result['load_options_url'] = self.load_options_url
     result['load_catalog_url'] = self.load_catalog_url
     return result
예제 #9
0
def test_more_vars_called(get_csrf_request_with_db):
    req = get_csrf_request_with_db()
    form = BaseFormView(req)
    form.schema = DummySchema()
    form.add_template_vars = ('arg', )
    form.arg = u"Test arg"
    result = form.__call__()
    assert (result['arg'] == u"Test arg")
예제 #10
0
    def before(self, form):
        BaseFormView.before(self, form)
        self.request.actionmenu.add(
            ViewLink(
                label=u"Revenir à la facture",
                path="/invoices/{id}.html",
                id=self.context.id,
                _anchor="payment",
            ))

        appstruct = []
        for tva_value, value in self.context.topay_by_tvas().items():
            tva = Tva.by_value(tva_value)
            appstruct.append({
                'tva_id':
                tva.id,
                'amount':
                floor_to_precision(value, precision=2, dialect_precision=5)
            })

        if len(appstruct) == 1:
            form.set_appstruct(appstruct[0])
        else:
            form.set_appstruct({'tvas': appstruct})
예제 #11
0
 def __init__(self, *args, **kwargs):
     BaseFormView.__init__(self, *args, **kwargs)
     ensure_doctypes_rel(self.current_userdatas.id, self.request)
예제 #12
0
 def __init__(self, *args, **kwargs):
     BaseFormView.__init__(self, *args, **kwargs)
     self.form_config = UserFormConfigState(self.session)
예제 #13
0
def test_init(get_csrf_request_with_db):
    req = get_csrf_request_with_db()
    form = BaseFormView(req)
    assert (form.dbsession == req.dbsession)
    assert (form.session == req.session)
예제 #14
0
파일: login.py 프로젝트: Swannbm/autonomie
 def __init__(self, *args, **kwargs):
     BaseFormView.__init__(self, *args, **kwargs)
     self.form_config = UserFormConfigState(self.session)
예제 #15
0
 def before(self, form):
     BaseFormView.before(self, form)
     populate_actionmenu(self.request)
     task_add_js.need()
예제 #16
0
 def before(self, form):
     BaseFormView.before(self, form)
     task_add_js.need()
예제 #17
0
 def before(self, form):
     BaseFormView.before(self, form)
     populate_actionmenu(self.request)
     task_add_js.need()
예제 #18
0
 def __init__(self, *args, **kwargs):
     BaseFormView.__init__(self, *args, **kwargs)
     ensure_doctypes_rel(self.current_userdatas.id, self.request)
예제 #19
0
 def before(self, form):
     BaseFormView.before(self, form)
     task_add_js.need()