mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-11 17:46:20 +01:00
Analytics Module
This commit is contained in:
42
allianceauth/analytics/migrations/0001_initial.py
Normal file
42
allianceauth/analytics/migrations/0001_initial.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-30 13:11
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AnalyticsIdentifier',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('identifier', models.UUIDField(default=uuid.uuid4, editable=False)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AnalyticsPath',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('ignore_path', models.CharField(default='/example/', max_length=254)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AnalyticsTokens',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=254)),
|
||||
('type', models.CharField(choices=[('GA-U', 'Google Analytics Universal'), ('GA-V4', 'Google Analytics V4')], max_length=254)),
|
||||
('token', models.CharField(max_length=254)),
|
||||
('send_page_views', models.BooleanField(default=False)),
|
||||
('send_celery_tasks', models.BooleanField(default=False)),
|
||||
('send_stats', models.BooleanField(default=False)),
|
||||
('ignore_paths', models.ManyToManyField(blank=True, to='analytics.AnalyticsPath')),
|
||||
],
|
||||
),
|
||||
]
|
||||
34
allianceauth/analytics/migrations/0002_add_AA_Team_Token.py
Normal file
34
allianceauth/analytics/migrations/0002_add_AA_Team_Token.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-30 08:53
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def add_aa_team_token(apps, schema_editor):
|
||||
# We can't import the Person model directly as it may be a newer
|
||||
# version than this migration expects. We use the historical version.
|
||||
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
|
||||
token = Tokens()
|
||||
token.type = 'GA-U'
|
||||
token.token = 'UA-186249766-2'
|
||||
token.send_page_views = True
|
||||
token.send_celery_views = True
|
||||
token.send_stats = True
|
||||
token.name = 'AA Team Public Google Analytics (Universal)'
|
||||
token.save()
|
||||
|
||||
|
||||
def remove_aa_team_token(apps, schema_editor):
|
||||
# Have to define some code to remove this identifier
|
||||
# In case of migration rollback?
|
||||
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
|
||||
token = Tokens.objects.filter(token="UA-186249766-2").delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [migrations.RunPython(add_aa_team_token, remove_aa_team_token)
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-30 08:53
|
||||
|
||||
from uuid import uuid4
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def generate_identifier(apps, schema_editor):
|
||||
# We can't import the Person model directly as it may be a newer
|
||||
# version than this migration expects. We use the historical version.
|
||||
Identifier = apps.get_model('analytics', 'AnalyticsIdentifier')
|
||||
identifier = Identifier()
|
||||
identifier.id = 1
|
||||
identifier.save()
|
||||
|
||||
|
||||
def zero_identifier(apps, schema_editor):
|
||||
# Have to define some code to remove this identifier
|
||||
# In case of migration rollback?
|
||||
Identifier = apps.get_model('analytics', 'AnalyticsIdentifier')
|
||||
Identifier.objects.filter(id=1).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0002_add_AA_Team_Token'),
|
||||
]
|
||||
|
||||
operations = [migrations.RunPython(generate_identifier, zero_identifier)
|
||||
]
|
||||
0
allianceauth/analytics/migrations/__init__.py
Normal file
0
allianceauth/analytics/migrations/__init__.py
Normal file
Reference in New Issue
Block a user