Exemplo n.º 1
0
 def fillresponse(self):
     if self.is_new:
         self.caption = self.caption_add
     else:
         self.caption = self.caption_modify
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, 0, False)
     if len(self.actions) == 0:
         self.add_action(self.get_action(TITLE_OK, 'images/ok.png'),
                         params={"SAVE": "YES"})
     for act, opt in ActionsManage.get_actions(
             ActionsManage.ACTION_IDENT_EDIT, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 2
0
 def fillresponse(self):
     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(self.caption)
     lbl.set_location(1, 0)
     self.add_component(lbl)
     self.fillresponse_header()
     self.fillresponse_body()
     if self.model is not None:
         for act, opt in ActionsManage.get_actions(
                 ActionsManage.ACTION_IDENT_LIST, self,
                 key=action_list_sorted):
             self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 3
0
 def fillresponse(self):
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0)
         dlg.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_record')
         lbl.set_value_as_name(_('record'))
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('record')
         lbl.set_value(six.text_type(self.item))
         lbl.set_location(2, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_current')
         lbl.set_value_as_name(_('current model'))
         lbl.set_location(1, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current')
         lbl.set_value(self.item.__class__._meta.verbose_name)
         lbl.set_location(2, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_newmodel')
         lbl.set_value_as_name(_('new model'))
         lbl.set_location(1, 3)
         dlg.add_component(lbl)
         lbl = XferCompSelect('newmodel')
         lbl.set_select(self.item.__class__.get_select_contact_type(False))
         lbl.set_location(2, 3)
         dlg.add_component(lbl)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL, params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
     else:
         new_model = apps.get_model(self.getparam('newmodel'))
         field_id_name = "%s_ptr_id" % self.model.__name__.lower()
         new_object = new_model(**{field_id_name: self.item.pk})
         new_object.save()
         new_object.__dict__.update(self.item.__dict__)
         new_object.save()
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self))
Exemplo n.º 4
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'))
Exemplo n.º 5
0
 def fillresponse(self):
     self.params['legal_entity'] = '1'
     img = XferCompImage('img')
     img.set_value(get_icon_path('lucterios.contacts/images/fields.png'))
     img.set_location(0, 0, 1, 2)
     self.add_component(img)
     lab = XferCompLabelForm("title")
     lab.set_value_as_title(_('Our structure and its management'))
     lab.set_location(1, 0, 4)
     self.add_component(lab)
     self.fill_from_model(1, 1, True)
     self.add_action(CurrentStructureAddModify.get_action(
         _("Edit"), "images/edit.png"),
                     close=CLOSE_NO)
     self.add_action(CurrentStructurePrint.get_action(
         _("Print"), "images/print.png"),
                     close=CLOSE_NO)
     self.add_action(WrapAction(_("Close"), "images/close.png"))
Exemplo n.º 6
0
 def fillresponse(self, params=(), nb_col=1):
     img_title = XferCompImage('img')
     img_title.set_location(0, 0)
     img_title.set_value(self.icon_path())
     self.add_component(img_title)
     lab = XferCompLabelForm('title')
     lab.set_location(1, 0, 2 * nb_col)
     lab.set_value_as_title(_("Edition of parameters"))
     self.add_component(lab)
     Params.fill(self, params, 1, 1, False, nb_col)
     titles = {}
     signal_and_lock.Signal.call_signal('get_param_titles', params, titles)
     for paramname in titles.keys():
         param_item = self.get_components(paramname)
         if param_item is not None:
             param_item.description = titles[paramname]
     self.add_action(ParamSave.get_action(_('Ok'), 'images/ok.png'))
     self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
Exemplo n.º 7
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
     lbl = XferCompLabelForm('lblPrintMode')
     lbl.set_value_as_name(_('Kind of report'))
     lbl.set_location(0, 0)
     gui.add_component(lbl)
     print_mode = XferCompSelect('PRINT_MODE')
     print_mode.set_select(self.print_selector)
     print_mode.set_value(PRINT_PDF_FILE)
     print_mode.set_location(1, 0)
     gui.add_component(print_mode)
     if self.selector is not None:
         row_idx = 1
         for name_selector, title_selector, option_selector in self.selector:
             lbl = XferCompLabelForm('lbl' + name_selector)
             lbl.set_value_as_name(title_selector)
             lbl.set_location(0, row_idx)
             gui.add_component(lbl)
             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])
             comp.set_location(1, row_idx)
             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
