예제 #1
0
def summary_contacts(xfer):
    if not hasattr(xfer, 'add_component'):
        return WrapAction.is_permission(xfer, 'contacts.change_abstractcontact')
    else:
        if WrapAction.is_permission(xfer.request, 'contacts.change_abstractcontact'):
            row = xfer.get_max_row() + 1
            lab = XferCompLabelForm('contactstitle')
            lab.set_value_as_infocenter(_("Addresses and contacts"))
            lab.set_location(0, row, 4)
            xfer.add_component(lab)
            nb_legal_entities = len(LegalEntity.objects.all())
            lbl_doc = XferCompLabelForm('lbl_nblegalentities')
            lbl_doc.set_location(0, row + 1, 4)
            lbl_doc.set_value_center(_("Total number of legal entities: %d") % nb_legal_entities)
            xfer.add_component(lbl_doc)
            nb_individual = len(Individual.objects.all())
            lbl_doc = XferCompLabelForm('lbl_nbindividuals')
            lbl_doc.set_location(0, row + 2, 4)
            lbl_doc.set_value_center(_("Total number of individuals: %d") % nb_individual)
            xfer.add_component(lbl_doc)
            lab = XferCompLabelForm('contactsend')
            lab.set_value_center('{[hr/]}')
            lab.set_location(0, row + 3, 4)
            xfer.add_component(lab)
            return True
        else:
            return False
예제 #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()
예제 #3
0
def summary_documents(xfer):
    if WrapAction.is_permission(xfer.request, 'documents.change_document'):
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('documenttitle')
        lab.set_value_as_infocenter(_('Document management'))
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
        filter_result = Q()
        if notfree_mode_connect():
            filter_result = filter_result & (Q(folder=None) | Q(
                folder__viewer__in=xfer.request.user.groups.all()))
        nb_doc = len(Document.objects.filter(*[filter_result]))
        lbl_doc = XferCompLabelForm('lbl_nbdocument')
        lbl_doc.set_location(0, row + 1, 4)
        if nb_doc == 0:
            lbl_doc.set_value_center(_("no file currently available"))
        elif nb_doc == 1:
            lbl_doc.set_value_center(_("one file currently available"))
        else:
            lbl_doc.set_value_center(
                _("%d files currently available") % nb_doc)
        xfer.add_component(lbl_doc)
        lab = XferCompLabelForm('documentend')
        lab.set_value_center('{[hr/]}')
        lab.set_location(0, row + 2, 4)
        xfer.add_component(lab)
        return True
    else:
        return False
예제 #4
0
def summary_dummy(xfer):
    if not hasattr(xfer, 'add_component'):
        return True
    else:
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('dummytitle')
        lab.set_value_as_infocenter("Dummy")
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
        lbl = XferCompLabelForm('dummy_time')
        lbl.set_color('blue')
        lbl.set_location(0, row + 1, 4)
        lbl.set_centered()
        lbl.set_value(datetime.now())
        lbl.set_format('H')
        xfer.add_component(lbl)

        btn = XferCompButton('btnscheduler')
        btn.set_action(xfer.request, AddSchedulerTask.get_action('Task', ''))
        btn.set_location(0, row + 2, 4)
        xfer.add_component(btn)
        lbl = XferCompLabelForm('dummy-value')
        lbl.set_location(0, row + 3, 4)
        lbl.set_value(Params.getvalue('dummy-value'))
        xfer.add_component(lbl)
        return True
