moocunsw / ontask3_UNSW

A platform offering teachers and educational designers the capacity to use data to personalise the experience for the learners.
https://ontasklearning.org
6 stars 6 forks source link

Documentation requires updates to allow for easy start up with Docker #151

Closed NgoniChoga closed 5 years ago

NgoniChoga commented 5 years ago

Two things in particular need to be updated in the documentation in order for docker to run a successful build first time:

  1. Env.py requires 3 additional variables, namely; AWS_REGION, ENABLE_CLOUDWATCH_LOGGING and DEMO_BUCKET
  2. Before running python manage.py createsuperuser one needs to run python3 manage.py loaddata user_groups in order to create the user groups.
mattchen089 commented 5 years ago

Thanks Ngonichoga, that explains all the error messages. I experienced another error after running python manage.py createsuperuser.

Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "/usr/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 59, in execute return super().execute(*args, **options) File "/usr/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute output = self.handle(*args, **options) File "/usr/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 184, in handle self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) File "/backend/accounts/models.py", line 38, in create_superuser user = self._create_user(email, password, **extra_fields) File "/backend/accounts/models.py", line 27, in _create_user user.save(using=self._db) File "/usr/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 73, in save super().save(*args, **kwargs) File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 718, in save force_update=force_update, update_fields=update_fields) File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 748, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 831, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 869, in _do_insert using=using, raw=raw) File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 1136, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/usr/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql cursor.execute(sql, params) File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute return super().execute(sql, params) File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/usr/lib/python3.6/site-packages/djongo/cursor.py", line 53, in execute params) File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 706, in __init__ self.parse() File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 769, in parse return handler(self, statement) File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 893, in _insert self._query = InsertQuery(self, self.db, self.connection_properties, sm, self._params) File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 354, in __init__ super().__init__(*args) File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 74, in __init__ self.parse() File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 442, in parse tok_id = self._table(2) File "/usr/lib/python3.6/site-packages/djongo/sql2mongo/query.py", line 361, in _table raise MigrationError(collection) djongo.sql2mongo.MigrationError: accounts_user

Have you experienced this before by any chance? Any idea how to resolve this one?

Btw, I think python manage.py createsuperuser should be python3 manage.py createsuperuser

NgoniChoga commented 5 years ago

Hey @mattchen089 , to get the migration working i ran the following in order:

  1. python3 manage.py makemigrations accounts
  2. python3 manage.py makemigrations
  3. python3 manage.py migrate
  4. python3 manage.py loaddata user_groups

I assume the error you are getting is because you did not run migration #1

mattchen089 commented 5 years ago

Thanks @NgoniChoga. I have restarted again following your instructions and it worked (For development). Much appreciated! Were you able to login after creating the superuser? I got an "Unhandled Rejection" after clicking the sign in button. I suspect it is related to the configuration in env.py.

2019-06-26_18-04-36

NgoniChoga commented 5 years ago

hi @mattchen089, Have you created your .env.development and .env.production files. Since you are setting up a dev environment, your file should look as follows:

REACT_APP_API_DOMAIN = https://localhost:8000
REACT_APP_AWS_ID = "YOUR_AWS_ID";
REACT_APP_AAF_URL = "<YOUR_AAF_IDP>";
NgoniChoga commented 5 years ago

Solved in, https://github.com/moocunsw/ontask3_UNSW/pull/154