Commit 8a8e8cf6 authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'frontend' into 'master'

New Frontend initialize

Closes #11

See merge request chehabfl/outgoing_rex!15
parents f7b3fc08 a157cc69
Pipeline #26686 passed with stages
in 3 minutes and 30 seconds
{
"presets": [
"env",
"react",
"es2015",
"stage-1"
],
"plugins": [
"transform-class-properties"
]
}
\ No newline at end of file
[run]
omit = *migrations*
source = .
omit =
*migrations*
tests/*
source = .
extends: google
[flake8]
# E501 line too long
ignore = E501
exclude = tests/*, env/*
\ No newline at end of file
exclude =
env/*
node_modules/*
......@@ -8,4 +8,5 @@ db.sqlite3
node_modules
.coverage
htmlcov
.vscode
\ No newline at end of file
.vscode
.pytest_cache
......@@ -14,9 +14,7 @@ testing:
- export DATABASE_URL=postgres://postgres:@postgres:5432/python-test-app
- pip install -r requirements.txt --quiet
- ./manage.py check
- coverage3 run manage.py test
- coverage3 report
- coverage3 html
- pytest -n 4 general/ frontend/ backend/ --cov-report html
artifacts:
paths:
- htmlcov/
......
......@@ -8,7 +8,9 @@
"**/.DS_Store": true,
"**/__pycache__":true,
"**/*.pyc":true,
"htmlcov":true
"htmlcov":false,
"env":true,
".coverage":true
},
"cSpell.language": "en,fr-FR,fr",
"python.linting.flake8Enabled": true
......
default_app_config = 'backend.apps.BackendConfig'
......@@ -47,6 +47,8 @@ from backend.models.user import PreviousDeparture
from backend.models.user import PreviousDepartureFeedback
from backend.models.user import UserData
from backend.models.my_model import PendingModeration
CLASSIC_MODELS = [
Country,
City,
......@@ -59,7 +61,8 @@ CLASSIC_MODELS = [
RecommendationList,
PreviousDeparture,
PreviousDepartureFeedback,
UserData
UserData,
PendingModeration
]
VERSIONNED_MODELS = [
......
......@@ -3,3 +3,6 @@ from django.apps import AppConfig
class BackendConfig(AppConfig):
name = 'backend'
def ready(self):
import backend.signals # noqa: F401
from .load_all import load_all # noqa: F401
from .loading_scripts import LoadAdminUser
from .loading_scripts import LoadCountries
from .loading_scripts import LoadUniversities
def load_all():
admin = LoadAdminUser().get()
LoadCountries(admin).load()
LoadUniversities(admin).load()
from .loadAdminUser import LoadAdminUser # noqa: F401
from .loadCountries import LoadCountries # noqa: F401
from .loadUniversities import LoadUniversities # noqa: F401
from django.contrib.auth.models import User
class LoadAdminUser(object):
def __init__(self):
admins = User.objects.filter(username="admin")
if len(admins) > 0:
self.admin = admins[0]
else:
self.admin = User.objects.create_superuser(
username='admin',
email='null@null.fr',
password='admin'
)
def get(self):
return self.admin
from backend.models.location import Country
import os
import pandas as pd
from .loadGeneric import LoadGeneric
class LoadCountries(LoadGeneric):
def __init__(self, admin):
self.admin = admin
def load(self):
tmp = os.path.join(os.path.realpath(__file__),
'../../assets/country.csv')
country_file_loc = os.path.abspath(tmp)
tmp = os.path.join(os.path.realpath(__file__),
'../../assets/alpha-conv-table.csv')
conv_alpha_file_loc = os.path.abspath(tmp)
country_pd = pd.read_csv(country_file_loc, sep=',', header=0,
dtype=object).fillna('')
# Need to load the information for converting
# Countries alpha-3 code to alpha-2 code
data_conv = pd.read_csv(conv_alpha_file_loc, sep=',',
header=0, na_filter=False)
conv_alpha = {}
for index, row in data_conv.iterrows():
conv_alpha[row["alpha-3"]] = row["alpha-2"]
for index, r in country_pd.iterrows():
Iso_3 = str(r['ISO-alpha3 Code'])
code_alpha_2 = None
if Iso_3 in conv_alpha.keys():
code_alpha_2 = conv_alpha[Iso_3]
else:
print("ignoring country :", Iso_3)
continue
country = Country(
name=r["Country or Area"],
iso_alpha2_code=code_alpha_2,
iso_alpha3_code=Iso_3,
region_name=r["Region Name"],
region_un_code=r["Region Code"],
sub_region_name=r["Sub-region Name"],
sub_region_un_code=r["Sub-region Code"],
intermediate_region_name=r["Intermediate Region Name"],
intermediate_region_un_code=r["Intermediate Region Code"],
)
country.save()
self.add_info(country, self.admin)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment