Skip to content

Commit

Permalink
Remove use of deprecated pytz, self.assertEquals and index_together
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Dec 5, 2023
1 parent b3ca9f5 commit c15bf53
Show file tree
Hide file tree
Showing 12 changed files with 556 additions and 516 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.8 on 2023-12-05 16:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("dashblocks", "0011_alter_dashblock_index_together_and_more"),
]

operations = [
migrations.RenameIndex(
model_name="dashblock",
new_name="dashblocks__org_id_024805_idx",
old_fields=("org", "is_active", "dashblock_type", "priority"),
),
migrations.RenameIndex(
model_name="dashblocktype",
new_name="dashblocks__slug_c0c6c6_idx",
old_fields=("slug", "name"),
),
]
8 changes: 6 additions & 2 deletions dash/dashblocks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def __str__(self):

class Meta:
ordering = ["name"]
index_together = ("slug", "name")
indexes = [
models.Index(fields=["slug", "name"])
]


class DashBlock(SmartModel):
Expand Down Expand Up @@ -149,7 +151,9 @@ def __str__(self):

class Meta:
ordering = ["dashblock_type", "title"]
index_together = ("org", "is_active", "dashblock_type", "priority")
indexes = [
models.Index(fields=["org", "is_active", "dashblock_type", "priority"])
]


class DashBlockImage(SmartModel):
Expand Down
2 changes: 1 addition & 1 deletion dash/orgs/management/commands/orgtasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
from datetime import timezone

from dash.orgs.models import Org, TaskState

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.8 on 2023-12-05 16:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("orgs", "0031_alter_orgbackend_index_together"),
]

operations = [
migrations.RenameIndex(
model_name="orgbackend",
new_name="orgs_orgbac_org_id_607508_idx",
old_fields=("org", "is_active", "slug"),
),
]
4 changes: 3 additions & 1 deletion dash/orgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,6 @@ def __str__(self):

class Meta:
unique_together = ("org", "slug")
index_together = ("org", "is_active", "slug")
indexes = [
models.Index(fields=["org", "is_active", "slug"])
]
2 changes: 1 addition & 1 deletion dash/orgs/templatetags/dashorgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import phonenumbers

from django import template
from django.utils import timezone
from datetime import timezone

register = template.Library()

Expand Down
2 changes: 1 addition & 1 deletion dash/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def ms_to_datetime(ms):
Converts a millisecond accuracy timestamp to a datetime
"""
dt = datetime.datetime.utcfromtimestamp(ms / 1000)
return dt.replace(microsecond=(ms % 1000) * 1000).replace(tzinfo=timezone.utc)
return dt.replace(microsecond=(ms % 1000) * 1000).replace(tzinfo=datetime.timezone.utc)


def get_month_range(d=None):
Expand Down
3 changes: 1 addition & 2 deletions dash/utils/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import json
import zoneinfo
from datetime import datetime
from datetime import datetime, timezone
from itertools import chain

from django.core.cache import cache
from django.utils import timezone

from dash.test import DashTest

Expand Down
Loading

0 comments on commit c15bf53

Please sign in to comment.