Address edition support (but not in the OIDC claims yet)

This commit is contained in:
Éloi Rivard 2023-03-11 20:11:55 +01:00
parent 822988536d
commit 4170242073
10 changed files with 159 additions and 62 deletions

View file

@ -16,6 +16,7 @@ Added
- SMTP SSL support. :pr:`108`
- Server side pagination. :issue:`114` :pr:`111`
- Department number support. :issue:`129`
- Address edition support (but not in the OIDC claims yet) :pr:`112`
Fixed
*****

View file

@ -132,14 +132,19 @@ GROUP_BASE = "ou=groups,dc=mydomain,dc=tld"
PERMISSIONS = ["edit_self", "use_oidc"]
READ = ["uid", "groups"]
WRITE = [
"jpegPhoto",
"givenName",
"sn",
"displayName",
"userPassword",
"telephoneNumber",
"jpegPhoto",
"mail",
"labeledURI",
"postalAddress",
"street",
"postalCode",
"l",
"st",
"preferredLanguage",
"employeeNumber",
"departmentNumber",

View file

@ -179,7 +179,31 @@ PROFILE_FORM_FIELDS = dict(
postalAddress=wtforms.StringField(
_("Address"),
render_kw={
"placeholder": _("132, Foobar Street, Gotham City 12401"),
"placeholder": _("132, Foobar Street, Gotham City 12401, XX"),
},
),
street=wtforms.StringField(
_("Street"),
render_kw={
"placeholder": _("132, Foobar Street"),
},
),
postalCode=wtforms.StringField(
_("Postal Code"),
render_kw={
"placeholder": "12401",
},
),
l=wtforms.StringField(
_("Locality"),
render_kw={
"placeholder": _("Gotham City"),
},
),
st=wtforms.StringField(
_("Region"),
render_kw={
"placeholder": _("Gotham City"),
},
),
jpegPhoto=FileField(

View file

@ -148,6 +148,24 @@
{% block postal_address_field scoped %}{{ render_field(form.postalAddress) }}{% endblock %}
{% endif %}
{% if "street" in form %}
{% block street_field scoped %}{{ render_field(form.street) }}{% endblock %}
{% endif %}
<div class="fluid equal width fields">
{% if "postalCode" in form %}
{% block postal_code_field scoped %}{{ render_field(form.postalCode) }}{% endblock %}
{% endif %}
{% if "l" in form %}
{% block locality_field scoped %}{{ render_field(form.l) }}{% endblock %}
{% endif %}
{% if "st" in form %}
{% block region_field scoped %}{{ render_field(form.st) }}{% endblock %}
{% endif %}
</div>
{% if "departmentNumber" in form and "employeeNumber" in form %}
<div class="two fields">
{% endif %}

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-03-11 12:54+0100\n"
"POT-Creation-Date: 2023-03-11 20:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -66,7 +66,7 @@ msgstr ""
msgid "You are already logged in, you cannot create an account."
msgstr ""
#: canaille/account.py:336 canaille/forms.py:243 canaille/forms.py:305
#: canaille/account.py:336 canaille/forms.py:267 canaille/forms.py:329
#: canaille/templates/groups.html:5 canaille/templates/groups.html:16
#: canaille/templates/partial/users.html:18
#: canaille/themes/default/base.html:61
@ -144,7 +144,7 @@ msgid "Email"
msgstr ""
#: canaille/admin.py:29 canaille/forms.py:75 canaille/forms.py:99
#: canaille/forms.py:171 canaille/forms.py:299
#: canaille/forms.py:171 canaille/forms.py:323
msgid "jane@doe.com"
msgstr ""
@ -172,7 +172,7 @@ msgstr ""
msgid "John Doe"
msgstr ""
#: canaille/apputils.py:34 canaille/forms.py:134 canaille/forms.py:287
#: canaille/apputils.py:34 canaille/forms.py:134 canaille/forms.py:311
msgid "jdoe"
msgstr ""
@ -213,15 +213,15 @@ msgstr ""
msgid "Login"
msgstr ""
#: canaille/forms.py:85 canaille/forms.py:108 canaille/forms.py:192
#: canaille/forms.py:85 canaille/forms.py:108 canaille/forms.py:216
msgid "Password"
msgstr ""
#: canaille/forms.py:111 canaille/forms.py:196
#: canaille/forms.py:111 canaille/forms.py:220
msgid "Password confirmation"
msgstr ""
#: canaille/forms.py:114 canaille/forms.py:199
#: canaille/forms.py:114 canaille/forms.py:223
msgid "Password and confirmation do not match."
msgstr ""
@ -229,11 +229,11 @@ msgstr ""
msgid "Automatic"
msgstr ""
#: canaille/forms.py:133 canaille/forms.py:286
#: canaille/forms.py:133 canaille/forms.py:310
msgid "Username"
msgstr ""
#: canaille/forms.py:137 canaille/forms.py:258 canaille/forms.py:272
#: canaille/forms.py:137 canaille/forms.py:282 canaille/forms.py:296
#: 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
@ -264,7 +264,7 @@ msgstr ""
msgid "Johnny"
msgstr ""
#: canaille/forms.py:165 canaille/forms.py:292
#: canaille/forms.py:165 canaille/forms.py:316
msgid "Email address"
msgstr ""
@ -287,55 +287,79 @@ msgid "Address"
msgstr ""
#: canaille/forms.py:182
msgid "132, Foobar Street, Gotham City 12401"
msgid "132, Foobar Street, Gotham City 12401, XX"
msgstr ""
#: canaille/forms.py:186
msgid "Photo"
msgid "Street"
msgstr ""
#: canaille/forms.py:190 canaille/templates/profile.html:105
msgid "Delete the photo"
#: canaille/forms.py:188
msgid "132, Foobar Street"
msgstr ""
#: canaille/forms.py:192
msgid "Postal Code"
msgstr ""
#: canaille/forms.py:198
msgid "Locality"
msgstr ""
#: canaille/forms.py:200 canaille/forms.py:206
msgid "Gotham City"
msgstr ""
#: canaille/forms.py:204
msgid "Employee number"
msgstr ""
#: canaille/forms.py:206 canaille/forms.py:212
msgid "1234"
msgid "Region"
msgstr ""
#: canaille/forms.py:210
msgid "Photo"
msgstr ""
#: canaille/forms.py:214 canaille/templates/profile.html:105
msgid "Delete the photo"
msgstr ""
#: canaille/forms.py:228
msgid "Employee number"
msgstr ""
#: canaille/forms.py:230 canaille/forms.py:236
msgid "1234"
msgstr ""
#: canaille/forms.py:234
msgid "Department number"
msgstr ""
#: canaille/forms.py:216
#: canaille/forms.py:240
msgid "Website"
msgstr ""
#: canaille/forms.py:218
#: canaille/forms.py:242
msgid "https://mywebsite.tld"
msgstr ""
#: canaille/forms.py:222
#: canaille/forms.py:246
msgid "Preferred language"
msgstr ""
#: canaille/forms.py:245
#: canaille/forms.py:269
msgid "users, admins …"
msgstr ""
#: canaille/forms.py:261
#: canaille/forms.py:285
msgid "group"
msgstr ""
#: canaille/forms.py:265 canaille/forms.py:279
#: canaille/forms.py:289 canaille/forms.py:303
#: canaille/templates/partial/groups.html:7
msgid "Description"
msgstr ""
#: canaille/forms.py:290
#: canaille/forms.py:314
msgid "Username editable by the invitee"
msgstr ""
@ -370,11 +394,11 @@ msgstr ""
msgid "You have been invited to create an account on {website_name}"
msgstr ""
#: canaille/ldap_backend/backend.py:55
#: canaille/ldap_backend/backend.py:61
msgid "Could not connect to the LDAP server '{uri}'"
msgstr ""
#: canaille/ldap_backend/backend.py:71
#: canaille/ldap_backend/backend.py:77
msgid "LDAP authentication failed with user '{user}'"
msgstr ""
@ -687,7 +711,7 @@ msgstr ""
msgid "Create group"
msgstr ""
#: canaille/templates/group.html:83 canaille/templates/profile.html:279
#: canaille/templates/group.html:83 canaille/templates/profile.html:297
msgid "Submit"
msgstr ""
@ -700,7 +724,7 @@ msgid "Add a group"
msgstr ""
#: canaille/templates/invite.html:5 canaille/templates/invite.html:85
#: canaille/templates/profile.html:274 canaille/templates/users.html:17
#: canaille/templates/profile.html:292 canaille/templates/users.html:17
msgid "Invite a user"
msgstr ""
@ -862,83 +886,83 @@ msgstr ""
msgid "Click to upload a photo"
msgstr ""
#: canaille/templates/profile.html:176
#: canaille/templates/profile.html:194
msgid "Account information"
msgstr ""
#: canaille/templates/profile.html:201
#: canaille/templates/profile.html:219
msgid "User password is not mandatory"
msgstr ""
#: canaille/templates/profile.html:204
#: canaille/templates/profile.html:222
msgid "The user password can be set:"
msgstr ""
#: canaille/templates/profile.html:206
#: canaille/templates/profile.html:224
msgid "by filling this form;"
msgstr ""
#: canaille/templates/profile.html:207
#: canaille/templates/profile.html:225
msgid ""
"by sending the user a password initialization mail, after the account "
"creation;"
msgstr ""
#: canaille/templates/profile.html:208 canaille/templates/profile.html:231
#: canaille/templates/profile.html:226 canaille/templates/profile.html:249
msgid ""
"or simply waiting for the user to sign-in a first time, and then receive "
"a password initialization mail."
msgstr ""
#: canaille/templates/profile.html:211 canaille/templates/profile.html:234
#: canaille/templates/profile.html:229 canaille/templates/profile.html:252
msgid "The user will not be able to authenticate unless the password is set"
msgstr ""
#: canaille/templates/profile.html:220
#: canaille/templates/profile.html:238
msgid "Send email"
msgstr ""
#: canaille/templates/profile.html:224
#: canaille/templates/profile.html:242
msgid "This user does not have a password yet"
msgstr ""
#: canaille/templates/profile.html:227
#: canaille/templates/profile.html:245
msgid "You can solve this by:"
msgstr ""
#: canaille/templates/profile.html:229
#: canaille/templates/profile.html:247
msgid "setting a password using this form;"
msgstr ""
#: canaille/templates/profile.html:230
#: canaille/templates/profile.html:248
msgid "sending the user a password initialization mail, by clicking this button;"
msgstr ""
#: canaille/templates/profile.html:242
#: canaille/templates/profile.html:260
msgid "Send mail"
msgstr ""
#: canaille/templates/mail/admin.html:72 canaille/templates/profile.html:245
#: canaille/templates/mail/admin.html:72 canaille/templates/profile.html:263
#: canaille/templates/reset-password.html:11
#: canaille/templates/reset-password.html:16
msgid "Password reset"
msgstr ""
#: canaille/templates/profile.html:247
#: canaille/templates/profile.html:265
msgid ""
"If the user has forgotten his password, you can send him a password reset"
" email by clicking this button."
msgstr ""
#: canaille/templates/profile.html:259
#: canaille/templates/profile.html:277
msgid "Delete the user"
msgstr ""
#: canaille/templates/profile.html:261
#: canaille/templates/profile.html:279
msgid "Delete my account"
msgstr ""
#: canaille/templates/profile.html:268
#: canaille/templates/profile.html:286
msgid "Impersonate"
msgstr ""

View file

@ -141,6 +141,11 @@ WRITE = [
"telephoneNumber",
"mail",
"labeledURI",
"postalAddress",
"street",
"postalCode",
"l",
"st",
"preferredLanguage",
"employeeNumber",
"departmentNumber",

View file

@ -142,6 +142,10 @@ WRITE = [
"mail",
"labeledURI",
"postalAddress",
"street",
"postalCode",
"l",
"st",
"preferredLanguage",
"employeeNumber",
"departmentNumber",

View file

@ -10,9 +10,13 @@ telephoneNumber: 555-000-000
employeeNumber: 1000
departmentNumber: east
labeledURI: https://admin.example
postalAddress: 123, Admin Lane - Gotham City 12345
userPassword: {SSHA}7zQVLckaEc6cJEsS0ylVipvb2PAR/4tS
displayName: Jane.D
postalAddress: 123, Admin Lane - Gotham City 12345
street: Admin Lane
postalCode: 12345
l: Gotham City
st: North Pole
dn: uid=moderator,ou=users,dc=mydomain,dc=tld
objectclass: top

View file

@ -102,6 +102,10 @@ def configuration(slapd_server, smtpd):
"userPassword",
"telephoneNumber",
"postalAddress",
"street",
"postalCode",
"l",
"st",
"employeeNumber",
"preferredLanguage",
"departmentNumber",

View file

@ -102,6 +102,10 @@ def test_edition(
res.form["mail"] = "email@mydomain.tld"
res.form["telephoneNumber"] = "555-666-777"
res.form["postalAddress"] = "postal_address"
res.form["street"] = "street"
res.form["postalCode"] = "postal_code"
res.form["l"] = "locality"
res.form["st"] = "region"
res.form["employeeNumber"] = 666
res.form["departmentNumber"] = 1337
res.form["groups"] = [
@ -117,17 +121,21 @@ def test_edition(
logged_user = User.get(id=logged_user.id)
logged_user.load_groups()
assert ["user"] == logged_user.uid
assert ["given_name"] == logged_user.givenName
assert ["family_name"] == logged_user.sn
assert "display_name" == logged_user.displayName
assert ["email@mydomain.tld"] == logged_user.mail
assert ["555-666-777"] == logged_user.telephoneNumber
assert ["postal_address"] == logged_user.postalAddress
assert "fr" == logged_user.preferredLanguage
assert "666" == logged_user.employeeNumber
assert ["1337"] == logged_user.departmentNumber
assert [jpeg_photo] == logged_user.jpegPhoto
assert logged_user.uid == ["user"]
assert logged_user.givenName == ["given_name"]
assert logged_user.sn == ["family_name"]
assert logged_user.displayName == "display_name"
assert logged_user.mail == ["email@mydomain.tld"]
assert logged_user.telephoneNumber == ["555-666-777"]
assert logged_user.postalAddress == ["postal_address"]
assert logged_user.street == ["street"]
assert logged_user.postalCode == ["postal_code"]
assert logged_user.l == ["locality"]
assert logged_user.st == ["region"]
assert logged_user.preferredLanguage == "fr"
assert logged_user.employeeNumber == "666"
assert logged_user.departmentNumber == ["1337"]
assert logged_user.jpegPhoto == [jpeg_photo]
foo_group.reload()
bar_group.reload()