def test_userdelete(self): add_user("user1") add_user("user2") self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 4) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty') self.assert_json_equal('', 'user_actif/@2/username', 'user1') self.assert_json_equal('', 'user_actif/@3/username', 'user2') self.factory.xfer = UsersDelete() self.calljson('/CORE/usersDelete', {'user_actif': '3;4'}, False) self.assert_observer('core.dialogbox', 'CORE', 'usersDelete') self.assertEqual(len(self.json_context), 1) self.assertEqual(self.json_context['user_actif'], '3;4') self.assert_json_equal('', 'type', '2') self.assert_json_equal('', 'text', 'Voulez-vous supprimer ces 2 utilisateurs?') self.assertEqual(len(self.json_actions), 2) self.assert_action_equal(self.json_actions[0], ('Oui', 'images/ok.png', 'CORE', 'usersDelete', 1, 1, 1)) self.assert_action_equal(self.json_actions[1], ('Non', 'images/cancel.png')) self.factory.xfer = UsersDelete() self.calljson('/CORE/usersDelete', {'user_actif': '3;4', 'CONFIRME': 'YES'}, False) self.assert_observer('core.acknowledge', 'CORE', 'usersDelete') self.assertEqual(len(self.json_context), 1) self.assertEqual(self.json_context['user_actif'], '3;4') self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 2) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty')
def test_userdeldisabled(self): user = add_user("user1") user.is_active = False user.save() self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 2) self.assert_count_equal('user_inactif', 1) self.factory.xfer = UsersDelete() self.calljson('/CORE/usersDelete', {'user_inactif': '3'}, False) self.assert_observer('core.dialogbox', 'CORE', 'usersDelete') self.assert_json_equal('', 'text', "Voulez-vous supprimer cet enregistrement de 'utilisateur'?") self.assertEqual(len(self.json_context), 1) self.assertEqual(self.json_context['user_inactif'], '3') self.factory.xfer = UsersDelete() self.calljson('/CORE/usersDelete', {'user_inactif': '3', "CONFIRME": 'YES'}, False) self.assert_observer('core.acknowledge', 'CORE', 'usersDelete') self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 2) self.assert_count_equal('user_inactif', 0)
def test_userdisabledenabled(self): add_user("user1") self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal("user_actif", 3) self.assert_count_equal("user_inactif", 0) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty') self.assert_json_equal('', 'user_actif/@2/username', 'user1') self.factory.xfer = UsersDisabled() self.calljson('/CORE/usersDisabled', {'user_actif': '3'}, False) self.assert_observer('core.acknowledge', 'CORE', 'usersDisabled') self.assertEqual(self.json_context['user_actif'], '3') self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 2) self.assert_count_equal('user_inactif', 1) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty') self.assert_json_equal('', 'user_inactif/@0/username', 'user1') self.factory.xfer = UsersEnabled() self.calljson('/CORE/usersEnabled', {'user_inactif': '3'}, False) self.assert_observer('core.acknowledge', 'CORE', 'usersEnabled') self.assertEqual(self.json_context['user_inactif'], '3') self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_count_equal('user_actif', 3) self.assert_count_equal('user_inactif', 0) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty') self.assert_json_equal('', 'user_actif/@2/username', 'user1')
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)
def test_auditlog_user(self): LucteriosAuditlogModelRegistry.set_state_packages(['CORE']) self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 0) self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_observer('core.custom', 'CORE', 'usersList') self.assert_count_equal('user_actif', 2) self.assert_count_equal('user_inactif', 0) self.factory.xfer = UsersEdit() self.calljson( '/CORE/usersEdit', { 'SAVE': 'YES', 'username': '******', 'first_name': 'John', 'last_name': 'Doe', 'user_permissions': '1;3;4' }, False) self.assert_observer('core.acknowledge', 'CORE', 'usersEdit') self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 1) self.factory.xfer = UsersDisabled() self.calljson('/CORE/usersDisabled', {'user_actif': '3'}, False) self.assert_observer('core.acknowledge', 'CORE', 'usersDisabled') self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 2) self.factory.xfer = UsersDelete() self.calljson('/CORE/usersDelete', { 'user_actif': '3', "CONFIRME": 'YES' }, False) self.assert_observer('core.acknowledge', 'CORE', 'usersDelete') self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 3) self.assert_json_equal('', 'lucterioslogentry/@0/action', 2) self.assert_json_equal('', 'lucterioslogentry/@0/object_repr', "abc") self.assert_json_equal('', 'lucterioslogentry/@1/action', 1) self.assert_json_equal('', 'lucterioslogentry/@1/object_repr', "abc") self.assert_json_equal('', 'lucterioslogentry/@2/action', 0) self.assert_json_equal('', 'lucterioslogentry/@2/object_repr', "abc")
def test_userlist(self): self.factory.xfer = UsersList() self.calljson('/CORE/usersList', {}, False) self.assert_observer('core.custom', 'CORE', 'usersList') self.assertEqual(self.json_meta['title'], 'Utilisateurs du logiciel') self.assertEqual(len(self.json_context), 0) self.assertEqual(len(self.json_actions), 1) self.assert_action_equal(self.json_actions[0], ('Fermer', 'images/close.png')) self.assert_count_equal('', 4) self.assert_json_equal('IMAGE', "img", '/static/lucterios.CORE/images/user.png') self.assert_coordcomp_equal("img", ('0', '0', '1', '1')) self.assert_json_equal('LABELFORM', "title", 'Utilisateurs du logiciel') self.assert_attrib_equal("title", "formatstr", "{[br/]}{[center]}{[u]}{[b]}%s{[/b]}{[/u]}{[/center]}") self.assert_coordcomp_equal("title", ('1', '0', '1', '1')) self.assert_coordcomp_equal("user_actif", ('0', '1', '2', '1')) self.assert_attrib_equal("user_actif", 'description', 'Liste des utilisateurs actifs') self.assert_coordcomp_equal("user_inactif", ('0', '3', '2', '1')) self.assert_attrib_equal("user_inactif", 'description', 'Liste des utilisateurs inactifs') self.assert_grid_equal('user_actif', {"username": "******", "first_name": "prénom", "last_name": "nom", "last_login": "******"}, 2) self.assert_json_equal('', 'user_actif/@0/username', 'admin') self.assert_json_equal('', 'user_actif/@1/username', 'empty') self.assert_json_equal('', 'user_actif/@0/first_name', 'administrator') self.assert_json_equal('', 'user_actif/@1/first_name', 'empty') self.assert_json_equal('', 'user_actif/@0/last_name', 'ADMIN') self.assert_json_equal('', 'user_actif/@1/last_name', 'NOFULL') self.assert_count_equal('#user_actif/actions', 4) self.assert_action_equal('#user_actif/actions/@0', ('Modifier', 'images/edit.png', 'CORE', 'usersEdit', 0, 1, 0)) self.assert_action_equal('#user_actif/actions/@1', ('Supprimer', 'images/delete.png', 'CORE', 'usersDelete', 0, 1, 2)) self.assert_action_equal('#user_actif/actions/@2', ('Créer', 'images/new.png', 'CORE', 'usersEdit', 0, 1, 1)) self.assert_action_equal('#user_actif/actions/@3', ('Désactiver', 'images/delete.png', 'CORE', 'usersDisabled', 0, 1, 0)) self.assert_grid_equal('user_inactif', {"username": "******", "first_name": "prénom", "last_name": "nom"}, 0) self.assert_count_equal('#user_inactif/actions', 2) self.assert_action_equal('#user_inactif/actions/@0', ('Réactiver', 'images/ok.png', 'CORE', 'usersEnabled', 0, 1, 0)) self.assert_action_equal('#user_inactif/actions/@1', ('Supprimer', 'images/delete.png', 'CORE', 'usersDelete', 0, 1, 2))