-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Metric collection: added consent in web UI #372
Closes #372
- Loading branch information
Showing
8 changed files
with
188 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django import forms | ||
|
||
from .models import MetricCollectionConsent | ||
|
||
|
||
class MetricCollectionConsentForm(forms.ModelForm): | ||
class Meta: | ||
model = MetricCollectionConsent | ||
widgets = {'user_consented': forms.CheckboxInput(attrs={'class': 'bold'})} | ||
fields = ['user_consented'] |
58 changes: 58 additions & 0 deletions
58
openwisp_utils/measurements/migrations/0002_metriccollectionconsent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 4.2.7 on 2024-04-15 05:54 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
import model_utils.fields | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("measurements", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="MetricCollectionConsent", | ||
fields=[ | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=uuid.uuid4, | ||
editable=False, | ||
primary_key=True, | ||
serialize=False, | ||
), | ||
), | ||
( | ||
"created", | ||
model_utils.fields.AutoCreatedField( | ||
default=django.utils.timezone.now, | ||
editable=False, | ||
verbose_name="created", | ||
), | ||
), | ||
( | ||
"modified", | ||
model_utils.fields.AutoLastModifiedField( | ||
default=django.utils.timezone.now, | ||
editable=False, | ||
verbose_name="modified", | ||
), | ||
), | ||
("has_shown_disclaimer", models.BooleanField(default=False)), | ||
( | ||
"user_consented", | ||
models.BooleanField( | ||
default=True, | ||
help_text='Allow OpenWISP to collect and share anonymous usage metrics to improve the software. Before opting-out kindly consider reading <a href="https://github.com/openwisp/openwisp-utils?tab=readme-ov-file#collection-of-usage-metrics" target="_blank">why we collect metrics</a>.', | ||
verbose_name="Allow collecting anonymous usage metrics", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
openwisp_utils/measurements/static/admin/js/metric-collection-consent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
django.jQuery(document).ready(function($) { | ||
$('#id_user_consented').change(function() { | ||
$('#id_metric_collection_consent_form').submit(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters