adaptive-learning / proso-apps

Django modules for an adaptive practice system (currently used by http://slepemapy.cz/ or https://anatom.cz/)
MIT License
2 stars 7 forks source link

load_flashcards fails on empty DB #186

Closed slaweet closed 7 years ago

slaweet commented 7 years ago

Here is the file I run it with: http://pastebin.com/aLq3cLx4

Here is the output

./manage.py load_flashcards new-flashcards.json 
 -  proso_flashcards.models.Term : proso_flashcards_term : item_id : lang
 -  proso_flashcards.models.Context : proso_flashcards_context : item_id : lang
 -  proso_flashcards.models.Flashcard : proso_flashcards_flashcard : item_id : lang
 -  proso_flashcards.models.Category : proso_flashcards_category : item_id : lang
After database updated: 4 valid item types and 0 invalid ones.

Initializing data from DB

Loading categories
[################################] 1/1 - 00:00:00

Filling item types

Building dependencies
[################################] 1/1 - 00:00:00
New total number of categories in DB: 6

Loading contexts
[################################] 1/1 - 00:00:00

Filling item types

Building dependencies
[################################] 1/1 - 00:00:00
New total number of contexts in DB: 6

Loading terms
[################################] 98/98 - 00:00:00

Filling item types

Building dependencies
[################################] 98/98 - 00:00:00
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/slaweet/.virtualenvs/geography/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/slaweet/.virtualenvs/geography/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/slaweet/.virtualenvs/geography/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/slaweet/.virtualenvs/geography/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/slaweet/git/proso-apps/proso_flashcards/management/commands/load_flashcards.py", line 55, in handle
    self._load_terms(data["terms"])
  File "/home/slaweet/git/proso-apps/proso_flashcards/management/commands/load_flashcards.py", line 167, in _load_terms
    self._load_item_relations(data, self._db_terms, 'categories')
  File "/home/slaweet/git/proso-apps/proso_flashcards/management/commands/load_flashcards.py", line 286, in _load_item_relations
    flatten(parent_subgraph.values()), lang
  File "/home/slaweet/git/proso-apps/proso_models/models.py", line 867, in translate_identifiers
    raise HttpError(404, "Can't translate the following identifiers: {}".format(set(identifiers) - set(result.keys())), 'identifier_not_found')
proso.django.response.HttpError: Can't translate the following identifiers: {'proso_flashcards_category/city', 'proso_flashcards_category/state'}
papousek commented 7 years ago

The problem here is there are no categories with identifiers "city" and "state". The only present category is "us".