mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
[FR] Add last updated column for supplier parts (#4214)
* Move to updated Meta mixin * [FR] Add last updated column for supplier parts Fixes #3327 * add updated to table * bump API version * add missing migration * incremetn api ;-)
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.16 on 2023-01-15 14:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('common', '0015_newsfeedentry'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='notificationentry',
|
||||
name='updated',
|
||||
field=models.DateTimeField(auto_now=True, help_text='Timestamp of last update', null=True, verbose_name='Updated'),
|
||||
),
|
||||
]
|
@ -49,6 +49,25 @@ import order.validators
|
||||
logger = logging.getLogger('inventree')
|
||||
|
||||
|
||||
class MetaMixin(models.Model):
|
||||
"""A base class for InvenTree models to include shared meta fields.
|
||||
|
||||
Attributes:
|
||||
- updated: The last time this object was updated
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
"""Meta options for MetaMixin."""
|
||||
abstract = True
|
||||
|
||||
updated = models.DateTimeField(
|
||||
verbose_name=_('Updated'),
|
||||
help_text=_('Timestamp of last update'),
|
||||
auto_now=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
|
||||
class EmptyURLValidator(URLValidator):
|
||||
"""Validator for filed with url - that can be empty."""
|
||||
|
||||
@ -1875,7 +1894,7 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
||||
}
|
||||
|
||||
|
||||
class PriceBreak(models.Model):
|
||||
class PriceBreak(MetaMixin):
|
||||
"""Represents a PriceBreak model."""
|
||||
|
||||
class Meta:
|
||||
@ -2246,7 +2265,7 @@ class WebhookMessage(models.Model):
|
||||
)
|
||||
|
||||
|
||||
class NotificationEntry(models.Model):
|
||||
class NotificationEntry(MetaMixin):
|
||||
"""A NotificationEntry records the last time a particular notifaction was sent out.
|
||||
|
||||
It is recorded to ensure that notifications are not sent out "too often" to users.
|
||||
@ -2272,11 +2291,6 @@ class NotificationEntry(models.Model):
|
||||
uid = models.IntegerField(
|
||||
)
|
||||
|
||||
updated = models.DateTimeField(
|
||||
auto_now=True,
|
||||
null=False,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def check_recent(cls, key: str, uid: int, delta: timedelta):
|
||||
"""Test if a particular notification has been sent in the specified time period."""
|
||||
|
Reference in New Issue
Block a user