gnowledge/gstudio — pull request #811 by AvadootNachankar (2014-09-17 13:21:25+00:00)
Title: filldb script updated to fill attribute_set & relation_set fields

* Please kindly take backup of your database & rcs-repo directory

- How to take backup:

1) Be in manage.py directory and run given command: **cp -vr gnowsys_ndf/ndf/rcs-repo/ ~/Documents/**

- This will create directory as '~/Documents/rcs-repo/'

2) Go to the rcs-repo backup directory and run given command (~/Documents/rcs-repo/): **mongodump -d studio-dev**

- It will create a directory as 'dump'

* Be in manage.py directory and run following command: **python manage.py filldb -nc**

- Check out log file created @ '.../management/commands/schema_files/filldb.log'

* For more details on options '-nc', refer below explanation!

- How to restore (if something goes wrong):

1) Go in mongo shell and delete existing database

- use studio-dev

- db.dropDatabase()

2) Go to the rcs-repo backup directory and run given command (~/Documents/rcs-repo/): **mongorestore dump/**

3) Copy paste the rcs-repo backup directory back to given path '.../gnowsys_ndf/ndf/'

**Functionalities implemented:**

1) settings.py

- Setting system's default encoding as 'utf-8'

2) filldb.py updated

- Script updated to fill attribute_set & relation_set fields of all existing GSystems.

- This command setup with new options which are as follows:

- **'-s'** or **'--setup-structure'**: This performs activities required for setting up default structure or updating it.

- **'-n'** or **'--no-structure'**: This skips performing any activities required for updating structure.

- **'-c'** or **'--clean-structure'**: This performs activities required in cleaning inconsistent data in structure.

- Use-cases are as follows:

1) By default, '-s' option is executed. [That is if you don't specify any option]

2) If you only want to clean the structure, you must expicitly specify '-c' option. [As cleaning is not done implicitly]

3) If you use only '-n', the script will do nothing as '-n' option tells script to by pass option '-s'.

- Logging feature is also implemented for this file.

3) models.py updated

- Bug: For Moderated Group that was created long time ago, I found 'member_of' is set as empty list. So it was going for searching fallback field 'gsystem_type' which doesn't exists now!

- This is resolved: ```member_of_names_list()``` function modified - Look for 'gsystem_type' field only if this key exists!