-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change loadinfrastructure #1820
Conversation
aff5bac
to
b163bdd
Compare
a35e94b
to
3c13ff6
Compare
01b4a0e
to
3b551dd
Compare
geotrek/infrastructure/management/commands/loadinfrastructure.py
Outdated
Show resolved
Hide resolved
geotrek/infrastructure/management/commands/loadinfrastructure.py
Outdated
Show resolved
Hide resolved
try: | ||
year = int(feature.get(field_implantation_year)) | ||
except ValueError: | ||
year = self.get_year_from_date(feature.get(field_implantation_year)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est trop spécifique à un cas particulier. C'est me genre de choses pour lequelles il faut prétraiter le fichier source en extrayant l'année dans une nouvelle colonne (en utilisant QGis ou autre) avant de l'importer.
|
||
def get_year_from_date(self, year): | ||
year_from_date = year.split('/')[-1] | ||
return int(year_from_date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A supprimer car trop spécifique à un cas particulier.
2650269
to
857cd35
Compare
elif options.get('condition_default'): | ||
condition = options.get('condition_default') | ||
else: | ||
condition = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le principe de .get() est de renvoyer None si la clé n'existe pas. Il y a donc moyen de simplifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a oui
en effet
description=description, | ||
implantation_year=year | ||
) | ||
fields_withtout_eid = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: withTout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
if field_condition_type in available_fields: | ||
condition = feature.get(field_condition_type) | ||
elif options.get('condition_default'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faut un simple else
. Sinon la variable condition
ne sera pas définie dans certains cas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
893a7cb
to
3c6ec96
Compare
3c6ec96
to
d7c8454
Compare
cb36209
to
e05b176
Compare
condition = feature.get(field_condition_type) | ||
else: | ||
condition = options.get('condition_default') | ||
structure = Structure.objects.get(feature.get(field_structure_type)) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attention a ne pas faire de .get (requete django) sans mettre un nom de colonne à matcher, unique de surcroit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en fait tu recuperes deja la structure plus haut, le Structure.objects.get ne sert pas la, si ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y'a un try/except fait pour plus haut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le premier c'est pour la valeur par default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il sert a recuperer uniquement la structure dans le fichier .shp avec --structure-field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
par contre il risque d'avoir un probleme normalement cette ligne elle est faite pour mettre la structure par default si la structure dans le fichier n'existe pas
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok par contre faut pas faire de .get si tu mets pas de parametre(s) de matching unique(s)
à moins que tu cherches à recuperer la seule entrée de la base, mais dans ce cas tes parametres de lookup ne servent à rien)
et c'est un peu dommage de s'occuper de la structure à deux endroits différents
pareil, y'a des conditions gérées en oneline c'est bien, autant le faire sur toutes. voila fixe ces points et je merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.