Skip to content

Commit

Permalink
core: migration: use django native JSONField
Browse files Browse the repository at this point in the history
  • Loading branch information
mik3y committed Jul 15, 2022
1 parent d9a1316 commit fd43ddd
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 60 deletions.
17 changes: 1 addition & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions pykeg/core/jsonfield.py

This file was deleted.

8 changes: 3 additions & 5 deletions pykeg/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.db import models, migrations
import pykeg.core.fields
import pykeg.core.models
Expand All @@ -8,7 +6,7 @@
import django.utils.timezone
from django.conf import settings
import django.core.validators
import pykeg.core.jsonfield
import pykeg.util.kbjson


class Migration(migrations.Migration):
Expand Down Expand Up @@ -1771,7 +1769,7 @@ class Migration(migrations.Migration):
),
("plugin_name", models.CharField(help_text="Plugin short name", max_length=127)),
("key", models.CharField(max_length=127)),
("value", pykeg.core.jsonfield.JSONField()),
("value", models.JSONField(encoder=pykeg.util.kbjson.JSONEncoder)),
],
options={},
bases=(models.Model,),
Expand All @@ -1786,7 +1784,7 @@ class Migration(migrations.Migration):
),
),
("time", models.DateTimeField(default=django.utils.timezone.now)),
("stats", pykeg.core.jsonfield.JSONField()),
("stats", models.JSONField(encoder=pykeg.util.kbjson.JSONEncoder)),
(
"is_first",
models.BooleanField(
Expand Down
2 changes: 0 additions & 2 deletions pykeg/core/migrations/0002_version_1_2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.db import models, migrations


Expand Down
68 changes: 48 additions & 20 deletions pykeg/core/migrations/0003_version_1_3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
# Generated by Django 3.2 on 2022-07-15 13:04

from django.db import migrations, models
from django.conf import settings
import django.contrib.auth.models
from django.db import migrations, models
import django.db.models.deletion
import pykeg.util.kbjson


class Migration(migrations.Migration):
Expand All @@ -28,31 +31,28 @@ class Migration(migrations.Migration):
model_name="keg",
name="keg_type",
field=models.CharField(
default="half-barrel",
help_text="Keg container type, used to initialize keg's full volume",
max_length=32,
choices=[
("mini", "Mini Keg (5 L)"),
("sixth", "Sixth Barrel (5.17 gal)"),
("corny-2_5-gal", "Corny Keg (2.5 gal)"),
("corny-3-gal", "Corny Keg (3.0 gal)"),
("corny", "Corny Keg (5 gal)"),
("half-barrel", "Half Barrel (15.5 gal)"),
("sixth", "Sixth Barrel (5.17 gal)"),
("euro-30-liter", "European DIN (30 L)"),
("euro", "European Full Barrel (100 L)"),
("corny-3-gal", "Corny Keg (3.0 gal)"),
("other", "Other"),
("euro-half", "European Half Barrel (50 L)"),
("quarter", "Quarter Barrel (7.75 gal)"),
("euro", "European Full Barrel (100 L)"),
("half-barrel", "Half Barrel (15.5 gal)"),
("other", "Other"),
],
default="half-barrel",
help_text="Keg container type, used to initialize keg's full volume",
max_length=32,
),
),
migrations.AlterField(
model_name="kegbotsite",
name="timezone",
field=models.CharField(
default="UTC",
help_text="Time zone for this system.",
max_length=255,
choices=[
("Africa/Abidjan", "Africa/Abidjan"),
("Africa/Accra", "Africa/Accra"),
Expand Down Expand Up @@ -159,7 +159,6 @@ class Migration(migrations.Migration):
("America/Fort_Nelson", "America/Fort_Nelson"),
("America/Fortaleza", "America/Fortaleza"),
("America/Glace_Bay", "America/Glace_Bay"),
("America/Godthab", "America/Godthab"),
("America/Goose_Bay", "America/Goose_Bay"),
("America/Grand_Turk", "America/Grand_Turk"),
("America/Grenada", "America/Grenada"),
Expand Down Expand Up @@ -213,6 +212,7 @@ class Migration(migrations.Migration):
("America/North_Dakota/Beulah", "America/North_Dakota/Beulah"),
("America/North_Dakota/Center", "America/North_Dakota/Center"),
("America/North_Dakota/New_Salem", "America/North_Dakota/New_Salem"),
("America/Nuuk", "America/Nuuk"),
("America/Ojinaga", "America/Ojinaga"),
("America/Panama", "America/Panama"),
("America/Pangnirtung", "America/Pangnirtung"),
Expand All @@ -222,6 +222,7 @@ class Migration(migrations.Migration):
("America/Port_of_Spain", "America/Port_of_Spain"),
("America/Porto_Velho", "America/Porto_Velho"),
("America/Puerto_Rico", "America/Puerto_Rico"),
("America/Punta_Arenas", "America/Punta_Arenas"),
("America/Rainy_River", "America/Rainy_River"),
("America/Rankin_Inlet", "America/Rankin_Inlet"),
("America/Recife", "America/Recife"),
Expand Down Expand Up @@ -271,6 +272,7 @@ class Migration(migrations.Migration):
("Asia/Aqtau", "Asia/Aqtau"),
("Asia/Aqtobe", "Asia/Aqtobe"),
("Asia/Ashgabat", "Asia/Ashgabat"),
("Asia/Atyrau", "Asia/Atyrau"),
("Asia/Baghdad", "Asia/Baghdad"),
("Asia/Bahrain", "Asia/Bahrain"),
("Asia/Baku", "Asia/Baku"),
Expand All @@ -287,6 +289,7 @@ class Migration(migrations.Migration):
("Asia/Dili", "Asia/Dili"),
("Asia/Dubai", "Asia/Dubai"),
("Asia/Dushanbe", "Asia/Dushanbe"),
("Asia/Famagusta", "Asia/Famagusta"),
("Asia/Gaza", "Asia/Gaza"),
("Asia/Hebron", "Asia/Hebron"),
("Asia/Ho_Chi_Minh", "Asia/Ho_Chi_Minh"),
Expand Down Expand Up @@ -320,8 +323,8 @@ class Migration(migrations.Migration):
("Asia/Pontianak", "Asia/Pontianak"),
("Asia/Pyongyang", "Asia/Pyongyang"),
("Asia/Qatar", "Asia/Qatar"),
("Asia/Qostanay", "Asia/Qostanay"),
("Asia/Qyzylorda", "Asia/Qyzylorda"),
("Asia/Rangoon", "Asia/Rangoon"),
("Asia/Riyadh", "Asia/Riyadh"),
("Asia/Sakhalin", "Asia/Sakhalin"),
("Asia/Samarkand", "Asia/Samarkand"),
Expand All @@ -342,6 +345,7 @@ class Migration(migrations.Migration):
("Asia/Vientiane", "Asia/Vientiane"),
("Asia/Vladivostok", "Asia/Vladivostok"),
("Asia/Yakutsk", "Asia/Yakutsk"),
("Asia/Yangon", "Asia/Yangon"),
("Asia/Yekaterinburg", "Asia/Yekaterinburg"),
("Asia/Yerevan", "Asia/Yerevan"),
("Atlantic/Azores", "Atlantic/Azores"),
Expand All @@ -357,7 +361,6 @@ class Migration(migrations.Migration):
("Australia/Adelaide", "Australia/Adelaide"),
("Australia/Brisbane", "Australia/Brisbane"),
("Australia/Broken_Hill", "Australia/Broken_Hill"),
("Australia/Currie", "Australia/Currie"),
("Australia/Darwin", "Australia/Darwin"),
("Australia/Eucla", "Australia/Eucla"),
("Australia/Hobart", "Australia/Hobart"),
Expand Down Expand Up @@ -414,6 +417,7 @@ class Migration(migrations.Migration):
("Europe/Samara", "Europe/Samara"),
("Europe/San_Marino", "Europe/San_Marino"),
("Europe/Sarajevo", "Europe/Sarajevo"),
("Europe/Saratov", "Europe/Saratov"),
("Europe/Simferopol", "Europe/Simferopol"),
("Europe/Skopje", "Europe/Skopje"),
("Europe/Sofia", "Europe/Sofia"),
Expand Down Expand Up @@ -450,7 +454,6 @@ class Migration(migrations.Migration):
("Pacific/Chuuk", "Pacific/Chuuk"),
("Pacific/Easter", "Pacific/Easter"),
("Pacific/Efate", "Pacific/Efate"),
("Pacific/Enderbury", "Pacific/Enderbury"),
("Pacific/Fakaofo", "Pacific/Fakaofo"),
("Pacific/Fiji", "Pacific/Fiji"),
("Pacific/Funafuti", "Pacific/Funafuti"),
Expand All @@ -459,7 +462,7 @@ class Migration(migrations.Migration):
("Pacific/Guadalcanal", "Pacific/Guadalcanal"),
("Pacific/Guam", "Pacific/Guam"),
("Pacific/Honolulu", "Pacific/Honolulu"),
("Pacific/Johnston", "Pacific/Johnston"),
("Pacific/Kanton", "Pacific/Kanton"),
("Pacific/Kiritimati", "Pacific/Kiritimati"),
("Pacific/Kosrae", "Pacific/Kosrae"),
("Pacific/Kwajalein", "Pacific/Kwajalein"),
Expand Down Expand Up @@ -491,16 +494,41 @@ class Migration(migrations.Migration):
("US/Pacific", "US/Pacific"),
("UTC", "UTC"),
],
default="UTC",
help_text="Time zone for this system.",
max_length=255,
),
),
migrations.AlterField(
model_name="plugindata",
name="value",
field=models.JSONField(encoder=pykeg.util.kbjson.JSONEncoder),
),
migrations.AlterField(
model_name="stats",
name="stats",
field=models.JSONField(encoder=pykeg.util.kbjson.JSONEncoder),
),
migrations.AlterField(
model_name="systemevent",
name="user",
field=models.ForeignKey(
blank=True,
help_text="User responsible for the event, if any.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="events",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="user",
name="email",
field=models.EmailField(max_length=254, verbose_name="email address", blank=True),
field=models.EmailField(blank=True, max_length=254, verbose_name="email address"),
),
migrations.AlterField(
model_name="user",
name="last_login",
field=models.DateTimeField(null=True, verbose_name="last login", blank=True),
field=models.DateTimeField(blank=True, null=True, verbose_name="last login"),
),
]
5 changes: 2 additions & 3 deletions pykeg/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
signals,
time_series,
)
from pykeg.core.jsonfield import JSONField
from pykeg.core.util import CtoF, get_version
from pykeg.util import kbjson, units
from pykeg.util.email import build_message
Expand Down Expand Up @@ -1941,7 +1940,7 @@ class Stats(models.Model):
"""

time = models.DateTimeField(default=timezone.now)
stats = JSONField(dump_kwargs={"cls": kbjson.JSONEncoder})
stats = models.JSONField(encoder=kbjson.JSONEncoder)
drink = models.ForeignKey(Drink, on_delete=models.CASCADE)

is_first = models.BooleanField(
Expand Down Expand Up @@ -2288,4 +2287,4 @@ class Meta(object):

plugin_name = models.CharField(max_length=127, help_text="Plugin short name")
key = models.CharField(max_length=127)
value = JSONField()
value = models.JSONField(encoder=kbjson.JSONEncoder)
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ django-registration = "*"
gunicorn = "*"
httplib2 = "*"
isodate = "*"
jsonfield = "*"
oauthlib = "*"
pilkit = "*"
protobuf = "3.20.0"
Expand Down

0 comments on commit fd43ddd

Please sign in to comment.