/accounts/: display restricted attributes edit links on main page (#86937)
gitea/authentic/pipeline/head This commit looks good
Details
gitea/authentic/pipeline/head This commit looks good
Details
This commit is contained in:
parent
9f94256ccf
commit
ecc6ff75cc
|
@ -74,6 +74,9 @@
|
|||
{% if allow_profile_edit %}
|
||||
<p><a href="{% url 'profile_edit' %}">{% trans "Edit account data" %}</a></p>
|
||||
{% endif %}
|
||||
{% for attribute in restricted_attributes %}
|
||||
<p><a href="{% url 'profile_edit_restricted_attribute' attribute=attribute.name %}">{% blocktranslate with label=attribute.label %}Edit your profile attribute “{{ label }}”{% endblocktranslate %}</a></p>
|
||||
{% endfor %}
|
||||
{% if allow_authorization_management %}
|
||||
<p><a href="{% url 'consents' %}">{% trans "Manage service authorizations" %}</a></p>
|
||||
{% endif %}
|
||||
|
|
|
@ -888,6 +888,13 @@ class ProfileView(HomeURLMixin, cbv.TemplateNamesMixin, TemplateView):
|
|||
and authenticator.phone_identifier_field.user_editable
|
||||
and not authenticator.phone_identifier_field.disabled
|
||||
)
|
||||
|
||||
restricted_attributes = models.Attribute.objects.filter(
|
||||
user_visible=True,
|
||||
user_editable=True,
|
||||
disabled=False,
|
||||
valueset_elements__isnull=False,
|
||||
).distinct()
|
||||
context.update(
|
||||
{
|
||||
'frontends_block': blocks,
|
||||
|
@ -902,6 +909,7 @@ class ProfileView(HomeURLMixin, cbv.TemplateNamesMixin, TemplateView):
|
|||
# TODO: deprecated should be removed when publik-base-theme is updated
|
||||
'allow_password_change': utils_misc.user_can_change_password(request=request),
|
||||
'federation_management': federation_management,
|
||||
'restricted_attributes': restricted_attributes,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -579,6 +579,16 @@ def test_accounts_edit_restricted_attribute_view(app, simple_user, settings):
|
|||
simple_user.save()
|
||||
|
||||
utils.login(app, simple_user)
|
||||
resp = app.get(reverse('account_management'))
|
||||
assert (
|
||||
resp.pyquery('a[href="/accounts/edit_restricted_attribute/favourite_colors/"]')[0].text_content()
|
||||
== 'Edit your profile attribute “Favourite colors”'
|
||||
)
|
||||
assert (
|
||||
resp.pyquery('a[href="/accounts/edit_restricted_attribute/favourite_shape/"]')[0].text_content()
|
||||
== 'Edit your profile attribute “Favourite shape”'
|
||||
)
|
||||
|
||||
resp = app.get(reverse('profile_edit_restricted_attribute', kwargs={'attribute': 'favourite_colors'}))
|
||||
assert len(resp.pyquery('ul#id_favourite_colors li')) == 4
|
||||
|
||||
|
|
Loading…
Reference in New Issue