systers/portal — pull request #14 by ana-balica (2014-06-25 20:14:40+00:00)
Title: Create user groups and assign permissions on post_syncdb signal

The following change is dependent on #9 and makes assumptions about model class names, since default permissions are created using those.

This PR will be changed accordingly and rebased against merged models. The manual testing was done using dummy models, but doesn't include those, nor the app `__init__.py`or updates in `base.py` settings.

The user groups define 4 different levels of access. The admin level is not included, since this is the Systers Keeper and by becoming Django superuser she has access to everything via admin panel.

I have written a test for the following change, but it fails, because the order of running syncdb handlers is different in test mode. By running `python manage.py syncdb` the order is the following:
* Running post-sync handlers for application dashboard
* Adding permission 'dashboard | model name | Can add/change/delete model name'
* Initializing data post_syncdb

When running `python manage.py test`:
* Running post-sync handlers for application dashboard
* Initializing data post_syncdb
* Exception raised because `create_user_groups` tries to get permission objects from the database, but those were not yet inserted

Is it possible to force a specific order on syncdb execution in test mode? Or maybe there is a better way to solve the issue?