示例#1
0
 def show(self, xfer):
     LucteriosEditor.show(self, xfer)
     obj_addr = xfer.get_components('address')
     xfer.tab = obj_addr.tab
     new_col = obj_addr.col
     xfer.move(obj_addr.tab, 1, 0)
     img_path = get_user_path(
         "contacts", "Image_%s.jpg" % self.item.abstractcontact_ptr_id)
     img = XferCompImage('logoimg')
     if exists(img_path):
         img.type = 'jpg'
         img.set_value(readimage_to_base64(img_path))
     else:
         img.set_value(
             get_icon_path("lucterios.contacts/images/NoImage.png"))
     img.set_location(new_col, obj_addr.row, 1, 6)
     xfer.add_component(img)
     if WrapAction.is_permission(xfer.request,
                                 'contacts.add_abstractcontact'):
         if (len(self.item.__class__.get_select_contact_type(False)) > 0):
             btn = XferCompButton('btn_promote')
             btn.set_location(new_col + 1, xfer.get_max_row() + 1, 4)
             btn.set_action(xfer.request,
                            ObjectPromote.get_action(
                                _('Promote'), "images/config.png"),
                            modal=FORMTYPE_MODAL,
                            close=CLOSE_YES,
                            params={
                                'modelname': xfer.model.get_long_name(),
                                'field_id': xfer.field_id
                            })
             xfer.add_component(btn)
     signal_and_lock.Signal.call_signal("show_contact", self.item, xfer)
示例#2
0
 def saving(self, xfer):
     uploadlogo = xfer.getparam('uploadlogo')
     if uploadlogo is not None:
         tmp_file = save_from_base64(uploadlogo)
         with open(tmp_file, "rb") as image_tmp:
             image = open_image_resize(image_tmp, 100, 100)
             image = image.convert("RGB")
             img_path = get_user_path("contacts", "Image_%s.jpg" % self.item.abstractcontact_ptr_id)
             with open(img_path, "wb") as image_file:
                 image.save(image_file, 'JPEG', quality=90)
         unlink(tmp_file)
     LucteriosEditor.saving(self, xfer)
     self.item.set_custom_values(xfer.params)
示例#3
0
 def saving(self, xfer):
     uploadlogo = xfer.getparam('uploadlogo')
     if uploadlogo is not None:
         tmp_file = save_from_base64(uploadlogo)
         with open(tmp_file, "rb") as image_tmp:
             image = open_image_resize(image_tmp, 100, 100)
             image = image.convert("RGB")
             img_path = get_user_path("contacts", "Image_%s.jpg" % self.item.abstractcontact_ptr_id)
             with open(img_path, "wb") as image_file:
                 image.save(image_file, 'JPEG', quality=90)
         unlink(tmp_file)
     LucteriosEditor.saving(self, xfer)
     self.item.set_custom_values(xfer.params)
示例#4
0
 def saving(self, xfer):
     args = {}
     for arg_name in ['min', 'max', 'prec', 'list', 'multi']:
         args_val = xfer.getparam('args_' + arg_name)
         if args_val is not None:
             if arg_name == 'list':
                 args[arg_name] = list(args_val.split(","))
             elif arg_name == 'multi':
                 args[arg_name] = (args_val != 'False') and (args_val != '0') and (args_val != '') and (args_val != 'n')
             else:
                 args[arg_name] = float(args_val)
     self.item.args = six.text_type(args)
     LucteriosEditor.saving(self, xfer)
     self.item.save()
示例#5
0
 def saving(self, xfer):
     args = {}
     for arg_name in ['min', 'max', 'prec', 'list', 'multi']:
         args_val = xfer.getparam('args_' + arg_name)
         if args_val is not None:
             if arg_name == 'list':
                 args[arg_name] = list(args_val.split(","))
             elif arg_name == 'multi':
                 args[arg_name] = (args_val != 'False') and (args_val != '0') and (args_val != '') and (args_val != 'n')
             else:
                 args[arg_name] = float(args_val)
     self.item.args = six.text_type(args)
     LucteriosEditor.saving(self, xfer)
     self.item.save()
示例#6
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)
示例#7
0
文件: models.py 项目: mayjo79/core
 def editor(self):
     try:
         root_module_name = ".".join(self.__module__.split('.')[:-1])
         module_editor = import_module(root_module_name + ".editors")
         class_name = self.__class__.__name__ + "Editor"
         class_editor = getattr(module_editor, class_name)
         return class_editor(self)
     except (ImportError, AttributeError):
         return LucteriosEditor(self)
示例#8
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)
示例#9
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)
示例#10
0
 def show(self, xfer):
     LucteriosEditor.show(self, xfer)
     obj_addr = xfer.get_components('address')
     xfer.tab = obj_addr.tab
     new_col = obj_addr.col
     xfer.move(obj_addr.tab, 1, 0)
     img_path = get_user_path("contacts", "Image_%s.jpg" % self.item.abstractcontact_ptr_id)
     img = XferCompImage('logoimg')
     if exists(img_path):
         img.type = 'jpg'
         img.set_value(readimage_to_base64(img_path))
     else:
         img.set_value(get_icon_path("lucterios.contacts/images/NoImage.png"))
     img.set_location(new_col, obj_addr.row, 1, 6)
     xfer.add_component(img)
     if WrapAction.is_permission(xfer.request, 'contacts.add_abstractcontact'):
         if (len(self.item.__class__.get_select_contact_type(False)) > 0):
             btn = XferCompButton('btn_promote')
             btn.set_location(new_col + 1, xfer.get_max_row() + 1, 4)
             btn.set_action(xfer.request, ObjectPromote.get_action(_('Promote'), "images/config.png"), modal=FORMTYPE_MODAL,
                            close=CLOSE_YES, params={'modelname': xfer.model.get_long_name(), 'field_id': xfer.field_id})
             xfer.add_component(btn)
     signal_and_lock.Signal.call_signal("show_contact", self.item, xfer)
