Skip to content

Commit

Permalink
Initial support for export locale CSV and small bug fix on locale CSV…
Browse files Browse the repository at this point in the history
… import
  • Loading branch information
joamag committed Jun 26, 2019
1 parent 059ae9f commit e04746e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/appier_extras/parts/admin/models/locale.py
Expand Up @@ -125,6 +125,7 @@ def import_csv_s(cls, file):
for line in csv_reader:
name, locales_v = line[0], line[1:]
for locale_n, locale_v in zip(locales_n, locales_v):
if not locale_v: continue
locale_m = result.get(locale_n, {})
locale_m[name] = locale_v
result[locale_n] = locale_m
Expand Down
16 changes: 11 additions & 5 deletions src/appier_extras/parts/admin/part.py
Expand Up @@ -1251,19 +1251,25 @@ def list_events_csv(self):
@appier.ensure(token = "admin", context = "admin")
def list_locales_csv(self):
object = appier.get_object(alias = True, find = True, limit = 0)
locales = self.admin_part._find_view(models.Locale, **object)
locales = self.admin_part._find_view(models.Locale, rules = False, **object)

header = ["name"]
locales_s = [header]

#@odo must first create the reverse data model to be able
# to then write to the CSV

for locale in locales:
header.append(locale.locale)

names = set()

for locale in locales:
pass
names.update(appier.legacy.keys(locale.data_j))

for name in names:
line = [name]
for locale in locales:
value = locale.data_j.get(name, "")
line.append(value)
locales_s.append(line)

result = appier.serialize_csv(locales_s, delimiter = ",")
self.content_type("text/csv")
Expand Down

0 comments on commit e04746e

Please sign in to comment.