예제 #5
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'))
예제 #6
0
def conf_wizard_document(wizard_ident, xfer):
    if isinstance(wizard_ident, list) and (xfer is None):
        wizard_ident.append(("document_params", 55))
    elif (xfer is not None) and (wizard_ident == "document_params"):
        xfer.add_title(_("Lucterios documents"), _("Parameters"))
        lbl = XferCompLabelForm("nb_folder")
        lbl.set_location(1, xfer.get_max_row() + 1)
        lbl.set_value(
            TEXT_TOTAL_NUMBER % {
                'name': Folder._meta.verbose_name_plural,
                'count': len(Folder.objects.all())
            })
        xfer.add_component(lbl)
        lbl = XferCompLabelForm("nb_doc")
        lbl.set_location(1, xfer.get_max_row() + 1)
        lbl.set_value(
            TEXT_TOTAL_NUMBER % {
                'name': Document._meta.verbose_name_plural,
                'count': len(Document.objects.all())
            })
        xfer.add_component(lbl)
        btn = XferCompButton("btnconf")
        btn.set_location(4, xfer.get_max_row() - 1, 1, 2)
        btn.set_action(xfer.request,
                       FolderList.get_action(TITLE_MODIFY, "images/edit.png"),
                       close=CLOSE_NO)
        xfer.add_component(btn)
예제 #7
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'))
예제 #8
0
    def fillresponse_show_criteria(self):
        criteria_text_list = self.get_text_search()
        label = XferCompLabelForm('labelsearchDescTitle')
        if len(criteria_text_list) > 0:
            label.set_value_as_info("Your criteria of search")
            label.set_location(0, 17, 2, 4)
        else:
            label.set_value_as_infocenter("No criteria of search")
            label.set_location(0, 17, 4)
        self.add_component(label)

        row = 17
        for criteria_id, criteria_text in criteria_text_list.items():
            label = XferCompLabelForm('labelSearchText_' + criteria_id)
            label.set_value(criteria_text)
            label.set_location(2, row, 2)
            self.add_component(label)
            comp = XferCompButton("searchButtonDel_" + criteria_id)
            comp.set_is_mini(True)
            comp.set_location(4, row)
            comp.set_action(self.request,
                            self.get_action("", "images/delete.png"),
                            modal=FORMTYPE_REFRESH,
                            close=CLOSE_NO,
                            params={'ACT': criteria_id})
            self.add_component(comp)
            row += 1
예제 #9
0
 def show(self, xfer):
     xfer.move_components('lbl_body', 0, 2)
     xfer.move_components('body', 0, 2)
     obj_recipients = xfer.get_components('recipients')
     new_recipients = XferCompGrid('recipient_list')
     new_recipients.set_location(obj_recipients.col, obj_recipients.row, obj_recipients.colspan)
     new_recipients.add_header("model", _('model'))
     new_recipients.add_header("filter", _('filter'))
     compid = 0
     for model_title, filter_desc in self.item.recipients_description:
         new_recipients.set_value(compid, "model", model_title)
         new_recipients.set_value(compid, "filter", filter_desc)
         compid += 1
     if compid > 0:
         nb_contact = len(self.item.get_contacts())
         contact_nb = XferCompLabelForm('contact_nb')
         contact_nb.set_location(obj_recipients.col, obj_recipients.row + 1, obj_recipients.colspan)
         contact_nb.set_value(_("Message defined for %d contacts") % nb_contact)
         xfer.add_component(contact_nb)
     lbl = XferCompLabelForm('sep_body')
     lbl.set_location(obj_recipients.col - 1, obj_recipients.row + 2, 4)
     lbl.set_value("{[hr/]}")
     xfer.add_component(lbl)
     xfer.remove_component('recipients')
     new_recipients.add_action_notified(xfer, 'recipient_list')
     xfer.add_component(new_recipients)
     return LucteriosEditor.show(self, xfer)
예제 #10
0
    def add_document(self):
        old_item = self.item
        self.model = DocumentContainer
        self.item = DocumentContainer()
        last_row = self.get_max_row() + 5
        lbl = XferCompLabelForm('sep1')
        lbl.set_location(0, last_row, 6)
        lbl.set_value("{[center]}{[hr/]}{[/center]}")
        self.add_component(lbl)
        lbl = XferCompLabelForm('sep2')
        lbl.set_location(0, last_row + 1, 2)
        lbl.set_value_as_infocenter(_("Add document"))
        self.add_component(lbl)

        self.fill_from_model(0, last_row + 3, False)
        self.remove_component('parent')

        btn_doc = XferCompButton('adddoc')
        btn_doc.set_location(1, last_row + 4)
        btn_doc.set_action(self.request,
                           DocumentAddModify.get_action(
                               TITLE_ADD, 'images/add.png'),
                           params={
                               'parent': self.current_folder,
                               'SAVE': 'YES'
                           },
                           close=CLOSE_NO)
        self.add_component(btn_doc)

        self.model = AbstractContainer
        self.item = old_item
