Code reformatting
This commit is contained in:
parent
c620342b42
commit
e8c00bf5c8
@ -2,25 +2,52 @@ from django.contrib import admin
|
|||||||
|
|
||||||
from .models import Hit, Session
|
from .models import Hit, Session
|
||||||
|
|
||||||
|
|
||||||
class HitInline(admin.TabularInline):
|
class HitInline(admin.TabularInline):
|
||||||
model = Hit
|
model = Hit
|
||||||
fk_name = "session"
|
fk_name = "session"
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class SessionAdmin(admin.ModelAdmin):
|
class SessionAdmin(admin.ModelAdmin):
|
||||||
list_display = ("uuid", "service", "start_time", "identifier", "ip", "asn", "country")
|
list_display = (
|
||||||
|
"uuid",
|
||||||
|
"service",
|
||||||
|
"start_time",
|
||||||
|
"identifier",
|
||||||
|
"ip",
|
||||||
|
"asn",
|
||||||
|
"country",
|
||||||
|
)
|
||||||
list_display_links = ("uuid",)
|
list_display_links = ("uuid",)
|
||||||
search_fields = ("ip", "user_agent", "device", "device_type", "identifier", "asn", "time_zone")
|
search_fields = (
|
||||||
|
"ip",
|
||||||
|
"user_agent",
|
||||||
|
"device",
|
||||||
|
"device_type",
|
||||||
|
"identifier",
|
||||||
|
"asn",
|
||||||
|
"time_zone",
|
||||||
|
)
|
||||||
list_filter = ("device_type",)
|
list_filter = ("device_type",)
|
||||||
inlines = [HitInline]
|
inlines = [HitInline]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Session, SessionAdmin)
|
admin.site.register(Session, SessionAdmin)
|
||||||
|
|
||||||
|
|
||||||
class HitAdmin(admin.ModelAdmin):
|
class HitAdmin(admin.ModelAdmin):
|
||||||
list_display = ("session", "initial", "start_time", "heartbeats", "tracker", "load_time")
|
list_display = (
|
||||||
|
"session",
|
||||||
|
"initial",
|
||||||
|
"start_time",
|
||||||
|
"heartbeats",
|
||||||
|
"tracker",
|
||||||
|
"load_time",
|
||||||
|
)
|
||||||
list_display_links = ("session",)
|
list_display_links = ("session",)
|
||||||
search_fields = ("initial", "tracker", "location", "referrer")
|
search_fields = ("initial", "tracker", "location", "referrer")
|
||||||
list_filter = ("initial", "tracker")
|
list_filter = ("initial", "tracker")
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Hit, HitAdmin)
|
admin.site.register(Hit, HitAdmin)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# Generated by Django 3.0.5 on 2020-04-14 14:40
|
# Generated by Django 3.0.5 on 2020-04-14 14:40
|
||||||
|
|
||||||
import analytics.models
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import analytics.models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -10,70 +11,115 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0001_initial'),
|
("core", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Session',
|
name="Session",
|
||||||
fields=[
|
fields=[
|
||||||
('uuid', models.UUIDField(default=analytics.models._default_uuid, primary_key=True, serialize=False)),
|
(
|
||||||
('identifier', models.TextField(blank=True, db_index=True)),
|
"uuid",
|
||||||
('start_time', models.DateTimeField(auto_now_add=True, db_index=True)),
|
models.UUIDField(
|
||||||
('last_seen', models.DateTimeField(auto_now_add=True)),
|
default=analytics.models._default_uuid,
|
||||||
('user_agent', models.TextField()),
|
primary_key=True,
|
||||||
('browser', models.TextField()),
|
serialize=False,
|
||||||
('device', models.TextField()),
|
),
|
||||||
('device_type', models.CharField(choices=[('PHONE', 'Phone'), ('TABLET', 'Tablet'), ('DESKTOP', 'Desktop'), ('ROBOT', 'Robot'), ('OTHER', 'Other')], default='OTHER', max_length=7)),
|
),
|
||||||
('os', models.TextField()),
|
("identifier", models.TextField(blank=True, db_index=True)),
|
||||||
('ip', models.GenericIPAddressField(db_index=True)),
|
("start_time", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||||
('asn', models.TextField(blank=True)),
|
("last_seen", models.DateTimeField(auto_now_add=True)),
|
||||||
('country', models.TextField(blank=True)),
|
("user_agent", models.TextField()),
|
||||||
('longitude', models.FloatField(null=True)),
|
("browser", models.TextField()),
|
||||||
('latitude', models.FloatField(null=True)),
|
("device", models.TextField()),
|
||||||
('time_zone', models.TextField(blank=True)),
|
(
|
||||||
('service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Service')),
|
"device_type",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("PHONE", "Phone"),
|
||||||
|
("TABLET", "Tablet"),
|
||||||
|
("DESKTOP", "Desktop"),
|
||||||
|
("ROBOT", "Robot"),
|
||||||
|
("OTHER", "Other"),
|
||||||
],
|
],
|
||||||
options={
|
default="OTHER",
|
||||||
'ordering': ['-start_time'],
|
max_length=7,
|
||||||
},
|
),
|
||||||
|
),
|
||||||
|
("os", models.TextField()),
|
||||||
|
("ip", models.GenericIPAddressField(db_index=True)),
|
||||||
|
("asn", models.TextField(blank=True)),
|
||||||
|
("country", models.TextField(blank=True)),
|
||||||
|
("longitude", models.FloatField(null=True)),
|
||||||
|
("latitude", models.FloatField(null=True)),
|
||||||
|
("time_zone", models.TextField(blank=True)),
|
||||||
|
(
|
||||||
|
"service",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="core.Service"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={"ordering": ["-start_time"],},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Hit',
|
name="Hit",
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
(
|
||||||
('initial', models.BooleanField(db_index=True, default=True)),
|
"id",
|
||||||
('start_time', models.DateTimeField(auto_now_add=True, db_index=True)),
|
models.AutoField(
|
||||||
('last_seen', models.DateTimeField(auto_now_add=True)),
|
auto_created=True,
|
||||||
('heartbeats', models.IntegerField(default=0)),
|
primary_key=True,
|
||||||
('tracker', models.TextField()),
|
serialize=False,
|
||||||
('location', models.TextField(blank=True, db_index=True)),
|
verbose_name="ID",
|
||||||
('referrer', models.TextField(blank=True, db_index=True)),
|
),
|
||||||
('load_time', models.FloatField(null=True)),
|
),
|
||||||
('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Session')),
|
("initial", models.BooleanField(db_index=True, default=True)),
|
||||||
|
("start_time", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||||
|
("last_seen", models.DateTimeField(auto_now_add=True)),
|
||||||
|
("heartbeats", models.IntegerField(default=0)),
|
||||||
|
("tracker", models.TextField()),
|
||||||
|
("location", models.TextField(blank=True, db_index=True)),
|
||||||
|
("referrer", models.TextField(blank=True, db_index=True)),
|
||||||
|
("load_time", models.FloatField(null=True)),
|
||||||
|
(
|
||||||
|
"session",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to="analytics.Session",
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
options={
|
options={"ordering": ["-start_time"],},
|
||||||
'ordering': ['-start_time'],
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
migrations.AddIndex(
|
migrations.AddIndex(
|
||||||
model_name='session',
|
model_name="session",
|
||||||
index=models.Index(fields=['service', '-start_time'], name='analytics_s_service_4b1137_idx'),
|
index=models.Index(
|
||||||
|
fields=["service", "-start_time"], name="analytics_s_service_4b1137_idx"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddIndex(
|
migrations.AddIndex(
|
||||||
model_name='session',
|
model_name="session",
|
||||||
index=models.Index(fields=['service', 'identifier'], name='analytics_s_service_82ab21_idx'),
|
index=models.Index(
|
||||||
|
fields=["service", "identifier"], name="analytics_s_service_82ab21_idx"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddIndex(
|
migrations.AddIndex(
|
||||||
model_name='hit',
|
model_name="hit",
|
||||||
index=models.Index(fields=['session', '-start_time'], name='analytics_h_session_b2667f_idx'),
|
index=models.Index(
|
||||||
|
fields=["session", "-start_time"], name="analytics_h_session_b2667f_idx"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddIndex(
|
migrations.AddIndex(
|
||||||
model_name='hit',
|
model_name="hit",
|
||||||
index=models.Index(fields=['session', 'location'], name='analytics_h_session_775f5a_idx'),
|
index=models.Index(
|
||||||
|
fields=["session", "location"], name="analytics_h_session_775f5a_idx"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddIndex(
|
migrations.AddIndex(
|
||||||
model_name='hit',
|
model_name="hit",
|
||||||
index=models.Index(fields=['session', 'referrer'], name='analytics_h_session_98b8bf_idx'),
|
index=models.Index(
|
||||||
|
fields=["session", "referrer"], name="analytics_h_session_98b8bf_idx"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -6,13 +6,15 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('analytics', '0001_initial'),
|
("analytics", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='hit',
|
model_name="hit",
|
||||||
name='tracker',
|
name="tracker",
|
||||||
field=models.TextField(choices=[('JS', 'JavaScript'), ('PIXEL', 'Pixel (noscript)')]),
|
field=models.TextField(
|
||||||
|
choices=[("JS", "JavaScript"), ("PIXEL", "Pixel (noscript)")]
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -2,10 +2,10 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.shortcuts import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from core.models import Service
|
from core.models import Service
|
||||||
from django.shortcuts import reverse
|
|
||||||
|
|
||||||
|
|
||||||
def _default_uuid():
|
def _default_uuid():
|
||||||
|
@ -6,8 +6,9 @@ import user_agents
|
|||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.utils import timezone
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from core.models import Service
|
from core.models import Service
|
||||||
|
|
||||||
from .models import Hit, Session
|
from .models import Hit, Session
|
||||||
|
@ -5,10 +5,12 @@ from .models import Service, User
|
|||||||
|
|
||||||
admin.site.register(User, UserAdmin)
|
admin.site.register(User, UserAdmin)
|
||||||
|
|
||||||
|
|
||||||
class ServiceAdmin(admin.ModelAdmin):
|
class ServiceAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "link", "owner", "status")
|
list_display = ("name", "link", "owner", "status")
|
||||||
list_display_links = ("name",)
|
list_display_links = ("name",)
|
||||||
list_filter = ("status",)
|
list_filter = ("status",)
|
||||||
search_fields = ("name", "link", "owner")
|
search_fields = ("name", "link", "owner")
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Service, ServiceAdmin)
|
admin.site.register(Service, ServiceAdmin)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class CoreConfig(AppConfig):
|
class CoreConfig(AppConfig):
|
||||||
name = "core"
|
name = "core"
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
# Generated by Django 3.0.5 on 2020-04-14 14:40
|
# Generated by Django 3.0.5 on 2020-04-14 14:40
|
||||||
|
|
||||||
import core.models
|
|
||||||
from django.conf import settings
|
|
||||||
import django.contrib.auth.models
|
import django.contrib.auth.models
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import django.utils.timezone
|
import django.utils.timezone
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import core.models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -13,47 +14,146 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('auth', '0011_update_proxy_permissions'),
|
("auth", "0011_update_proxy_permissions"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='User',
|
name="User",
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
(
|
||||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
"id",
|
||||||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
models.AutoField(
|
||||||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
auto_created=True,
|
||||||
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
|
primary_key=True,
|
||||||
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
|
serialize=False,
|
||||||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
verbose_name="ID",
|
||||||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
),
|
||||||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
),
|
||||||
('username', models.TextField(default=core.models._default_uuid, unique=True)),
|
("password", models.CharField(max_length=128, verbose_name="password")),
|
||||||
('email', models.EmailField(max_length=254, unique=True)),
|
(
|
||||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
"last_login",
|
||||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
models.DateTimeField(
|
||||||
|
blank=True, null=True, verbose_name="last login"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"is_superuser",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text="Designates that this user has all permissions without explicitly assigning them.",
|
||||||
|
verbose_name="superuser status",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"first_name",
|
||||||
|
models.CharField(
|
||||||
|
blank=True, max_length=30, verbose_name="first name"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"last_name",
|
||||||
|
models.CharField(
|
||||||
|
blank=True, max_length=150, verbose_name="last name"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"is_staff",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text="Designates whether the user can log into this admin site.",
|
||||||
|
verbose_name="staff status",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"is_active",
|
||||||
|
models.BooleanField(
|
||||||
|
default=True,
|
||||||
|
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
|
||||||
|
verbose_name="active",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"date_joined",
|
||||||
|
models.DateTimeField(
|
||||||
|
default=django.utils.timezone.now, verbose_name="date joined"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"username",
|
||||||
|
models.TextField(default=core.models._default_uuid, unique=True),
|
||||||
|
),
|
||||||
|
("email", models.EmailField(max_length=254, unique=True)),
|
||||||
|
(
|
||||||
|
"groups",
|
||||||
|
models.ManyToManyField(
|
||||||
|
blank=True,
|
||||||
|
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
|
||||||
|
related_name="user_set",
|
||||||
|
related_query_name="user",
|
||||||
|
to="auth.Group",
|
||||||
|
verbose_name="groups",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user_permissions",
|
||||||
|
models.ManyToManyField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Specific permissions for this user.",
|
||||||
|
related_name="user_set",
|
||||||
|
related_query_name="user",
|
||||||
|
to="auth.Permission",
|
||||||
|
verbose_name="user permissions",
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name': 'user',
|
"verbose_name": "user",
|
||||||
'verbose_name_plural': 'users',
|
"verbose_name_plural": "users",
|
||||||
'abstract': False,
|
"abstract": False,
|
||||||
},
|
},
|
||||||
managers=[
|
managers=[("objects", django.contrib.auth.models.UserManager()),],
|
||||||
('objects', django.contrib.auth.models.UserManager()),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Service',
|
name="Service",
|
||||||
fields=[
|
fields=[
|
||||||
('uuid', models.UUIDField(default=core.models._default_uuid, primary_key=True, serialize=False)),
|
(
|
||||||
('name', models.TextField(max_length=64)),
|
"uuid",
|
||||||
('created', models.DateTimeField(auto_now_add=True)),
|
models.UUIDField(
|
||||||
('link', models.URLField(blank=True)),
|
default=core.models._default_uuid,
|
||||||
('origins', models.TextField(default='*')),
|
primary_key=True,
|
||||||
('status', models.CharField(choices=[('AC', 'Active'), ('AR', 'Archived')], db_index=True, default='AC', max_length=2)),
|
serialize=False,
|
||||||
('collaborators', models.ManyToManyField(blank=True, related_name='collaborating_services', to=settings.AUTH_USER_MODEL)),
|
),
|
||||||
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owning_services', to=settings.AUTH_USER_MODEL)),
|
),
|
||||||
|
("name", models.TextField(max_length=64)),
|
||||||
|
("created", models.DateTimeField(auto_now_add=True)),
|
||||||
|
("link", models.URLField(blank=True)),
|
||||||
|
("origins", models.TextField(default="*")),
|
||||||
|
(
|
||||||
|
"status",
|
||||||
|
models.CharField(
|
||||||
|
choices=[("AC", "Active"), ("AR", "Archived")],
|
||||||
|
db_index=True,
|
||||||
|
default="AC",
|
||||||
|
max_length=2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"collaborators",
|
||||||
|
models.ManyToManyField(
|
||||||
|
blank=True,
|
||||||
|
related_name="collaborating_services",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"owner",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="owning_services",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -6,12 +6,11 @@ from django.db import migrations
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0001_initial'),
|
("core", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='service',
|
name="service", options={"ordering": ["name", "uuid"]},
|
||||||
options={'ordering': ['name', 'uuid']},
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -6,8 +6,8 @@ from django.contrib.auth.models import AbstractUser
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.functions import TruncDate
|
from django.db.models.functions import TruncDate
|
||||||
from django.db.utils import NotSupportedError
|
from django.db.utils import NotSupportedError
|
||||||
from django.utils import timezone
|
|
||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
def _default_uuid():
|
def _default_uuid():
|
||||||
@ -179,7 +179,4 @@ class Service(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse(
|
return reverse("dashboard:service", kwargs={"pk": self.pk},)
|
||||||
"dashboard:service",
|
|
||||||
kwargs={"pk": self.pk},
|
|
||||||
)
|
|
||||||
|
@ -5,5 +5,7 @@ from django.views.generic import RedirectView
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", RedirectView.as_view(url=reverse_lazy("dashboard:dashboard")), name="index"),
|
path(
|
||||||
|
"", RedirectView.as_view(url=reverse_lazy("dashboard:dashboard")), name="index"
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
|
||||||
class IndexView(TemplateView):
|
class IndexView(TemplateView):
|
||||||
template_name = "dashboard/pages/index.html"
|
template_name = "dashboard/pages/index.html"
|
@ -1,11 +1,13 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class DashboardConfig(AppConfig):
|
class DashboardConfig(AppConfig):
|
||||||
name = 'dashboard'
|
name = "dashboard"
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
if not settings.ACCOUNT_SIGNUPS_ENABLED:
|
if not settings.ACCOUNT_SIGNUPS_ENABLED:
|
||||||
# Normally you'd do this in settings.py, but this must be done _after_ apps are enabled
|
# Normally you'd do this in settings.py, but this must be done _after_ apps are enabled
|
||||||
from allauth.account.adapter import DefaultAccountAdapter
|
from allauth.account.adapter import DefaultAccountAdapter
|
||||||
|
|
||||||
DefaultAccountAdapter.is_open_for_signup = lambda k, v: False
|
DefaultAccountAdapter.is_open_for_signup = lambda k, v: False
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
|
from django.db.models import Q
|
||||||
from django.shortcuts import get_object_or_404, reverse
|
from django.shortcuts import get_object_or_404, reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
|
||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
@ -11,13 +12,13 @@ from django.views.generic import (
|
|||||||
UpdateView,
|
UpdateView,
|
||||||
)
|
)
|
||||||
from rules.contrib.views import PermissionRequiredMixin
|
from rules.contrib.views import PermissionRequiredMixin
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from analytics.models import Session
|
from analytics.models import Session
|
||||||
|
from core.models import Service
|
||||||
|
|
||||||
from .forms import ServiceForm
|
from .forms import ServiceForm
|
||||||
from .mixins import DateRangeMixin
|
from .mixins import DateRangeMixin
|
||||||
from core.models import Service
|
|
||||||
|
|
||||||
class DashboardView(LoginRequiredMixin, DateRangeMixin, TemplateView):
|
class DashboardView(LoginRequiredMixin, DateRangeMixin, TemplateView):
|
||||||
template_name = "dashboard/pages/dashboard.html"
|
template_name = "dashboard/pages/dashboard.html"
|
||||||
@ -77,7 +78,9 @@ class ServiceUpdateView(
|
|||||||
return reverse("dashboard:service", kwargs={"pk": self.object.uuid})
|
return reverse("dashboard:service", kwargs={"pk": self.object.uuid})
|
||||||
|
|
||||||
|
|
||||||
class ServiceDeleteView(LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, DeleteView):
|
class ServiceDeleteView(
|
||||||
|
LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, DeleteView
|
||||||
|
):
|
||||||
model = Service
|
model = Service
|
||||||
form_class = ServiceForm
|
form_class = ServiceForm
|
||||||
template_name = "dashboard/pages/service_delete.html"
|
template_name = "dashboard/pages/service_delete.html"
|
||||||
|
Loading…
Reference in New Issue
Block a user