Skip to content

Commit

Permalink
Fix endpoint fields
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Jun 29, 2024
1 parent 185d197 commit 0d45c4c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
19 changes: 19 additions & 0 deletions api/migrations/0048_alter_order_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.6 on 2024-06-29 14:07

import api.models.order
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0047_notification'),
]

operations = [
migrations.AlterField(
model_name='order',
name='reference',
field=models.UUIDField(default=api.models.order.custom_uuid, editable=False),
),
]
7 changes: 7 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,17 @@ class Meta:


class ListNotificationSerializer(serializers.ModelSerializer):
status = serializers.SerializerMethodField(
help_text="The `status` of the order when the notification was trigered",
)
class Meta:
model = Notification
fields = ("title", "description", "order_id", "status")

def get_status(self, notification) -> int:
return notification.order.status



class OrderPublicSerializer(serializers.ModelSerializer):
maker_nick = serializers.CharField(required=False)
Expand Down
4 changes: 0 additions & 4 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,7 @@ def get(self, request, format=None):
notification_data = []
for notification in queryset:
data = self.serializer_class(notification).data
data["title"] = str(notification.title)
data["description"] = str(notification.description)
data["order_id"] = notification.order.id
data["status"] = notification.order.status

notification_data.append(data)

return Response(notification_data, status=status.HTTP_200_OK)
Expand Down
5 changes: 5 additions & 0 deletions docs/assets/schemas/api-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,13 @@ components:
order_id:
type: integer
readOnly: true
status:
type: integer
readOnly: true
description: The `status` of the order when the notification was trigered
required:
- order_id
- status
ListOrder:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/MakerForm/AutocompletePayments.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useAutocomplete } from '@mui/base/useAutocomplete';
import useAutocomplete from '@mui/base/useAutocomplete';
import { styled } from '@mui/material/styles';
import {
Button,
Expand Down

0 comments on commit 0d45c4c

Please sign in to comment.