Misc cleanup

This commit is contained in:
Jeremy Stretch 2024-07-04 16:16:00 -04:00
parent ba11e97b1e
commit 6bec89d46b
4 changed files with 5 additions and 5 deletions

View File

@ -276,7 +276,7 @@ class NotificationListView(LoginRequiredMixin, generic.ObjectListView):
template_name = 'account/notifications.html'
def get_queryset(self, request):
return Notification.objects.filter(user=request.user)
return request.user.notifications.all()
def get_extra_context(self, request):
return {
@ -289,7 +289,7 @@ class SubscriptionListView(LoginRequiredMixin, generic.ObjectListView):
template_name = 'account/subscriptions.html'
def get_queryset(self, request):
return Subscription.objects.filter(user=request.user)
return request.user.subscriptions.all()
def get_extra_context(self, request):
return {

View File

@ -151,7 +151,6 @@ class NotificationViewSet(NetBoxModelViewSet):
class NotificationGroupViewSet(NetBoxModelViewSet):
metadata_class = ContentTypeMetadata
queryset = NotificationGroup.objects.all()
serializer_class = serializers.NotificationGroupSerializer

View File

@ -37,7 +37,7 @@ class Migration(migrations.Migration):
('created', models.DateTimeField(auto_now_add=True)),
('object_id', models.PositiveBigIntegerField()),
('object_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='contenttypes.contenttype')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'subscription',

View File

@ -176,7 +176,8 @@ class Subscription(models.Model):
)
user = models.ForeignKey(
to=settings.AUTH_USER_MODEL,
on_delete=models.CASCADE
on_delete=models.CASCADE,
related_name='subscriptions'
)
object_type = models.ForeignKey(
to='contenttypes.ContentType',