def testBasicPlugin(self): self._add_plugin('basic') self.assertEqual(self.plugins.count, 1) self.assertEqual(self.plugins[0].name, 'basic') self.assertEqual(self.plugins[0].title, 'basic') self.assertEqual(self.plugins[0].version, '0.0.1') self.assertEqual(Params.getobject("CORE-PluginPermission"), {"basic": []})
def create_account_atomic(self, username, legalentity): defaultgroup = Params.getobject("contacts-defaultgroup") user = LucteriosUser() user.username = username user.first_name = self.item.firstname user.last_name = self.item.lastname user.email = self.item.email user.save() if defaultgroup is not None: user.groups.add(defaultgroup) self.item.address = '---' self.item.postal_code = '---' self.item.city = '---' self.item.user = user self.item.save() if legalentity != '': entity = LegalEntity() entity.name = legalentity entity.address = '---' entity.postal_code = '---' entity.city = '---' entity.email = self.item.email entity.save() Responsability.objects.create(individual=self.item, legal_entity=entity)
def testAdvancePlugin(self): Params.setvalue("CORE-PluginPermission", '{"basic": []}') self._add_plugin('advance', title='Advance tool', version='1.2.3') self.assertEqual(self.plugins.count, 1) self.assertEqual(self.plugins[0].name, 'advance') self.assertEqual(self.plugins[0].title, 'Advance tool') self.assertEqual(self.plugins[0].version, '1.2.3') self.assertEqual(Params.getobject("CORE-PluginPermission"), {"advance": []})
def evaluate(self, text_to_evaluate): from base64 import b64encode value = text_to_evaluate for doc_key, doc_value in self.doc_list.items(): if "#%s" % doc_key in value: image_file = Params.getobject(doc_value) if image_file is None: image_base64 = b'' else: image_base64 = get_binay(BASE64_PREFIX) + b64encode(image_file.content.read()) value = value.replace("#%s" % doc_key, image_base64.decode()) return value
def edit(self, xfer): IndividualEditor.edit(self, xfer) birthday = xfer.get_components('birthday') if birthday is not None: birthday.needed = True if (self.item.id is None) and (xfer.getparam( 'legal_entity', 0) == 0) and (Params.getobject("member-family-type") is not None): genre = xfer.get_components('genre') genre.colspan -= 1 btn = XferCompButton('famillybtn') btn.set_location(genre.col + genre.colspan, genre.row) btn.set_action(xfer.request, ActionsManage.get_action_url( 'member.Adherent', 'familyAdherentAdd', xfer), modal=FORMTYPE_MODAL, close=CLOSE_YES) xfer.add_component(btn)
def test_groupedit(self): group = LucteriosGroup.objects.create(name="plugin") Params.setvalue("CORE-PluginPermission", '{"useraccess": [%d]}' % group.id) self._add_plugin('useraccess', add_view=True) self._add_plugin('view', add_view=True) self._add_plugin('advance', title='Advance tool', version='1.2.3') self.factory.xfer = GroupsEdit() self.calljson('/CORE/groupsEdit', {'group': group.id}, False) self.assert_observer('core.custom', 'CORE', 'groupsEdit') self.assert_count_equal('', 4) self.assert_json_equal('EDIT', "name", 'plugin',) self.assert_json_equal('CHECKLIST', "permissions", []) self.assert_select_equal("plugins", {'advance': 'Advance tool', 'useraccess': 'useraccess', 'view': 'view'}, True) self.assert_json_equal('CHECKLIST', "plugins", ['useraccess']) self.factory.xfer = GroupsEdit() self.calljson('/CORE/groupsEdit', {'SAVE': 'YES', 'group': group.id, 'name': 'plugin', "plugins": 'advance;view'}, False) self.assert_observer('core.acknowledge', 'CORE', 'groupsEdit') self.assertEqual(Params.getobject("CORE-PluginPermission"), {"advance": [group.id], 'useraccess': [], 'view': [group.id]})
def testEmpty(self): self.assertTrue(isdir(self.plugins.plugins_dir())) self.assertTrue(isfile(join(self.plugins.plugins_dir(), '__init__.py'))) self.assertEqual(self.plugins.count, 0) self.assertEqual(list(self.plugins), []) self.assertEqual(Params.getobject("CORE-PluginPermission"), {})
def show(self, xfer): IndividualEditor.show(self, xfer) if xfer.getparam('adherent') is None: xfer.params['adherent'] = xfer.getparam('individual', 0) if xfer.getparam('individual') is None: xfer.params['individual'] = xfer.getparam('adherent', 0) img = xfer.get_components('img') img.set_value(get_icon_path("diacamma.member/images/adherent.png")) if Params.getobject("member-family-type") is not None: xfer.tab = 1 row_init = xfer.get_max_row() + 1 lbl = XferCompLabelForm("family") current_family = self.item.family if current_family is None: lbl.set_value(None) else: lbl.set_value(six.text_type(self.item.family)) lbl.set_location(1, row_init, 2) lbl.description = _('family') xfer.add_component(lbl) btn = XferCompButton('famillybtn') btn.is_mini = True btn.set_location(3, row_init) if current_family is None: act = ActionsManage.get_action_url('member.Adherent', 'FamilyAdd', xfer) act.set_value("", "images/add.png") btn.set_action(xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO) else: act = ActionsManage.get_action_url('contacts.LegalEntity', 'Show', xfer) act.set_value("", "images/edit.png") btn.set_action( xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'legal_entity': six.text_type(current_family.id)}) xfer.add_component(btn) if xfer.item.current_subscription is not None: xfer.tab = 1 row_init = xfer.get_max_row() + 1 row = row_init + 1 for doc in xfer.item.current_subscription.docadherent_set.all(): ckc = XferCompCheck("doc_%d" % doc.id) ckc.set_value(doc.value) ckc.set_location(2, row) ckc.description = six.text_type(doc.document) xfer.add_component(ckc) row += 1 if row != row_init + 1: lbl = XferCompLabelForm("lbl_doc_sep") lbl.set_value("{[hr/]}") lbl.set_location(1, row_init, 4) xfer.add_component(lbl) lbl = XferCompLabelForm("lbl_doc") lbl.set_value_as_name(_('documents needs')) lbl.set_location(1, row_init + 1) xfer.add_component(lbl) btn = XferCompButton("btn_doc") btn.set_location(4, row_init + 1, 1, row - row_init) btn.set_action(xfer.request, ActionsManage.get_action_url( "member.Adherent", "Doc", xfer), close=CLOSE_NO) xfer.add_component(btn)