gnowledge/gstudio — pull request #832 by sunnychaudhari (2014-09-23 08:23:21+00:00)
Title: Collection manager updated

**NOTE: run this command ```python manage.py filldb```**

Collection manager updated as bellow:

* node_edit_base.html template modified. Made the proper alignment of the code by checking each starting and closing tags. Removed unwanted structure.
Also provided blocks for each drawer widget.
As previously due to some of the unending tags causes problem in page structure of edit.
Removed the h1 tag defined for editing name text, due to which page was looking messy as half of the page has occupied of editing name in text box. Now made the proper alignment of the widgets in edit page.

* For editing page ,file there are:
"requires", "collection", "metadata" and "teaches" tabs
For editing topic there is "assesses" tab also included.

* For making collections there are two types as "homogeneous" and "heterogeneous" as previous.
For selection of homogeneous collection radio buttons provided.
All radio buttons have organised in proper alignment. Improved the font style for those.
When user clicks on radio button which mean he/she needs to create homogeneous collection of certain, type. According to the users selection left and right drawer changes as per the type selected.
As previously it was not. Previously we hav fixed the right drawer for making any type of collection.

* For saving collection:
* When user clicks on collection tab by default there is heterogeneous collection mechanism for which collection elements can be added, removed, and ordered using arrows.
But when user presses any radio button for selecting the resourse type, only adding is possible. I.e. only right arrow can be displayed. Since it was not making sense in keeping all those arrows due to which user may loose its collection elements or its order

* Also when user selects any resourse type using radio button, save button disabled. As collection saving mechanism works on ajax request, and save button code fetches the right drawer list for saving and maintaining the order.

* Previously we were facing problem due to this as by clicking on save button for collection it was only working properly with heterogeneous collections. Selected homogeneous gets disappears at same time.

* Hence, now there is only right arrow to be visible for making collection of homogeneous type.
When user clicks on right shift arrow to select and keep the elements in right drawer ,it asks for saving the selection , If user clicks OK , then those particular selected collection elements get saved and drawer refreshes. Or if user clicks on Cancel then current selection removes and drawer refreshes. Due to this provision now user will not loose his/her selected collection elements.

* For editing resources all tabs such as "requires", "collection", "teaches" and "assesses" for which drawer widget is used are activated only on click of them. All tabs works on ajax call so that editing page performance increased.

* Implemented pagination successfully on left drawer elements.
* Used mongokit paginator for working with all cursor objects and loading only 10 elements at a time.

* Due to this feature we can again load the drawer with node objects since we can get the related info of each drawer element along with thumbnail within a short time. This will help the user to navigate from pagination numbers to get the drawer elements.

* Pagination implemented for left drawer only. We also hav to keep this for right drawer as wel. Am currently working on it. Due to this user can maintain as many collection as he wants without causing a performance level.

* In Mongokit there is Paginator class in paginator.py file, in which all pagination related functions written to work with mongodb cursor objects. As we are difining the cursor objects as "drawer" in get_drawers function in methods.py which enables us to make use of pagination in drawers to navigate from as many as of drawer elements.

* ```paginator.Paginator(drawer, page_no, 10)``` --> this is used for paginating the drawer elements (you can check this in ```ajax_views.py --> drawer_widget()``` ), "drawer" is our cursor object of desired drawer elements, "page_no" is the starting page number from which pagination starts, and "10" is the pagination limit on desired drawer elements.

* Due to this pagination feature our drawer loading performance has increased. Also this will help the curators to navigate easily from the drawer elements.

* Implemented search on left collection drawer.
* While making a collection user can also search the desired element from drawer.

* Previously, search feature on drawer was not proper since it was getting long time to load the drawer elements by desired search results.

* Now search module is updated n improved using an ajax call for searching elements.

* For to make use of search on collection drawer, user need to atleast type first 3 characters of desired element. As soon as 3 charaters are typed, ajax call goes and update the drawer with providing desired search results.

* For this implemented mongodb search feature for searching the elements using the regular expression query, which gives us the results of matching elements.
Due to pagination and search feature, collection manager performance have improved.

* Also updated code for theme drawer which is used to add the theme items or topics.

* Now topic editing page updated.
* ```node_edit_base.html``` template used for topic editing. So that any changes made will be reflected as same for page, resource and topics.

* Previously, there are separate template kept for topic editing and evrytime when node_edit_base.html updated, simultaneously we needed to apply those changes in topic_create_edit.html. Hence its avoided now by using only one template ```node_edit_base.html``` works fine for editing topics.

* ```theme_topic_create_edit``` function modified in ```browse_topic.py``` according to get_drawers function used to manipulate drawer items for topic and themes

* get_drawers function in methods.py on which all drawer widgets are getting manipulated with elements is modified, as we implemented pagination on drawer elements , and mongokit paginator uses mongodb cursor objects to implement pagination on drawer. Hence now get_drawer functuion returns the cursor object as "drawer".

* "File" & "Pandora_video" ST included (in factory_type.py) for teaches(RT) subject_type & object_type, since previously it was getting error due to selected elements doesnt exist with member_of of these ST.

* Now metadata editing possible.
* Used variables defined in settings.py file for attributes to fill metadata.

* Dropdown available for filling the metadata values. When user saves the metadata it shows highlighted in dropdown for particular node.

* Included "GSTUDIO_RESOURCES_TIME_REQUIRED" , "GSTUDIO_RESOURCES_AGE_RANGE" & "GSTUDIO_RESOURCES_READING_LEVEL" variables in setting.py for resources metadata, previously these variables was not defined, also "GSTUDIO_RESOURCES_READING_LEVEL" this variable is kept blank temporarily, we need to fix the values for this.

* ```node_edit_base.html``` template modified according to display all attributes defined for resources to fill the metadata. get_metadata_values --> tag defined for manipulating the metadata attributes for resources, get_attribute_value --> tag defined for fetching the object_value for desired attribute of the node.

* As its automated whenever we need to provide any attribute to fill the metadata value then we just need to define that variable in settings it will populate the values in dropdown automatically.

* Saving of metadata values for pandora videos bug resolved.

**Special NOTE:**
For developers who wants to display the drawers on page overlay(i,e on page reveal), make use of edit_drawer_widget() tag defined in ndf_tags.py, which is specifically made for displaying drawers on page overlay, since now our drawers are managed on ajax call, due to which script and css used for managing the drawers in "drawer_widget.html" doesnt applicable on overlay, and because of which it will not display drawers on overlay properly.

SInce i have modified the get_drawers() in methods.py, if you find any problem regarding displaying drawer widget in your code, please report bug to me.