diff --git a/app/serializers.py b/app/serializers.py index 4a1b54e..ec8ce8a 100644 --- a/app/serializers.py +++ b/app/serializers.py @@ -11,7 +11,7 @@ class Meta: class HsCodeSerializer(serializers.ModelSerializer): class Meta: model = HsCode - fields = "__all__" + fields = ["id", "hs_code", "description", "created_at"] class CategorySerializer(serializers.ModelSerializer): diff --git a/app/services/category_service.py b/app/services/category_service.py deleted file mode 100644 index 80a6a22..0000000 --- a/app/services/category_service.py +++ /dev/null @@ -1,111 +0,0 @@ -# Chapter-to-category mapping for ZIMRA HS codes -HS_CHAPTER_CATEGORIES = { - "01": "Live Animals", - "02": "Meat & Edible Offal", - "03": "Fish & Seafood", - "04": "Dairy, Eggs & Honey", - "05": "Other Animal Products", - "06": "Live Plants & Flowers", - "07": "Vegetables", - "08": "Fruit & Nuts", - "09": "Coffee, Tea & Spices", - "10": "Cereals", - "11": "Milling Products", - "12": "Oil Seeds & Misc Grains", - "13": "Lac, Gums & Resins", - "14": "Vegetable Plaiting Materials", - "15": "Animal & Vegetable Fats & Oils", - "16": "Prepared Meat & Fish", - "17": "Sugars & Confectionery", - "18": "Cocoa & Chocolate", - "19": "Cereals, Flour & Starch Preparations", - "20": "Prepared Vegetables & Fruit", - "21": "Misc Edible Preparations", - "22": "Beverages, Spirits & Vinegar", - "23": "Animal Feed", - "24": "Tobacco", - "25": "Salt, Sulphur & Stone", - "26": "Ores, Slag & Ash", - "27": "Mineral Fuels & Oils", - "28": "Inorganic Chemicals", - "29": "Organic Chemicals", - "30": "Pharmaceutical Products", - "31": "Fertilisers", - "32": "Tanning, Dyeing & Paints", - "33": "Essential Oils & Cosmetics", - "34": "Soap, Waxes & Polishes", - "35": "Albuminoidal Substances & Glues", - "36": "Explosives & Pyrotechnics", - "37": "Photographic Products", - "38": "Miscellaneous Chemical Products", - "39": "Plastics", - "40": "Rubber", - "41": "Raw Hides & Leather", - "42": "Leather Articles & Handbags", - "43": "Furskins", - "44": "Wood & Articles of Wood", - "45": "Cork", - "46": "Basketware & Wickerwork", - "47": "Wood Pulp & Paper Waste", - "48": "Paper & Paperboard", - "49": "Printed Books & Publications", - "50": "Silk", - "51": "Wool & Animal Hair", - "52": "Cotton", - "53": "Other Vegetable Textile Fibres", - "54": "Man-made Filaments", - "55": "Man-made Staple Fibres", - "56": "Wadding, Felt & Nonwovens", - "57": "Carpets & Floor Coverings", - "58": "Special Woven Fabrics", - "59": "Impregnated Textile Fabrics", - "60": "Knitted & Crocheted Fabrics", - "61": "Knitted Clothing", - "62": "Woven Clothing", - "63": "Other Made-up Textile Articles", - "64": "Footwear", - "65": "Headgear", - "66": "Umbrellas & Walking Sticks", - "67": "Artificial Flowers & Wigs", - "68": "Stone, Plaster & Cement Articles", - "69": "Ceramic Products", - "70": "Glass & Glassware", - "71": "Precious Stones & Jewellery", - "72": "Iron & Steel", - "73": "Iron or Steel Articles", - "74": "Copper", - "75": "Nickel", - "76": "Aluminium", - "78": "Lead", - "79": "Zinc", - "80": "Tin", - "81": "Other Base Metals", - "82": "Tools & Cutlery", - "83": "Miscellaneous Base Metal Articles", - "84": "Industrial Machinery", - "85": "Electrical Machinery & Electronics", - "86": "Railway Equipment", - "87": "Motor Vehicles", - "88": "Aircraft", - "89": "Ships & Boats", - "90": "Optical & Medical Instruments", - "91": "Clocks & Watches", - "92": "Musical Instruments", - "93": "Arms & Ammunition", - "94": "Furniture & Lighting", - "95": "Toys, Games & Sports", - "96": "Miscellaneous Manufactured Articles", - "97": "Works of Art", - "98": "Flat Rate Provisions", - "99": "VAT Services", -} - - -def get_or_create_category_for_hs_code(hs_code: str) -> "Category": - """Derive category from HS code chapter prefix and get or create it.""" - from app.models import Category - - chapter = hs_code[:2] - name = HS_CHAPTER_CATEGORIES.get(chapter, f"Chapter {chapter}") - category, _ = Category.objects.get_or_create(name=name) - return category diff --git a/app/services/file_upload_service.py b/app/services/file_upload_service.py index cd3b17a..394303d 100644 --- a/app/services/file_upload_service.py +++ b/app/services/file_upload_service.py @@ -2,9 +2,7 @@ import io from dataclasses import dataclass -from app.models import HsCode, HsCodeFile, Category -from .category_service import HS_CHAPTER_CATEGORIES, get_or_create_category_for_hs_code - +from app.models import HsCode, HsCodeFile @dataclass class UploadResult: diff --git a/app/views.py b/app/views.py index b58e3e5..1500b5e 100644 --- a/app/views.py +++ b/app/views.py @@ -42,7 +42,9 @@ def post(self, request): class HsCodeSearchView(generics.ListAPIView): serializer_class = HsCodeSerializer - + authentication_classes = [] + permission_classes = [] + def get_queryset(self): try: q = self.request.query_params.get("q") diff --git a/requirements.txt b/requirements.txt index a512000..fcae17d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,11 +3,7 @@ attrs==26.1.0 dj-database-url==3.1.2 Django==6.0.5 django-cors-headers==4.9.0 -django-filter==25.2 -django-redis==6.0.0 djangorestframework==3.17.1 -djangorestframework_simplejwt==5.5.1 -drf-spectacular==0.29.0 gunicorn==26.0.0 inflection==0.5.1 jsonschema==4.26.0