Example #1
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)
Example #2
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()
Example #3
0
    def fillresponse(self):
        if self.getparam('SAVE') is None:
            dlg = self.create_custom()
            dlg.item = self.item
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 3)
            dlg.add_component(img)
            lbl = XferCompLabelForm('title')
            lbl.set_value_as_title(self.caption)
            lbl.set_location(1, 0, 6)
            dlg.add_component(lbl)

            dlg.fill_from_model(1, 1, False, desc_fields=['parent'])
            parent = dlg.get_components('parent')
            parent.colspan = 3

            self.add_components(dlg)
            dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), {
                'close': CLOSE_YES,
                'params': {
                    'SAVE': 'YES'
                }
            })
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'), {})
        else:
            if self.getparam("parent", 0) != 0:
                self.item = Folder.objects.get(id=self.getparam("parent", 0))
            else:
                self.item = Folder()
            self.run_archive()
Example #4
0
    def fillresponse(self):
        if self.getparam('SAVE') is None:
            dlg = self.create_custom()
            dlg.item = self.item
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 3)
            dlg.add_component(img)
            lbl = XferCompLabelForm('title')
            lbl.set_value_as_title(self.caption)
            lbl.set_location(1, 0, 6)
            dlg.add_component(lbl)

            dlg.fill_from_model(1, 1, False, desc_fields=['parent'])
            parent = dlg.get_components('parent')
            parent.colspan = 3

            self.add_components(dlg)
            dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
        else:
            if self.getparam("parent", 0) != 0:
                self.item = Folder.objects.get(id=self.getparam("parent", 0))
            else:
                self.item = Folder()
            self.run_archive()
Example #5
0
 def show(self, xfer):
     if xfer.item.cost_accounting is None:
         xfer.remove_component("cost_accounting")
         xfer.remove_component("lbl_cost_accounting")
     xfer.params['new_account'] = Params.getvalue('invoice-account-third')
     xfer.move(0, 0, 1)
     lbl = XferCompLabelForm('title')
     lbl.set_location(1, 0, 4)
     lbl.set_value_as_title(get_value_if_choices(
         self.item.bill_type, self.item.get_field_by_name('bill_type')))
     xfer.add_component(lbl)
     details = xfer.get_components('detail')
     if Params.getvalue("invoice-vat-mode") != 0:
         if Params.getvalue("invoice-vat-mode") == 1:
             details.headers[2] = XferCompHeader(details.headers[2].name, _(
                 'price excl. taxes'), details.headers[2].type, details.headers[2].orderable)
             details.headers[6] = XferCompHeader(details.headers[6].name, _(
                 'total excl. taxes'), details.headers[6].type, details.headers[6].orderable)
         elif Params.getvalue("invoice-vat-mode") == 2:
             details.headers[2] = XferCompHeader(details.headers[2].name, _(
                 'price incl. taxes'), details.headers[2].type, details.headers[2].orderable)
             details.headers[6] = XferCompHeader(details.headers[6].name, _(
                 'total incl. taxes'), details.headers[6].type, details.headers[6].orderable)
         xfer.get_components('lbl_total_excltax').set_value_as_name(
             _('total excl. taxes'))
         xfer.filltab_from_model(1, xfer.get_max_row() + 1, True,
                                 [((_('VTA sum'), 'vta_sum'), (_('total incl. taxes'), 'total_incltax'))])
     if self.item.status == 0:
         SupportingEditor.show_third(self, xfer, 'invoice.add_bill')
     else:
         SupportingEditor.show_third_ex(self, xfer)
         details.actions = []
         if self.item.bill_type != 0:
             SupportingEditor.show(self, xfer)
     return
Example #6
0
    def fillresponse(self):
        model_module = ".".join(self.item.model_associated().__module__.split('.')[:-1])
        if self.getparam('SAVE') is None:
            dlg = self.create_custom(self.model)
            dlg.item = self.item
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 3)
            dlg.add_component(img)
            lbl = XferCompLabelForm('title')
            lbl.set_value_as_title(self.caption)
            lbl.set_location(1, 0, 6)
            dlg.add_component(lbl)

            lbl = XferCompLabelForm('lbl_default_model')
            lbl.set_value_as_name(_("Model to reload"))
            lbl.set_location(1, 1)
            dlg.add_component(lbl)
            sel = XferCompSelect('default_model')
            sel.set_select(PrintModel.get_default_model(model_module, self.item.modelname, self.item.kind))
            sel.set_location(2, 1)
            dlg.add_component(sel)

            dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
        else:
            if self.item.load_model(model_module, self.getparam("default_model", ""), is_default=None):
                self.message(_('Model reloaded'))
Example #7
0
 def fillresponse(self):
     img_title = XferCompImage('img')
     img_title.set_location(0, 0, 1, 6)
     img_title.set_value(self.icon_path())
     self.add_component(img_title)
     lab = XferCompLabelForm('title')
     lab.set_location(1, 0, 2)
     lab.set_value_as_title(_("Print models"))
     self.add_component(lab)
     self.fill_from_model(2, 1, False, ['name'])
     self.fill_from_model(2, 2, True, ['kind'])
     self.item.mode = int(self.item.mode)
     if self.item.kind == 1:
         self.fill_from_model(2, 3, False, ['mode'])
         self.get_components('mode').set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
         if (self.item.mode == 1) and (self.item.value[:6] != '<model'):
             self.item.value = "<model>\n<body>\n<text>%s</text></body>\n</model>" % self.item.value
     if self.item.kind == 0:
         self._fill_listing_editor()
     elif (self.item.kind == 1) and (self.item.mode == 0):
         self._fill_label_editor()
     elif (self.item.kind == 2) or ((self.item.kind == 1) and (self.item.mode == 1)):
         self._fill_report_editor()
     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_CLOSE, 'images/close.png'))
Example #8
0
 def fillresponse(self):
     self.action_list = []
     if self.final_class is not None:
         self.add_action(self.final_class.get_action(TITLE_OK, "images/ok.png"))
     model_current = self.getparam('modelname')
     if model_current is None:
         self.model = self.inital_model
     else:
         self.model = apps.get_model(model_current)
     self.field_id = self.model.__name__.lower()
     if self.field_id == 'legalentity':
         self.field_id = 'legal_entity'
     self.item = self.model()
     XferSearchEditor.fillresponse(self)
     self.remove_component('title')
     lbl = XferCompLabelForm('modelname_lbl')
     lbl.set_value_as_title(_('model'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     selected_model = XferCompSelect('modelname')
     selected_model.set_value(model_current)
     selected_model.set_select(self.inital_model.get_select_contact_type())
     selected_model.set_location(2, 0, 3)
     selected_model.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(selected_model)
     if self.select_class is not None:
         grid = self.get_components(self.field_id)
         grid.add_action(self.request, self.select_class.get_action(_("Select"), "images/ok.png"),
                         close=CLOSE_YES, unique=self.mode_select, params={'pkname': self.field_id}, pos_act=0)
Example #9
0
 def fillresponse(self, field_id):
     if field_id is not None:
         self.field_id = field_id
     if hasattr(self.item, 'abstractcontact_ptr_id'):
         XferShowEditor.fillresponse(self)
     else:
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         self.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(
             _('this contact is inconstitant, you must to be promote it !'))
         lbl.set_location(1, 0)
         self.add_component(lbl)
         btn = XferCompButton('btn_promote')
         btn.set_location(1, 1)
         btn.set_action(self.request,
                        ObjectPromote.get_action(_('Promote'),
                                                 "images/config.png"),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES,
                        params={
                            'modelname': self.model.get_long_name(),
                            'field_id': self.field_id
                        })
         self.add_component(btn)
Example #10
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"))
Example #11
0
    def fillresponse(self):
        current_year = FiscalYear.get_current()
        if self.item.type_load == 0:
            for year_item in FiscalYear.objects.filter(
                    begin__gte=current_year.begin):
                costs = self.item.setcost_set.filter(year=year_item)
                if len(costs) == 0:
                    self.item.create_new_cost(year=year_item.id)

        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.item.name)
        lbl.set_location(1, 0)
        self.add_component(lbl)
        self.fill_grid(
            0, CostAccounting, 'costaccounting',
            CostAccounting.objects.filter(
                setcost__set=self.item).order_by('-setcost__year__begin'))
        grid = self.get_components('costaccounting')
        grid.delete_header("is_default")
        new_actions = []
        grid = self.get_components('costaccounting')
        for grid_action in grid.actions:
            if grid_action[0].icon_path.endswith('images/print.png'):
                new_actions.append(grid_action)
        grid.actions = new_actions
        grid.add_action(self.request,
                        ClassCategoryBudget.get_action(),
                        close=CLOSE_NO,
                        unique=SELECT_SINGLE)
        self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Example #12
0
    def fillresponse(self):
        if self.getparam('SAVE') is None:
            dlg = self.create_custom(self.model)
            dlg.item = self.item
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 3)
            dlg.add_component(img)
            lbl = XferCompLabelForm('title')
            lbl.set_value_as_title(self.caption)
            lbl.set_location(1, 0, 6)
            dlg.add_component(lbl)

            lbl = XferCompLabelForm('lbl_import_model')
            lbl.set_value_as_name(_("file to load"))
            lbl.set_location(1, 1)
            dlg.add_component(lbl)
            upload = XferCompUpLoad('import_model')
            upload.compress = False
            upload.http_file = True
            upload.maxsize = 128 * 1024 * 1024  # 128Mo
            upload.add_filter('.mdl')
            upload.set_location(2, 1)
            dlg.add_component(upload)

            dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
        else:
            if 'import_model' in self.request.FILES.keys():
                upload_file = self.request.FILES['import_model']
                if self.item.import_file(upload_file):
                    self.message(_('Model loaded'))
