-
Notifications
You must be signed in to change notification settings - Fork 32
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
Showing
8 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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 @@ | ||
# Register your models here. |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AdministrationsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "administrations" |
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,58 @@ | ||
import json | ||
from pathlib import Path | ||
from typing import Dict, List | ||
|
||
BASE_DATA_PATH = Path("/home/symroe/Data/StaticOrgLayer/") | ||
|
||
|
||
class Administration: | ||
def __init__(self, admin_id, data: Dict): | ||
self.admin_id = admin_id | ||
self.data = data | ||
|
||
@property | ||
def administration_type(self): | ||
if self.admin_id.startswith("D::"): | ||
return "division" | ||
return "organisation" | ||
|
||
@property | ||
def role_type(self): | ||
return self.admin_id.split("::")[-1] | ||
|
||
def friendly_name(self): | ||
org_name = self.data["organisation"]["common_name"] | ||
|
||
if self.administration_type == "organisation": | ||
if self.role_type == "mayor": | ||
org_name = f"Mayor of {org_name}" | ||
|
||
return org_name | ||
div_name = self.data["division"]["name"] | ||
|
||
if self.role_type == "local": | ||
div_name = f"{div_name} ward" | ||
|
||
if self.role_type == "parl": | ||
return f"MP for {div_name}" | ||
return f"{org_name}: {div_name}" | ||
|
||
def seats_contested(self): ... | ||
|
||
def friendly_description(self): | ||
return "asd" | ||
|
||
|
||
class AdministrationsHelper: | ||
def __init__(self, administration_ids: List[str]): | ||
self.administration_ids = administration_ids | ||
self.data_path = BASE_DATA_PATH | ||
self.administrations: List[Administration] = [] | ||
for admin_id in self.administration_ids: | ||
data = self.load_json(admin_id) | ||
self.administrations.append(Administration(admin_id, data)) | ||
|
||
def load_json(self, administration_id): | ||
path = self.data_path / f"{administration_id}.json" | ||
with path.open() as f: | ||
return json.load(f) |
Empty file.
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 @@ | ||
# Create your models here. |
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 @@ | ||
# Create your tests here. |
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 @@ | ||
# Create your views here. |