Exemplo n.º 8
0
 def fillresponse(self):
     self.fields_desc.initial(self.item)
     self.read_criteria_from_params()
     self.fillresponse_add_title()
     self.fillresponse_search_select()
     self.fillresponse_search_values()
     self.fillresponse_show_criteria()
     row = self.get_max_row()
     self.filter_items()
     grid = XferCompGrid(self.field_id)
     grid.set_model(self.items, self.fieldnames, self)
     grid.add_action_notified(self)
     grid.set_location(0, row + 4, 6)
     grid.set_size(200, 500)
     self.add_component(grid)
     for act, opt in ActionsManage.get_actions(
             ActionsManage.ACTION_IDENT_LIST, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(_('Close'), 'images/close.png'))
Exemplo n.º 9
0
    def fillresponse(self, current_folder=0, docext=""):
        if current_folder == 0:
            self.item.parent_id = None
        else:
            self.item.parent_id = current_folder
        if self.getparam('CONFIRME', '') == 'YES':
            self.params = {}
            filename_spited = self.item.name.split('.')
            if len(filename_spited) > 1:
                filename_spited = filename_spited[:-1]
            self.item.name = "%s.%s" % (".".join(filename_spited), docext)
            self.item.editor.before_save(self)
            self.item.save()
            self.item.content = ""
            self.redirect_action(DocumentEditor.get_action(),
                                 modal=FORMTYPE_NOMODAL,
                                 close=CLOSE_YES,
                                 params={'document': self.item.id})
        else:
            dlg = self.create_custom(self.model)
            max_row = dlg.get_max_row() + 1
            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, max_row, True, ['parent'])
            dlg.fill_from_model(1, max_row + 1, False, ['name', 'description'])

            max_row = dlg.get_max_row() + 1
            select = XferCompSelect('docext')
            select.set_select([
                (item, item)
                for item in DocEditor.get_all_extension_supported()
            ])
            select.set_value(select.select_list[0][1])
            select.set_location(1, max_row)
            select.description = _('document type')
            dlg.add_component(select)
            dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'),
                           close=CLOSE_YES,
                           params={'CONFIRME': 'YES'})
            dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 10
0
 def fillresponse(self):
     if self.getparam("CONVERT") is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0)
         dlg.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         year_list = ["{[i]} - %s{[/i]}" % year for year in FiscalYear.objects.filter(status__lt=2)]
         lab = XferCompLabelForm('info')
         lab.set_value(
             _("This conversion tool will change your account to respect French law about condominium.{[br/]}For the no-closed fiscal years:{[newline]}%s{[newline]}It will do:{[newline]} - To change accounting code for each owners.{[newline]} - To de-validate all your entity.{[br/]} - To delete all entity link to call of funds or expenses.{[br/]} - To de-archive call of funds or expenses.{[br/]} - To generate correct account for call of funds or expenses.{[br/]}{[center]}{[u]}{[b]}Warning: This action is  definitive.{[/b]}{[/u]}{[center]}") %
             '{[br/]}'.join(year_list))
         lab.set_location(0, 1, 4)
         dlg.add_component(lab)
         dlg.new_tab(_("Third accounts"))
         self.fill_third_convert(dlg)
         dlg.new_tab(_("Parameters"))
         fill_params(dlg, True, True)
         dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CONVERT': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         Parameter.change_value('condominium-old-accounting', False)
         Params.clear()
         try:
             thirds_convert = self.get_thirds_convert()
             for set_cost in SetCost.objects.filter(year__status=2, cost_accounting__status=0):
                 set_cost.cost_accounting.is_protected = True
                 set_cost.cost_accounting.save()
                 if (set_cost.year.status == 2) and (set_cost.cost_accounting.status == 0):
                     set_cost.cost_accounting.close()
             for owner in Owner.objects.all():
                 owner.check_account()
             for year in FiscalYear.objects.filter(status__lt=2):
                 convert_accounting(year, thirds_convert)
         except BaseException:
             Params.clear()
             raise
         self.message(_("Data converted"))
