Commit 0fdf0d90 authored by Jean-samuel TETTEKPOE's avatar Jean-samuel TETTEKPOE
Browse files

Solve serializer problem

parent 04242a20
Pipeline #9080 failed with stage
in 37 seconds
from datetime import date, timedelta
from mock import Mock
from django.db import models
from django.db.models import Count, F, Sum, Prefetch
from django.db.models import Count, F, Sum, Prefetch, fields
from rest_framework import viewsets, serializers, decorators
from rest_framework.response import Response
from rest_framework.decorators import action
......@@ -72,6 +72,7 @@ def makeAgiosTransaction(bar, account, amount):
class BarSerializer(serializers.ModelSerializer):
class Meta:
model = Bar
fields = '__all__'
_type = VirtualField("Bar")
settings = serializers.PrimaryKeyRelatedField(read_only=True)
count_accounts = serializers.IntegerField(read_only=True)
......
from django.db import models
from django.db.models import fields
from bars_django.utils import VirtualField, permission_logic, get_root_bar, CurrentBarCreateOnlyDefault
from rest_framework import viewsets, serializers
......@@ -41,6 +42,7 @@ class Role(models.Model):
class RoleSerializer(serializers.ModelSerializer):
class Meta:
model = Role
fields = '__all__'
_type = VirtualField("Role")
bar = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentBarCreateOnlyDefault())
perms = serializers.ListField(child=serializers.CharField(max_length=127), read_only=True, source='get_permissions')
......
from django.http import Http404
from django.db import models
from django.db.models import Prefetch
from django.db.models import Prefetch, fields
from rest_framework import viewsets, serializers, permissions
from rest_framework.response import Response
from rest_framework.serializers import ValidationError
......@@ -40,6 +40,7 @@ class BuyItem(models.Model):
class BuyItemSerializer(serializers.ModelSerializer):
class Meta:
model = BuyItem
fields = '__all__'
_type = VirtualField("BuyItem")
def to_representation(self, buyitem):
......
from django.http import Http404
from django.db import models
from django.db.models import Sum, F, Prefetch, Value as V
from django.db.models import Sum, F, Prefetch, Value as V, fields
from rest_framework import viewsets, serializers
from bars_django.utils import VirtualField, permission_logic
from rest_framework.response import Response
......@@ -34,6 +34,7 @@ class ItemDetails(models.Model):
class ItemDetailsSerializer(serializers.ModelSerializer):
class Meta:
model = ItemDetails
fields = '__all__'
_type = VirtualField("ItemDetails")
def to_representation(self, itemdetails):
......
from django.http import Http404, HttpResponseBadRequest
from django.db import models
from django.db.models import Sum, F, Prefetch
from django.db.models import Sum, F, Prefetch, fields
import datetime
from django.utils.timezone import utc
from rest_framework import viewsets, serializers, exceptions
......@@ -94,6 +94,7 @@ class SellItem(models.Model):
class SellItemSerializer(serializers.ModelSerializer):
class Meta:
model = SellItem
fields = '__all__'
read_only_fields = ("id", "bar")
extra_kwargs = {'stockitems': {'required': False},
'unit_factor': {'required': False}}
......
......@@ -28,6 +28,7 @@ class SuggestedItem(models.Model):
class SuggestedItemSerializer(serializers.ModelSerializer):
class Meta:
model = SuggestedItem
fields = '__all__'
_type = VirtualField("SuggestedItem")
bar = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentBarCreateOnlyDefault())
......
......@@ -77,6 +77,7 @@ class MenuSerializer(serializers.ModelSerializer):
class Meta:
model = Menu
fields = '__all__'
read_only_fields = ('bar', 'user', )
def create(self, data):
......
......@@ -29,6 +29,7 @@ class News(models.Model):
class NewsSerializer(serializers.ModelSerializer):
class Meta:
model = News
fields = '__all__'
_type = VirtualField("News")
bar = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentBarCreateOnlyDefault())
......
......@@ -26,7 +26,7 @@ class TransactionOperationTests(APITestCase):
self.user, _ = User.objects.get_or_create(username='user')
self.user.role_set.all().delete()
self.user = reload(self.user)
self.user.refresh_from_db()
self.account, _ = Account.objects.get_or_create(bar=self.bar, owner=self.user)
self.account.money = 100
self.account.save()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment