Beispiel #1
0
 def _make_binding(self, binding, current_row):
     binding_dictionary = {}
     binding_name = binding.name()
     binding_condition = binding.condition()
     binding_column = binding.binding_column()
     if binding_column and current_row is not None:
         condition = pytis.data.EQ(binding_column, current_row.row()[0])
         if binding_condition is not None:
             condition = pytis.data.AND(condition, binding_condition(current_row))
     elif binding_condition and current_row is not None:
         condition = binding_condition(current_row)
     else:
         condition = pytis.data.AND()
     view, data = form_view_data(self._resolver, binding_name)
     table = pytis.output.data_table(view, data, condition=condition, sorting=(),
                                     transaction=self._transaction)
     binding_dictionary['table'] = table.lcg()
     binding_dictionary['data'] = _DataIterator(self._resolver, binding_name,
                                                condition=condition, sorting=(),
                                                transaction=self._transaction)
     codebooks = LCGFormatter._retrieve_codebooks(view, resolver=self._resolver)
     binding_dictionary['codebook'] = _DataIterator(self._resolver, binding_name,
                                                    condition=condition, sorting=(),
                                                    transaction=self._transaction,
                                                    codebooks=codebooks)
     return binding_dictionary
Beispiel #2
0
 def _make_binding(self, binding, current_row):
     binding_dictionary = {}
     binding_name = binding.name()
     binding_condition = binding.condition()
     binding_column = binding.binding_column()
     if binding_column and current_row is not None:
         condition = pytis.data.EQ(binding_column, current_row.row()[0])
         if binding_condition is not None:
             condition = pytis.data.AND(condition, binding_condition(current_row))
     elif binding_condition and current_row is not None:
         condition = binding_condition(current_row)
     else:
         condition = pytis.data.AND()
     view, data = form_view_data(self._resolver, binding_name)
     table = pytis.output.data_table(view, data, condition=condition, sorting=(),
                                     transaction=self._transaction)
     binding_dictionary['table'] = table.lcg()
     binding_dictionary['data'] = _DataIterator(self._resolver, binding_name,
                                                condition=condition, sorting=(),
                                                transaction=self._transaction)
     codebooks = LCGFormatter._retrieve_codebooks(view, resolver=self._resolver)
     binding_dictionary['codebook'] = _DataIterator(self._resolver, binding_name,
                                                    condition=condition, sorting=(),
                                                    transaction=self._transaction,
                                                    codebooks=codebooks)
     return binding_dictionary
Beispiel #3
0
 def __init__(self,
              resolver,
              form_name,
              condition,
              sorting,
              transaction,
              codebooks=None):
     self._transaction = transaction
     self._select_kwargs = dict(condition=condition,
                                sort=sorting,
                                transaction=transaction)
     view, self._data = form_view_data(resolver, form_name)
     self._presented_row = pytis.presentation.PresentedRow(view.fields(),
                                                           self._data,
                                                           None,
                                                           singleline=True)
     self._codebooks = None
     if codebooks:
         self._codebooks = {}
         for field_id, cb_fields, cb in codebooks:
             permitted = pytis.form.has_access(
                 form_name,
                 perm=pytis.data.Permission.VIEW,
                 column=field_id)
             columns = []
             secret_columns = []
             for cb_id, _cb_label in cb_fields:
                 columns.append(cb_id)
                 if (not permitted or not pytis.form.has_access(
                         cb, perm=pytis.data.Permission.VIEW,
                         column=cb_id)):
                     secret_columns.append(cb_id)
             self._codebooks[field_id] = (columns, secret_columns)
     super(_DataIterator, self).__init__()
Beispiel #4
0
 def __init__(self, resolver, form_name, condition, sorting, transaction, codebooks=None):
     self._transaction = transaction
     self._select_kwargs = dict(condition=condition, sort=sorting, transaction=transaction)
     view, self._data = form_view_data(resolver, form_name)
     self._presented_row = pytis.presentation.PresentedRow(view.fields(), self._data, None,
                                                           singleline=True)
     self._codebooks = None
     if codebooks:
         self._codebooks = {}
         for field_id, cb_fields, cb in codebooks:
             permitted = pytis.form.has_access(form_name, perm=pytis.data.Permission.VIEW,
                                               column=field_id)
             columns = []
             secret_columns = []
             for cb_id, _cb_label in cb_fields:
                 columns.append(cb_id)
                 if (not permitted or
                     not pytis.form.has_access(cb, perm=pytis.data.Permission.VIEW,
                                               column=cb_id)):
                     secret_columns.append(cb_id)
             self._codebooks[field_id] = (columns, secret_columns)
     super(_DataIterator, self).__init__()