-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from countable-web/master
flag modal and help button changes
- Loading branch information
Showing
7 changed files
with
108 additions
and
27 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,53 @@ | ||
import pandas as pd | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from language.models import Language, Community, CommunityLanguageStats | ||
|
||
|
||
class Command(BaseCommand): | ||
def handle(self, *args, **options): | ||
filename = options["filename"] | ||
check = options["check"] or 1 | ||
update_language_stats(filename, check) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--filename", nargs="?", type=str, help="Specify the filename" | ||
) | ||
parser.add_argument( | ||
"--check", | ||
nargs="?", | ||
type=int, | ||
help="Check if there are no missing data from the database", | ||
) | ||
|
||
|
||
def update_language_stats(filename, check=1): | ||
print("Reading ", filename) | ||
print("Check ", check) | ||
|
||
df = pd.read_csv(filename) | ||
|
||
if check: | ||
error = False | ||
|
||
for index, row in df.iterrows(): | ||
row_number = index + 1 | ||
current_community = row["Community"] | ||
current_language = row["Language"] | ||
|
||
try: | ||
Community.objects.get(name__unaccent__iexact=current_community) | ||
except Community.DoesNotExist: | ||
error = True | ||
print(f"Row {row_number} - Community not found: {current_community}") | ||
|
||
try: | ||
Language.objects.get(name__unaccent__iexact=current_language) | ||
except Language.DoesNotExist: | ||
error = True | ||
print(f"Row {row_number} - Language not found: {current_language}") | ||
|
||
if not error: | ||
print("File check passed") |
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 @@ | ||
# Generated by Django 2.2.13 on 2023-11-13 06:27 | ||
|
||
from django.db import migrations | ||
from django.contrib.postgres.operations import UnaccentExtension | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("language", "0141_auto_20230811_0256"), | ||
] | ||
|
||
operations = [UnaccentExtension()] |
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