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

wip: add a 403.html template #2396

Merged
merged 7 commits into from
Dec 23, 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
24 changes: 24 additions & 0 deletions docs-users/fr/support/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,27 @@ Toute propriété de l'élément sera disponible, ainsi que:
- `{zoom}` → le zoom actuel de la carte
- `{lat}` → la latitude du centre actuel de la carte
- `{lng}` → la longitude du centre actuel de la carte


## Quels statuts peut avoir une carte ? {: #map-statuses}

### En accès

* **Brouillon (privé)**: Vous seul et votre équipe pouvez accéder à la carte.
* **Tout le monde (public)**: Tout le monde peut accéder à la carte, qui est visible dans la recherche et la page d’accueil. La carte est indexée dans les moteurs de recherche (Google, etc.).
* **Quiconque a le lien**: La carte est visible par toutes les personnes qui en ont le lien. Elle n’est pas indexée dans les moteurs de recherche.
* **Éditeurs et équipe seulement**: Vous seul et votre équipe pouvez accéder à la carte.

Les personnes affichant une carte à laquelle elles n’ont pas accès auront une page d’erreur 403.

### En édition

* **Propriétaire uniquement**: Vous seul pouvez modifier la carte.
* **Éditeurs et équipe seulement**: Vous seul et votre équipe pouvez modifier la carte.
* **Tout le monde**: Tout le monde peut modifier la carte, même les comptes anonymes.

Pour les cartes créées sans compte :

* **Modifiable seulement avec le lien d’édition secret**: Seules les personnes avec un lien d’édition pourront modifier la carte.

Ces réglages sont aussi disponibles pour chaque calque.
26 changes: 25 additions & 1 deletion docs-users/support/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ With macOS, replace `Ctrl` by `Cmd`.
When the condition match, the associated style will be applied to the corresponding feature.


## How to use variables ? {: #variables}
## How to use variables? {: #variables}

In general, using a variable is as simple as `{myvar}`.

Expand Down Expand Up @@ -92,3 +92,27 @@ Any property of the feature will be available, plus:
- `{zoom}` → the current map zoom
- `{lat}` → the latitude of the current map center
- `{lng}` → the longitude of the current map center


## Which statuses can have a map? {: #map-statuses}

### Access statuses

* **Draft (private)**: Only you and your collaborators are able to see the map.
* **Everybody (public)**: Everybody can see your map, it is listed on search results and potentially the homepage. It is indexed by search engines like Google.
* **Anyone with link**: The map will be accessible only to people knowing the link. The map is not indexed by search engines.
* **Editors and team only**: Only you and your collaborators will be able to see the map.

Providing a link of a map to unallowed people will display a `403 Forbidden` error.

### Edit statuses

* **Owner only**: only the owner of the map can edit it.
* **Editors and team only**: the owner, editors and members of the linked team will be able to edit the map.
* **Everyone**: Everybody can edit the map without even being logged in.

Only for maps created without an account:

* **Only editable with secret edit link**: Only people with a secret link will be able to edit the map.

These settings are also available for each layer.
4 changes: 3 additions & 1 deletion umap/decorators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from functools import wraps

from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseForbidden
from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy
from django.utils.translation import gettext as _

from .models import Map, Team
from .views import simple_json_response
Expand Down Expand Up @@ -55,7 +57,7 @@ def wrapper(request, *args, **kwargs):
map_inst = get_object_or_404(Map, pk=kwargs["map_id"])
kwargs["map_inst"] = map_inst # Avoid rerequesting the map in the view
if not map_inst.can_view(request):
return HttpResponseForbidden()
raise PermissionDenied(_("This map is not publicly available"))
return view_func(request, *args, **kwargs)

return wrapper
Expand Down
31 changes: 18 additions & 13 deletions umap/static/umap/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,31 +208,36 @@ input[type="submit"],
}

/* **************************** */
/* 404 */
/* 40x */
/* **************************** */
.content404 {
width: 400px;
.content-40x {
max-width: 600px;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
text-align: center;
}
.content404 a {
.content-40x a {
color: #3A4259;
}
.content404 h1 {
font-size: 10em;
.content-40x h1 {
font-size: 2em;
margin-bottom: 0;
line-height: 0.5em;
margin-top: 40px;
}
.content404 h2 {
font-size: 4em;
margin-top: 0;
}
.content404 img {
.content-404 img {
width: 32%;
}
.page-40x {
background-image: url('./img/logo_lightcyan.svg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
height: 75vh;
margin: 1rem;
}
.page-40x a {
text-decoration: underline;
}


/* **************************** */
Expand Down
4 changes: 4 additions & 0 deletions umap/static/umap/img/logo_lightcyan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions umap/templates/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "40x.html" %}

{% load i18n %}

{% block content %}
<div class="content-40x">
<h1>{{ exception }}</h1>
<p>{% blocktrans %}<a href="https://discover.umap-project.org/support/faq/#map-statuses" target="_blank">Find out here the documentation</a> on how to manage map’s permissions.{% endblocktrans %}</p>
<hr>
<p><a href="{% url 'home' %}">{% trans "← Go to the homepage" %}</a></p>
</div>
{% endblock content %}
17 changes: 4 additions & 13 deletions umap/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
{% extends "base.html" %}
{% extends "40x.html" %}

{% load i18n static %}

{% block content %}
<div class="content404">
<a href="{% url "home" %}"
title="{% trans "Take me to the home page" %}">
<h1>
4
<img alt="0" width="128px" height="128px" src="{% static "umap/img/logo.svg" %}">
4
</h1>
<h2>
Not Found
</h2>
</a>
<div class="content-40x content-404">
<h1>{% trans "404 Page Not Found" %}</h1>
<p><a href="{% url 'home' %}">{% trans "← Go to the homepage" %}</a></p>
</div>
{% endblock content %}
9 changes: 9 additions & 0 deletions umap/templates/40x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% load umap_tags %}
{% block body_class %}page-40x{% endblock body_class %}
{% block extra_head %}
{% umap_css %}
{{ block.super }}
{% umap_js %}
{% endblock extra_head %}
Loading