예제 #11
0
파일: views.py 프로젝트: julienM77/syndic
def finalizeyear_condo(xfer):
    year = FiscalYear.get_current(xfer.getparam('year'))
    if year is not None:
        ventilate = xfer.getparam("ventilate", 0)
        if xfer.observer_name == "core.custom":
            if year.check_to_close() > 0:
                raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!"))
            result = year.total_revenue - year.total_expense
            if abs(result) > 0.001:
                row = xfer.get_max_row() + 1
                lbl = XferCompLabelForm('title_condo')
                lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5))
                lbl.set_location(0, row, 2)
                xfer.add_component(lbl)
                lbl = XferCompLabelForm('question_condo')
                lbl.set_value(_('Where do you want to ventilate this amount?'))
                lbl.set_location(0, row + 1)
                xfer.add_component(lbl)
                sel_cmpt = [('0', _("For each owner"))]
                for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'):
                    sel_cmpt.append((account.id, six.text_type(account)))
                sel = XferCompSelect("ventilate")
                sel.set_select(sel_cmpt)
                sel.set_value(ventilate)
                sel.set_location(1, row + 1)
                xfer.add_component(sel)
        elif xfer.observer_name == "core.acknowledge":
            for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0):
                if ventilate == 0:
                    current_system_condo().ventilate_costaccounting(set_cost.set, set_cost.cost_accounting, 1, Params.getvalue("condominium-current-revenue-account"))
                set_cost.cost_accounting.close()
            current_system_condo().ventilate_result(year, ventilate)
예제 #12
0
def conf_wizard_core(wizard_ident, xfer):
    if isinstance(wizard_ident, list) and (xfer is None):
        wizard_ident.append(("core_home", 0))
        wizard_ident.append(("core_users", 100))
    elif (xfer is not None) and (wizard_ident == "core_home"):
        initial_wizard = Params.getvalue("CORE-Wizard")
        param_wizard = xfer.getparam("CORE-Wizard", initial_wizard)
        if initial_wizard != param_wizard:
            Parameter.change_value("CORE-Wizard", param_wizard)
            Params.clear()
        lbl = XferCompLabelForm('title')
        lbl.set_centered()
        lbl.set_value_as_info(six.text_type(settings.APPLIS_NAME))
        lbl.set_location(0, 3, 6)
        xfer.add_component(lbl)
        lbl = XferCompImage('img')
        lbl.type = 'jpg'
        lbl.set_value(settings.APPLIS_LOGO)
        lbl.set_location(2, 4, 2)
        xfer.add_component(lbl)
        lbl = XferCompLabelForm('home')
        lbl.set_value(_('This wizard will help you to configure this software.'))
        lbl.set_location(0, 5, 6)
        xfer.add_component(lbl)
        Params.fill(xfer, ['CORE-Wizard'], 1, 6, False)
        check = xfer.get_components("CORE-Wizard")
        check.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        lbl = XferCompLabelForm('lbl_wizard')
        lbl.set_value_as_name(check.description)
        lbl.set_location(2, 6)
        xfer.add_component(lbl)
        check.description = ""
    elif (xfer is not None) and (wizard_ident == "core_users"):
        xfer.add_title(six.text_type(settings.APPLIS_NAME), _("Groups and users"))
        param_lists = ['CORE-connectmode', 'CORE-Wizard']
        Params.fill(xfer, param_lists, 1, xfer.get_max_row() + 1)
        btn = XferCompButton('editparam')
        btn.set_location(4, xfer.get_max_row())
        btn.set_is_mini(True)
        btn.set_action(xfer.request, ParamEdit.get_action(TITLE_MODIFY, 'images/edit.png'), close=CLOSE_NO,
                       params={'params': param_lists})
        xfer.add_component(btn)
        lbl = XferCompLabelForm("nb_user")
        lbl.set_location(1, xfer.get_max_row() + 1)
        lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosUser._meta.verbose_name_plural, 'count': len(LucteriosUser.objects.all())})
        xfer.add_component(lbl)
        btn = XferCompButton("btnusers")
        btn.set_location(4, xfer.get_max_row())
        btn.set_action(xfer.request, UsersList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO)
        xfer.add_component(btn)
        lbl = XferCompLabelForm("nb_group")
        lbl.set_location(1, xfer.get_max_row() + 1)
        lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosGroup._meta.verbose_name_plural, 'count': len(LucteriosGroup.objects.all())})
        xfer.add_component(lbl)
        btn = XferCompButton("btngroups")
        btn.set_location(4, xfer.get_max_row())
        btn.set_action(xfer.request, GroupsList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO)
        xfer.add_component(btn)
