conflict resolution
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from companies.models import Company
|
from companies.models import Company
|
||||||
|
|
||||||
|
from drf_extra_fields.geo_fields import PointField
|
||||||
|
|
||||||
from utils.tag_serializers import TagListSerializerField, TaggitSerializer
|
from utils.tag_serializers import TagListSerializerField, TaggitSerializer
|
||||||
|
|
||||||
class CompanySerializer(TaggitSerializer, serializers.ModelSerializer):
|
class CompanySerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||||
|
|
||||||
tags = TagListSerializerField(required=False)
|
tags = TagListSerializerField(required=False)
|
||||||
|
geo = PointField(required=False, allow_null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Company
|
model = Company
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.core import serializers
|
|
||||||
from django.core.mail import EmailMessage
|
from django.core.mail import EmailMessage
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
@@ -61,6 +60,5 @@ class CompanyViewSet(viewsets.ModelViewSet):
|
|||||||
@permission_classes([IsAuthenticated,])
|
@permission_classes([IsAuthenticated,])
|
||||||
def my_company(request):
|
def my_company(request):
|
||||||
qs = Company.objects.filter(creator=request.user)
|
qs = Company.objects.filter(creator=request.user)
|
||||||
data = serializers.serialize('json', qs)
|
company_serializer = CompanySerializer(qs)
|
||||||
return Response(data=data)
|
return Response(data=company_serializer.data)
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class CustomUserSerializer(serializers.ModelSerializer):
|
class CustomUserSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.CustomUser
|
model = User
|
||||||
fields = ('email', 'full_name', 'role', 'is_active')
|
fields = ('email', 'full_name', 'role', 'is_active')
|
||||||
|
|
||||||
|
|
||||||
class CustomUserReadSerializer(serializers.ModelSerializer):
|
class CustomUserReadSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.CustomUser
|
model = User
|
||||||
fields = ('id', 'email', 'full_name', 'role', 'is_active', 'provider', 'notify')
|
fields = ('id', 'email', 'full_name', 'role', 'is_active', 'provider', 'notify')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import datetime
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core import serializers
|
|
||||||
from django.utils.http import urlsafe_base64_decode
|
from django.utils.http import urlsafe_base64_decode
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
@@ -151,8 +150,9 @@ def create_company_user(request):
|
|||||||
@permission_classes([IsAuthenticated,])
|
@permission_classes([IsAuthenticated,])
|
||||||
def my_user(request):
|
def my_user(request):
|
||||||
qs = User.objects.filter(email=request.user.email)
|
qs = User.objects.filter(email=request.user.email)
|
||||||
data = serializers.serialize('json', qs)
|
user_serializer = core_serializers.CustomUserReadSerializer(qs, many=True)
|
||||||
return Response(data=data)
|
return Response(data=user_serializer.data)
|
||||||
|
|
||||||
|
|
||||||
@api_view(['POST',])
|
@api_view(['POST',])
|
||||||
@permission_classes([IsAdminUser,])
|
@permission_classes([IsAdminUser,])
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.core import serializers
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
|||||||
@@ -390,12 +390,11 @@ class ProductSearchTest(TestCase):
|
|||||||
url = f"{self.endpoint}?query_string={query_string}"
|
url = f"{self.endpoint}?query_string={query_string}"
|
||||||
# send in request
|
# send in request
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
|
# import ipdb; ipdb.set_trace()
|
||||||
# check re sponse
|
# check re sponse
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
# check for object creation
|
# check for object creation
|
||||||
data = json.loads(response.data)
|
self.assertEquals(len(response.data), len(expected_instances))
|
||||||
self.assertEquals(len(data), len(expected_instances))
|
|
||||||
|
|
||||||
|
|
||||||
class MyProductsViewTest(APITestCase):
|
class MyProductsViewTest(APITestCase):
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from functools import reduce
|
|||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import serializers
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@@ -46,8 +45,8 @@ class ProductViewSet(viewsets.ModelViewSet):
|
|||||||
@permission_classes([IsAuthenticated,])
|
@permission_classes([IsAuthenticated,])
|
||||||
def my_products(request):
|
def my_products(request):
|
||||||
qs = Product.objects.filter(creator=request.user)
|
qs = Product.objects.filter(creator=request.user)
|
||||||
data = serializers.serialize('json', qs)
|
product_serializer = ProductSerializer(qs)
|
||||||
return Response(data=data)
|
return Response(data=product_serializer.data)
|
||||||
|
|
||||||
|
|
||||||
@api_view(['POST',])
|
@api_view(['POST',])
|
||||||
@@ -166,8 +165,8 @@ def product_search(request):
|
|||||||
for item in products:
|
for item in products:
|
||||||
result_set.add(item)
|
result_set.add(item)
|
||||||
|
|
||||||
serializer = ProductSerializer(result_set, many=True)
|
# serialize and respond
|
||||||
|
product_serializer = ProductSerializer(result_set)
|
||||||
return Response(data=serializer.data)
|
return Response(data=product_serializer.data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Response({"errors": {"details": str(type(e))}})
|
return Response({"errors": {"details": str(type(e))}})
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ django-cors-headers==3.5.0
|
|||||||
django-taggit-serializer==0.1.7
|
django-taggit-serializer==0.1.7
|
||||||
django-tagulous==1.1.0
|
django-tagulous==1.1.0
|
||||||
Pillow==8.1.0
|
Pillow==8.1.0
|
||||||
|
drf-extra-fields==3.0.4
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.core import serializers
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
|||||||
Reference in New Issue
Block a user