Exemplo n.º 11
0
 def fillresponse(self):
     editor = self.item.get_doc_editors()
     if self.getparam('SAVE', '') == 'YES':
         editor.save_content()
     elif self.getparam('CLOSE', '') == 'YES':
         editor.close()
     else:
         editor.send_content()
         dlg = self.create_custom(self.model)
         dlg.item = self.item
         dlg.fill_from_model(0, 0, True, [('parent', 'name')])
         frame = XferCompLabelForm('frame')
         frame.set_value(editor.get_iframe())
         frame.set_location(0, 2, 2, 0)
         dlg.add_component(frame)
         dlg.add_action(self.get_action(TITLE_SAVE, 'images/save.png'),
                        close=CLOSE_NO,
                        params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
         dlg.set_close_action(self.get_action(), params={'CLOSE': 'YES'})
Exemplo n.º 12
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'))
Exemplo n.º 13
0
 def fillresponse(self, field_id):
     self.items = self.model.objects.filter(id__in=self.getparam(field_id, ())).distinct()
     if len(self.items) < 2:
         raise LucteriosException(IMPORTANT, _("Impossible: you must to select many records!"))
     item_id = self.getparam('mrg_' + self.field_id, 0)
     if item_id != 0:
         self.item = self.model.objects.get(id=item_id)
     if (self.item is None) or (self.item.id is None):
         self.item = self.items[0]
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         grid = XferCompGrid('mrg_' + self.field_id)
         grid.add_header('value', _('designation'))
         grid.add_header('select', _('is main?'), 'B')
         for item in self.items:
             grid.set_value(item.id, 'value', six.text_type(item))
             grid.set_value(item.id, 'select', item.id == self.item.id)
         grid.set_location(1, 1)
         grid.add_action(self.request, self.get_action(_("Edit"), "images/show.png"),
                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE, params={"CONFIRME": 'OPEN'})
         grid.add_action(self.request, self.get_action(_("Select"), "images/ok.png"),
                         modal=FORMTYPE_REFRESH, close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.add_component(grid)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL,
                        params={'CONFIRME': 'YES', 'mrg_' + self.field_id: self.item.id})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
     elif self.getparam("CONFIRME") == 'YES':
         alias_objects = []
         for item in self.items:
             if item.id != self.item.id:
                 alias_objects.append(item.get_final_child())
         self.item.get_final_child().merge_objects(alias_objects)
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self), params={field_id: self.item.id})
     else:
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self), params={field_id: self.item.id})
Exemplo n.º 14
0
 def fillresponse(self, ventilate=False):
     msg = self.item.check_close()
     if msg is not None:
         if self.getparam('CLOSE') is None:
             dlg = self.create_custom(self.model)
             img = XferCompImage('img')
             img.set_value(self.icon_path())
             img.set_location(0, 0)
             dlg.add_component(img)
             lbl = XferCompLabelForm('title')
             lbl.set_value_as_title(self.caption)
             lbl.set_location(1, 0, 2)
             dlg.add_component(lbl)
             lbl = XferCompLabelForm('info')
             lbl.set_value(
                 _('This class load has a difference of %s between those call of funds and those expenses.'
                   ) % msg)
             lbl.set_location(1, 1)
             dlg.add_component(lbl)
             lbl = XferCompCheck('ventilate')
             lbl.set_value(ventilate)
             lbl.set_location(1, 2)
             lbl.description = 'Do you want to ventilate this amount for each owner?'
             dlg.add_component(lbl)
             dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'),
                            modal=FORMTYPE_MODAL,
                            close=CLOSE_YES,
                            params={'CLOSE': 'YES'})
             dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
         else:
             if self.item.type_load == 0:
                 self.item.close_current(ventilate)
             else:
                 self.item.close_exceptional(ventilate)
     elif self.confirme(_('Do you want to close this class load?')):
         if self.item.type_load == 0:
             self.item.close_current()
         else:
             self.item.close_exceptional()
