mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00

* Resolve F541 errors * Resolve F841 errors * Resolve F811 errors * Resolve F901 errors * Resolve E714 errors * Ignore F821 errors for GraphQL mixins * Replace pycodestyle with ruff * Move ignores to ruff.toml
25 lines
680 B
Python
25 lines
680 B
Python
from typing import Annotated, List
|
|
|
|
import strawberry
|
|
import strawberry_django
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
from core.models import ObjectChange
|
|
|
|
__all__ = (
|
|
'ChangelogMixin',
|
|
)
|
|
|
|
|
|
@strawberry.type
|
|
class ChangelogMixin:
|
|
|
|
@strawberry_django.field
|
|
def changelog(self, info) -> List[Annotated["ObjectChangeType", strawberry.lazy('.types')]]: # noqa: F821
|
|
content_type = ContentType.objects.get_for_model(self)
|
|
object_changes = ObjectChange.objects.filter(
|
|
changed_object_type=content_type,
|
|
changed_object_id=self.pk
|
|
)
|
|
return object_changes.restrict(info.context.request.user, 'view')
|