コード例 #1
0
ファイル: settings.py プロジェクト: loudubewe/core
def fill_appli_gui(module_to_setup, setting_module):
    setattr(module_to_setup, 'APPLIS_LOGO', readimage_to_base64(setting_module.APPLIS_LOGO_NAME) if 'APPLIS_LOGO_NAME' in dir(setting_module) else b'')
    if not hasattr(module_to_setup, 'APPLIS_STYLE'):
        setattr(module_to_setup, 'APPLIS_STYLE', read_file(setting_module.APPLIS_STYLE_NAME) if 'APPLIS_STYLE_NAME' in dir(setting_module) else b'')
    if not hasattr(module_to_setup, 'APPLIS_BACKGROUND'):
        setattr(module_to_setup, 'APPLIS_BACKGROUND', readimage_to_base64(setting_module.APPLIS_BACKGROUND_NAME) if 'APPLIS_BACKGROUND_NAME' in dir(setting_module) else b'')
    setattr(module_to_setup, 'APPLI_SUPPORT', setting_module.APPLI_SUPPORT if 'APPLI_SUPPORT' in dir(setting_module) else lambda: "")
コード例 #2
0
ファイル: models.py プロジェクト: badenweb/contacts
 def image(self):
     img_path = get_user_path("contacts", "Image_%s.jpg" % self.abstractcontact_ptr_id)
     if exists(img_path):
         img = readimage_to_base64(img_path)
     else:
         img = readimage_to_base64(join(dirname(__file__), "static", 'lucterios.contacts', "images", "NoImage.png"))
     return img.decode('ascii')
コード例 #3
0
ファイル: settings.py プロジェクト: povtux/core
def fill_appli_settings(appli_name, addon_modules=None, module_to_setup=None):
    if module_to_setup is None:
        last_frm = stack()[1]
        module_to_setup = getmodule(last_frm[0])
    setup_path = dirname(module_to_setup.__file__)
    extra_setting = _get_extra(module_to_setup)
    setattr(module_to_setup, "EXTRA", extra_setting)
    logging.getLogger(__name__).debug("Add settings from appli '%s' to %s ", appli_name, module_to_setup.__name__)
    for (key_name, setting_value) in DEFAULT_SETTINGS.items():
        if key_name not in extra_setting.keys():
            setattr(module_to_setup, key_name, setting_value)
    my_log = getattr(module_to_setup, 'LOGGING', {})
    try:
        if my_log['handlers']['file']['filename'] == 'error.log':
            my_log['handlers']['file']['filename'] = join(dirname(setup_path), 'error.log')
    except KeyError:
        pass
    my_database = getattr(module_to_setup, 'DATABASES', {})
    if ('default' in my_database.keys()):
        if 'ATOMIC_REQUESTS' not in my_database['default']:
            my_database['default']['ATOMIC_REQUESTS'] = True
    setattr(module_to_setup, "BASE_DIR", dirname(setup_path))
    if not hasattr(module_to_setup, "MEDIA_ROOT"):
        setattr(module_to_setup, "MEDIA_ROOT", join(setup_path, 'usr'))
    if isinstance(addon_modules, tuple):
        module_to_setup.INSTALLED_APPS = module_to_setup.INSTALLED_APPS + addon_modules
    module_to_setup.INSTALLED_APPS = module_to_setup.INSTALLED_APPS + (appli_name,)
    appli_module = import_module(appli_name)
    setattr(module_to_setup, 'APPLIS_MODULE', appli_module)
    setattr(module_to_setup, 'LOCALE_PATHS', _get_locale_pathes(appli_name, addon_modules))
    setattr(module_to_setup, 'STATIC_ROOT', join(setup_path, 'static'))
    setattr(module_to_setup, 'STATICFILES_DIRS', (setup_path, ))
    setting_module = import_module("%s.appli_settings" % appli_name)
    for item in dir(setting_module):
        if item == item.upper():
            setattr(module_to_setup, item, getattr(setting_module, item))
    if 'APPLIS_LOGO_NAME' in dir(setting_module):
        setattr(module_to_setup, 'APPLIS_LOGO', readimage_to_base64(setting_module.APPLIS_LOGO_NAME))
    else:
        setattr(module_to_setup, 'APPLIS_LOGO', '')
    if 'APPLIS_BACKGROUND_NAME' in dir(setting_module):
        setattr(module_to_setup, 'APPLIS_BACKGROUND', readimage_to_base64(setting_module.APPLIS_BACKGROUND_NAME))
    else:
        setattr(module_to_setup, 'APPLIS_BACKGROUND', '')
    if 'APPLI_SUPPORT' in dir(setting_module):
        setattr(module_to_setup, 'APPLI_SUPPORT', setting_module.APPLI_SUPPORT)
    else:
        setattr(module_to_setup, 'APPLI_SUPPORT', lambda: "")