Exemplo n.º 15
0
 def fillresponse(self):
     img_title = XferCompImage('img')
     img_title.set_location(0, 0, 1, 10)
     img_title.set_value(self.icon_path())
     self.add_component(img_title)
     lab = XferCompLabelForm('title')
     lab.set_location(1, 0, 3)
     lab.set_value('{[br/]}{[center]}{[b]}{[u]}%s{[/u]}{[/b]}{[/center]}' % _("Software configuration"))
     self.add_component(lab)
     setting_list = {}
     signal_and_lock.Signal.call_signal("config", setting_list)
     for tab_name in sorted(list(setting_list.keys())):
         self.new_tab(tab_name[tab_name.find('@') + 1:])
         Params.fill(self, setting_list[tab_name], 0, 0)
         btn = XferCompButton(tab_name + "_btn")
         btn.set_action(self.request, ParamEdit.get_action(_('Modify'), 'images/edit.png'), close=CLOSE_NO, params={'params': setting_list[tab_name]})
         btn.set_location(0, self.get_max_row() + 1)
         self.add_component(btn)
     steplist = get_wizard_step_list()
     if steplist != '':
         self.add_action(ConfigurationWizard.get_action(_("Wizard"), "images/config.png"), close=CLOSE_NO, params={'steplist': steplist})
     self.add_action(WrapAction(_('Close'), 'images/close.png'))
Exemplo n.º 16
0
 def fillresponse(self):
     if "SAVE" in self.params.keys():
         del self.params["SAVE"]
     if self.has_changed:
         self.item.editor.before_save(self)
         try:
             self.item.save()
             self.has_changed = False
             if self.fill_manytomany_fields():
                 self.item.save()
         except IntegrityError as err:
             getLogger("lucterios.core.container").info("%s", err)
             six.print_(err)
             self.raise_except(
                 _("This record exists yet!"), self.raise_except_class)
     if self.except_msg == '':
         self.item.editor.saving(self)
     if self.getparam('URL_TO_REDIRECT') is not None:
         url_text = self.getparam('URL_TO_REDIRECT')
         self.redirect_action(WrapAction('', '', url_text=url_text), params={self.field_id: self.item.id})
     elif isinstance(self.redirect_to_show, six.text_type):
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), self.redirect_to_show, self),
                              params={self.field_id: self.item.id})
Exemplo n.º 17
0
 def fillresponse(self):
     img = XferCompImage('img')
     img.set_value(get_icon_path('lucterios.contacts/images/account.png'))
     img.set_location(0, 0, 1, 2)
     self.add_component(img)
     lab = XferCompLabelForm("title")
     lab.set_value_as_title(_('View my account.'))
     lab.set_location(1, 0, 2)
     self.add_component(lab)
     try:
         self.item = Individual.objects.get(user=self.request.user)
         self.item = self.item.get_final_child()
         self.model = Individual
         self.field_id = 'individual'
         self.params['individual'] = six.text_type(self.item.id)
         self.add_action(AccountAddModify.get_action(
             _("Edit"), "images/edit.png"),
                         close=CLOSE_NO)
         is_individual = True
     except ObjectDoesNotExist:
         self.item = LucteriosUser.objects.get(id=self.request.user.id)
         self.add_action(
             UsersEdit.get_action(_("Edit"), "images/edit.png"),
             close=CLOSE_NO,
             params={'user_actif': six.text_type(self.request.user.id)})
         is_individual = False
     self.fill_from_model(1, 1, True)
     if is_individual:
         legal_entities = LegalEntity.objects.filter(
             responsability__individual=self.item).exclude(id=1)
         if len(legal_entities) == 1:
             self.add_legalentity(legal_entities[0])
         elif len(legal_entities) > 1:
             self.add_legalentities(legal_entities)
         signal_and_lock.Signal.call_signal("add_account", self.item, self)
     self.add_action(WrapAction(_("Close"), "images/close.png"))
