Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
API fixes
Browse files Browse the repository at this point in the history
- [x] Country code fixes in Total Contracts View
- [x] Response data type from [] to ""

CP-236 Country dataset delete functionality

- [x] Deleted temp table data, tender, goodsservices, red-flag, equity
- [x] Added confirmation box while deleting the dataset.
- [x] Contract api and contract-status fixes
  • Loading branch information
sonikabaniya committed Apr 8, 2021
1 parent be6a855 commit b2fefeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions country/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.db.models import Sum
from rest_framework import serializers
from rest_framework_serializer_extensions.serializers import SerializerExtensionsMixin

from .models import Buyer, Country, Language, OverallSummary, RedFlag, Supplier, Tender


Expand Down Expand Up @@ -434,6 +435,7 @@ def get_buyer_code(self, obj):
def get_goods_services(self, obj):
a = obj.goods_services.all().values(
"goods_services_category__category_name",
"contract_desc",
"contract_value_usd",
"quantity_units",
"ppu_including_vat",
Expand Down
18 changes: 9 additions & 9 deletions vizualization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def get(self, request):
"amount_local": i["local"] if i["local"] else 0,
"amount_usd": i["usd"] if i["usd"] else 0,
"tender_count": i["count"],
"local_currency_code": i["country__currency"] if "country__currency" in i else [],
"local_currency_code": i["country__currency"] if "country__currency" in i else "",
"procedure": "direct",
}
else:
Expand All @@ -537,7 +537,7 @@ def get(self, request):
"amount_local": i["local"] if i["local"] else 0,
"amount_usd": i["usd"] if i["usd"] else 0,
"tender_count": i["count"],
"local_currency_code": i["country__currency"] if "country__currency" in i else [],
"local_currency_code": i["country__currency"] if "country__currency" in i else "",
"procedure": "open",
}
else:
Expand Down Expand Up @@ -589,7 +589,7 @@ def get(self, request):

if country:
try:
country_res = Country.objects.get(name=country)
country_res = Country.objects.get(country_code_alpha_2=country)
currency_code = country_res.currency
except Exception as e:
print(e)
Expand Down Expand Up @@ -2001,7 +2001,7 @@ def get(self, request):
Tender.objects.filter(**filter_args)
.annotate(month=TruncMonth("contract_date"))
.values(
"country__country_code",
"country__country_code_alpha_2",
"country__currency",
"month",
"goods_services__goods_services_category__id",
Expand All @@ -2016,7 +2016,7 @@ def get(self, request):
Tender.objects.filter(**filter_args)
.annotate(month=TruncMonth("contract_date"))
.values(
"country__country_code",
"country__country_code_alpha_2",
"country__currency",
"month",
"goods_services__goods_services_category__id",
Expand All @@ -2029,7 +2029,7 @@ def get(self, request):
{
"amount_local": i["local"],
"amount_usd": i["usd"],
"country_code": i["country__country_code"],
"country_code": i["country__country_code_alpha_2"],
"currency": i["country__currency"],
"month": i["month"].strftime("%Y-%m"),
"product_id": i["goods_services__goods_services_category__id"],
Expand All @@ -2044,7 +2044,7 @@ def get(self, request):
amount_usd_local = (
Tender.objects.annotate(month=TruncMonth("contract_date"))
.values(
"country__country_code",
"country__country_code_alpha_2",
"country__currency",
"month",
"goods_services__goods_services_category__id",
Expand All @@ -2058,7 +2058,7 @@ def get(self, request):
count = (
Tender.objects.annotate(month=TruncMonth("contract_date"))
.values(
"country__country_code",
"country__country_code_alpha_2",
"country__currency",
"month",
"goods_services__goods_services_category__id",
Expand All @@ -2071,7 +2071,7 @@ def get(self, request):
{
"amount_local": i["local"],
"amount_usd": i["usd"],
"country_code": i["country__country_code"],
"country_code": i["country__country_code_alpha_2"],
"currency": i["country__currency"],
"month": i["month"].strftime("%Y-%m"),
"product_id": i["goods_services__goods_services_category__id"],
Expand Down

0 comments on commit b2fefeb

Please sign in to comment.