Example #13
0
    def fillresponse(self, show_only_failed=False):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        self.add_component(img)
        begin = XferCompLabelForm('title')
        begin.set_location(1, 0, 2)
        begin.set_value_as_title(_('Transmission report'))
        self.add_component(begin)

        self.filltab_from_model(1, 1, True,
                                [((_('date begin of send'), 'date_begin'),
                                  (_('date end of send'), 'date_end')),
                                 ('emailsent_set', )])
        if not show_only_failed:
            grid = self.get_components('emailsent')
            grid.delete_header('error')

        check = XferCompCheck('show_only_failed')
        check.set_value(show_only_failed)
        check.description = _('Show only failed')
        check.set_location(1, 3, 2)
        check.set_action(self.request,
                         self.get_action(),
                         modal=FORMTYPE_REFRESH,
                         close=CLOSE_NO)
        self.add_component(check)

        show_only_failed
        self.add_action(WrapAction(_('Close'), 'images/close.png'))
Example #14
0
 def fillresponse(self, year=0):
     current_year = FiscalYear.objects.get(id=year)
     if self.getparam("CONFIRME") is None:
         nb_entry_noclose = current_year.check_to_close()
         text_confirm = six.text_type(_('close-fiscal-year-confirme'))
         if nb_entry_noclose > 0:
             if nb_entry_noclose == 1:
                 text_confirm += six.text_type(_('warning, entry no validated'))
             else:
                 text_confirm += six.text_type(_('warning, %d entries no validated') % nb_entry_noclose)
         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)
         dlg.add_component(lbl)
         lab = XferCompLabelForm('info')
         lab.set_value(text_confirm)
         lab.set_location(0, 1, 4)
         dlg.add_component(lab)
         signal_and_lock.Signal.call_signal("finalize_year", dlg)
         dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         signal_and_lock.Signal.call_signal("finalize_year", self)
         current_year.closed()
Example #15
0
File: views.py Project: povtux/core
 def fillresponse(self):
     img_title = XferCompImage('img')
     img_title.set_location(0, 0, 1, 6)
     img_title.set_value(self.icon_path())
     self.add_component(img_title)
     lab = XferCompLabelForm('title')
     lab.set_location(1, 0, 2)
     lab.set_value_as_title(_("Print models"))
     self.add_component(lab)
     self.fill_from_model(1, 1, False, ['name'])
     self.fill_from_model(1, 2, True, ['kind'])
     self.item.mode = int(self.item.mode)
     if self.item.kind == 1:
         self.fill_from_model(1, 3, False, ['mode'])
         self.get_components('mode').set_action(
             self.request, self.get_action('', ''), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO})
         if (self.item.mode == 1) and (self.item.value[:6] != '<model'):
             self.item.value = "<model>\n<body>\n<text>%s</text></body>\n</model>" % self.item.value
     if self.item.kind == 0:
         self._fill_listing_editor()
     elif (self.item.kind == 1) and (self.item.mode == 0):
         self._fill_label_editor()
     elif (self.item.kind == 2) or ((self.item.kind == 1) and (self.item.mode == 1)):
         self._fill_report_editor()
     self.add_action(
         PrintModelSave.get_action(_("ok"), "images/ok.png"), {})
     self.add_action(WrapAction(_('cancel'), 'images/cancel.png'), {})
