-
Notifications
You must be signed in to change notification settings - Fork 299
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
In #5145 we will introduce a new Country model for storing countries that submissions will target.
We haven't populated this table yet, and we will do this in the scope of this issue.
Technical requirements
We will be utilizing the list of countries provided by pycountry. Therefore, we will need to install this new package and add it to our requirements.in file, then run pip-compile requirements.in to freeze it in our requirements.txt file.
The pycountry package does not support Kosovo which is present in our frontend's country list. Consequently, at the module level in the loadconstants.py file, we will add this country to pycountry's list by following the pycountry guidance:
pycountry.countries.add_entry(alpha_2="XK", alpha_3="XXK", name="Kosovo", numeric="926")Next, within our loadconstants command, create a new CountryGenerator class that inherits from ConstantGenerator.
- Point its
modelfield to the newCountrymodel.
- Point its
default_listproperty topycountry.countries. - Override the
id_fieldproperty and set it tocode, which is the primary key (PK) field in theCountrymodel. - Override the
get_dictmethod to return only thecodeandnameof the country in dictionary format.
Finally, we will instantiate this CountryGenerator class, retrieve the generated list, and add it to the CONSTANTS array, that will then be inserted to the database when running the loadconstants command.
Acceptance criteria
- The countries constants are now loaded to the database after running
make migratein Studio.
