diff --git a/CHANGES.rst b/CHANGES.rst index b7179017..3f5a575a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_. +Added +***** + +- Organization field. :pr:`116` + Changed ******* diff --git a/canaille/account.py b/canaille/account.py index a1c5f107..812f58de 100644 --- a/canaille/account.py +++ b/canaille/account.py @@ -442,6 +442,7 @@ def profile_edition(user, username): "departmentNumber", "labeledURI", "preferredLanguage", + "o", } data = { k: getattr(user, k)[0] diff --git a/canaille/conf/config.sample.toml b/canaille/conf/config.sample.toml index 6a9d685f..a02100d4 100644 --- a/canaille/conf/config.sample.toml +++ b/canaille/conf/config.sample.toml @@ -149,6 +149,7 @@ WRITE = [ "employeeNumber", "departmentNumber", "title", + "o", ] [ACL.ADMIN] diff --git a/canaille/forms.py b/canaille/forms.py index 68193659..74054b19 100644 --- a/canaille/forms.py +++ b/canaille/forms.py @@ -241,6 +241,12 @@ PROFILE_FORM_FIELDS = dict( "placeholder": _("1234"), }, ), + o=wtforms.StringField( + _("Organization"), + render_kw={ + "placeholder": _("Cogip LTD."), + }, + ), labeledURI=wtforms.URLField( _("Website"), render_kw={ diff --git a/canaille/templates/profile_add.html b/canaille/templates/profile_add.html index e074bd06..c94daf00 100644 --- a/canaille/templates/profile_add.html +++ b/canaille/templates/profile_add.html @@ -105,10 +105,6 @@ {% if "jpegPhoto" in form %}{% endif %} - {% if "title" in form %} - {% block title_field scoped %}{{ render_field(form.title) }}{% endblock %} - {% endif %} - {% if "mail" in form %} {% block mail_field scoped %}{{ render_field(form.mail) }}{% endblock %} {% endif %} @@ -139,21 +135,29 @@ {% endif %} - {% if "departmentNumber" in form and "employeeNumber" in form %} -
- {% endif %} +
- {% if "departmentNumber" in form %} - {% block department_number_field scoped %}{{ render_field(form.departmentNumber) }}{% endblock %} - {% endif %} + {% if "departmentNumber" in form %} + {% block department_number_field scoped %}{{ render_field(form.departmentNumber) }}{% endblock %} + {% endif %} - {% if "employeeNumber" in form %} - {% block employee_number_field scoped %}{{ render_field(form.employeeNumber) }}{% endblock %} - {% endif %} + {% if "employeeNumber" in form %} + {% block employee_number_field scoped %}{{ render_field(form.employeeNumber) }}{% endblock %} + {% endif %} - {% if "departmentNumber" in form and "employeeNumber" in form %} -
- {% endif %} +
+ +
+ + {% if "title" in form %} + {% block title_field scoped %}{{ render_field(form.title) }}{% endblock %} + {% endif %} + + {% if "o" in form %} + {% block organization_field scoped %}{{ render_field(form.o) }}{% endblock %} + {% endif %} + +
{% if "labeledURI" in form %} {% block labeled_uri_field scoped %}{{ render_field(form.labeledURI) }}{% endblock %} diff --git a/canaille/templates/profile_edit.html b/canaille/templates/profile_edit.html index 43f04f3c..f91e0362 100644 --- a/canaille/templates/profile_edit.html +++ b/canaille/templates/profile_edit.html @@ -162,11 +162,18 @@ {% if "employeeNumber" in form %} {% block employee_number_field scoped %}{{ render_field(form.employeeNumber) }}{% endblock %} {% endif %} + + +
{% if "title" in form %} {% block title_field scoped %}{{ render_field(form.title) }}{% endblock %} {% endif %} + {% if "o" in form %} + {% block organization_field scoped %}{{ render_field(form.o) }}{% endblock %} + {% endif %} +
{% if "labeledURI" in form %} diff --git a/canaille/translations/messages.pot b/canaille/translations/messages.pot index 6a2b332b..7091be71 100644 --- a/canaille/translations/messages.pot +++ b/canaille/translations/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-03-16 19:17+0100\n" +"POT-Creation-Date: 2023-03-17 17:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,7 +42,7 @@ msgid "" "should receive it within a few minutes." msgstr "" -#: canaille/account.py:179 canaille/account.py:523 +#: canaille/account.py:179 canaille/account.py:524 msgid "Could not send the password initialization email" msgstr "" @@ -62,7 +62,7 @@ msgstr "" msgid "You are already logged in, you cannot create an account." msgstr "" -#: canaille/account.py:309 canaille/forms.py:255 canaille/forms.py:335 +#: canaille/account.py:309 canaille/forms.py:261 canaille/forms.py:341 #: canaille/templates/groups.html:5 canaille/templates/groups.html:25 #: canaille/templates/partial/users.html:18 #: canaille/themes/default/base.html:61 @@ -81,61 +81,61 @@ msgstr "" msgid "User account creation succeed." msgstr "" -#: canaille/account.py:459 canaille/account.py:575 +#: canaille/account.py:460 canaille/account.py:576 msgid "Profile edition failed." msgstr "" -#: canaille/account.py:485 canaille/account.py:590 +#: canaille/account.py:486 canaille/account.py:591 msgid "Profile updated successfuly." msgstr "" -#: canaille/account.py:517 +#: canaille/account.py:518 msgid "" "A password initialization link has been sent at the user email address. " "It should be received within a few minutes." msgstr "" -#: canaille/account.py:534 +#: canaille/account.py:535 msgid "" "A password reset link has been sent at the user email address. It should " "be received within a few minutes." msgstr "" -#: canaille/account.py:540 +#: canaille/account.py:541 msgid "Could not send the password reset email" msgstr "" -#: canaille/account.py:612 +#: canaille/account.py:613 #, python-format msgid "The user %(user)s has been sucessfuly deleted" msgstr "" -#: canaille/account.py:642 +#: canaille/account.py:643 msgid "Could not send the password reset link." msgstr "" -#: canaille/account.py:646 +#: canaille/account.py:647 msgid "" "A password reset link has been sent at your email address. You should " "receive it within a few minutes." msgstr "" -#: canaille/account.py:657 +#: canaille/account.py:658 #, python-format msgid "" "The user '%(user)s' does not have permissions to update their password. " "We cannot send a password reset email." msgstr "" -#: canaille/account.py:672 +#: canaille/account.py:673 msgid "We encountered an issue while we sent the password recovery email." msgstr "" -#: canaille/account.py:691 +#: canaille/account.py:692 msgid "The password reset link that brought you here was invalid." msgstr "" -#: canaille/account.py:700 +#: canaille/account.py:701 msgid "Your password has been updated successfuly" msgstr "" @@ -144,7 +144,7 @@ msgid "Email" msgstr "" #: canaille/admin.py:29 canaille/forms.py:75 canaille/forms.py:99 -#: canaille/forms.py:176 canaille/forms.py:329 +#: canaille/forms.py:176 canaille/forms.py:335 msgid "jane@doe.com" msgstr "" @@ -172,7 +172,7 @@ msgstr "" msgid "John Doe" msgstr "" -#: canaille/apputils.py:34 canaille/forms.py:136 canaille/forms.py:317 +#: canaille/apputils.py:34 canaille/forms.py:136 canaille/forms.py:323 msgid "jdoe" msgstr "" @@ -229,11 +229,11 @@ msgstr "" msgid "Automatic" msgstr "" -#: canaille/forms.py:135 canaille/forms.py:316 +#: canaille/forms.py:135 canaille/forms.py:322 msgid "Username" msgstr "" -#: canaille/forms.py:139 canaille/forms.py:288 canaille/forms.py:302 +#: canaille/forms.py:139 canaille/forms.py:294 canaille/forms.py:308 #: canaille/oidc/forms.py:17 canaille/templates/partial/groups.html:6 #: canaille/templates/partial/oidc/admin/client_list.html:6 #: canaille/templates/partial/users.html:12 @@ -272,7 +272,7 @@ msgstr "" msgid "Johnny" msgstr "" -#: canaille/forms.py:170 canaille/forms.py:322 +#: canaille/forms.py:170 canaille/forms.py:328 msgid "Email address" msgstr "" @@ -330,7 +330,7 @@ msgstr "" msgid "Photo" msgstr "" -#: canaille/forms.py:219 canaille/templates/profile_add.html:126 +#: canaille/forms.py:219 canaille/templates/profile_add.html:72 #: canaille/templates/profile_edit.html:90 msgid "Delete the photo" msgstr "" @@ -348,31 +348,39 @@ msgid "Department number" msgstr "" #: canaille/forms.py:245 -msgid "Website" +msgid "Organization" msgstr "" #: canaille/forms.py:247 -msgid "https://mywebsite.tld" +msgid "Cogip LTD." msgstr "" #: canaille/forms.py:251 -msgid "Preferred language" +msgid "Website" +msgstr "" + +#: canaille/forms.py:253 +msgid "https://mywebsite.tld" msgstr "" #: canaille/forms.py:257 +msgid "Preferred language" +msgstr "" + +#: canaille/forms.py:263 msgid "users, admins …" msgstr "" -#: canaille/forms.py:291 +#: canaille/forms.py:297 msgid "group" msgstr "" -#: canaille/forms.py:295 canaille/forms.py:309 +#: canaille/forms.py:301 canaille/forms.py:315 #: canaille/templates/partial/groups.html:7 msgid "Description" msgstr "" -#: canaille/forms.py:320 +#: canaille/forms.py:326 msgid "Username editable by the invitee" msgstr "" @@ -678,13 +686,13 @@ msgid "Group edition" msgstr "" #: canaille/templates/group.html:22 canaille/templates/groups.html:12 -#: canaille/templates/invite.html:16 canaille/templates/profile_add.html:24 +#: canaille/templates/invite.html:16 canaille/templates/profile_add.html:17 #: canaille/templates/users.html:16 msgid "View" msgstr "" #: canaille/templates/group.html:26 canaille/templates/groups.html:16 -#: canaille/templates/invite.html:20 canaille/templates/profile_add.html:28 +#: canaille/templates/invite.html:20 canaille/templates/profile_add.html:21 #: canaille/templates/users.html:20 msgid "Add" msgstr "" @@ -702,16 +710,14 @@ msgstr "" #: canaille/templates/group.html:44 #: canaille/templates/oidc/admin/client_edit.html:47 #: canaille/templates/oidc/admin/token_view.html:50 -#: canaille/templates/profile_add.html:72 -#: canaille/templates/profile_settings.html:64 +#: canaille/templates/profile_settings.html:60 msgid "Cancel" msgstr "" #: canaille/templates/group.html:45 #: canaille/templates/oidc/admin/client_edit.html:48 #: canaille/templates/oidc/admin/token_view.html:51 -#: canaille/templates/profile_add.html:73 -#: canaille/templates/profile_settings.html:65 +#: canaille/templates/profile_settings.html:61 msgid "Delete" msgstr "" @@ -738,9 +744,9 @@ msgstr "" msgid "Create group" msgstr "" -#: canaille/templates/group.html:96 canaille/templates/profile_add.html:332 -#: canaille/templates/profile_edit.html:183 -#: canaille/templates/profile_settings.html:188 +#: canaille/templates/group.html:96 canaille/templates/profile_add.html:220 +#: canaille/templates/profile_edit.html:190 +#: canaille/templates/profile_settings.html:160 msgid "Submit" msgstr "" @@ -749,12 +755,10 @@ msgid "Group members" msgstr "" #: canaille/templates/invite.html:5 canaille/templates/invite.html:99 -#: canaille/templates/profile_add.html:327 -#: canaille/templates/profile_settings.html:183 msgid "Invite a user" msgstr "" -#: canaille/templates/invite.html:24 canaille/templates/profile_add.html:33 +#: canaille/templates/invite.html:24 canaille/templates/profile_add.html:26 #: canaille/templates/users.html:25 msgid "Invite" msgstr "" @@ -860,199 +864,169 @@ msgstr "" msgid "Sign in" msgstr "" -#: canaille/templates/profile_add.html:6 canaille/templates/profile_add.html:82 +#: canaille/templates/profile_add.html:5 canaille/templates/profile_add.html:40 #: canaille/templates/profile_edit.html:6 -#: canaille/templates/profile_settings.html:6 msgid "User creation" msgstr "" -#: canaille/templates/profile_add.html:8 canaille/templates/profile_add.html:84 -#: canaille/templates/profile_edit.html:8 -#: canaille/templates/profile_edit.html:52 -#: canaille/templates/profile_settings.html:8 -msgid "My profile" -msgstr "" - -#: canaille/templates/profile_add.html:10 -#: canaille/templates/profile_add.html:86 -#: canaille/templates/profile_edit.html:10 -#: canaille/templates/profile_edit.html:54 -#: canaille/templates/profile_settings.html:10 -msgid "User profile edition" -msgstr "" - -#: canaille/templates/profile_add.html:49 -#: canaille/templates/profile_edit.html:41 -#: canaille/templates/profile_settings.html:41 -msgid "This user cannot edit this field" -msgstr "" - -#: canaille/templates/profile_add.html:51 -#: canaille/templates/profile_edit.html:43 -#: canaille/templates/profile_settings.html:43 -msgid "This user cannot see this field" -msgstr "" - -#: canaille/templates/profile_add.html:60 -#: canaille/templates/profile_settings.html:52 -msgid "Account deletion" -msgstr "" - -#: canaille/templates/profile_add.html:65 -#: canaille/templates/profile_settings.html:57 -msgid "" -"Are you sure you want to delete this user? This action is unrevokable and" -" all the data about this user will be removed." -msgstr "" - -#: canaille/templates/profile_add.html:67 -#: canaille/templates/profile_settings.html:59 -msgid "" -"Are you sure you want to delete your account? This action is unrevokable " -"and all your data will be removed forever." -msgstr "" - -#: canaille/templates/profile_add.html:92 +#: canaille/templates/profile_add.html:44 msgid "Create a new user account" msgstr "" -#: canaille/templates/profile_add.html:94 -#: canaille/templates/profile_edit.html:60 -msgid "Edit your personal information" -msgstr "" - -#: canaille/templates/profile_add.html:96 -#: canaille/templates/profile_edit.html:62 -msgid "Edit information about a user" -msgstr "" - -#: canaille/templates/profile_add.html:111 +#: canaille/templates/profile_add.html:58 #: canaille/templates/profile_edit.html:23 -#: canaille/templates/profile_settings.html:23 +#: canaille/templates/profile_settings.html:21 msgid "Personal information" msgstr "" -#: canaille/templates/profile_add.html:123 -#: canaille/templates/profile_add.html:134 +#: canaille/templates/profile_add.html:69 +#: canaille/templates/profile_add.html:80 #: canaille/templates/profile_edit.html:87 #: canaille/templates/profile_edit.html:98 msgid "Click to upload a photo" msgstr "" -#: canaille/templates/profile_add.html:221 +#: canaille/templates/profile_add.html:171 #: canaille/templates/profile_edit.html:27 -#: canaille/templates/profile_settings.html:27 -#: canaille/templates/profile_settings.html:73 +#: canaille/templates/profile_settings.html:25 +#: canaille/templates/profile_settings.html:69 msgid "Account information" msgstr "" -#: canaille/templates/profile_add.html:246 -#: canaille/templates/profile_settings.html:110 +#: canaille/templates/profile_add.html:195 msgid "User password is not mandatory" msgstr "" -#: canaille/templates/profile_add.html:249 -#: canaille/templates/profile_settings.html:113 +#: canaille/templates/profile_add.html:198 msgid "The user password can be set:" msgstr "" -#: canaille/templates/profile_add.html:251 -#: canaille/templates/profile_settings.html:115 +#: canaille/templates/profile_add.html:200 msgid "by filling this form;" msgstr "" -#: canaille/templates/profile_add.html:252 -#: canaille/templates/profile_settings.html:116 +#: canaille/templates/profile_add.html:201 msgid "" "by sending the user a password initialization mail, after the account " "creation;" msgstr "" -#: canaille/templates/profile_add.html:253 -#: canaille/templates/profile_add.html:282 -#: canaille/templates/profile_settings.html:117 -#: canaille/templates/profile_settings.html:140 +#: canaille/templates/profile_add.html:202 +#: canaille/templates/profile_settings.html:118 msgid "" "or simply waiting for the user to sign-in a first time, and then receive " "a password initialization mail." msgstr "" -#: canaille/templates/profile_add.html:258 +#: canaille/templates/profile_add.html:207 msgid "" "The user will not be able to authenticate unless the password is set, but" " they will be able to ask for a password initialization mail." msgstr "" -#: canaille/templates/profile_add.html:260 -#: canaille/templates/profile_add.html:286 +#: canaille/templates/profile_add.html:209 msgid "The user will not be able to authenticate unless the password is set." msgstr "" -#: canaille/templates/profile_add.html:271 -#: canaille/templates/profile_settings.html:129 +#: canaille/templates/profile_edit.html:8 +#: canaille/templates/profile_edit.html:52 +#: canaille/templates/profile_settings.html:6 +msgid "My profile" +msgstr "" + +#: canaille/templates/profile_edit.html:10 +#: canaille/templates/profile_edit.html:54 +#: canaille/templates/profile_settings.html:8 +msgid "User profile edition" +msgstr "" + +#: canaille/templates/profile_edit.html:41 +#: canaille/templates/profile_settings.html:37 +msgid "This user cannot edit this field" +msgstr "" + +#: canaille/templates/profile_edit.html:43 +#: canaille/templates/profile_settings.html:39 +msgid "This user cannot see this field" +msgstr "" + +#: canaille/templates/profile_edit.html:60 +msgid "Edit your personal information" +msgstr "" + +#: canaille/templates/profile_edit.html:62 +msgid "Edit information about a user" +msgstr "" + +#: canaille/templates/profile_settings.html:48 +msgid "Account deletion" +msgstr "" + +#: canaille/templates/profile_settings.html:53 +msgid "" +"Are you sure you want to delete this user? This action is unrevokable and" +" all the data about this user will be removed." +msgstr "" + +#: canaille/templates/profile_settings.html:55 +msgid "" +"Are you sure you want to delete your account? This action is unrevokable " +"and all your data will be removed forever." +msgstr "" + +#: canaille/templates/profile_settings.html:107 msgid "Send email" msgstr "" -#: canaille/templates/profile_add.html:275 -#: canaille/templates/profile_settings.html:133 +#: canaille/templates/profile_settings.html:111 msgid "This user does not have a password yet" msgstr "" -#: canaille/templates/profile_add.html:278 -#: canaille/templates/profile_settings.html:136 +#: canaille/templates/profile_settings.html:114 msgid "You can solve this by:" msgstr "" -#: canaille/templates/profile_add.html:280 -#: canaille/templates/profile_settings.html:138 +#: canaille/templates/profile_settings.html:116 msgid "setting a password using this form;" msgstr "" -#: canaille/templates/profile_add.html:281 -#: canaille/templates/profile_settings.html:139 +#: canaille/templates/profile_settings.html:117 msgid "sending the user a password initialization mail, by clicking this button;" msgstr "" -#: canaille/templates/profile_add.html:295 -#: canaille/templates/profile_settings.html:151 +#: canaille/templates/profile_settings.html:121 +msgid "The user will not be able to authenticate unless the password is set" +msgstr "" + +#: canaille/templates/profile_settings.html:129 msgid "Send mail" msgstr "" #: canaille/templates/mail/admin.html:97 -#: canaille/templates/profile_add.html:298 -#: canaille/templates/profile_settings.html:154 +#: canaille/templates/profile_settings.html:132 #: canaille/templates/reset-password.html:11 #: canaille/templates/reset-password.html:16 msgid "Password reset" msgstr "" -#: canaille/templates/profile_add.html:300 -#: canaille/templates/profile_settings.html:156 +#: canaille/templates/profile_settings.html:134 msgid "" "If the user has forgotten his password, you can send him a password reset" " email by clicking this button." msgstr "" -#: canaille/templates/profile_add.html:312 -#: canaille/templates/profile_settings.html:168 +#: canaille/templates/profile_settings.html:146 msgid "Delete the user" msgstr "" -#: canaille/templates/profile_add.html:314 -#: canaille/templates/profile_settings.html:170 +#: canaille/templates/profile_settings.html:148 msgid "Delete my account" msgstr "" -#: canaille/templates/profile_add.html:321 -#: canaille/templates/profile_settings.html:177 +#: canaille/templates/profile_settings.html:155 msgid "Impersonate" msgstr "" -#: canaille/templates/profile_settings.html:120 -#: canaille/templates/profile_settings.html:143 -msgid "The user will not be able to authenticate unless the password is set" -msgstr "" - #: canaille/templates/users.html:5 canaille/templates/users.html:35 #: canaille/themes/default/base.html:54 msgid "Users" @@ -1155,8 +1129,8 @@ msgstr "" #: canaille/templates/mail/admin.html:42 msgid "" -"This form will send a fake invitation email to the address you want. This" -" should be used for testing mail configuration." +"This form will send a dummy email to the address you want. This should be" +" used for testing mail configuration." msgstr "" #: canaille/templates/mail/admin.html:61 diff --git a/demo/conf-docker/canaille.toml b/demo/conf-docker/canaille.toml index ef87a3e6..880f3d36 100644 --- a/demo/conf-docker/canaille.toml +++ b/demo/conf-docker/canaille.toml @@ -150,6 +150,7 @@ WRITE = [ "employeeNumber", "departmentNumber", "title", + "o", ] [ACL.ADMIN] diff --git a/demo/conf/canaille.toml b/demo/conf/canaille.toml index 3bcb4112..6f66b1bf 100644 --- a/demo/conf/canaille.toml +++ b/demo/conf/canaille.toml @@ -150,6 +150,7 @@ WRITE = [ "employeeNumber", "departmentNumber", "title", + "o", ] [ACL.ADMIN] diff --git a/tests/conftest.py b/tests/conftest.py index 9749ab71..cb6ede60 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -110,6 +110,7 @@ def configuration(slapd_server, smtpd): "preferredLanguage", "departmentNumber", "title", + "o", ], }, "ADMIN": { diff --git a/tests/test_profile_edition.py b/tests/test_profile_edition.py index db493859..ebb583f4 100644 --- a/tests/test_profile_edition.py +++ b/tests/test_profile_edition.py @@ -117,6 +117,7 @@ def test_edition( res.form["employeeNumber"] = 666 res.form["departmentNumber"] = 1337 res.form["title"] = "title" + res.form["o"] = "organization" res.form["preferredLanguage"] = "fr" res.form["jpegPhoto"] = Upload("logo.jpg", jpeg_photo) @@ -142,6 +143,7 @@ def test_edition( assert logged_user.employeeNumber == "666" assert logged_user.departmentNumber == ["1337"] assert logged_user.title == ["title"] + assert logged_user.o == ["organization"] assert logged_user.jpegPhoto == [jpeg_photo] logged_user.cn = ["John (johnny) Doe"]