first commit
This commit is contained in:
commit
3e4574dcdd
163 files changed
+3559
No files matched your search
@@ -0,0 +1,31 @@
|
||||
from apps.project.models import Project as ProjectModel
|
||||
from apps.order.models import Order as OrderModel
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
|
||||
def get_order(order_id):
|
||||
try:
|
||||
order = OrderModel.objects.get(id=order_id)
|
||||
return order
|
||||
except Exception as exp:
|
||||
raise ValidationError({'error': f'error get order: {str(exp)}'})
|
||||
|
||||
|
||||
def get_orders_list(status: str = 'waiting'):
|
||||
try:
|
||||
base_filter = {}
|
||||
if status:
|
||||
base_filter['status'] = status
|
||||
|
||||
orders = OrderModel.objects.filter(**base_filter)
|
||||
return orders
|
||||
except Exception as exp:
|
||||
raise ValidationError({'error': f'error get orders: {str(exp)}'})
|
||||
|
||||
|
||||
def get_project_by_id(project_id):
|
||||
try:
|
||||
project = ProjectModel.objects.get(id=project_id)
|
||||
return project
|
||||
except Exception as exp:
|
||||
raise ValidationError({'error': f'error get project: {str(exp)}'})
|
||||
Reference in new issue
Block a user