Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a setting to prevent users from editing their profile #2133

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/config/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ Should uMap allows user without an account to create maps (default is False).

Can be set through env var: `UMAP_ALLOW_ANONYMOUS=1`

#### UMAP_ALLOW_EDIT_PROFILE

Should uMap allows users to edit their profile (default is True).

Can be unset through env var: `UMAP_ALLOW_EDIT_PROFILE=0`

#### UMAP_CUSTOM_TEMPLATES
To be used when you want to override some HTML templates:

Expand Down
1 change: 1 addition & 0 deletions umap/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def settings(request):
"UMAP_READONLY": djsettings.UMAP_READONLY,
"UMAP_DEMO_SITE": djsettings.UMAP_DEMO_SITE,
"UMAP_HOST_INFOS": djsettings.UMAP_HOST_INFOS,
"UMAP_ALLOW_EDIT_PROFILE": djsettings.UMAP_ALLOW_EDIT_PROFILE,
}


Expand Down
1 change: 1 addition & 0 deletions umap/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
# Miscellaneous project settings
# =============================================================================
UMAP_ALLOW_ANONYMOUS = env.bool("UMAP_ALLOW_ANONYMOUS", default=False)
UMAP_ALLOW_EDIT_PROFILE = env.bool("UMAP_ALLOW_EDIT_PROFILE", default=True)

UMAP_EXTRA_URLS = {
"routing": "http://www.openstreetmap.org/directions?engine=osrm_car&route={lat},{lng}&locale={locale}#map={zoom}/{lat}/{lng}", # noqa
Expand Down
6 changes: 4 additions & 2 deletions umap/templates/umap/dashboard_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ <h2 class="section tabs">
{% else %}
<a href="{% url 'user_dashboard' %}">{% trans "My Maps" %}</a>
{% endif %}
<a {% if selected == "profile" %}class="selected"{% endif %}
href="{% url 'user_profile' %}">{% trans "My profile" %}</a>
{% if UMAP_ALLOW_EDIT_PROFILE %}
<a {% if selected == "profile" %}class="selected"{% endif %}
href="{% url 'user_profile' %}">{% trans "My profile" %}</a>
{% endif %}
<a {% if selected == "teams" %}class="selected"{% endif %}
href="{% url 'user_teams' %}">{% trans "My teams" %}</a>
</h2>
Expand Down
6 changes: 5 additions & 1 deletion umap/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@
name="map_star",
),
path("me", views.user_dashboard, name="user_dashboard"),
path("me/profile", views.user_profile, name="user_profile"),
path("me/download", views.user_download, name="user_download"),
path("me/teams", views.UserTeams.as_view(), name="user_teams"),
path("team/create/", views.TeamNew.as_view(), name="team_new"),
)

if settings.UMAP_ALLOW_EDIT_PROFILE:
i18n_urls.append(
path("me/profile", login_required(views.user_profile), name="user_profile")
)
i18n_urls += decorated_patterns(
[login_required, team_members_only],
path("team/<int:pk>/edit/", views.TeamUpdate.as_view(), name="team_update"),
Expand Down
Loading