gnowledge/gstudio — pull request #905 by sunnychaudhari (2014-11-13 08:15:01+00:00)
Title: Collection save is made on click of save button, remodified collection manipulation methods

**Remodified last commit ("#898") along with Feature Enhancements**

* Collection save is made on click of save button itself , previously saving of collection elements are made on right shift button in collection drawer, due to which lot of confusion occured.

* Conditions modified for removal of multiple collection elements

* Previously unnecessarily code was manipulating collections , prior node, teaches , assesses list and metadata on saving of each and every node , now conditions added according to the selection type , it means collections will get manipulated or saved when user clicks on collection tab, teaches list will be manipulated or saved when user clicks on teaches tab ....and so on.

* Also check is made for saving of metadata info.

* Input hidden field is added in drawer_widget.html for identifying the selection type such as collection, requires, teaches, assesses lists. Also input hidden field is added on click of metadata tab so as to check the saving of metadata info for a node.

* These conditions and checks were added while saving of each node according to the selection tab.
get_node_common_ field() method is modified in methods.py with above checks and conditions.

* Code removed on right shift collection save in ```drawer_widget.html``` template.

* While making homogeneous collections , previously there was only right shift button visible, now left shift and right shift buttons are visible since user can also remove collection elements from homogeneous collection of node.

* Shift up and shift down button in collection drawers are disabled while in homogeneous collection , since ordering doesnt makes sense in homogeneous.

* For heterogeneous collections all left , right, up, down shift buttons are visible.

* Collection tree elements in left panel font size decreased.

* **Looping structure removed from collections**
* while displaying collections in left panel now looping of collection elements are avoided.

* Code implemented to not to select nodes while building collection which forms the loop.
functions implemented for for this :
```filter_drawer_nodes() in methods.py```
This method finds entire parents hierarchy of node , and if it finds the parent nodes which also consists of same node which forms the loop in it ,will get removed from left drawer elements.
* Hence in any case we acheived the feature to not to form a loop while building collections of any node.
* Also written a script **(remove_collection_loop.py)** to remove already available collection elements in database which forms the loop in particular collection.

* **Collection elements removal bug resolved**
* Previously while removing collection elements from heterogeneous was possible, but when you remove elements from homogeneous drawer it was overwriting the existing collection set, due to this heterogeneous collection elements which available was getting removed. Since we were just taking the right drawer list of current context to save the collection.

* Now checks implemented in ```drawer_widget.html```
* Included **checked** variable which takes the value of currently clicked homogeneous type while saving, to identify from which homogeneous type collection elements to be removed.

* ```build_collection()``` method implemented in methods.py where all collection drawers (prior node, collection, teaches, assesses drawers) are getting manipulated this function accepts cheked variable for identifying in which homogeneous type manipulation is required.

* Logic implemented for removal of elements from homogeneous collection drawer :
* While taking right drawer list it identifies first from which type of drawer element is removed, above mentioned "checked" variable receives that value, then from nodes collection_set only those elements will get collected which are of type ("checked") , such as (Page, File, Image, Video, Pandora video, Quiz etc).
and if nodes collection_set is not matched with incomming right_drawer_list then that not matching collection element will get removed from nodes colection_set.
* Previously when we removed all elements from any homogeneous drawer , all other collection elements of node was also getting removed. since right_drawer_list receives the empty list.
* Hence now after removing all elements from homogeneous drawer it first identifies from ("checked") which type of drawer it is, then collect only those elements which has member_of ("checked") and remove those elements only from nodes collection_set.
* Reason behind this change is, we have "right_drawer_list" which we are using for saving as well as removing collection elements.

* Bug resolved in displaying teaches and assesses list on node detail view.
Previously only one element was displayed in teaches & assesses list in detail view of any node.
```get_teaches_list() and get_assesses_list() --> ndf_tags.py```
These functions implemented to manipulate the entire teaches and assesses list to display into the detail view of node.

* Bug resolved in creating a new page

**What is to test**

* First of all run script as : **python manage.py remove_collection_loop**
This script will remove those collection elements which are forming loop in particular node.

* check whether collection , requires, teaches lists are saving properly on click of save button.

* check whether all right drawer elements can be removed or not.

* Now collection can be saved on click of save button bellow the drawers. Save button is now enabled for all selection types( such as collection, requires, teaches and assesses lists) to save.

* Check for removal of collection elements in all drawers. check for homogeneous as well as heterogeneous collections removal.

* Also check that, while selecting collection elements , you will not find those elements in left drawer which will make loop in collection.