Ejemplo n.º 1
0
    def get(self, request, *args, **kwargs):
        user = decode_token(request.META)
        products = user.product_created_by.all()
        product_serializer = ProductSerializer(products, many=True)
        context = {'message': 'All Products', 'data': product_serializer.data}

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 2
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        brands = user_into.brand_created_by.all()
        brand_serializer = BrandSerializer(brands, many=True)

        context = {'message': 'All brands', 'data': brand_serializer.data}
        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 3
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        companies = user_into.company_created_by.all()
        company_serializer = CompanySerializer(companies, many=True)

        context = {'message': 'All companies', 'data': company_serializer.data}
        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     user = decode_token(request.META)
     data = request.data
     product = Product.objects.create(
         item_key=data.get('item_key'),
         item_name=data.get('item_name'),
         type=data.get('type'),
         stock_alert=data.get('stock_alert'),
         unit=data.get('unit'),
         vat=data.get('vat'),
         description=data.get('description'),
         track=data.get('track'),
         brand=Brand.objects.filter(id=data.get('brand')).first(),
         category=Category.objects.filter(id=data.get('category')).first(),
         warehouse=Warehouse.objects.filter(
             id=data.get('warehouse')).first(),
         company=Company.objects.filter(id=data.get('company')).first(),
         created_by=user,
     )
     product_serializer = ProductSerializer(product)
     context = {
         'message': 'Product Created Successfully',
         'data': product_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 5
0
 def post(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     data = request.data
     print(data)
     company = Company.objects.create(
         name=data.get('name'),
         website=data.get('website'),
         email=data.get('email'),
         address=data.get('address'),
         city=City.objects.get(pk=data.get('city')),
         region=data.get('region'),
         postcode=data.get('postcode'),
         country=Country.objects.get(pk=data.get('country')),
         phone=data.get('phone'),
         fax=data.get('fax'),
         image=data.get('image'),
         logo=data.get('logo'),
         created_by=user_into,
     )
     company_serializer = CompanySerializer(company)
     context = {
         'message': 'Company Created Successfully',
         'data': company_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 6
0
    def put(self, request, *args, **kwargs):
        user = decode_token(request.META)
        data = request.data
        VariantType.objects.filter(pk=kwargs.get('variant_type_id')).update(
            name=data.get('name'), updated_by=user)
        context = {'message': 'Variant type updated successfully'}

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 7
0
 def get(self, request, *args, **kwargs):
     user = decode_token(request.META)
     partner = Partnership.objects.filter(pk=kwargs.get('partnership_id')).first()
     partner_serializer = PartnershipSerializer(partner)
     context = {
         'message': 'Single Partners',
         'data': partner_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 8
0
 def get(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     sell_record = SellRecord.objects.filter(pk=kwargs.get('sell_record_id'))
     sell_record_serializer = ProductSerializer(sell_record)
     context = {
         'message': 'Single Sell Record',
         'data': sell_record_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 9
0
 def get(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     online_store = EcommerceSite.objects.filter(pk=kwargs.get('e_commerce_id')).first()
     online_store_serializer = EcommerceSiteSerializer(online_store)
     context = {
         'message': 'Single E-commerce',
         'data': online_store_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 10
0
 def get(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     sell_records = SellRecord.objects.all()
     sell_record_serializer = SellRecordSerializer(sell_records, many=True)
     context = {
         'message': 'All Sell Records',
         'data': sell_record_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 11
0
 def get(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     company = Company.objects.get(pk=kwargs.get('company_id'))
     company_serializer = CompanySerializer(company)
     context = {
         'message': 'Single Company',
         'data': company_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 12
0
    def get(self, request, *args, **kwargs):
        user = decode_token(request.META)
        warehouses = user.warehouse_created_by.all()
        warehouse_serializer = WarehouseSerializer(warehouses, many=True)
        context = {
            'message': 'All Warehouse',
            'data': warehouse_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 13
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        product = Product.objects.filter(pk=kwargs.get('product_id')).first()
        product_serializer = ProductSerializer(product)
        context = {
            'message': 'Single products',
            'data': product_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 14
0
    def get(self, request, *args, **kwargs):
        user = decode_token(request.META)
        categories = user.category_created_by.all()
        category_serializer = CategorySerializer(categories, many=True)

        context = {
            "message": "All Categories",
            "data": category_serializer.data
        }
        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 15
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        store_product = EcommerceHasProduct.objects.all()
        store_product_serializer = EcommerceHasProductSerializer(store_product, many=True)
        context = {
            'message': 'All Online Store has Product',
            'data': store_product_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 16
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        online_stores = EcommerceSite.objects.all()
        online_stores_serializer = EcommerceSiteSerializer(online_stores, many=True)
        context = {
            'message': 'All E-commerce',
            'data': online_stores_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 17
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        store_has_product = EcommerceSite.objects.filter(pk=kwargs.get('e_commerce_has_product_id')).first()
        store_has_product_serializer = EcommerceHasProductSerializer(store_has_product)
        context = {
            'message': 'Single Online Store has Product',
            'data': store_has_product_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 18
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        variant_type = VariantType.objects.all()
        variant_type_serializer = VariantTypeSerializer(variant_type,
                                                        many=True)
        context = {
            'message': 'All variants',
            'data': variant_type_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 19
0
    def get(self, request, *args, **kwargs):
        user = decode_token(request.META)
        variant_type_option = user.varianttypeoption_created_by.all()
        variant_type_option_serializer = VariantTypeOptionSerializer(
            variant_type_option, many=True)
        context = {
            'message': 'All variants',
            'data': variant_type_option_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 20
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        product_variant = ProductVariant.objects.all()
        product_variant_serializer = ProductVariantSerializer(product_variant,
                                                              many=True)
        context = {
            'message': 'All Product Variants',
            'data': product_variant_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 21
0
    def get(self, request, *args, **kwargs):
        user = decode_token(request.META)
        variant_type = VariantType.objects.filter(
            pk=kwargs.get('variant_type_id')).first()
        variant_type_serializer = VariantTypeSerializer(variant_type)
        context = {
            'message': 'Single Variant Type',
            'data': variant_type_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 22
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        warehouse = Warehouse.objects.filter(
            pk=kwargs.get('warehouse_id')).first()
        warehouse_serializer = WarehouseSerializer(warehouse)
        context = {
            'message': 'Single warehouse',
            'data': warehouse_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 23
0
    def get(self, request, *args, **kwargs):
        user_into = decode_token(request.META)
        partnership = Partnership.objects.all()
        partnership_serializer = PartnershipSerializer(partnership, many=True)

        context = {
            'message': 'All Partnerships',
            'data': partnership_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 24
0
    def post(self, request, *args, **kwargs):
        user = decode_token(request.META)
        data = request.data
        variant_type = VariantType.objects.create(name=data.get('name'),
                                                  created_by=user)
        variant_type_serializer = VariantTypeSerializer(variant_type)
        context = {
            'message': 'All Variant types',
            'data': variant_type_serializer.data
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 25
0
    def post(self, request, *args, **kwargs):
        user = decode_token(request.META)
        data = request.data

        brand = Brand.objects.create(name=data.get('name'),
                                     created_by=user,
                                     logo=data.get('brand_logo'),
                                     url=data.get('brand_url'))
        brand_serializer = BrandSerializer(brand)
        context = {
            'message': 'Brand created successfully',
            'data': brand_serializer.data
        }
        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 26
0
 def put(self, request, *args, **kwargs):
     user = decode_token(request.META)
     data = request.data
     partner = Partnership.objects.filter(pk=kwargs.get('partnership_id')).update(
         partner=User.objects.filter(username=data.get('partner_username')).first(),
         company=Company.objects.filter(name=data.get('partner_company')).first(),
         product=Product.objects.filter(item_name=data.get('partner_product')).first(),
         percentage=data.get('partnership_percentage'),
         updated_by=user,
     )
     context = {
         'message': 'Partner updated successfully',
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 27
0
 def put(self, request, *args, **kwargs):
     user = decode_token(request.META)
     data = request.data
     product_image = ProductImage.objects.filter(
         pk=kwargs.get('product_image_id')).update(
             image_path=data.get('image_path'),
             product_id=data.get('product'),
             variant_id=data.get('variant'),
             updated_by=user,
         )
     context = {
         'message': 'Product Image Updated Successfully',
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 28
0
 def post(self, request, *args, **kwargs):
     user_into = decode_token(request.META)
     data = request.data
     sell_record = SellRecord.objects.create(
         price=data.get('sell_record_price'),
         quantity=data.get('sell_record_quantity'),
         ecommerce_has_product=EcommerceHasProduct.objects.filter(pk=data.get('sell_record_store_has_product')).first(),
         created_by=user_into
     )
     sell_record_serializer = SellRecordSerializer(sell_record)
     context = {
         'message': 'Sell Record Created Successfully',
         'data': sell_record_serializer.data
     }
     return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 29
0
    def put(self, request, *args, **kwargs):
        user = decode_token(request.META)
        data = request.data
        store_product = EcommerceHasProduct.objects.filter(pk=kwargs.get('e_commerce_has_product_id')).update(
            price=data.get('store_product_price'),
            quantity=data.get('store_product_quantity'),
            product=Product.objects.filter(item_name=data.get('store_product_product')).first(),
            ecommerce=EcommerceSite.objects.filter(name=data.get('store_product_e_commerce')).first(),
            updated_by=user,
        )
        context = {
            'message': 'Online Store has product updated successfully',
        }

        return Response(context, status=status.HTTP_200_OK)
Ejemplo n.º 30
0
    def put(self, request, *args, **kwargs):
        user = decode_token(request.META)
        data = request.data
        EcommerceSite.objects.filter(pk=kwargs.get('e_commerce_id')).update(
            name=data.get('online_store_name'),
            logo=data.get('online_store_logo_path'),
            website=data.get('online_store_website'),
            shop_link=data.get('online_store_shop_link'),
            updated_by=user,
        )
        context = {
            'message': 'E-commerce Updated Successfully',
        }

        return Response(context, status=status.HTTP_200_OK)