Skip to content

Commit 6eadd4e

Browse files
committed
[chores:ui] Minor improvements to metric collection consent UI
(cherry picked from commit 5a32721) # Conflicts: # openwisp_utils/metric_collection/helper.py # openwisp_utils/metric_collection/migrations/0001_initial.py # openwisp_utils/metric_collection/models.py # openwisp_utils/metric_collection/tests/test_consent.py
1 parent 97a450c commit 6eadd4e

6 files changed

Lines changed: 58 additions & 26 deletions

File tree

openwisp_utils/admin_theme/static/admin/css/openwisp-info.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
display: block;
99
margin-top: 8px;
1010
}
11+
12+
#metric-consent {
13+
margin-top: 50px;
14+
}

openwisp_utils/admin_theme/templates/admin/openwisp_info.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,29 @@ <h2>{% trans "OS Information" %}</h2>
2121
<p><strong>{% trans "Kernel version" %}:</strong> {{ system_info.kernel_version }}</p>
2222
<p><strong>{% trans "Hardware platform" %}:</strong> {{ system_info.hardware_platform }}</p>
2323

24+
<div id="metric-consent">
2425
{% block metric_collect_consent %}
25-
{% if metric_collection_installed %}
26-
<h2>Metric collection</h2>
27-
<form method="POST" id="id_metric_collection_consent_form">
28-
{% csrf_token %}
29-
{{ metric_consent_form }}
30-
<p><input type="submit" style="display:none;"></p>
31-
</form>
32-
{% endif %}
26+
{% if metric_collection_installed %}
27+
<h2>Metric collection</h2>
28+
<form method="POST" id="id_metric_collection_consent_form">
29+
{% csrf_token %}
30+
{% for field in metric_consent_form %}
31+
<p>
32+
{% for error in field.errors %}
33+
<span class="error">{{ error }}</span>
34+
{% endfor %}
35+
{{ field.label_tag }}
36+
{{ field }}
37+
</p>
38+
{% if field.help_text %}
39+
<p class="helptext">{{ field.help_text|safe }}</p>
40+
{% endif %}
41+
{% endfor %}
42+
<p><input type="submit" style="display:none;"></p>
43+
</form>
44+
{% endif %}
3345
{% endblock metric_collect_consent %}
46+
</div>
3447
{% endblock content %}
3548

3649
{% block extrahead %}

openwisp_utils/metric_collection/helper.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ def show_consent_info(cls, request):
3737
consent = cls._get_consent()
3838

3939
if not consent.shown_once:
40-
messages.warning(
40+
messages.info(
4141
request,
4242
mark_safe(
4343
_(
44-
'We gather anonymous usage '
45-
'metrics to enhance OpenWISP. '
46-
'You can opt out from the '
44+
"<strong>Congratulations for installing "
45+
"OpenWISP successfully!</strong><br>"
46+
"Use the navigation menu on the left to explore "
47+
"the interface and begin deploying your network.<br>"
48+
"Keep in mind: we gather anonymous usage "
49+
"metrics to improve OpenWISP. "
50+
"You can opt out from the "
4751
'<a href="{url}">System Information page</a>.'
4852
).format(url=reverse('admin:ow-info'))
4953
),

openwisp_utils/metric_collection/migrations/0001_initial.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ class Migration(migrations.Migration):
4545
"user_consented",
4646
models.BooleanField(
4747
default=True,
48+
verbose_name=(
49+
"Help improve OpenWISP by allowing the collection "
50+
"of anonymous usage metrics."
51+
),
4852
help_text=(
49-
'Allow OpenWISP to collect and share anonymous usage metrics to improve'
50-
' the software. Before opting-out kindly consider reading'
51-
' <a href="https://openwisp.io/docs/user/usage-metric-collection.html"'
52-
' target="_blank">why we collect metrics</a>.'
53+
"These statistics help us prioritize features, "
54+
" fix bugs, and better support real-world usage,"
55+
" all without collecting any personal data. "
56+
'<a href="https://openwisp.io/docs/user/usage-metric-collection.html"'
57+
' target="_blank">Learn more about why we collect metrics</a>.'
5358
),
54-
verbose_name="Allow collecting anonymous usage metrics",
5559
),
5660
),
5761
],

openwisp_utils/metric_collection/models.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ class Consent(TimeStampedEditableModel):
192192
# usage metrics with the OpenWISP project.
193193
user_consented = models.BooleanField(
194194
default=True,
195-
verbose_name=_('Allow collecting anonymous usage metrics'),
195+
verbose_name=_(
196+
"Help improve OpenWISP by allowing the "
197+
"collection of anonymous usage metrics."
198+
),
196199
help_text=_(
197-
'Allow OpenWISP to collect and share anonymous usage metrics to improve'
198-
' the software. Before opting-out kindly consider reading'
199-
' <a href="https://openwisp.io/docs/user/usage-metric-collection.html"'
200-
' target="_blank">why we collect metrics</a>.'
200+
"These statistics help us prioritize features, "
201+
" fix bugs, and better support real-world usage,"
202+
" all without collecting any personal data. "
203+
'<a href="https://openwisp.io/docs/user/usage-metric-collection.html"'
204+
' target="_blank">Learn more about why we collect metrics</a>.'
201205
),
202206
)

openwisp_utils/metric_collection/tests/test_consent.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ def _get_user(self, **kwargs):
2121

2222
def test_info_message(self):
2323
expected_message = (
24-
'<li class="warning">We gather anonymous usage metrics '
25-
'to enhance OpenWISP. You can opt out from the '
26-
'<a href="/admin/openwisp-system-info/">System '
27-
'Information page</a>.</li>'
24+
'<li class="info"><strong>Congratulations for installing '
25+
"OpenWISP successfully!</strong><br>Use the navigation "
26+
"menu on the left to explore the interface and begin "
27+
"deploying your network.<br>Keep in mind: we gather "
28+
"anonymous usage metrics to improve OpenWISP. You can "
29+
'opt out from the <a href="/admin/openwisp-system-info/">'
30+
"System Information page</a>.</li>"
2831
)
2932
non_superuser = self._get_user(is_staff=True, is_superuser=False)
3033
superuser1 = self._get_user(

0 commit comments

Comments
 (0)