Skip to content

Commit

Permalink
Merge branch 'release/0.3.26' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jul 18, 2023
2 parents b6a4792 + 9c26b71 commit d3d2162
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 7 additions & 0 deletions edc_sites/get_countries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib.sites.models import Site


def get_countries() -> list[str]:
"""Returns the countries"""
countries = set(s.siteprofile.country for s in Site.objects.all())
return sorted(list(countries))
11 changes: 10 additions & 1 deletion edc_sites/get_sites_by_country.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from django_extensions.management.color import color_style

from .get_all_sites import get_all_sites
from .get_country import get_current_country
from .get_sites_module import get_sites_module

if TYPE_CHECKING:
from .single_site import SingleSite

style = color_style()


def get_sites_by_country(country=None, all_sites=None, sites_module_name=None):
def get_sites_by_country(
country: str = None, all_sites: dict[str, list[SingleSite]] | None = None
) -> list[SingleSite]:
"""Returns a sites tuple for the country."""
if not all_sites or get_all_sites():
all_sites = get_sites_module().all_sites
Expand Down
8 changes: 4 additions & 4 deletions edc_sites/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from edc_sites.single_site import SingleSite

default_country = getattr(settings, "EDC_SITES_DEFAULT_COUNTRY", "botswana")
default_country_code = getattr(settings, "EDC_SITES_DEFAULT_COUNTRY_CODE", "bw")
default_domain = getattr(settings, "EDC_SITES_DEFAULT_DOMAIN", "localhost")
default_country: str = getattr(settings, "EDC_SITES_DEFAULT_COUNTRY", "botswana")
default_country_code: str = getattr(settings, "EDC_SITES_DEFAULT_COUNTRY_CODE", "bw")
default_domain: str = getattr(settings, "EDC_SITES_DEFAULT_DOMAIN", "localhost")

all_sites = {
all_sites: dict[str, list[SingleSite]] = {
default_country
or "site": [
SingleSite(
Expand Down

0 comments on commit d3d2162

Please sign in to comment.