Skip to content

Commit

Permalink
Added new methods get_delivery_cost, get_city, get_rw for DataService…
Browse files Browse the repository at this point in the history
… class
  • Loading branch information
dev-lymar committed Jun 8, 2024
1 parent 05212a0 commit 54a5d55
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion makedoc/data_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from clients.models import Client
from goods.models import Product
from logistics.models import Factory
from logistics.models import Factory, RailwayStation


class DataService:
Expand Down Expand Up @@ -75,3 +75,32 @@ def get_factory(processed_data):
return factory_data
except Factory.DoesNotExist:
raise Exception("Factory not found")

@staticmethod
def get_delivery_cost(processed_data):
delivery_cost = processed_data.get("delivery_cost")
if delivery_cost is None:
raise Exception("Delivery cost not found")
return delivery_cost

@staticmethod
def get_city(processed_data):
city = processed_data.get("destination")
if city is None:
raise Exception("City not found")
return city

@staticmethod
def get_rw(processed_data):
try:
rw_id = processed_data.get("destination")
rw = RailwayStation.objects.get(id=rw_id)
rw_data = {
"id": int(rw.id),
"station_name": str(rw.station_name),
"station_id": int(rw.station_id),
"station_branch": str(rw.station_branch),
}
return rw_data
except RailwayStation.DoesNotExist:
raise Exception("Railway station not found")

0 comments on commit 54a5d55

Please sign in to comment.