Fix endpoint fields

This commit is contained in:
koalasat 2024-06-29 17:09:04 +02:00
parent 9855e5d1f2
commit 53bdb30166
5 changed files with 38 additions and 11 deletions

View File

@ -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),
),
]

View File

@ -491,10 +491,17 @@ class OrderDetailSerializer(serializers.ModelSerializer):
class ListNotificationSerializer(serializers.ModelSerializer): class ListNotificationSerializer(serializers.ModelSerializer):
status = serializers.SerializerMethodField(
help_text="The `status` of the order when the notification was trigered",
)
class Meta: class Meta:
model = Notification model = Notification
fields = ("title", "description", "order_id", "status") fields = ("title", "description", "order_id", "status")
def get_status(self, notification) -> int:
return notification.order.status
class OrderPublicSerializer(serializers.ModelSerializer): class OrderPublicSerializer(serializers.ModelSerializer):
maker_nick = serializers.CharField(required=False) maker_nick = serializers.CharField(required=False)

View File

@ -761,11 +761,7 @@ class NotificationsView(ListAPIView):
notification_data = [] notification_data = []
for notification in queryset: for notification in queryset:
data = self.serializer_class(notification).data data = self.serializer_class(notification).data
data["title"] = str(notification.title)
data["description"] = str(notification.description)
data["order_id"] = notification.order.id data["order_id"] = notification.order.id
data["status"] = notification.order.status
notification_data.append(data) notification_data.append(data)
return Response(notification_data, status=status.HTTP_200_OK) return Response(notification_data, status=status.HTTP_200_OK)

View File

@ -15,7 +15,7 @@ version: '3.9'
services: services:
bitcoind: bitcoind:
image: ruimarinho/bitcoin-core:${BITCOIND_VERSION:-24.0.1}-alpine image: ruimarinho/bitcoin-core:${BITCOIND_VERSION:-24.0.1}-alpine
container_name: btc container_name: test-btc
restart: always restart: always
ports: ports:
- "8000:8000" - "8000:8000"
@ -50,7 +50,7 @@ services:
coordinator-LND: coordinator-LND:
image: lightninglabs/lnd:${LND_VERSION:-v0.17.0-beta} image: lightninglabs/lnd:${LND_VERSION:-v0.17.0-beta}
container_name: coordinator-LND container_name: test-coordinator-LND
restart: always restart: always
volumes: volumes:
- bitcoin:/root/.bitcoin/ - bitcoin:/root/.bitcoin/
@ -83,7 +83,7 @@ services:
coordinator-CLN: coordinator-CLN:
image: elementsproject/lightningd:${CLN_VERSION:-v24.05} image: elementsproject/lightningd:${CLN_VERSION:-v24.05}
restart: always restart: always
container_name: coordinator-CLN container_name: test-coordinator-CLN
environment: environment:
LIGHTNINGD_NETWORK: 'regtest' LIGHTNINGD_NETWORK: 'regtest'
volumes: volumes:
@ -97,7 +97,7 @@ services:
robot-LND: robot-LND:
image: lightninglabs/lnd:${LND_VERSION:-v0.17.0-beta} image: lightninglabs/lnd:${LND_VERSION:-v0.17.0-beta}
container_name: robot-LND container_name: test-robot-LND
restart: always restart: always
volumes: volumes:
- bitcoin:/root/.bitcoin/ - bitcoin:/root/.bitcoin/
@ -129,7 +129,7 @@ services:
redis: redis:
image: redis:${REDIS_VERSION:-7.2.1}-alpine image: redis:${REDIS_VERSION:-7.2.1}-alpine
container_name: redis container_name: test-redis
restart: always restart: always
volumes: volumes:
- redisdata:/data - redisdata:/data
@ -141,7 +141,7 @@ services:
args: args:
DEVELOPMENT: True DEVELOPMENT: True
image: backend-image image: backend-image
container_name: coordinator container_name: test-coordinator
restart: always restart: always
environment: environment:
DEVELOPMENT: True DEVELOPMENT: True
@ -171,7 +171,7 @@ services:
postgres: postgres:
image: postgres:${POSTGRES_VERSION:-14.2}-alpine image: postgres:${POSTGRES_VERSION:-14.2}-alpine
container_name: sql container_name: test-sql
restart: always restart: always
environment: environment:
POSTGRES_PASSWORD: 'example' POSTGRES_PASSWORD: 'example'

View File

@ -1106,8 +1106,13 @@ components:
order_id: order_id:
type: integer type: integer
readOnly: true readOnly: true
status:
type: integer
readOnly: true
description: The `status` of the order when the notification was trigered
required: required:
- order_id - order_id
- status
ListOrder: ListOrder:
type: object type: object
properties: properties: