Skip to content

Commit

Permalink
Fix: migrations being generated when settings are altered (#37)
Browse files Browse the repository at this point in the history
* fix: migrations being generated when settings are altered

* fix: fix deepsource warnings

---------

Co-authored-by: Caio Fontes <caio.castro@mindsight.com.br>
  • Loading branch information
Caiofcas and Caio Fontes authored May 3, 2023
1 parent 74ac545 commit 9560017
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions durin/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class DurinConfig(AppConfig):
name = "durin"
default_auto_field = "django.db.models.BigAutoField"
23 changes: 23 additions & 0 deletions durin/migrations/0003_alter_client_token_ttl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1.3 on 2022-11-25 18:39

from django.db import migrations, models
import durin.models


class Migration(migrations.Migration):

dependencies = [
("durin", "0002_client_throttlerate"),
]

operations = [
migrations.AlterField(
model_name="client",
name="token_ttl",
field=models.DurationField(
default=durin.models.get_DEFAULT_TOKEN_TTL,
help_text="\n Token Time To Live (TTL) in timedelta. Format: <code>DAYS HH:MM:SS</code>.\n ",
verbose_name="Token Time To Live (TTL)",
),
),
]
7 changes: 6 additions & 1 deletion durin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def _create_token_string() -> str:
).decode()


def get_DEFAULT_TOKEN_TTL():
"""Default token TTL value."""
return durin_settings.DEFAULT_TOKEN_TTL


class Client(models.Model):
"""
Identifier to represent any API client/browser that consumes your RESTful API.
Expand All @@ -41,7 +46,7 @@ class Client(models.Model):
#: Token Time To Live (TTL) in timedelta. Format: ``DAYS HH:MM:SS``.
token_ttl = models.DurationField(
null=False,
default=durin_settings.DEFAULT_TOKEN_TTL,
default=get_DEFAULT_TOKEN_TTL,
verbose_name=_("Token Time To Live (TTL)"),
help_text=_(
"""
Expand Down

0 comments on commit 9560017

Please sign in to comment.