Exemplo n.º 18
0
    def fillresponse(self):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)

        pwd = XferCompPassword('oldpass')
        pwd.set_location(1, 0, 1, 1)
        pwd.security = 0
        pwd.description = _("old password")
        self.add_component(pwd)

        pwd = XferCompPassword('newpass1')
        pwd.set_location(1, 1, 1, 1)
        pwd.description = _("new password")
        self.add_component(pwd)

        pwd = XferCompPassword('newpass2')
        pwd.set_location(1, 2, 1, 1)
        pwd.description = _("new password (again)")
        self.add_component(pwd)

        self.add_action(ModifyPassword.get_action(_('Ok'), 'images/ok.png'))
        self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
Exemplo n.º 19
0
 def _get_zipextract(self):
     filename = self._get_reports_archive()
     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
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     gui.add_component(lbl)
     zipdown = XferCompDownLoad('filename')
     zipdown.compress = False
     zipdown.http_file = True
     zipdown.maxsize = 0
     zipdown.set_value(filename)
     zipdown.set_download(filename)
     zipdown.set_location(1, 15, 2)
     gui.add_component(zipdown)
     gui.add_action(WrapAction(_("Close"), "images/close.png"))
     return gui
Exemplo n.º 20
0
 def fillresponse_redirect():
     self.factory.xfer.redirect_action(
         WrapAction("redirect", "", "customer", "list"))
Exemplo n.º 21
0
 def fillresponse_close():
     self.factory.xfer.set_close_action(
         WrapAction("close", "", "customer", "list"))