예제 #13
0
파일: views.py 프로젝트: loudubewe/syndic
 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"))
예제 #14
0
파일: views.py 프로젝트: htwalid/syndic
def summary_condo(xfer):
    if not hasattr(xfer, 'add_component'):
        return WrapAction.is_permission(xfer, 'condominium.change_set')
    else:
        if WrapAction.is_permission(xfer.request, 'condominium.change_set'):
            row = xfer.get_max_row() + 1
            lab = XferCompLabelForm('condotitle')
            lab.set_value_as_infocenter(_('Condominium'))
            lab.set_location(0, row, 4)
            xfer.add_component(lab)
            nb_set = len(Set.objects.filter(is_active=True))
            nb_owner = len(Owner.objects.all())
            lab = XferCompLabelForm('condoinfo')
            lab.set_value_as_header(
                _("There are %(set)d classes of loads for %(owner)d owners") %
                {
                    'set': nb_set,
                    'owner': nb_owner
                })
            lab.set_location(0, row + 1, 4)
            xfer.add_component(lab)
            if Params.getvalue("condominium-old-accounting"):
                lab = XferCompLabelForm('condoconvinfo')
                lab.set_value_as_header(
                    _("Your condominium account is not in respect of French law{[newline]}An conversion is necessary."
                      ))
                lab.set_color('red')
                lab.set_location(0, row + 2, 4)
                xfer.add_component(lab)
                btn = XferCompButton('condoconv')
                btn.set_location(0, row + 3, 4)
                btn.set_action(xfer.request,
                               CondominiumConvert.get_action(
                                   _('Convertion ...'), ""),
                               close=CLOSE_NO)
                xfer.add_component(btn)
            if hasattr(settings, "DIACAMMA_MAXOWNER"):
                lbl = XferCompLabelForm("limit_owner")
                lbl.set_value(
                    _('limitation: %d owners allowed') %
                    getattr(settings, "DIACAMMA_MAXOWNER"))
                lbl.set_italic()
                lbl.set_location(0, row + 4, 4)
                xfer.add_component(lbl)
            row = xfer.get_max_row() + 1
            lab = XferCompLabelForm('condosep')
            lab.set_value_as_infocenter("{[hr/]}")
            lab.set_location(0, row, 4)
            xfer.add_component(lab)
            return True
        else:
            return False
