This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kushal Raj Shrestha
committed
Jul 18, 2021
1 parent
769bf27
commit e99e4a1
Showing
20 changed files
with
473 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from .buyer import Buyer | ||
from .country import Country | ||
from .covid_monthly_active_cases import CovidMonthlyActiveCases | ||
from .currency_conversion_cache import CurrencyConversionCache | ||
from .data_provider import DataProvider | ||
from .equity_category import EquityCategory | ||
from .equity_keywords import EquityKeywords | ||
from .goods_services import GoodsServices | ||
from .goods_services_category import GoodsServicesCategory | ||
from .import_batch import ImportBatch | ||
from .language import Language | ||
from .overall_summary import OverallSummary | ||
from .red_flag import RedFlag | ||
from .supplier import Supplier | ||
from .temp_data_import_table import TempDataImportTable | ||
from .tender import Tender | ||
from .topic import Topic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models.country import Country | ||
|
||
|
||
class Buyer(models.Model): | ||
buyer_id = models.CharField(verbose_name=_("Buyer ID"), max_length=50, null=True) | ||
buyer_name = models.CharField(verbose_name=_("Buyer name"), max_length=250, null=True, blank=True, db_index=True) | ||
buyer_address = models.CharField(verbose_name=_("Buyer address"), max_length=250, null=True, blank=True) | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="buyers", null=True) | ||
summary = models.JSONField(null=True) | ||
|
||
def __str__(self): | ||
return f"{self.buyer_id} - {self.buyer_name}" | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator | ||
from django.db import models | ||
from django.template.defaultfilters import slugify | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class CountryManager(models.Manager): | ||
def get_by_natural_key(self, name): | ||
return self.get(name=name) | ||
|
||
|
||
class Country(models.Model): | ||
CONTINENT_CHOICES = [ | ||
("africa", "Africa"), | ||
("asia", "Asia"), | ||
("europe", "Europe"), | ||
("middle_east", "Middle East"), | ||
("north_america", "North America"), | ||
("south_america", "South America"), | ||
("oceanic", "Oceanic"), | ||
] | ||
|
||
alphaSpaces = RegexValidator(r"^[a-zA-Z ]+$", "Only letters and spaces are allowed in the Country Name") | ||
|
||
slug = models.SlugField(null=True, unique=True) | ||
name = models.CharField(verbose_name=_("Name"), null=False, unique=True, max_length=50, validators=[alphaSpaces]) | ||
continent = models.CharField( | ||
verbose_name=_("Continent"), max_length=25, choices=CONTINENT_CHOICES, null=True, blank=False | ||
) | ||
population = models.BigIntegerField( | ||
verbose_name=_("Population"), null=True, blank=True, validators=[MinValueValidator(0)] | ||
) | ||
gdp = models.FloatField( | ||
verbose_name=_("GDP per capita, $"), null=True, blank=True, validators=[MinValueValidator(0)] | ||
) | ||
country_code = models.CharField(verbose_name=_("Country code"), max_length=10, null=False) | ||
country_code_alpha_2 = models.CharField( | ||
verbose_name=_("Country code alpha-2"), max_length=2, null=False, db_index=True | ||
) | ||
currency = models.CharField(verbose_name=_("Currency"), max_length=50, null=False) | ||
healthcare_budget = models.FloatField( | ||
verbose_name=_("Healthcare spending, $ per capita"), null=True, blank=True, validators=[MinValueValidator(0)] | ||
) | ||
healthcare_gdp_pc = models.FloatField( | ||
verbose_name=_("% of GDP to healthcare"), | ||
null=True, | ||
blank=True, | ||
validators=[MinValueValidator(0), MaxValueValidator(100)], | ||
) | ||
covid_cases_total = models.BigIntegerField( | ||
verbose_name=_("Total COVID-19 cases"), null=True, blank=True, validators=[MinValueValidator(0)] | ||
) | ||
covid_deaths_total = models.BigIntegerField( | ||
verbose_name=_("Total deaths by Covid-19"), null=True, blank=True, validators=[MinValueValidator(0)] | ||
) | ||
covid_data_last_updated = models.DateTimeField(null=True, blank=True) | ||
|
||
objects = CountryManager() | ||
|
||
class Meta: | ||
verbose_name_plural = _("Countries") | ||
app_label = "country" | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def save(self, *args, **kwargs): | ||
self.slug = slugify(self.name) | ||
super(Country, self).save(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models import Country | ||
|
||
|
||
class CovidMonthlyActiveCases(models.Model): | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="covid_monthly_active_cases") | ||
covid_data_date = models.DateField() | ||
active_cases_count = models.BigIntegerField(verbose_name=_("Active cases count"), null=True, blank=True) | ||
death_count = models.BigIntegerField(verbose_name=_("Death count"), null=True, blank=True) | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class CurrencyConversionCache(models.Model): | ||
source_currency = models.CharField(verbose_name=_("Source currency"), max_length=50, null=True) | ||
dst_currency = models.CharField(verbose_name=_("Dst currency"), max_length=50, null=True) | ||
conversion_date = models.DateField(verbose_name=_("Conversion date"), null=True) | ||
conversion_rate = models.FloatField(verbose_name=_("Conversion rate"), null=True) | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.core.validators import RegexValidator | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models import Country | ||
|
||
|
||
class DataProvider(models.Model): | ||
alphaSpaces = RegexValidator(r"^[a-zA-Z ]+$", "Only letters and spaces are allowed in the Country Name") | ||
name = models.CharField(verbose_name=_("Name"), null=False, unique=True, max_length=50, validators=[alphaSpaces]) | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, blank=False, null=False) | ||
website = models.URLField(max_length=200) | ||
logo = models.ImageField(upload_to="dataprovider/logo", height_field=None, width_field=None, max_length=100) | ||
remark = models.TextField(verbose_name=_("Remark"), null=False, unique=True, max_length=500000) | ||
|
||
class Meta: | ||
verbose_name_plural = _("Data Providers") | ||
app_label = "country" | ||
|
||
def __str__(self): | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class EquityCategoryManager(models.Manager): | ||
def get_by_natural_key(self, category_name): | ||
return self.get(category_name=category_name) | ||
|
||
|
||
class EquityCategory(models.Model): | ||
category_name = models.CharField(verbose_name=_("Category name"), max_length=50, null=True, unique=True) | ||
|
||
objects = EquityCategoryManager() | ||
|
||
def __str__(self): | ||
return self.category_name | ||
|
||
class Meta: | ||
verbose_name_plural = "Equity Categories" | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models import Country, EquityCategory | ||
|
||
|
||
class EquityKeywords(models.Model): | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="equity_keywords", null=True) | ||
equity_category = models.ForeignKey( | ||
EquityCategory, on_delete=models.CASCADE, related_name="equity_keywords", null=True | ||
) | ||
keyword = models.CharField(verbose_name=_("Keyword"), max_length=100, null=False) | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models.buyer import Buyer | ||
from country.models.country import Country | ||
from country.models.goods_services_category import GoodsServicesCategory | ||
from country.models.supplier import Supplier | ||
from country.models.tender import Tender | ||
|
||
|
||
class GoodsServices(models.Model): | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="goods_services", null=True) | ||
goods_services_category = models.ForeignKey( | ||
GoodsServicesCategory, on_delete=models.CASCADE, related_name="goods_services", null=True | ||
) | ||
contract = models.ForeignKey(Tender, on_delete=models.CASCADE, related_name="goods_services", null=True) | ||
|
||
classification_code = models.CharField( | ||
verbose_name=_("Classification code"), max_length=100, null=True, blank=True | ||
) | ||
no_of_bidders = models.BigIntegerField(verbose_name=_("Number of bidders"), null=True, blank=True) | ||
|
||
contract_title = models.TextField(verbose_name=_("Contract title"), null=True, blank=True) | ||
contract_desc = models.TextField(verbose_name=_("Contract description"), null=True, blank=True) | ||
|
||
supplier = models.ForeignKey( | ||
Supplier, on_delete=models.CASCADE, related_name="goods_services", null=True, blank=True | ||
) | ||
buyer = models.ForeignKey(Buyer, on_delete=models.CASCADE, related_name="goods_services", null=True, blank=True) | ||
|
||
quantity_units = models.CharField(verbose_name=_("Quantity,units"), max_length=1500, null=True) | ||
ppu_including_vat = models.CharField(verbose_name=_("Price per units including VAT"), max_length=1500, null=True) | ||
|
||
tender_value_local = models.FloatField(verbose_name=_("Tender value local"), null=True, blank=True) | ||
tender_value_usd = models.FloatField(verbose_name=_("Tender value USD"), null=True, blank=True) | ||
award_value_local = models.FloatField(verbose_name=_("Award value local"), null=True, blank=True) | ||
award_value_usd = models.FloatField(verbose_name=_("Award value USD"), null=True, blank=True) | ||
contract_value_local = models.FloatField( | ||
verbose_name=_("Contract value local"), null=True, blank=True, db_index=True | ||
) | ||
contract_value_usd = models.FloatField(verbose_name=_("Contract value USD"), null=True, blank=True, db_index=True) | ||
|
||
def __str__(self): | ||
return str(self.id) | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class GoodsServicesCategory(models.Model): | ||
category_name = models.CharField( | ||
verbose_name=_("Category name"), max_length=100, null=False, unique=True, db_index=True | ||
) | ||
category_desc = models.TextField(verbose_name=_("Category description"), null=True, blank=True) | ||
|
||
def __str__(self): | ||
return self.category_name | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models import Country | ||
|
||
|
||
class ImportBatch(models.Model): | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="import_batch_country", null=True) | ||
import_type = models.CharField(verbose_name=_("Import Type"), max_length=150, null=False) | ||
description = models.CharField(verbose_name=_("Description"), max_length=500, null=False) | ||
data_import_id = models.IntegerField(null=True) | ||
|
||
def __str__(self): | ||
return f"Import batch id: {str(self.id)}" | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.db import models | ||
|
||
|
||
class Language(models.Model): | ||
name = models.CharField(max_length=50) | ||
code = models.CharField(max_length=10) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.db import models | ||
|
||
from country.models import Country | ||
|
||
|
||
class OverallSummary(models.Model): | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="overall_summary") | ||
statistic = models.JSONField(null=True) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
def __str__(self): | ||
return self.statistic | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class RedFlag(models.Model): | ||
title = models.CharField( | ||
verbose_name=_("Title"), | ||
max_length=250, | ||
null=True, | ||
blank=True, | ||
db_index=True, | ||
help_text=_("A short description of the red flag, as shown in the frontend."), | ||
) | ||
description = models.CharField( | ||
verbose_name=_("Description"), max_length=300, null=True, blank=True, db_index=True, help_text=_("Not used.") | ||
) | ||
function_name = models.CharField( | ||
verbose_name=_("Function"), | ||
max_length=300, | ||
null=True, | ||
blank=True, | ||
db_index=True, | ||
help_text=_("This corresponds to a function in the code. Do not edit it unless you are a developer."), | ||
) | ||
implemented = models.BooleanField( | ||
null=True, | ||
blank=True, | ||
default=False, | ||
help_text=_("Display the red flag. Do not enable unless you know the red flag is implemented."), | ||
) | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
class Meta: | ||
app_label = "country" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country.models import Country | ||
|
||
|
||
class Supplier(models.Model): | ||
supplier_id = models.CharField(verbose_name=_("Supplier ID"), max_length=50, null=True) | ||
supplier_name = models.CharField( | ||
verbose_name=_("Supplier name"), max_length=250, null=True, blank=True, db_index=True | ||
) | ||
supplier_address = models.CharField(verbose_name=_("Supplier address"), max_length=250, null=True, blank=True) | ||
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="suppliers", null=True) | ||
summary = models.JSONField(null=True) | ||
|
||
def __str__(self): | ||
return f"{self.supplier_id} - {self.supplier_name}" | ||
|
||
class Meta: | ||
app_label = "country" |
Oops, something went wrong.