Beispiel #1
0
    def fillresponse(self, payer="", reference=""):
        self.fill_header(payer, reference)

        grid = XferCompGrid('entry')
        grid.define_page(self)
        grid.add_header('bill', _('bill'))
        grid.add_header('payer', _('payer'), horderable=1)
        grid.add_header('amount', _('amount'), horderable=1)
        grid.add_header('date', _('date'), horderable=1)
        grid.add_header('reference', _('reference'), horderable=1)
        payoff_nodeposit = DepositDetail.get_payoff_not_deposit(
            payer, reference, grid.order_list)
        for payoff in payoff_nodeposit:
            payoffid = payoff['id']
            grid.set_value(payoffid, 'bill', payoff['bill'])
            grid.set_value(payoffid, 'payer', payoff['payer'])
            grid.set_value(payoffid, 'amount', payoff['amount'])
            grid.set_value(payoffid, 'date', payoff['date'])
            grid.set_value(payoffid, 'reference', payoff['reference'])
        grid.set_location(0, 2, 4)

        grid.add_action(self.request, DepositDetailSave.get_action(_("select"), "images/ok.png"), close=CLOSE_YES, unique=SELECT_MULTI)
        self.add_component(grid)

        self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Beispiel #2
0
 def add_legalentities(self, legal_entities):
     self.new_tab(_("Legal entities"))
     grid = XferCompGrid('legal_entity')
     grid.set_model(legal_entities, LegalEntity.get_default_fields())
     grid.add_action(self.request, CurrentLegalEntityShow.get_action(
         _("Edit"), "images/show.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.set_location(1, 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
Beispiel #3
0
 def add_legalentities(self, legal_entities):
     self.new_tab(_("Legal entities"))
     grid = XferCompGrid('legal_entity')
     grid.set_model(legal_entities, LegalEntity.get_default_fields())
     grid.add_action(self.request,
                     CurrentLegalEntityShow.get_action(
                         _("Edit"), "images/show.png"),
                     modal=FORMTYPE_MODAL,
                     close=CLOSE_NO,
                     unique=SELECT_SINGLE)
     grid.set_location(1, 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
Beispiel #4
0
def thirdaddon_invoice(item, xfer):
    if WrapAction.is_permission(xfer.request, 'invoice.change_bill'):
        try:
            FiscalYear.get_current()
            xfer.new_tab(_('Invoice'))
            current_filter, status_filter = _add_bill_filter(xfer, 1)
            current_filter &= Q(third=item)
            bills = Bill.objects.filter(current_filter)
            bill_grid = XferCompGrid('bill')
            bill_grid.set_model(bills, Bill.get_default_fields(status_filter), xfer)
            bill_grid.set_location(0, 2, 2)
            bill_grid.add_action(xfer.request, ActionsManage.get_action_url('invoice.Bill', 'Show', xfer), modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            xfer.add_component(bill_grid)
        except LucteriosException:
            pass
Beispiel #5
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)
Beispiel #6
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [
             Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(
         *identfilter)
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
Beispiel #7
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(*identfilter).distinct()
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
Beispiel #8
0
def thirdaddon_accounting(item, xfer):
    if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'):
        try:
            entry_lines_filter = Q(entrylineaccount__third=item)
            lines_filter = xfer.getparam('lines_filter', 0)
            if lines_filter == 0:
                entry_lines_filter &= Q(year=FiscalYear.get_current())
            elif lines_filter == 1:
                entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False)
            xfer.new_tab(_('entry of account'))
            lbl = XferCompLabelForm('lbl_lines_filter')
            lbl.set_value_as_name(_('Accounts filter'))
            lbl.set_location(0, 1)
            xfer.add_component(lbl)
            edt = XferCompSelect("lines_filter")
            edt.set_select([(0, _('All entries of current fiscal year')), (1, _(
                'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))])
            edt.set_value(lines_filter)
            edt.set_location(1, 1)
            edt.set_action(xfer.request, xfer.get_action(),
                           modal=FORMTYPE_REFRESH, close=CLOSE_NO)
            xfer.add_component(edt)
            entries = EntryAccount.objects.filter(entry_lines_filter)
            link_grid_lines = XferCompGrid('entryaccount')
            link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer)
            link_grid_lines.set_location(0, 2, 2)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            xfer.add_component(link_grid_lines)
        except LucteriosException:
            pass
Beispiel #9
0
 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}})
Beispiel #10
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})
Beispiel #11
0
 def show(self, xfer):
     self._add_cost_savebtn(xfer)
     last_row = xfer.get_max_row() + 10
     lbl = XferCompLabelForm('sep3')
     lbl.set_location(0, last_row + 1, 6)
     lbl.set_value_center("{[hr/]}")
     xfer.add_component(lbl)
     xfer.filltab_from_model(1, last_row + 2, True, ['entrylineaccount_set'])
     grid_lines = xfer.get_components('entrylineaccount')
     grid_lines.actions = []
     if self.item.has_third:
         sum_customer = get_amount_sum(self.item.entrylineaccount_set.filter(
             account__code__regex=current_system_account().get_third_mask()).aggregate(Sum('amount')))
         if ((sum_customer < 0) and not self.item.has_cash) or ((sum_customer > 0) and self.item.has_cash):
             lbl = XferCompLabelForm('asset_warning')
             lbl.set_location(0, last_row + 3, 6)
             lbl.set_value_as_header(_("entry of accounting for an asset"))
             xfer.add_component(lbl)
     if self.item.link is not None:
         linkentries = EntryAccount.objects.filter(link=self.item.link).exclude(id=self.item.id)
         if len(linkentries) == 0:
             self.item.unlink()
         else:
             lbl = XferCompLabelForm('sep4')
             lbl.set_location(0, last_row + 4, 6)
             lbl.set_value_center("{[hr/]}")
             xfer.add_component(lbl)
             lbl = XferCompLabelForm('entrylinklab')
             lbl.set_location(1, last_row + 5, 5)
             lbl.set_value_center(_("Linked entries"))
             xfer.add_component(lbl)
             link_grid_lines = XferCompGrid('entryaccount_link')
             link_grid_lines.set_model(linkentries, fieldnames=None, xfer_custom=xfer)
             link_grid_lines.set_location(1, last_row + 6, 5)
             link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url(
                 'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_YES, params={'field_id': 'entryaccount_link', 'journal': ''})
             xfer.add_component(link_grid_lines)
     if self.added:
         xfer.add_action(xfer.get_action(TITLE_MODIFY, "images/ok.png"), params={"SAVE": "YES"})
Beispiel #12
0
    def show(self, xfer):
        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        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:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('documents')
        xfer.remove_component('documents')
        new_documents = XferCompGrid('document')
        new_documents.tab = old_documents.tab
        new_documents.set_location(old_documents.col, old_documents.row,
                                   old_documents.colspan)
        new_documents.set_model(self.item.documents.all(),
                                ["name", "description", "date_modification"],
                                xfer)
        new_documents.add_action(xfer.request,
                                 DocumentShow.get_action(
                                     TITLE_EDIT, "images/show.png"),
                                 modal=FORMTYPE_MODAL,
                                 close=CLOSE_NO,
                                 unique=SELECT_SINGLE)
        if self.item.status == 0:
            new_documents.add_action(xfer.request,
                                     MessageRemoveDoc.get_action(
                                         _("Remove"), "images/delete.png"),
                                     modal=FORMTYPE_MODAL,
                                     close=CLOSE_NO,
                                     unique=SELECT_MULTI)
            new_documents.add_action(xfer.request,
                                     MessageInsertDoc.get_action(
                                         _("Insert"), "images/add.png"),
                                     modal=FORMTYPE_MODAL,
                                     close=CLOSE_NO,
                                     unique=SELECT_NONE)
        xfer.tab = new_documents.tab
        xfer.add_component(new_documents)

        return LucteriosEditor.show(self, xfer)
Beispiel #13
0
    def show(self, xfer):
        obj_body = xfer.get_components('body')
        obj_body.value = "{[div style='border:1px solid black;background-color:#EEE;padding:5px;']}%s{[div]}" % obj_body.value

        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        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:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('attachments')
        xfer.remove_component('attachments')
        if xfer.item.is_dynamic:
            xfer.remove_component('__tab_3')
            xfer.remove_component('doc_in_link')
            xfer.remove_component('empty')
        else:
            new_documents = XferCompGrid('attachments')
            new_documents.tab = old_documents.tab
            new_documents.set_location(old_documents.col, old_documents.row, old_documents.colspan)
            new_documents.set_model(self.item.attachments.all(), ["name", "description", "date_modification"], xfer)
            new_documents.add_action(xfer.request, DocumentShow.get_action(TITLE_EDIT, "images/show.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
            if self.item.status == 0:
                new_documents.add_action(xfer.request, MessageRemoveDoc.get_action(_("Remove"), "images/delete.png"),
                                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_MULTI)
                new_documents.add_action(xfer.request, MessageInsertDoc.get_action(_("Insert"), "images/add.png"),
                                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_NONE)
            xfer.tab = new_documents.tab
            xfer.add_component(new_documents)
        contact_nb = xfer.get_components('contact_nb')
        if (contact_nb is not None) and (self.item.nb_total > 0):
            xfer.tab = contact_nb.tab
            xfer.fill_from_model(contact_nb.col, contact_nb.row + 1, True, [((_('statistic'), 'statistic'),)])
        return LucteriosEditor.show(self, xfer)
Beispiel #14
0
 def show(self, xfer):
     row = xfer.get_max_row() + 1
     lbl = XferCompLabelForm('lbl_entrylineaccount')
     lbl.set_location(1, row)
     lbl.set_value_as_name(EntryLineAccount._meta.verbose_name)
     xfer.add_component(lbl)
     comp = XferCompGrid('entryaccount')
     comp.set_model(EntryAccount.objects.filter(entrylineaccount__account=self.item), None, xfer)
     comp.add_action(xfer.request, ActionsManage.get_action_url(
         'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_NO)
     comp.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer), unique=SELECT_MULTI, close=CLOSE_NO)
     if self.item.is_third:
         comp.add_action(xfer.request, ActionsManage.get_action_url(
             'accounting.EntryAccount', 'Link', xfer), unique=SELECT_MULTI, close=CLOSE_NO)
     comp.set_location(2, row)
     xfer.add_component(comp)
Beispiel #15
0
    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'), {})
Beispiel #16
0
    def show(self, xfer):
        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        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:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('documents')
        xfer.remove_component('documents')
        new_documents = XferCompGrid('document')
        new_documents.tab = old_documents.tab
        new_documents.set_location(old_documents.col, old_documents.row, old_documents.colspan)
        new_documents.set_model(self.item.documents.all(), ["name", "description", "date_modification"], xfer)
        new_documents.add_action(xfer.request, DocumentShow.get_action(TITLE_EDIT, "images/show.png"),
                                 modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
        if self.item.status == 0:
            new_documents.add_action(xfer.request, MessageRemoveDoc.get_action(_("Remove"), "images/delete.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_MULTI)
            new_documents.add_action(xfer.request, MessageInsertDoc.get_action(_("Insert"), "images/add.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_NONE)
        xfer.tab = new_documents.tab
        xfer.add_component(new_documents)

        return LucteriosEditor.show(self, xfer)