コード例 #4
0
    def test_logo(self):
        self.assertFalse(exists(get_user_path('contacts', 'Image_1.jpg')))
        logo_path = join(dirname(__file__), "static", 'lucterios.contacts',
                         'images', 'ourDetails.png')
        logo_stream = "image.jpg;" + \
            readimage_to_base64(logo_path, False).decode("utf-8")

        self.factory.xfer = CurrentStructureAddModify()
        self.calljson('/lucterios.contacts/currentStructureAddModify', {
            "SAVE": 'YES',
            "uploadlogo": logo_stream
        }, False)
        self.assert_observer('core.acknowledge', 'lucterios.contacts',
                             'currentStructureAddModify')
        self.assertTrue(exists(get_user_path('contacts', 'Image_1.jpg')))

        self.factory.xfer = CurrentStructure()
        self.calljson('/lucterios.contacts/currentStructure', {}, False)
        self.assert_observer('core.custom', 'lucterios.contacts',
                             'currentStructure')
        self.assert_json_equal('IMAGE', 'logoimg',
                               "data:image/*;base64,/9j/4AAQSkZJRg", True)

        self.factory.xfer = CurrentStructurePrint()
        self.calljson('/lucterios.contacts/currentStructurePrint', {}, False)
        self.assert_observer('core.print', 'lucterios.contacts',
                             'currentStructurePrint')
        pdf_value = b64decode(
            six.text_type(self.response_json['print']['content']))
        self.assertEqual(pdf_value[:4], "%PDF".encode('ascii', 'ignore'))