예제 #15
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:
            self._add_option_selectors(gui)
        gui.add_action(self.return_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
예제 #16
0
    def create_dlg(self, username, legalentity):
        dlg = self.create_custom(self.model)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        dlg.add_component(img)
        dlg.fill_from_model(1, 0, False,
                            ['genre', 'lastname', 'firstname', 'email'])
        dlg.get_components(
            'email'
        ).mask = '^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$'
        row = dlg.get_max_row() + 1
        lbl = XferCompLabelForm("username_lbl")
        lbl.set_location(1, row)
        lbl.set_value_as_name(_('username'))
        dlg.add_component(lbl)
        edt = XferCompEdit("username")
        edt.set_location(2, row)
        edt.set_needed(True)
        edt.set_value(username)
        dlg.add_component(edt)
        if Params.getvalue("contacts-createaccount") == 2:
            row = dlg.get_max_row() + 1
            lbl = XferCompLabelForm("legalentity_lbl")
            lbl.set_location(1, row)
            lbl.set_value_as_name(_("your structure name"))
            dlg.add_component(lbl)
            edt = XferCompEdit("legalentity")
            edt.set_location(2, row)
            edt.set_needed(True)
            edt.set_value(legalentity)
            dlg.add_component(edt)
        row = dlg.get_max_row() + 1
        lbl = XferCompLabelForm("captcha_lbl")
        lbl.set_location(1, row)
        lbl.set_value_as_name(_("captcha"))
        dlg.add_component(lbl)
        edt = XferCompCaptcha("captcha")
        edt.set_location(2, row)
        dlg.add_component(edt)

        lbl = XferCompLabelForm("error_lbl")
        lbl.set_location(2, row + 1)
        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'))
예제 #17
0
    def _get_from_custom(self, request, *args, **kwargs):
        dlg = XferContainerCustom()
        dlg.request = self.request
        dlg.is_view_right = self.is_view_right
        dlg.caption = self.caption
        dlg.extension = self.extension
        dlg.action = self.action
        img_title = XferCompImage('img_title')
        img_title.set_location(0, 0, 1, 2)
        img_title.set_value(self.traitment_data[0])
        dlg.add_component(img_title)

        lbl = XferCompLabelForm("info")
        lbl.set_location(1, 0)
        dlg.add_component(lbl)
        if self.getparam("RELOAD") is not None:
            lbl.set_value(six.text_type(self.traitment_data[2]))
            dlg.add_action(WrapAction(_("Close"), "images/close.png"))
        else:
            lbl.set_value_center("{[br/]}" +
                                 six.text_type(self.traitment_data[1]))
            btn = XferCompButton("Next")
            btn.set_location(1, 1)
            btn.set_size(50, 300)
            btn.set_action(self.request,
                           self.return_action(_('Traitment...'), ""),
                           params={"RELOAD": "YES"})
            btn.java_script = "parent.refresh()"
            dlg.params["RELOAD"] = "YES"
            dlg.add_component(btn)
            dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
        return dlg.get_post(request, *args, **kwargs)
예제 #18
0
 def get_read_comp(self):
     param_cmp = XferCompLabelForm(self.name)
     if self.type == 5:  # password
         param_cmp.set_value(''.ljust(len(self.value), '*'))
     else:
         param_cmp.set_value(self.get_read_text())
     return param_cmp
예제 #19
0
 def fillresponse(self):
     if not will_mail_send():
         raise LucteriosException(IMPORTANT, _('Bad email parameter!'))
     legal = LegalEntity.objects.get(id=1)
     if self.getparam('CONFIRME') is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         dlg.add_component(img)
         lbl = XferCompLabelForm('lbl_title')
         lbl.set_location(1, 0, 2)
         lbl.set_value_as_header(self.caption)
         dlg.add_component(lbl)
         email = XferCompEdit('recipient')
         email.set_location(1, 1)
         email.set_value(legal.email)
         email.mask = r"[^@]+@[^@]+\.[^@]+"
         email.description = _("email")
         dlg.add_component(email)
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         address = []
         address.append("")
         address.append("")
         address.append(six.text_type(legal))
         address.append(legal.address)
         address.append("%s %s" % (legal.postal_code, legal.city))
         message = _('EMail sent to check configuration')
         message += "{[br/]}".join(address).replace('{[newline]}', "{[br/]}").replace("\n", '{[br/]}')
         bad_sended = send_email(self.getparam('recipient'), _("EMail try"), "<html><body>%s</body></html>" % message.replace('{[', '<').replace(']}', '>'))
         if len(bad_sended) != 0:
             raise EmailException(bad_sended)
         self.message(_("EMail send, check it."))
예제 #20
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'))
예제 #21
0
 def add_title(self, title, subtitle, helptext=''):
     lbl = XferCompLabelForm('title')
     lbl.set_centered()
     lbl.set_value_as_info(title)
     lbl.set_location(0, 3, 6)
     self.add_component(lbl)
     lbl = XferCompLabelForm('subtitle')
     lbl.set_centered()
     lbl.set_value_as_name(subtitle)
     lbl.set_location(0, 4, 6)
     self.add_component(lbl)
     lbl = XferCompLabelForm('help')
     lbl.set_italic()
     lbl.set_value(helptext + "{[br/]}")
     lbl.set_location(0, 5, 6)
     self.add_component(lbl)
예제 #22
0
 def fillresponse(self, model='', objid=0):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.model = apps.get_model(model)
     if objid != 0:
         self.item = self.model.objects.get(id=objid)
         fieldnames = []
         for fieldname in self.model.get_default_fields():
             if isinstance(fieldname, tuple):
                 fieldnames.append(fieldname[1])
             else:
                 fieldnames.append(fieldname)
         self.fill_from_model(1, 0, True, desc_fields=fieldnames)
         log_items = LucteriosLogEntry.objects.get_for_object(self.item)
     else:
         content_type = ContentType.objects.get_for_model(self.model)
         lbl = XferCompLabelForm('ModelName')
         lbl.set_value_as_header(six.text_type(content_type))
         lbl.description = _("content type")
         lbl.set_location(1, 0, 2)
         self.add_component(lbl)
         log_items = LucteriosLogEntry.objects.get_for_model(self.model)
     grid = XferCompGrid(self.field_id)
     grid.set_model(log_items, None, self)
     grid.set_location(1, self.get_max_row() + 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
예제 #23
0
 def fillresponse(self):
     legal = LegalEntity.objects.get(id=1)
     if self.getparam('CONFIRME') is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 3)
         dlg.add_component(img)
         lbl = XferCompLabelForm('lbl_title')
         lbl.set_location(1, 0, 2)
         lbl.set_value_as_header(self.caption)
         dlg.add_component(lbl)
         email = XferCompEdit('recipient')
         email.set_location(1, 1)
         email.set_value(legal.email)
         email.mask = r"[^@]+@[^@]+\.[^@]+"
         email.description = _("email")
         dlg.add_component(email)
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                        close=CLOSE_YES,
                        params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         abs_url = self.request.META.get(
             'HTTP_REFERER', self.request.build_absolute_uri()).split('/')
         self.item.http_root_address = '/'.join(abs_url[:-2])
         send_email([self.getparam('recipient')],
                    self.item.subject,
                    self.item.email_content,
                    files=self.item.attach_files)
         self.message(_("EMail send, check it."))
예제 #24
0
 def fillresponse_header(self):
     modelname = self.getparam('modelname', "")
     lab = XferCompLabelForm('lblmodelname')
     lab.set_location(0, 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_list = list(model_list.items())
     model_list.sort(key=lambda item: item[1])
     model_sel = XferCompSelect('modelname')
     model_sel.set_location(1, 1)
     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)
     self.filter = Q(modelname=modelname)
     self.fieldnames = ['name', 'kind', 'is_default']
     return
예제 #25
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'))
예제 #26
0
파일: editors.py 프로젝트: mdanielo44/asso
 def _add_season_comp(self, xfer, row):
     season = self.item.season
     if self.item.subscriptiontype.duration == 0:  # annually
         lbl = XferCompLabelForm("seasondates")
         lbl.set_location(1, row)
         lbl.set_value(
             "%s => %s" %
             (formats.date_format(season.begin_date, "SHORT_DATE_FORMAT"),
              formats.date_format(season.end_date, "SHORT_DATE_FORMAT")))
         lbl.description = _('annually')
         xfer.add_component(lbl)
     elif self.item.subscriptiontype.duration == 1:  # periodic
         sel = XferCompSelect('period')
         sel.set_needed(True)
         sel.set_select_query(season.period_set.all())
         sel.set_location(1, row)
         sel.description = _('period')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 2:  # monthly
         sel = XferCompSelect('month')
         sel.set_needed(True)
         sel.set_select(season.get_months())
         sel.set_location(1, row)
         sel.description = _('month')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         begindate = XferCompDate('begin_date')
         begindate.set_needed(True)
         begindate.set_value(season.date_ref)
         begindate.set_location(1, row)
         begindate.description = _('begin date')
         xfer.add_component(begindate)
예제 #27
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()
예제 #28
0
    def fill_header(self):
        self.item = FiscalYear.get_current(self.getparam("year"))
        new_begin = convert_date(self.getparam("begin"), self.item.begin)
        new_end = convert_date(self.getparam("end"), self.item.end)
        if (new_begin >= self.item.begin) and (new_end <= self.item.end):
            self.item.begin = new_begin
            self.item.end = new_end
        img = XferCompImage('img')
        img.set_value(self.current_image())
        if not img.value.startswith('/static/'):
            img.type = 'jpg'
        img.set_location(0, 0, 1, 5)
        self.add_component(img)

        if self.item.last_fiscalyear is not None:
            lbl = XferCompLabelForm('year_1')
            lbl.set_location(1, 0, 3)
            lbl.description = _('year N-1')
            lbl.set_value(six.text_type(self.item.last_fiscalyear))
            self.add_component(lbl)
        select_year = XferCompSelect(self.field_id)
        select_year.set_location(1, 1, 3)
        select_year.set_select_query(FiscalYear.objects.all())
        select_year.description = _('year N')
        select_year.set_value(self.item.id)
        select_year.set_needed(True)
        select_year.set_action(self.request,
                               self.__class__.get_action(),
                               close=CLOSE_NO,
                               modal=FORMTYPE_REFRESH)
        self.add_component(select_year)
        self.filter = Q(entry__year=self.item)
        self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
예제 #29
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'))
예제 #30
0
def conf_wizard_condominium(wizard_ident, xfer):
    if isinstance(wizard_ident, list) and (xfer is None):
        wizard_ident.append(("condominium_params", 35))
        wizard_ident.append(("condominium_owner", 45))
        wizard_ident.append(("condominium_lot", 46))
        wizard_ident.append(("condominium_classload", 47))
    elif (xfer is not None) and (wizard_ident == "condominium_params"):
        xfer.add_title(_("Diacamma condominium"),
                       _("Condominium configuration"))
        fill_params(xfer, True)
    elif (xfer is not None) and (wizard_ident == "condominium_owner"):
        xfer.add_title(_("Diacamma condominium"), _("Owners"),
                       _('Add owners of your condominium.'))
        xfer.fill_grid(xfer.get_max_row(), Owner, 'owner', Owner.objects.all())
    elif (xfer is not None) and (wizard_ident == "condominium_lot"):
        xfer.add_title(_("Diacamma condominium"), _("Property lots"),
                       _('Define the lots for each owners.'))
        xfer.fill_grid(xfer.get_max_row(), PropertyLot, 'propertylot',
                       PropertyLot.objects.all())
        lbl = XferCompLabelForm("total_lot")
        lbl.set_location(0, xfer.get_max_row() + 1)
        lbl.set_value(
            _("Total of lot parts: %d") % PropertyLot.get_total_part())
        xfer.add_component(lbl)
    elif (xfer is not None) and (wizard_ident == "condominium_classload"):
        xfer.add_title(_("Diacamma condominium"), _("Class loads"),
                       _('Define the class loads of your condominium.'))
        xfer.fill_grid(xfer.get_max_row(), Set, 'set', Set.objects.all())