Example #16
0
 def fillresponse_add_title(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)
Example #17
0
 def fillresponse_add_title(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, 5)
     self.add_component(lbl)
Example #18
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__in=(FiscalYear.STATUS_BUILDING,
                             FiscalYear.STATUS_RUNNING))
         ]
         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.return_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 == FiscalYear.STATUS_FINISHED
                     ) and (set_cost.cost_accounting.status
                            == CostAccounting.STATUS_OPENED):
                     set_cost.cost_accounting.close()
             for owner in Owner.objects.all():
                 owner.check_account()
             for year in FiscalYear.objects.filter(
                     status__in=(FiscalYear.STATUS_BUILDING,
                                 FiscalYear.STATUS_RUNNING)):
                 convert_accounting(year, thirds_convert)
         except BaseException:
             Params.clear()
             raise
         self.message(_("Data converted"))
Example #19
0
File: views.py Project: povtux/core
 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)
     self.add_action(ParamSave.get_action(_('Ok'), 'images/ok.png'), {})
     self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'), {})
Example #20
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'))
Example #21
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()
     add_auditlogs_button(self, self.model, 0, self.get_max_row() + 20)
     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'))
Example #22
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_type, title, icon in self.action_list:
             self.add_action(ActionsManage.get_act_changed(
                 self.model.__name__, act_type, title, icon), {'close': CLOSE_NO})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Example #23
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"))
Example #24
0
File: views.py Project: povtux/core
 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_act_changed(self.model.__name__, 'show', '', ''), {})
Example #25
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     dlg.get_components('activity').colspan = 3
     dlg.get_components('date').colspan = 3
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     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'))
Example #26
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('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     self.add_component(lbl)
     zipdown = XferCompDownLoad('filename')
     zipdown.compress = False
     zipdown.http_file = True
     zipdown.maxsize = 0
     zipdown.set_value("%s.mdl" % self.item.name)
     zipdown.set_download(self.item.extract_file())
     zipdown.set_location(1, 15, 2)
     self.add_component(zipdown)
Example #27
0
File: views.py Project: povtux/core
    def fillresponse(self, modelname=''):
        img_title = XferCompImage('img')
        img_title.set_location(0, 0, 1, 2)
        img_title.set_value(self.icon_path())
        self.add_component(img_title)
        lab = XferCompLabelForm('title')
        lab.set_location(1, 0, 3)
        lab.set_value_as_title(_("Print models"))
        self.add_component(lab)

        lab = XferCompLabelForm('lblmodelname')
        lab.set_location(1, 1)
        lab.set_value_as_name(_('model'))
        self.add_component(lab)
        model_list = {}
        for print_model in PrintModel.objects.all():
            if print_model.modelname not in model_list.keys():
                try:
                    model_list[
                        print_model.modelname] = print_model.model_associated_title()
                    if modelname == '':
                        modelname = print_model.modelname
                except LookupError:
                    pass
        model_sel = XferCompSelect('modelname')
        model_sel.set_location(2, 1, 2)
        model_sel.set_select(model_list)
        model_sel.set_value(modelname)
        model_sel.set_action(self.request, self.get_action(
            "", ""), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO})
        self.add_component(model_sel)

        items = PrintModel.objects.filter(
            modelname=modelname)
        grid = XferCompGrid('print_model')
        grid.set_location(1, 2, 3)
        grid.set_model(items, ['name', 'kind'], self)
        grid.add_action(self.request, PrintModelEdit.get_action(
            _('edit'), 'images/edit.png'), {'unique': SELECT_SINGLE})
        grid.add_action(self.request, PrintModelClone.get_action(
            _('clone'), 'images/clone.png'), {'unique': SELECT_SINGLE})
        grid.add_action(self.request, PrintModelDelete.get_action(
            _('delete'), 'images/delete.png'), {'unique': SELECT_SINGLE})
        self.add_component(grid)

        self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Example #28