Exemplo n.º 22
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(1, 0)
     sel.description = _('season')
     sel.set_action(self.request,
                    self.get_action('', ''),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(
         TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO,
                     params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 23
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
Exemplo n.º 24
0
    def test_connect_free(self):
        Params.clear()
        self.calljson('/CORE/authentification', {
            'username': '',
            'password': ''
        })
        self.assert_observer('core.auth', 'CORE', 'authentification')
        self.assert_json_equal('', '', 'BADAUTH')

        param = Parameter.objects.get(name='CORE-connectmode')
        param.value = '2'
        param.save()
        Params.clear()

        self.calljson('/CORE/authentification', {
            'username': '',
            'password': ''
        })
        self.assert_observer('core.auth', 'CORE', 'authentification')
        self.assert_json_equal('', '', 'OK')
        self.assertEqual(self.response_json['connexion']['LOGIN'], '')
        self.assertEqual(self.response_json['connexion']['REALNAME'], '')
        self.assertEqual(self.response_json['connexion']['MODE'], '2')

        self.assertTrue(WrapAction.mode_connect_notfree is not None,
                        "mode_connect_notfree is not None")
        self.assertFalse(
            WrapAction('', '').mode_connect_notfree(),
            "mode_connect_notfree()")
        self.assertFalse(
            WrapAction.mode_connect_notfree is None
            or WrapAction('', '').mode_connect_notfree(),
            "mode_connect_notfree is None or mode_connect_notfree()")
        request = RequestFactory().post('/')
        request.user = AnonymousUser()
        act1 = WrapAction('free', 'free', is_view_right=None)
        self.assertEqual(act1.is_view_right, None, 'act1.is_view_right')
        self.assertFalse(act1.check_permission(request),
                         'check_permission None')
        act2 = WrapAction('free',
                          'free',
                          is_view_right='CORE.change_parameter')
        act2.with_log = True
        self.assertEqual(act2.is_view_right, 'CORE.change_parameter',
                         'act2.is_view_right')
        self.assertTrue(act2.check_permission(request),
                        'check_permission CORE.change_parameter')

        self.calljson('/CORE/configuration', {})
        self.assert_observer('core.custom', 'CORE', 'configuration')
        self.assert_json_equal('LABELFORM', "CORE-connectmode", "Accès libre")

        self.calljson('/CORE/menu', {})
        self.assert_observer('core.menu', 'CORE', 'menu')
        self.assertEqual(len(self.response_json['menus']), 3)
        self.assertEqual(self.response_json['menus'][0]['id'], 'core.menu')
        self.assertEqual(self.response_json['menus'][1]['id'], 'dummy.foo')
        self.assertEqual(len(self.response_json['menus'][1]['menus']), 9)
        self.assertEqual(self.response_json['menus'][2]['id'], 'core.admin')
        self.assertEqual(self.response_json['menus'][2]['text'],
                         'Administration')
        self.assertEqual(self.response_json['menus'][2]['menus'][3]['id'],
                         'core.right')
        self.assertEqual(self.response_json['menus'][2]['menus'][3]['text'],
                         'Gestion des droits')
        self.assertEqual(
            self.response_json['menus'][2]['menus'][3]['menus'][0]['id'],
            'CORE/groupsList')
        self.assertEqual(
            self.response_json['menus'][2]['menus'][3]['menus'][0]['text'],
            'Les groupes')
Exemplo n.º 25
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)
Exemplo n.º 26
0
 def fill_buttons(self):
     self.add_action(FiscalYearReportPrint.get_action(TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO, params={"modulename": __name__, 'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 27
0
 def fillresponse(self):
     self._fill_functions()
     self._fill_structuretype()
     self._fill_customfield()
     self.add_action(WrapAction(_("Close"), "images/close.png"))
Exemplo n.º 28
0
    def fillresponse(self, modelname, quotechar="'", delimiter=";", encoding="utf-8", dateformat="%d/%m/%Y", step=0):
        def add_item_if_not_null(new_item):
            if new_item is not None:
                self.items_imported[new_item.id] = new_item

        if modelname is not None:
            self.model = apps.get_model(modelname)
        self.quotechar = quotechar
        self.delimiter = delimiter
        self.encoding = encoding
        self.dateformat = dateformat

        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        self.add_component(img)
        if step == 0:
            lbl = self._select_csv_parameters()
            step = 1
        elif step == 1:
            lbl = XferCompLabelForm('modelname')
            lbl.set_value(self.model._meta.verbose_name.title())
            lbl.set_location(1, 0)
            lbl.description = _('model')
            self.add_component(lbl)
            self._read_csv()
            self.new_tab(_("Fields"))
            self._select_fields()
            self.new_tab(_("Current content"))
            self._show_initial_csv()
            step = 2
        elif step == 2:
            lbl = XferCompLabelForm('modelname')
            lbl.set_value(self.model._meta.verbose_name.title())
            lbl.set_location(1, 0)
            lbl.description = _('model')
            self.add_component(lbl)
            fields_description, csv_readed = self._read_csv_and_convert()
            tbl = XferCompGrid('CSV')
            for field_description in fields_description:
                tbl.add_header(field_description[0], field_description[1], field_description[2], formatstr=field_description[3])
            row_idx = 1
            for row in csv_readed:
                for field_description in fields_description:
                    tbl.set_value(row_idx, field_description[0], row[field_description[0]])
                row_idx += 1
            tbl.set_location(1, 1, 2)
            self.add_component(tbl)
            lbl = XferCompLabelForm('nb_line')
            lbl.set_value(_("Total number of items: %d") % (row_idx - 1))
            lbl.set_location(1, 2, 2)
            self.add_component(lbl)
            step = 3
        elif step == 3:
            fields_description, csv_readed = self._read_csv_and_convert()
            self.model.initialize_import()
            self.items_imported = {}
            for rowdata in csv_readed:
                add_item_if_not_null(self.model.import_data(rowdata, dateformat))
            add_item_if_not_null(self.model.finalize_import())
            lbl = XferCompLabelForm('result')
            lbl.set_value_as_header(_("%d items are been imported") % len(self.items_imported))
            lbl.set_location(1, 2, 2)
            self.add_component(lbl)
            step = 4
        if step < 4:
            if step > 1:
                self.add_action(self.get_action(_('Back'), "images/left.png"),
                                close=CLOSE_NO, modal=FORMTYPE_REFRESH, params={'step': step - 2})
            self.add_action(self.get_action(_('Ok'), "images/ok.png"),
                            close=CLOSE_NO, modal=FORMTYPE_REFRESH, params={'step': step})
            self.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
        else:
            self.add_action(WrapAction(_("Close"), "images/close.png"))
Exemplo n.º 29
0
 def fillresponse(self, step=0, steplist=[]):
     self.header_title(step, steplist)
     signal_and_lock.Signal.call_signal("conf_wizard", steplist[step], self)
     self.add_action(WrapAction(TITLE_CLOSE, "images/close.png"))