Skip to content

Commit

Permalink
[Fixes] Optimise fetch property in importspreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaboiangiu committed Apr 20, 2017
1 parent 01390e3 commit b21a5ec
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions gemet/thesaurus/management/commands/importspreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ def _create_concepts(self, sheet):

self.concepts[label.lower()] = concept
for name, value in properties.iteritems():
pending_property = models.Property.objects.filter(
current_property = models.Property.objects.filter(
concept=concept,
language=self.language,
name=name,
status=PENDING
status__in=[PENDING, PUBLISHED]
).first()
if pending_property:
pending_property.value = value
pending_property.save()
else:
if current_property:
if current_property.status == PENDING:
current_property.value = value
current_property.save()
else:
current_property.status = DELETED_PENDING
current_property.save()
if not (current_property and
current_property.status == PENDING):
models.Property.objects.create(
status=PENDING,
version_added=self.version,
Expand All @@ -96,15 +101,6 @@ def _create_concepts(self, sheet):
name=name,
value=value,
)
published_property = models.Property.objects.filter(
concept=concept,
language=self.language,
name=name,
status=PUBLISHED
).first()
if published_property:
published_property.status = DELETED_PENDING
published_property.save()
if is_new_concept:
search_text = get_search_text(
concept.id, self.language.code, PENDING, self.version)
Expand Down

0 comments on commit b21a5ec

Please sign in to comment.