コード例 #5
0
ファイル: views.py プロジェクト: Lucterios2/contacts
    def add_legalentity(self, legal_entity):
        self.new_tab(_("Legal entity"))
        self.item = legal_entity
        fields = LegalEntity.get_show_fields()
        self.fill_from_model(1, 1, True, fields[_('001@Identity')])
        self.get_components('name').colspan = 2
        self.get_components('structure_type').colspan = 2
        img_path = get_user_path(
            "contacts", "Image_%s.jpg" % legal_entity.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(0, 2, 1, 6)
        self.add_component(img)

        btn = XferCompButton('btn_edit')
        btn.set_is_mini(True)
        btn.set_location(4, 1, 1, 2)
        btn.set_action(self.request, CurrentLegalEntityModify.get_action(
            _('Edit'), "images/edit.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'legal_entity': legal_entity.id})
        self.add_component(btn)
コード例 #6
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)
コード例 #7
0
    def add_legalentity(self, legal_entity):
        self.new_tab(_("Legal entity"))
        self.item = legal_entity
        fields = LegalEntity.get_show_fields()
        self.fill_from_model(1, 1, True, fields[_('001@Identity')])
        self.get_components('name').colspan = 2
        self.get_components('structure_type').colspan = 2
        img_path = get_user_path(
            "contacts", "Image_%s.jpg" % legal_entity.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(0, 2, 1, 6)
        self.add_component(img)

        btn = XferCompButton('btn_edit')
        btn.set_is_mini(True)
        btn.set_location(4, 1, 1, 2)
        btn.set_action(self.request,
                       CurrentLegalEntityModify.get_action(
                           _('Edit'), "images/edit.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_NO,
                       params={'legal_entity': legal_entity.id})
        self.add_component(btn)
コード例 #8
0
ファイル: models.py プロジェクト: mdanielo44/documents
 def get_icon(self):
     if isinstance(self.get_final_child(), FolderContainer):
         icon_name = "folder.png"
     else:
         icon_name = "file.png"
     img = readimage_to_base64(join(dirname(__file__), "static", 'lucterios.documents', "images", icon_name))
     return img.decode('ascii')
コード例 #9
0
ファイル: tests.py プロジェクト: Lucterios2/contacts
    def test_logo(self):
        self.assertFalse(exists(get_user_path('contacts', 'Image_1.jpg')))
        logo_path = join(dirname(__file__), "static", 'lucterios.contacts', 'images', 'ourDetails.png')
        logo_stream = "image.jpg;" + \
            readimage_to_base64(logo_path, False).decode("utf-8")

        self.factory.xfer = CurrentStructureAddModify()
        self.calljson('/lucterios.contacts/currentStructureAddModify',
                      {"SAVE": 'YES', "uploadlogo": logo_stream}, False)
        self.assert_observer('core.acknowledge', 'lucterios.contacts', 'currentStructureAddModify')
        self.assertTrue(exists(get_user_path('contacts', 'Image_1.jpg')))

        self.factory.xfer = CurrentStructure()
        self.calljson('/lucterios.contacts/currentStructure', {}, False)
        self.assert_observer('core.custom', 'lucterios.contacts', 'currentStructure')
        self.assert_json_equal('IMAGE', 'logoimg', "data:image/*;base64,/9j/4AAQSkZJRg", True)

        self.factory.xfer = CurrentStructurePrint()
        self.calljson('/lucterios.contacts/currentStructurePrint', {}, False)
        self.assert_observer('core.print', 'lucterios.contacts', 'currentStructurePrint')
        pdf_value = b64decode(six.text_type(self.response_json['print']['content']))
        self.assertEqual(pdf_value[:4], "%PDF".encode('ascii', 'ignore'))
コード例 #10
0
ファイル: editors.py プロジェクト: Lucterios2/contacts
 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
ファイル: views_report.py プロジェクト: julienM77/syndic
 def current_image(self, icon_path=None):
     img_path = get_user_path("contacts", "Image_1.jpg")
     if exists(img_path):
         return readimage_to_base64(img_path)
     else:
         return self.icon_path(icon_path)
コード例 #12
0
ファイル: settings.py プロジェクト: mdanielo44/core
def fill_appli_settings(appli_name, addon_modules=None, module_to_setup=None):
    if module_to_setup is None:
        last_frm = stack()[1]
        module_to_setup = getmodule(last_frm[0])
    setup_path = dirname(module_to_setup.__file__)
    extra_setting = _get_extra(module_to_setup)
    setattr(module_to_setup, "EXTRA", extra_setting)
    setattr(module_to_setup, "SETUP", module_to_setup)
    logging.getLogger(__name__).debug("Add settings from appli '%s' to %s ",
                                      appli_name, module_to_setup.__name__)
    for (key_name, setting_value) in DEFAULT_SETTINGS.items():
        if key_name not in extra_setting.keys():
            setattr(module_to_setup, key_name, setting_value)
    my_log = getattr(module_to_setup, 'LOGGING', {})
    try:
        if my_log['handlers']['file']['filename'] == 'error.log':
            my_log['handlers']['file']['filename'] = join(
                dirname(setup_path), 'error.log')
    except KeyError:
        pass
    try:
        my_template = getattr(module_to_setup, 'TEMPLATES', [])
        dir_list = []
        for addon_module in addon_modules:
            module = import_module(addon_module)
            dir_list.append(dirname(module.__file__))
        my_template[0]['DIRS'].extend(dir_list)
    except KeyError:
        pass
    my_database = getattr(module_to_setup, 'DATABASES', {})
    if ('default' in my_database.keys()):
        if 'ATOMIC_REQUESTS' not in my_database['default']:
            my_database['default']['ATOMIC_REQUESTS'] = True
    setattr(module_to_setup, "BASE_DIR", dirname(setup_path))
    if not hasattr(module_to_setup, "MEDIA_ROOT"):
        setattr(module_to_setup, "MEDIA_ROOT", join(setup_path, 'usr'))
    if isinstance(addon_modules, tuple):
        module_to_setup.INSTALLED_APPS = module_to_setup.INSTALLED_APPS + addon_modules
    module_to_setup.INSTALLED_APPS = module_to_setup.INSTALLED_APPS + (
        appli_name, )
    appli_module = import_module(appli_name)
    setattr(module_to_setup, 'APPLIS_MODULE', appli_module)
    setattr(module_to_setup, 'LOCALE_PATHS',
            _get_locale_pathes(appli_name, addon_modules))
    setattr(module_to_setup, 'STATIC_ROOT', join(setup_path, 'static'))
    setattr(module_to_setup, 'STATICFILES_DIRS', (setup_path, ))
    setting_module = import_module("%s.appli_settings" % appli_name)
    for item in dir(setting_module):
        if item == item.upper():
            setattr(module_to_setup, item, getattr(setting_module, item))
    if 'APPLIS_LOGO_NAME' in dir(setting_module):
        setattr(module_to_setup, 'APPLIS_LOGO',
                readimage_to_base64(setting_module.APPLIS_LOGO_NAME))
    else:
        setattr(module_to_setup, 'APPLIS_LOGO', b'')
    if not hasattr(module_to_setup, 'APPLIS_STYLE'):
        if 'APPLIS_STYLE_NAME' in dir(setting_module):
            setattr(module_to_setup, 'APPLIS_STYLE',
                    read_file(setting_module.APPLIS_STYLE_NAME))
        else:
            setattr(module_to_setup, 'APPLIS_STYLE', b'')
    if not hasattr(module_to_setup, 'APPLIS_BACKGROUND'):
        if 'APPLIS_BACKGROUND_NAME' in dir(setting_module):
            setattr(module_to_setup, 'APPLIS_BACKGROUND',
                    readimage_to_base64(setting_module.APPLIS_BACKGROUND_NAME))
        else:
            setattr(module_to_setup, 'APPLIS_BACKGROUND', b'')
    if 'APPLI_SUPPORT' in dir(setting_module):
        setattr(module_to_setup, 'APPLI_SUPPORT', setting_module.APPLI_SUPPORT)
    else:
        setattr(module_to_setup, 'APPLI_SUPPORT', lambda: "")