示例#11
0
    def edit(self, xfer):
        if self.item.id is not None:
            xfer.change_to_readonly('username')
            obj_username = xfer.get_components('username')
            xfer.filltab_from_model(obj_username.col - 1, obj_username.row + 1,
                                    True, ['date_joined', 'last_login'])
        xfer.change_to_readonly('is_active')
        obj_email = xfer.get_components('email')
        xfer.tab = obj_email.tab
        new_row = obj_email.row
        ckk = XferCompCheck('password_change')
        ckk.set_location(0, new_row + 1, 1, 1)
        ckk.set_value(True)
        ckk.description = _("To change password?")
        ckk.java_script = """
var pwd_change=current.getValue();
parent.get('password1').setEnabled(pwd_change);
parent.get('password2').setEnabled(pwd_change);
"""
        xfer.add_component(ckk)

        pwd1 = XferCompPassword('password1')
        pwd1.set_location(0, new_row + 2, 1, 1)
        pwd1.empty = 1
        pwd1.description = _("password")
        xfer.add_component(pwd1)
        pwd2 = XferCompPassword('password2')
        pwd2.set_location(0, new_row + 3, 1, 1)
        pwd2.empty = 1
        pwd2.description = _("password (again)")
        xfer.add_component(pwd2)
        if Signal.call_signal("send_connection", None, None, None) > 0:
            ckkg = XferCompCheck('password_generate')
            ckkg.set_location(0, new_row + 4)
            ckkg.description = _("Generate new password?")
            ckkg.set_value(False)
            ckkg.java_script = """
    var pwd_change=current.getValue();
    parent.get('password_change').setEnabled(!pwd_change);
    parent.get('password1').setEnabled(!pwd_change);
    parent.get('password2').setEnabled(!pwd_change);
    """
            xfer.add_component(ckkg)
        if xfer.getparam("IDENT_READ") is not None:
            xfer.change_to_readonly('first_name')
            xfer.change_to_readonly('last_name')
            xfer.change_to_readonly('email')
        return LucteriosEditor.edit(self, xfer)
示例#12
0
    def edit(self, xfer):
        if self.item.id is not None:
            xfer.change_to_readonly('username')
            obj_username = xfer.get_components('username')
            xfer.filltab_from_model(obj_username.col - 1, obj_username.row + 1, True, ['date_joined', 'last_login'])
        xfer.change_to_readonly('is_active')
        obj_email = xfer.get_components('email')
        xfer.tab = obj_email.tab
        new_row = obj_email.row
        ckk = XferCompCheck('password_change')
        ckk.set_location(0, new_row + 1, 1, 1)
        ckk.set_value(True)
        ckk.description = _("To change password?")
        ckk.java_script = """
var pwd_change=current.getValue();
parent.get('password1').setEnabled(pwd_change);
parent.get('password2').setEnabled(pwd_change);
"""
        xfer.add_component(ckk)

        pwd1 = XferCompPassword('password1')
        pwd1.set_location(0, new_row + 2, 1, 1)
        pwd1.empty = 1
        pwd1.description = _("password")
        xfer.add_component(pwd1)
        pwd2 = XferCompPassword('password2')
        pwd2.set_location(0, new_row + 3, 1, 1)
        pwd2.empty = 1
        pwd2.description = _("password (again)")
        xfer.add_component(pwd2)
        if Signal.call_signal("send_connection", None, None, None) > 0:
            ckkg = XferCompCheck('password_generate')
            ckkg.set_location(0, new_row + 4)
            ckkg.description = _("Generate new password?")
            ckkg.set_value(False)
            ckkg.java_script = """
    var pwd_change=current.getValue();
    parent.get('password_change').setEnabled(!pwd_change);
    parent.get('password1').setEnabled(!pwd_change);
    parent.get('password2').setEnabled(!pwd_change);
    """
            xfer.add_component(ckkg)
        if xfer.getparam("IDENT_READ") is not None:
            xfer.change_to_readonly('first_name')
            xfer.change_to_readonly('last_name')
            xfer.change_to_readonly('email')
        return LucteriosEditor.edit(self, xfer)
示例#13
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)
示例#14
0
 def edit(self, xfer):
     obj_body = xfer.get_components('body')
     obj_body.with_hypertext = True
     obj_body.set_size(500, 600)
     return LucteriosEditor.edit(self, xfer)
示例#15
0
 def edit(self, xfer):
     obj_body = xfer.get_components('body')
     obj_body.with_hypertext = True
     obj_body.set_size(500, 600)
     return LucteriosEditor.edit(self, xfer)
示例#16
0
 def __init__(self, model):
     LucteriosEditor.__init__(self, model)
     self.added = False
示例#17
0
 def before_save(self, xfer):
     self.item.is_revenu = self.item.get_final_child().payoff_is_revenu()
     return LucteriosEditor.before_save(self, xfer)