-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from betagouv/mixin-cleaning
Nettoyage (partiel) des mixins / behaviours
- Loading branch information
Showing
21 changed files
with
102 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from simple_history.admin import SimpleHistoryAdmin | ||
|
||
|
||
class IngredientAdminWithHistoryChangedFields(SimpleHistoryAdmin): | ||
history_list_display = ['changed_fields'] | ||
class IngredientAdminHistorisableChangedFields(SimpleHistoryAdmin): | ||
history_list_display = ["changed_fields"] | ||
|
||
def changed_fields(self, obj): | ||
if obj.prev_record: | ||
delta = obj.diff_against(obj.prev_record) | ||
return delta.changed_fields | ||
return None | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from .auto_validable import AutoValidable # noqa: F401 | ||
from .time_stampable import TimeStampable # noqa: F401 | ||
from .historisable import Historisable # noqa: F401 | ||
from .deactivable import Deactivable, DeactivableQuerySet # noqa: F401 | ||
from .expirable import Expirable, ExpirableQuerySet # noqa: F401 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.db import models | ||
from simple_history.models import HistoricalRecords | ||
|
||
|
||
class Historisable(models.Model): | ||
class Meta: | ||
abstract = True | ||
|
||
history = HistoricalRecords(inherit=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
|
||
|
||
class TimeStampableQueryset(models.query.QuerySet): | ||
class Meta: | ||
abstract = True | ||
|
||
def created_between(self, i_start, i_end): | ||
""" | ||
Returns all objects created between the provided interval | ||
""" | ||
|
||
assert i_start <= i_end | ||
return self.filter(creation_date__lte=i_end, creation_date__gte=i_start) | ||
|
||
|
||
class TimeStampable(models.Model): | ||
class Meta: | ||
abstract = True | ||
|
||
creation_date = models.DateTimeField(auto_now_add=True) | ||
modification_date = models.DateTimeField(auto_now=True) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tokens/migrations/0003_remove_magiclinktoken_created_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 5.0.3 on 2024-03-26 13:39 | ||
|
||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("tokens", "0002_alter_magiclinktoken_usage"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="magiclinktoken", | ||
name="created", | ||
), | ||
migrations.RemoveField( | ||
model_name="magiclinktoken", | ||
name="modified", | ||
), | ||
migrations.AddField( | ||
model_name="magiclinktoken", | ||
name="creation_date", | ||
field=models.DateTimeField( | ||
auto_now_add=True, default=django.utils.timezone.now | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="magiclinktoken", | ||
name="modification_date", | ||
field=models.DateTimeField(auto_now=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters