예제 #1
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [
             Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(
         *identfilter)
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
예제 #2
0
    def edit_account_for_line(self, xfer, column, row, debit_rest, credit_rest):
        num_cpt_txt = xfer.getparam('num_cpt_txt', '')
        num_cpt = xfer.getparam('num_cpt', 0)

        lbl = XferCompLabelForm('numCptlbl')
        lbl.set_location(column, row, 3)
        lbl.set_value_as_headername(_('account'))
        xfer.add_component(lbl)
        edt = XferCompEdit('num_cpt_txt')
        edt.set_location(column, row + 1, 2)
        edt.set_value(num_cpt_txt)
        edt.set_size(20, 25)
        edt.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        xfer.add_component(edt)
        sel_val = []
        current_account = None
        if num_cpt_txt != '':
            year = FiscalYear.get_current(xfer.getparam('year'))
            sel_val, current_account = year.get_account_list(num_cpt_txt, num_cpt)
        sel = XferCompSelect('num_cpt')
        sel.set_location(column + 2, row + 1, 1)
        sel.set_select(sel_val)
        sel.set_size(20, 150)
        sel.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        if current_account is not None:
            sel.set_value(current_account.id)
            self.item.account = current_account
            self.item.set_montant(
                float(xfer.getparam('debit_val', 0.0)), float(xfer.getparam('credit_val', 0.0)))
            if abs(self.item.amount) < 0.0001:
                self.item.set_montant(debit_rest, credit_rest)
        xfer.add_component(sel)
        return lbl, edt
예제 #3
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(*identfilter).distinct()
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
예제 #4
0
 def fillresponse(self):
     if not will_mail_send():
         raise LucteriosException(IMPORTANT, _('Bad email parameter!'))
     legal = LegalEntity.objects.get(id=1)
     if self.getparam('CONFIRME') is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         dlg.add_component(img)
         lbl = XferCompLabelForm('lbl_title')
         lbl.set_location(1, 0, 2)
         lbl.set_value_as_header(self.caption)
         dlg.add_component(lbl)
         email = XferCompEdit('recipient')
         email.set_location(1, 1)
         email.set_value(legal.email)
         email.mask = r"[^@]+@[^@]+\.[^@]+"
         email.description = _("email")
         dlg.add_component(email)
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         address = []
         address.append("")
         address.append("")
         address.append(six.text_type(legal))
         address.append(legal.address)
         address.append("%s %s" % (legal.postal_code, legal.city))
         message = _('EMail sent to check configuration')
         message += "{[br/]}".join(address).replace('{[newline]}', "{[br/]}").replace("\n", '{[br/]}')
         bad_sended = send_email(self.getparam('recipient'), _("EMail try"), "<html><body>%s</body></html>" % message.replace('{[', '<').replace(']}', '>'))
         if len(bad_sended) != 0:
             raise EmailException(bad_sended)
         self.message(_("EMail send, check it."))
예제 #5
0
 def fillresponse(self):
     legal = LegalEntity.objects.get(id=1)
     if self.getparam('CONFIRME') is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         dlg.add_component(img)
         lbl = XferCompLabelForm('lbl_title')
         lbl.set_location(1, 0, 2)
         lbl.set_value_as_header(self.caption)
         dlg.add_component(lbl)
         email = XferCompEdit('recipient')
         email.set_location(1, 1)
         email.set_value(legal.email)
         email.mask = r"[^@]+@[^@]+\.[^@]+"
         email.description = _("email")
         dlg.add_component(email)
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                        close=CLOSE_YES,
                        params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         abs_url = self.request.META.get(
             'HTTP_REFERER', self.request.build_absolute_uri()).split('/')
         self.item.http_root_address = '/'.join(abs_url[:-2])
         send_email([self.getparam('recipient')],
                    self.item.subject,
                    self.item.email_content,
                    files=self.item.attach_files)
         self.message(_("EMail send, check it."))
예제 #6
0
 def fillresponse_header(self):
     name_filter = self.getparam('filter')
     if name_filter is None:
         name_filter = ""
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(0, 2)
     comp.is_default = True
     comp.description = _('Filtrer by name')
     self.add_component(comp)
     if name_filter != "":
         self.filter = Q(firstname__icontains=name_filter) | Q(
             lastname__icontains=name_filter)
예제 #7
0
파일: views.py 프로젝트: julienM77/syndic
 def fillresponse_header(self):
     self.new_tab(_("Owners"))
     contact_filter = self.getparam('filter', '')
     comp = XferCompEdit('filter')
     comp.set_value(contact_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(0, 0, 2)
     comp.is_default = True
     comp.description = _('Filtrer by owner')
     self.add_component(comp)
     self.filter = Q()
     if contact_filter != "":
         q_legalentity = Q(third__contact__legalentity__name__icontains=contact_filter)
         q_individual = Q(completename__icontains=contact_filter)
         self.filter &= (q_legalentity | q_individual)
예제 #8
0
 def _edit_add_args(self, xfer, obj_kind):
     args = self.item.get_args()
     arg = XferCompCheck('args_multi')
     arg.set_value(args['multi'])
     arg.set_location(obj_kind.col, obj_kind.row + 1, obj_kind.colspan, 1)
     arg.description = _('multi-line')
     xfer.add_component(arg)
     arg = XferCompFloat('args_min', -10000, 10000, 0)
     arg.set_value(args['min'])
     arg.set_location(obj_kind.col, obj_kind.row + 2, obj_kind.colspan, 1)
     arg.description = _('min')
     xfer.add_component(arg)
     arg = XferCompFloat('args_max', -10000, 10000, 0)
     arg.set_value(args['max'])
     arg.set_location(obj_kind.col, obj_kind.row + 3, obj_kind.colspan, 1)
     arg.description = _('max')
     xfer.add_component(arg)
     arg = XferCompFloat('args_prec', 0, 10, 0)
     arg.set_value(args['prec'])
     arg.set_location(obj_kind.col, obj_kind.row + 4, obj_kind.colspan, 1)
     arg.description = _('precision')
     xfer.add_component(arg)
     arg = XferCompEdit('args_list')
     arg.set_value(','.join(args['list']))
     arg.set_location(obj_kind.col, obj_kind.row + 5, obj_kind.colspan, 1)
     arg.description = _('list')
     xfer.add_component(arg)
예제 #9
0
 def get_comp(self, value):
     comp = None
     args = self.item.get_args()
     if self.item.kind == 0:
         if args['multi']:
             comp = XferCompMemo(self.item.get_fieldname())
         else:
             comp = XferCompEdit(self.item.get_fieldname())
         comp.set_value(value)
     elif (self.item.kind == 1) or (self.item.kind == 2):
         comp = XferCompFloat(
             self.item.get_fieldname(), args['min'], args['max'], args['prec'])
         comp.set_value(value)
     elif self.item.kind == 3:
         comp = XferCompCheck(self.item.get_fieldname())
         comp.set_value(value)
     elif self.item.kind == 4:
         val_selected = value
         try:
             select_id = int(value)
         except ValueError:
             select_id = 0
         select_list = []
         for sel_item in args['list']:
             if sel_item == val_selected:
                 select_id = len(select_list)
             select_list.append((len(select_list), sel_item))
         comp = XferCompSelect(self.item.get_fieldname())
         comp.set_select(select_list)
         comp.set_value(select_id)
     return comp
예제 #10
0
 def fillresponse_header(self):
     filter_postal_code = self.getparam('filter_postal_code')
     if filter_postal_code is None:
         local_struct = LegalEntity.objects.get(id=1)
         filter_postal_code = six.text_type(local_struct.postal_code)
     comp = XferCompEdit('filter_postal_code')
     comp.set_value(filter_postal_code)
     comp.is_default = True
     comp.set_action(self.request,
                     self.get_action(),
                     modal=FORMTYPE_REFRESH,
                     close=CLOSE_NO)
     comp.set_location(1, 1)
     comp.description = _('Filtrer by postal code')
     self.add_component(comp)
     self.filter = Q(postal_code__startswith=filter_postal_code)
예제 #11
0
 def _add_option_selectors(self, gui):
     row_idx = 3
     for name_selector, title_selector, option_selector in self.selector:
         if isinstance(option_selector, list):
             comp = XferCompSelect(name_selector)
             comp.set_select(option_selector)
             comp.set_value(gui.getparam(name_selector, 0))
         elif isinstance(option_selector, tuple):
             comp = XferCompFloat(name_selector, option_selector[0],
                                  option_selector[1], option_selector[2])
             comp.set_value(option_selector[0])
         elif isinstance(option_selector, six.binary_type):
             comp = XferCompEdit(name_selector)
             comp.set_value(option_selector.decode())
         elif isinstance(option_selector, six.text_type):
             comp = XferCompMemo(name_selector)
             comp.with_hypertext = True
             comp.set_value(option_selector)
         elif isinstance(option_selector, bool):
             comp = XferCompCheck(name_selector)
             comp.set_value(option_selector)
         else:
             comp = None
         if comp is not None:
             comp.set_location(0, row_idx, 2)
             comp.description = title_selector
             gui.add_component(comp)
             row_idx += 1
예제 #12
0
 def get_write_comp(self):
     if self.type == 0:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
             param_cmp.with_hypertext = self.args['HyperText']
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == 1:  # Integer
         param_cmp = XferCompFloat(
             self.name, minval=self.args['Min'], maxval=self.args['Max'], precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 2:  # Real
         param_cmp = XferCompFloat(self.name, minval=self.args['Min'], maxval=self.args[
                                   'Max'], precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 3:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == 4:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = []
         for sel_idx in range(0, self.args['Enum']):
             selection.append((sel_idx, ugettext_lazy(self.name + ".%d" % sel_idx)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 5:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.security = 0
         param_cmp.set_value('')
     elif self.type == 6:  # select in object
         if (self.meta_info[0] != "") and (self.meta_info[1] != ""):
             db_mdl = apps.get_model(self.meta_info[0], self.meta_info[1])
         else:
             db_mdl = None
         if self.args['Multi']:
             param_cmp = XferCompCheckList(self.name)
             param_cmp.simple = 2
         else:
             param_cmp = XferCompSelect(self.name)
         param_cmp.set_needed(self.meta_info[4])
         selection = []
         if not self.meta_info[4]:
             if (self.args['oldtype'] == 1) or (self.args['oldtype'] == 2):
                 selection.append((0, None))
             else:
                 selection.append(('', None))
         if db_mdl is None:
             selection = self.meta_info[2]
         else:
             for obj_item in db_mdl.objects.filter(self.meta_info[2]):
                 selection.append((getattr(obj_item, self.meta_info[3]), six.text_type(obj_item)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
     param_cmp.description = six.text_type(ugettext_lazy(self.name))
     return param_cmp
예제 #13
0
 def fillresponse_header(self):
     name_filter = self.getparam('filter')
     if name_filter is None:
         name_filter = ""
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(0, 2)
     comp.is_default = True
     comp.description = _('Filtrer by name')
     self.add_component(comp)
     if name_filter != "":
         self.filter = Q(firstname__icontains=name_filter) | Q(
             lastname__icontains=name_filter)
예제 #14
0
    def fillresponse_header(self):
        contact_filter = self.getparam('filter', '')
        show_filter = self.getparam('show_filter', 0)
        lbl = XferCompLabelForm('lbl_filtre')
        lbl.set_value_as_name(_('Filtrer by contact'))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        comp = XferCompEdit('filter')
        comp.set_value(contact_filter)
        comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        comp.set_location(1, 2)
        self.add_component(comp)

        lbl = XferCompLabelForm('lbl_showing')
        lbl.set_value_as_name(_('Accounts displayed'))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        edt = XferCompSelect("show_filter")
        edt.set_select([(0, _('Hide the account total of thirds')), (1, _('Show the account total of thirds')),
                        (2, _('Filter any thirds unbalanced'))])
        edt.set_value(show_filter)
        edt.set_location(1, 3)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)
        if show_filter != 0:
            self.fieldnames = Third.get_other_fields()

        self.filter = Q(status=0)
        if contact_filter != "":
            q_legalentity = Q(contact__legalentity__name__icontains=contact_filter)
            q_individual = (Q(contact__individual__firstname__icontains=contact_filter) | Q(contact__individual__lastname__icontains=contact_filter))
            self.filter &= (q_legalentity | q_individual)
예제 #15
0
파일: views.py 프로젝트: povtux/core
    def fillresponse(self):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)
        lbl = XferCompLabelForm('lbl_title')
        lbl.set_location(1, 0, 2)
        lbl.set_value_as_header(
            _("To receive by email your login and a new password."))
        self.add_component(lbl)

        lbl = XferCompLabelForm('lbl_email')
        lbl.set_location(1, 1)
        lbl.set_value_as_name(_("email"))
        self.add_component(lbl)
        pwd = XferCompEdit('email')
        pwd.set_location(2, 1)
        self.add_component(pwd)

        self.add_action(
            AskPasswordAct.get_action(_('Ok'), 'images/ok.png'), {})
        self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'), {})
예제 #16
0
 def fillresponse_header(self):
     filter_postal_code = self.getparam('filter_postal_code')
     if filter_postal_code is None:
         local_struct = LegalEntity.objects.get(id=1)
         filter_postal_code = six.text_type(local_struct.postal_code)
     lbl = XferCompLabelForm('filtre')
     lbl.set_value_as_name(_('Filtrer by postal code'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     comp = XferCompEdit('filter_postal_code')
     comp.set_value(filter_postal_code)
     comp.is_default = True
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 1)
     self.add_component(comp)
     self.filter = Q(postal_code__startswith=filter_postal_code)
예제 #17
0
 def fill_filterCode(self):
     if self.add_filtering:
         filtercode = self.getparam('filtercode', '')
         lbl = XferCompLabelForm('filtercode_lbl')
         lbl.set_value_as_name(_("Accounting code starting with"))
         lbl.set_location(2, 3, 1)
         self.add_component(lbl)
         edt = XferCompEdit('filtercode')
         edt.set_value(filtercode)
         edt.set_location(3, 3, 2)
         edt.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
         self.add_component(edt)
         if filtercode != '':
             self.filter &= Q(account__code__startswith=filtercode)
예제 #18
0
 def fillresponse_header(self):
     filter_postal_code = self.getparam('filter_postal_code')
     if filter_postal_code is None:
         local_struct = LegalEntity.objects.get(id=1)
         filter_postal_code = six.text_type(local_struct.postal_code)
     lbl = XferCompLabelForm('filtre')
     lbl.set_value_as_name(_('Filtrer by postal code'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     comp = XferCompEdit('filter_postal_code')
     comp.set_value(filter_postal_code)
     comp.set_action(self.request,
                     self.get_action(),
                     modal=FORMTYPE_REFRESH,
                     close=CLOSE_NO)
     comp.set_location(1, 1)
     self.add_component(comp)
     self.filter = Q(postal_code__startswith=filter_postal_code)
예제 #19
0
 def get_write_comp(self):
     param_cmp = None
     if self.type == Parameter.TYPE_STRING:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
             param_cmp.with_hypertext = self.args['HyperText']
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == Parameter.TYPE_INTEGER:  # Integer
         param_cmp = XferCompFloat(self.name,
                                   minval=self.args['Min'],
                                   maxval=self.args['Max'],
                                   precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_REAL:  # Real
         param_cmp = XferCompFloat(self.name,
                                   minval=self.args['Min'],
                                   maxval=self.args['Max'],
                                   precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_BOOL:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_SELECT:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = [(sel_idx, ugettext_lazy(self.name + ".%d" % sel_idx))
                      for sel_idx in range(0, self.args['Enum'])]
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_PASSWORD:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.security = 0
         param_cmp.set_value('')
     elif self.type == Parameter.TYPE_META:  # select in object
         param_cmp = self._get_meta_comp()
         param_cmp.set_needed(self.meta_info[4])
         param_cmp.set_select(self._get_selection_from_object())
         param_cmp.set_value(self.value)
     param_cmp.description = six.text_type(ugettext_lazy(self.name))
     return param_cmp
예제 #20
0
    def fillresponse_search_values(self):
        comp = XferCompButton("searchButtonAdd")
        comp.is_default = True
        comp.set_is_mini(True)
        comp.set_location(4, 10, 1, 7)
        comp.set_action(self.request,
                        self.get_action("", "images/add.png"),
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO,
                        params={'ACT': 'ADD'})
        self.add_component(comp)

        comp = XferCompDate("searchValueDate")
        comp.set_needed(True)
        comp.set_location(3, 11)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompFloat("searchValueFloat")
        comp.set_needed(True)
        comp.set_location(3, 12)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompEdit("searchValueStr")
        comp.set_location(3, 13)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompCheckList("searchValueList")
        comp.set_location(3, 14)
        comp.set_size(80, 200)
        self.add_component(comp)
        comp = XferCompCheck("searchValueBool")
        comp.set_location(3, 15)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompTime("searchValueTime")
        comp.set_needed(True)
        comp.set_location(3, 16)
        comp.set_size(20, 200)
        self.add_component(comp)

        label = XferCompLabelForm('labelsearchSep')
        label.set_value("")
        label.set_size(1, 200)
        label.set_location(3, 17)
        self.add_component(label)
예제 #21
0
 def get_writing_comp(self, field_name):
     from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
     from django.db.models.fields.related import ForeignKey
     comp = None
     dep_field = self.item.get_field_by_name(field_name)
     for field_type in (IntegerField, DecimalField, BooleanField, TextField,
                        DateField, TimeField, DateTimeField, ForeignKey):
         if isinstance(dep_field, field_type):
             fct = getattr(self,
                           "_create_comp_%s" % field_type.__name__.lower(),
                           None)
             if fct is not None:
                 comp = fct(field_name, dep_field)
                 break
     if comp is None:
         if (dep_field is not None
             ) and dep_field.is_relation and dep_field.many_to_many:
             comp = XferCompCheckList(field_name)
             comp.simple = 2
             if self.item.id is not None:
                 values = []
                 for item in getattr(self.item, field_name).all():
                     values.append(item.id)
                 comp.set_value(values)
             if hasattr(self.item, field_name + '_query'):
                 sub_select = getattr(self.item, field_name + '_query')
             else:
                 sub_select = get_dico_from_setquery(
                     get_corrected_setquery(
                         dep_field.remote_field.model.objects.all()))
             comp.set_select(sub_select)
         else:
             comp = XferCompEdit(field_name)
             comp.set_value(
                 self._get_value_from_field(field_name, dep_field, ""))
             if isinstance(dep_field, CharField):
                 comp.size = dep_field.max_length
     comp.set_needed(dep_field.unique
                     or not (dep_field.blank or dep_field.null))
     return comp
예제 #22
0
    def fillresponse(self):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)
        lbl = XferCompLabelForm('lbl_title')
        lbl.set_location(1, 0, 2)
        lbl.set_value_as_header(_("To receive by email your login and a new password."))
        self.add_component(lbl)

        email = XferCompEdit('email')
        email.set_location(1, 1)
        email.mask = r"[^@]+@[^@]+\.[^@]+"
        email.description = _("email")
        self.add_component(email)

        self.add_action(AskPasswordAct.get_action(_('Ok'), 'images/ok.png'))
        self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
예제 #23
0
 def edit_extra_for_line(self, xfer, column, row, vertical=True):
     try:
         if self.item.has_account and self.item.account.is_third:
             edit_third_for_line(
                 xfer, column, row, self.item.account.code, self.item.third, vertical)
         else:
             lbl = XferCompLabelForm('referencelbl')
             lbl.set_value_as_name(_('reference'))
             edt = XferCompEdit('reference')
             reference = xfer.getparam('reference', self.item.reference)
             if reference is not None:
                 edt.set_value(reference)
             if vertical:
                 edt.set_location(column, row + 1)
                 lbl.set_location(column, row)
             else:
                 edt.set_location(column + 2, row)
                 lbl.set_location(column, row, 2)
             xfer.add_component(lbl)
             xfer.add_component(edt)
     except ObjectDoesNotExist:
         pass
예제 #24
0
 def fillresponse_header(self):
     if 'status_filter' in self.params:
         del self.params['status_filter']
     contact_filter = self.getparam('filter', '')
     lbl = XferCompLabelForm('lbl_filtre')
     lbl.set_value_as_name(_('Filtrer by contact'))
     lbl.set_location(0, 2)
     self.add_component(lbl)
     comp = XferCompEdit('filter')
     comp.set_value(contact_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     self.add_component(comp)
     self.filter = Q(status=0)
     if self.code_mask != '':
         self.filter &= Q(accountthird__code__regex=self.code_mask)
     if contact_filter != "":
         q_legalentity = Q(
             contact__legalentity__name__contains=contact_filter)
         q_individual = (Q(contact__individual__firstname__contains=contact_filter) | Q(
             contact__individual__lastname__contains=contact_filter))
         self.filter &= (q_legalentity | q_individual)
예제 #25
0
 def show(self, xfer):
     if not isfile(self.item.file_path):
         raise LucteriosException(IMPORTANT, _("File not found!"))
     obj_cmt = xfer.get_components('creator')
     down = XferCompDownLoad('filename')
     down.compress = True
     down.http_file = True
     down.maxsize = 0
     down.set_value(self.item.name)
     down.set_download(self.item.file_path)
     down.set_action(xfer.request,
                     ActionsManage.get_action_url(
                         'documents.DocumentContainer', 'AddModify', xfer),
                     modal=FORMTYPE_MODAL,
                     close=CLOSE_NO)
     down.set_location(obj_cmt.col, obj_cmt.row + 1, 4)
     xfer.add_component(down)
     link = self.item.shared_link
     if link is not None:
         shared_link = XferCompEdit('shared_link')
         shared_link.description = _('shared link')
         shared_link.set_value(link)
         shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4)
         xfer.add_component(shared_link)
예제 #26
0
 def get_writing_comp(self, field_name):
     from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
     from django.db.models.fields.related import ForeignKey, ManyToManyField
     comp = None
     dep_field = self.item.get_field_by_name(field_name)
     for field_type in (IntegerField, DecimalField, BooleanField, TextField,
                        DateField, TimeField, DateTimeField, ForeignKey,
                        ManyToManyField):
         if isinstance(dep_field, field_type):
             fct = getattr(self,
                           "_create_comp_%s" % field_type.__name__.lower(),
                           None)
             if fct is not None:
                 comp = fct(field_name, dep_field)
                 break
     if comp is None:
         comp = XferCompEdit(field_name)
         comp.set_value(
             self._get_value_from_field(field_name, dep_field, ""))
         if isinstance(dep_field, CharField):
             comp.size = dep_field.max_length
     comp.set_needed(dep_field.unique
                     or not (dep_field.blank or dep_field.null))
     return comp
예제 #27
0
 def edit(self, xfer):
     if xfer.item.id is None:
         xfer.get_components("paytype").set_action(
             xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH
         )
     else:
         xfer.change_to_readonly("paytype")
     items = self.item.get_items()
     for fieldid, fieldtitle, fieldtype in self.item.get_extra_fields():
         row = xfer.get_max_row() + 1
         lbl = XferCompLabelForm("lbl_item_%d" % fieldid)
         lbl.set_value_as_name(fieldtitle)
         lbl.set_location(1, row)
         xfer.add_component(lbl)
         if fieldtype == 0:
             edt = XferCompEdit("item_%d" % fieldid)
         elif fieldtype == 1:
             edt = XferCompMemo("item_%d" % fieldid)
         edt.set_value(items[fieldid - 1])
         edt.set_location(2, row)
         xfer.add_component(edt)
예제 #28
0
 def show(self, xfer):
     destination_file = join("documents", "document_%s" % six.text_type(self.item.id))
     if not isfile(join(get_user_dir(), destination_file)):
         raise LucteriosException(IMPORTANT, _("File not found!"))
     obj_cmt = xfer.get_components('creator')
     down = XferCompDownLoad('filename')
     down.compress = True
     down.http_file = True
     down.maxsize = 0
     down.set_value(self.item.name)
     down.set_download(destination_file)
     down.set_action(xfer.request, ActionsManage.get_action_url('documents.Document', 'AddModify', xfer),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     down.set_location(obj_cmt.col, obj_cmt.row + 1, 4)
     xfer.add_component(down)
     link = self.item.shared_link
     if link is not None:
         shared_link = XferCompEdit('shared_link')
         shared_link.description = _('shared link')
         shared_link.set_value(link)
         shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4)
         xfer.add_component(shared_link)
예제 #29
0
 def fill_header(self, payer, reference):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(_("select cheque to deposit"))
     lbl.set_location(1, 0, 3)
     self.add_component(lbl)
     lbl = XferCompLabelForm('lbl_payer')
     lbl.set_value_as_name(_("payer contains"))
     lbl.set_location(0, 1)
     self.add_component(lbl)
     edt = XferCompEdit('payer')
     edt.set_value(payer)
     edt.set_location(1, 1)
     edt.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(edt)
     lbl = XferCompLabelForm('lbl_reference')
     lbl.set_value_as_name(_("reference contains"))
     lbl.set_location(2, 1)
     self.add_component(lbl)
     edt = XferCompEdit('reference')
     edt.set_value(reference)
     edt.set_location(3, 1)
     edt.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(edt)
예제 #30
0
    def _get_from_selector(self):
        if not isinstance(self.selector, list) and (self.selector is not None):
            raise LucteriosException(GRAVE, "Error of print selector!")
        gui = XferContainerCustom()
        gui.model = self.model
        gui._initialize(self.request)
        gui.is_view_right = self.is_view_right
        gui.caption = self.caption
        gui.extension = self.extension
        gui.action = self.action
        gui.params = self.params
        pdfreport = self.get_persistent_pdfreport()
        if (pdfreport is not None) and (not isinstance(pdfreport, list)
                                        or len(pdfreport) == len(self.items)):
            presitent_report = XferCompCheck('PRINT_PERSITENT')
            presitent_report.set_value(True)
            presitent_report.set_location(0, 0, 2)
            presitent_report.description = _('Get saved report')
            presitent_report.java_script = """
var is_persitent=current.getValue();
parent.get('PRINT_MODE').setEnabled(!is_persitent);
parent.get('print_sep').setEnabled(!is_persitent);
"""
            if self.selector is not None:
                for name_selector, _selector, _selector in self.selector:
                    presitent_report.java_script += "parent.get('%s').setEnabled(!is_persitent);\n" % name_selector
            gui.add_component(presitent_report)
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_REGENERATE_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)
        elif (pdfreport is not None):
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_WARNING_SAVING_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)

        print_mode = XferCompSelect('PRINT_MODE')
        print_mode.set_select(self.print_selector)
        print_mode.set_value(PRINT_PDF_FILE)
        print_mode.set_location(0, 2, 2)
        print_mode.description = _('Kind of report')
        gui.add_component(print_mode)
        if self.selector is not None:
            row_idx = 3
            for name_selector, title_selector, option_selector in self.selector:
                if isinstance(option_selector, list):
                    comp = XferCompSelect(name_selector)
                    comp.set_select(option_selector)
                    comp.set_value(gui.getparam(name_selector, 0))
                elif isinstance(option_selector, tuple):
                    comp = XferCompFloat(name_selector, option_selector[0],
                                         option_selector[1],
                                         option_selector[2])
                    comp.set_value(option_selector[0])
                elif isinstance(option_selector, six.binary_type):
                    comp = XferCompEdit(name_selector)
                    comp.set_value(option_selector.decode())
                elif isinstance(option_selector, six.text_type):
                    comp = XferCompMemo(name_selector)
                    comp.with_hypertext = True
                    comp.set_value(option_selector)
                elif isinstance(option_selector, bool):
                    comp = XferCompCheck(name_selector)
                    comp.set_value(option_selector)
                else:
                    comp = None
                if comp is not None:
                    comp.set_location(0, row_idx, 2)
                    comp.description = title_selector
                    gui.add_component(comp)
                    row_idx += 1
        gui.add_action(self.get_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
예제 #31
0
    def create_dlg(self, username, legalentity):
        dlg = self.create_custom(self.model)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        dlg.add_component(img)
        dlg.fill_from_model(1, 0, False,
                            ['genre', 'lastname', 'firstname', 'email'])
        dlg.get_components(
            'email'
        ).mask = r'^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$'
        row = dlg.get_max_row() + 1
        edt = XferCompEdit("username")
        edt.set_location(1, row)
        edt.set_needed(True)
        edt.set_value(username)
        edt.description = _('username')
        dlg.add_component(edt)
        if Params.getvalue("contacts-createaccount") == 2:
            row = dlg.get_max_row() + 1
            edt = XferCompEdit("legalentity")
            edt.set_location(1, row)
            edt.set_needed(True)
            edt.set_value(legalentity)
            edt.description = _("your structure name")
            dlg.add_component(edt)
        row = dlg.get_max_row() + 1
        edt = XferCompCaptcha("captcha")
        edt.set_location(1, row)
        edt.description = _("captcha")
        dlg.add_component(edt)

        lbl = XferCompLabelForm("error_lbl")
        lbl.set_location(1, row + 1, 2)
        lbl.set_color('red')
        lbl.set_value(self.getparam('error', ''))
        dlg.add_component(lbl)
        dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'),
                       params={"SAVE": "YES"})
        dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
예제 #32
0
 def _select_csv_parameters(self):
     model_select = XferCompSelect('modelname')
     if self.model is not None:
         model_select.set_value(self.model.get_long_name())
     model_select.set_select(self.get_select_models())
     model_select.set_location(1, 0, 3)
     model_select.description = _('model')
     self.add_component(model_select)
     upld = XferCompUpLoad('csvcontent')
     upld.http_file = True
     upld.add_filter(".csv")
     upld.set_location(1, 1, 2)
     upld.description = _('CSV file')
     self.add_component(upld)
     lbl = XferCompEdit('encoding')
     lbl.set_value(self.encoding)
     lbl.set_location(1, 2)
     lbl.description = _('encoding')
     self.add_component(lbl)
     lbl = XferCompEdit('dateformat')
     lbl.set_value(self.dateformat)
     lbl.set_location(2, 2)
     lbl.description = _('date format')
     self.add_component(lbl)
     lbl = XferCompEdit('delimiter')
     lbl.set_value(self.delimiter)
     lbl.set_location(1, 3)
     lbl.description = _('delimiter')
     self.add_component(lbl)
     lbl = XferCompEdit('quotechar')
     lbl.set_value(self.quotechar)
     lbl.set_location(2, 3)
     lbl.description = _('quotechar')
     self.add_component(lbl)
     return lbl
예제 #33
0
파일: views.py 프로젝트: Lucterios2/core
    def fillresponse(self, edt1='aaa', flt1=3.1399999, mm1='xyz', dt1='2007-04-23', tm1='12:34:00',
                     ck1=False, slct1='1', flt2=5, cl1=['1', '2'], cl2=['b', 'd', 'f'], stm1='2008-07-12 23:47:31'):
        act_modif = self.get_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select(
            {'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        checklist.set_value(cl1)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select(
            {'a': '123', 'b': '456', 'c': '789', 'd': '147', 'e': '258', 'f': '369'})
        checklist.set_value(cl2)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES)
예제 #34
0
    def fillresponse(self,
                     edt1='aaa',
                     flt1=3.1399999,
                     mm1='xyz',
                     dt1='2007-04-23',
                     tm1='12:34:00',
                     ck1=False,
                     slct1='1',
                     flt2=5,
                     cl1=['1', '2'],
                     cl2=['b', 'd', 'f'],
                     stm1='2008-07-12 23:47:31'):
        act_modif = self.return_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request,
                            act_modif,
                            modal=FORMTYPE_REFRESH,
                            close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request,
                         act_modif,
                         modal=FORMTYPE_REFRESH,
                         close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select({
            '1': 'abc',
            '2': 'def',
            '3': 'ghij',
            '4': 'klmn'
        })
        checklist.set_value(cl1)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select({
            'a': '123',
            'b': '456',
            'c': '789',
            'd': '147',
            'e': '258',
            'f': '369'
        })
        checklist.set_value(cl2)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES)
예제 #35
0
    def get_writing_comp(self, field_name):
        def get_value_from_field(default):
            try:
                val = getattr(self.item, field_name)
            except ObjectDoesNotExist:
                getLogger("lucterios.core").exception(
                    "fieldname '%s' not found", field_name)
                val = None
            if val is None:
                if is_needed:
                    if dep_field.default != NOT_PROVIDED:
                        val = dep_field.default
                    else:
                        val = default
            return val

        from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
        from django.db.models.fields.related import ForeignKey
        dep_field = self.item.get_field_by_name(field_name)
        is_needed = dep_field.unique or not (dep_field.blank or dep_field.null)
        if isinstance(dep_field, IntegerField):
            if (dep_field.choices
                    is not None) and (len(dep_field.choices) > 0):
                comp = XferCompSelect(field_name)
                comp.set_select(list(dep_field.choices))
                min_value = 0
            else:
                min_value, max_value = get_range_value(dep_field)
                comp = XferCompFloat(field_name, min_value, max_value, 0)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, DecimalField):
            min_value, max_value = get_range_value(dep_field)
            comp = XferCompFloat(field_name, min_value, max_value,
                                 dep_field.decimal_places)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, BooleanField):
            comp = XferCompCheck(field_name)
            comp.set_value(get_value_from_field(False))
        elif isinstance(dep_field, TextField):
            comp = XferCompMemo(field_name)
            comp.set_value(get_value_from_field(""))
        elif isinstance(dep_field, DateField):
            comp = XferCompDate(field_name)
            comp.set_value(get_value_from_field(datetime.date.today()))
        elif isinstance(dep_field, TimeField):
            comp = XferCompTime(field_name)
            comp.set_value(get_value_from_field(datetime.time()))
        elif isinstance(dep_field, DateTimeField):
            comp = XferCompDateTime(field_name)
            comp.set_value(get_value_from_field(datetime.datetime.now()))
        elif isinstance(dep_field, ForeignKey):
            comp = XferCompSelect(field_name)
            try:
                value = self.item
                for fieldname in field_name.split('.'):
                    value = getattr(value, fieldname)
            except ObjectDoesNotExist:
                value = None
            if value is None:
                comp.set_value(0)
            else:
                comp.set_value(value.id)
            if hasattr(self.item, fieldname + '_query'):
                sub_select = getattr(self.item, fieldname + '_query')
            else:
                sub_select = dep_field.remote_field.model.objects.all()
            comp.set_needed(not dep_field.null)
            comp.set_select_query(sub_select)
        elif (dep_field is not None
              ) and dep_field.is_relation and dep_field.many_to_many:
            comp = XferCompCheckList(field_name)
            comp.simple = 2
            if self.item.id is not None:
                values = []
                for item in getattr(self.item, field_name).all():
                    values.append(item.id)
                comp.set_value(values)
            if hasattr(self.item, field_name + '_query'):
                sub_select = getattr(self.item, field_name + '_query')
            else:
                sub_select = get_dico_from_setquery(
                    get_corrected_setquery(
                        dep_field.remote_field.model.objects.all()))
            comp.set_select(sub_select)
        else:
            comp = XferCompEdit(field_name)
            comp.set_value(get_value_from_field(""))
            if isinstance(dep_field, CharField):
                comp.size = dep_field.max_length
        comp.set_needed(is_needed)
        return comp
예제 #36
0
    def create_dlg(self, username, legalentity):
        dlg = self.create_custom(self.model)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        dlg.add_component(img)
        dlg.fill_from_model(1, 0, False, ['genre', 'lastname', 'firstname', 'email'])
        dlg.get_components('email').mask = '^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$'
        row = dlg.get_max_row() + 1
        edt = XferCompEdit("username")
        edt.set_location(1, row)
        edt.set_needed(True)
        edt.set_value(username)
        edt.description = _('username')
        dlg.add_component(edt)
        if Params.getvalue("contacts-createaccount") == 2:
            row = dlg.get_max_row() + 1
            edt = XferCompEdit("legalentity")
            edt.set_location(1, row)
            edt.set_needed(True)
            edt.set_value(legalentity)
            edt.description = _("your structure name")
            dlg.add_component(edt)
        row = dlg.get_max_row() + 1
        edt = XferCompCaptcha("captcha")
        edt.set_location(1, row)
        edt.description = _("captcha")
        dlg.add_component(edt)

        lbl = XferCompLabelForm("error_lbl")
        lbl.set_location(1, row + 1, 2)
        lbl.set_color('red')
        lbl.set_value(self.getparam('error', ''))
        dlg.add_component(lbl)
        dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"})
        dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))