-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minor [skip ci] * adds administrative_division and mgm to update/populate this filed * readme updates [skip ci]
- Loading branch information
Showing
10 changed files
with
170 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ hansi.csv | |
hansi.json | ||
1824-12-05.json | ||
1914-12-05.json | ||
sources.csv |
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 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 |
---|---|---|
|
@@ -72,7 +72,6 @@ | |
"news", | ||
"analyze", | ||
"archeutils", | ||
|
||
] | ||
|
||
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5" | ||
|
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 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 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,23 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from shps.models import Source, TempSpatial | ||
from shps.utils import gsheet_to_df | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
help = """updates administrative_division fields according to | ||
https://docs.google.com/spreadsheets/d/14WNuiB7KnnezWndKJslw-j-EdHRF04CH2M1HqVSmPGg""" | ||
|
||
def handle(self, *args, **options): | ||
df = gsheet_to_df("14WNuiB7KnnezWndKJslw-j-EdHRF04CH2M1HqVSmPGg") | ||
for i, row in df.iterrows(): | ||
adm = row["adm"].lower().replace(" ", "") | ||
source = Source.objects.get(id=row["id"]) | ||
source.administrative_division = adm | ||
source.save() | ||
print(f"processing objects related to {source}") | ||
for x in TempSpatial.objects.filter(source=source): | ||
x.administrative_division = adm | ||
x.save() | ||
print("done") |
79 changes: 79 additions & 0 deletions
79
shps/migrations/0002_source_administrative_division_and_more.py
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,79 @@ | ||
# Generated by Django 5.1.3 on 2024-12-04 11:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("shps", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="source", | ||
name="administrative_division", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
( | ||
"adm1", | ||
"ADM 1: a primary administrative division of a country, such as a state in the United States", | ||
), | ||
( | ||
"adm2", | ||
"ADM 2: a subdivision of a first-order administrative division", | ||
), | ||
( | ||
"adm3", | ||
"ADM 3: a subdivision of a second-order administrative division", | ||
), | ||
( | ||
"adm4", | ||
"ADM 4: a subdivision of a third-order administrative division", | ||
), | ||
( | ||
"adm5", | ||
"ADM 5: a subdivision of a fourth-order administrative division", | ||
), | ||
], | ||
help_text="Mainly used to group objects by similar hierarchy level; (http://www.geonames.org/export/codes.html)", | ||
max_length=5, | ||
null=True, | ||
verbose_name="administrative division", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="tempspatial", | ||
name="administrative_division", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
( | ||
"adm1", | ||
"ADM 1: a primary administrative division of a country, such as a state in the United States", | ||
), | ||
( | ||
"adm2", | ||
"ADM 2: a subdivision of a first-order administrative division", | ||
), | ||
( | ||
"adm3", | ||
"ADM 3: a subdivision of a second-order administrative division", | ||
), | ||
( | ||
"adm4", | ||
"ADM 4: a subdivision of a third-order administrative division", | ||
), | ||
( | ||
"adm5", | ||
"ADM 5: a subdivision of a fourth-order administrative division", | ||
), | ||
], | ||
help_text="Mainly used to group objects by similar hierarchy level; (http://www.geonames.org/export/codes.html)", | ||
max_length=5, | ||
null=True, | ||
verbose_name="administrative division", | ||
), | ||
), | ||
] |
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 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 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