0
 def fillresponse(self, send_email=True):
     cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(self.model)
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 4)
         dlg.add_component(img)
         lab = XferCompLabelForm('lbl_title')
         lab.set_value_as_title(self.caption)
         lab.set_location(1, 0, 2)
         dlg.add_component(lab)
         grid = XferCompGrid('AdhCmd')
         for fname, ftitle in cmd_manager.get_fields():
             grid.add_header(fname, ftitle)
         for cmd_id, cmd_item in cmd_manager.get_content_txt():
             for head_name, value in cmd_item.items():
                 grid.set_value(cmd_id, head_name, value)
         grid.set_location(1, 2, 2)
         grid.add_action(self.request, AdherentCommandModify.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         grid.add_action(self.request, AdherentCommandDelete.get_action(TITLE_DELETE, "images/delete.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.params['CMD_FILE'] = cmd_manager.file_name
         dlg.add_component(grid)
         if len(grid.records) > 0:
             lab = XferCompLabelForm('lbl_send_email')
             lab.set_value_as_name(_('Send quotition by email for each adherent.'))
             lab.set_location(1, 3)
             dlg.add_component(lab)
             chk = XferCompCheck('send_email')
             chk.set_value(send_email)
             chk.set_location(2, 3)
             dlg.add_component(chk)
             dlg.add_action(AdherentCommand.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
         if send_email:
             param_email = self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language
         else:
             param_email = None
         nb_sub, nb_bill = cmd_manager.create_subscription(dateref, param_email)
         if send_email:
             msg = _('%(nbsub)d new subscription and %(nbbill)d quotation have been sent.') % {'nbsub': nb_sub, 'nbbill': nb_bill}
         else:
             msg = _('%d new subscription have been prepared.') % nb_sub
         self.message(msg)
Example #29
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))
Example #30
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'))
Example #31
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"))
Example #32
0
 def open_zipfile(self, filename):
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.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)
     dlg.add_component(zipdown)
Example #33
0
 def fillresponse(self):
     if self.getparam("year") is None:
         self.item = FiscalYear.get_current()
     destination_file = self.item.get_xml_export()
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(_('Export fiscal year'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     down = XferCompDownLoad('filename')
     down.compress = False
     down.set_value('export_year_%s_%s.xml' %
                    (self.item.begin.isoformat(), self.item.end.isoformat()))
     down.set_download(destination_file)
     down.set_location(1, 1)
     self.add_component(down)
Example #34
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():
                 for num_account in range(1, 5):
                     AccountThird.objects.create(third=owner.third,
                                                 code=correct_accounting_code(Params.getvalue("condominium-default-owner-account%d" % num_account)))
             for year in FiscalYear.objects.filter(status__lt=2):
                 convert_accounting(year, thirds_convert)
         except:
             Params.clear()
             raise
         self.message(_("Data converted"))
Example #35
0
 def fillresponse(self, field_id):
     if field_id is not None:
         self.field_id = field_id
     if hasattr(self.item, 'abstractcontact_ptr_id'):
         XferShowEditor.fillresponse(self)
     else:
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         self.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(_('this contact is inconstitant, you must to be promote it !'))
         lbl.set_location(1, 0)
         self.add_component(lbl)
         btn = XferCompButton('btn_promote')
         btn.set_location(1, 1)
         btn.set_action(self.request, ObjectPromote.get_action(_('Promote'), "images/config.png"), modal=FORMTYPE_MODAL,
                        close=CLOSE_YES, params={'modelname': self.model.get_long_name(), 'field_id': self.field_id})
         self.add_component(btn)
Example #36
0
 def open_zipfile(self, filename):
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.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)
     dlg.add_component(zipdown)
Example #37
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     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'))
Example #38
0
File: views.py Project: povtux/core
 def fillresponse(self, field_id):
     self.items = self.model.objects.filter(
         id__in=self.getparam(field_id, ()))
     if len(self.items) < 2:
         raise LucteriosException(
             IMPORTANT, _("Impossible: you must to select many records!"))
     if 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(self.field_id)
         grid.add_header('value', _('designation'))
         grid.add_header('select', _('is main?'), 'bool')
         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', 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_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
     else:
         self.redirect_action(ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
Example #39
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})
Example #40
0
 def fillresponse(self):
     self.action_list = []
     if self.final_class is not None:
         self.add_action(
             self.final_class.get_action(TITLE_OK, "images/ok.png"))
     model_current = self.getparam('modelname')
     if model_current is None:
         self.model = self.inital_model
     else:
         self.model = apps.get_model(model_current)
     self.field_id = self.model.__name__.lower()
     if self.field_id == 'legalentity':
         self.field_id = 'legal_entity'
     self.item = self.model()
     XferSearchEditor.fillresponse(self)
     self.remove_component('title')
     lbl = XferCompLabelForm('modelname_lbl')
     lbl.set_value_as_title(_('model'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     selected_model = XferCompSelect('modelname')
     selected_model.set_value(model_current)
     selected_model.set_select(self.inital_model.get_select_contact_type())
     selected_model.set_location(2, 0, 3)
     selected_model.set_action(self.request,
                               self.get_action(),
                               modal=FORMTYPE_REFRESH,
                               close=CLOSE_NO)
     self.add_component(selected_model)
     if self.select_class is not None:
         grid = self.get_components(self.field_id)
         grid.add_action(self.request,
                         self.select_class.get_action(
                             _("Select"), "images/ok.png"),
                         close=CLOSE_YES,
                         unique=self.mode_select,
                         params={'pkname': self.field_id},
                         pos_act=0)
Example #41
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
Example #42
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"))
Example #43
0
    def fillresponse(self, show_only_failed=False):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        self.add_component(img)
        begin = XferCompLabelForm('title')
        begin.set_location(1, 0, 2)
        begin.set_value_as_title(_('Transmission report'))
        self.add_component(begin)

        self.filltab_from_model(1, 1, True, [((_('date begin of send'), 'date_begin'), (_('date end of send'), 'date_end')), ('emailsent_set',)])
        if not show_only_failed:
            grid = self.get_components('emailsent')
            grid.delete_header('error')

        check = XferCompCheck('show_only_failed')
        check.set_value(show_only_failed)
        check.description = _('Show only failed')
        check.set_location(1, 3, 2)
        check.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(check)

        show_only_failed
        self.add_action(WrapAction(_('Close'), 'images/close.png'))
Example #44
0
 def fillresponse(self, AdhCmd=0):
     cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(self.model)
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 4)
         dlg.add_component(img)
         lab = XferCompLabelForm('lbl_title')
         lab.set_value_as_title(self.caption)
         lab.set_location(1, 0)
         dlg.add_component(lab)
         row = dlg.get_max_row() + 1
         cmd_item = cmd_manager.get(AdhCmd)
         cmd_item_txt = cmd_manager.get_txt(cmd_item)
         for fname, ftitle in cmd_manager.get_fields():
             lbl = XferCompLabelForm("lbl" + fname)
             lbl.set_value_as_name(ftitle)
             lbl.set_location(1, row)
             dlg.add_component(lbl)
             if fname == "type":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(SubscriptionType.objects.all())
                 sel.set_value(cmd_item[fname])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "team":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(Team.objects.all())
                 sel.set_value(cmd_item[fname][0])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "activity":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(Activity.objects.all())
                 sel.set_value(cmd_item[fname][0])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "reduce":
                 sel = XferCompFloat(fname)
                 sel.set_value(cmd_item[fname])
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             else:
                 lbl = XferCompLabelForm(fname)
                 lbl.set_value(cmd_item_txt[fname])
                 lbl.set_location(2, row)
                 dlg.add_component(lbl)
             row += 1
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         cmd_item = cmd_manager.get(AdhCmd)
         cmd_item['type'] = self.getparam("type", cmd_item['type'])
         cmd_item['team'] = self.getparam("team", cmd_item['team'])
         cmd_item['activity'] = self.getparam("activity", cmd_item['activity'])
         cmd_item['reduce'] = self.getparam("reduce", cmd_item['reduce'])
         cmd_manager.set(AdhCmd, cmd_item)