gnowledge/gstudio — pull request #934 by AvadootNachankar (2014-12-07 06:02:14+00:00)
Title: Student-Course Enrollment Approval Implementation and Bug fixes & other improvements

**Functionalities implemented:**
1) Student-Course Enrollment Approval
2) Batch: Bug fix and Improvements
3) Registraion UI updated
4) Bug fixes and Other Improvements

**Student-Course Enrollment Approval**

1. urls/ajax-urls.py
- Following url's added: ```get_students_for_approval``` & ```approve_students```

2. urls/mis.py
- ```mis_enroll``` url modified

3. views/ajax_views.py
- ```get_announced_courses_with_ctype()``` modified
- response_dict varaible, by default, now holds two keys ```success``` and ```message```
- If no announced course(s) found, sending proper message which gets displayed to user.
- ```get_anncourses_allstudents()``` modified
- Queries modified to search in group_set if group_id is of college group; otherwise making use of student_belongs_to_college relationship for listing students
- Also populating already enrolled students in right drawer using StudentCourseEnrollment node created for given announced course
- **get_students_for_approval()** created
- This returns data-review list of students that need approval for Course enrollment
- **approve_students()** created
- This returns approved and/or rejected students count respectively.

4. views/methods.py
- **create_task()** added
- Creates/updates task with required attribute(s) and relation(s).
- Accepts two parameters:
- ```task_dict``` - a dictionary with following keys set: _id[optional], name, group_set, created_by, modified_by, contributors, content_org, created_by_name, Status, Priority, start_time, end_time, Assignee, has_type
- ```task_type_creation``` - accepts following values:
- single: Only one task is created for single/multiple assignee(s)
- group: If given task is a group task (create a task for each Assignee from the list)

5. views/course.py
- ```course_create_edit()``` modified
- announced-course name pattern modified
- course-code_college-code_start-time:MMM-YYYY_end-time:MMM-YYYY
- Code added to create task for Program Officer of respective college for which announced course is going to be announced

6. templates/ndf/student_list.html
- ```Enroll in Courses``` button commented for time being
- Enrollment now possible only via link provided in enrollment task's description.

7. views/person.py
- ```person_enroll()``` modified
- Based on enroll state ("In Progress", "Complete"), saving functionality modified
- Modifying respective **StudentCourseEnrollment** node
- When enroll state is "Complete", creating task for group admin of MIS_admin group for approving students enrolled in given announced course
- In case of GET request, passing following context parameters to template which are required while enrollemnt of students in courses:
- ```task_id``` - ObjectId of StudentCourseEnrollment task
- ```nussd_course_type``` - Course type name from selected StudentCourseEnrollment node
- ```ann_course_id``` - Announced Course ObjectId from selected StudentCourseEnrollment node
- ```person_create_edit()``` modified
- Unnecessary query removed

8. templates/ndf/student_enroll.html
- UI modified
- Announced-course dropdown along with it's duration details shifted to ```Select Students``` fieldset
- ```Enroll``` button replaced by ```In Progress``` and ```Complete``` buttons
- Few hidden input elements added to hold announced-courses' list, task's ObjectId and enroll-state ("In Progress"/"Complete")
- Document ready updated
- Now on load if course type has any value that value is set
- Similarly with announced-course and it's duration

9. views/userDashboard.py
- ```group_dashboard()``` modified
- Returns enrollment details of each announced course of each college along with count of enrolled, approved & rejected
- ```uDashboard()``` modified
- Assigned task's retrieval for User updated - Listing only "New" and "In Progress" task

10. templates/ndf/group_dashboard.html
- New tab created: "Approval"
- This tab is shown only when approval-details exists
- Passing a boolean variable ```approval``` from views
- This tab holds two parts:
1) Enrollment Approval details (Summarized form)
2) Approval details (Detailed information about each student)
- This part exists only when there's any enrollment is going on.

11. templates/ndf/approval_data_review.html
- Displays detailed information about each student for course enrollment approval

**Batch: Bug fix and Improvements**
1. views/ajax_views.py (Bug fix)
- ```get_students_for_batches()``` modified
- Previously only considering group for searching students approved in given course
- Now either considers group or college; because when students were added via csv there group_set field gets updated with MIS_admin group's ObjectId and not by college group's ObjectId

2. views/batch.py
- Unecessary queries removed
- Unecessary if-else block removed and context variables' dictionary updated

3. templates/ndf/new_create_batch.html
- Default selection for announced-course modified
- Previously it was having any one of the announced-course value
- Now " - - - Select Course - - - " is set
- On page load activities also modified for creation and updation of a batch

**Registraion UI updated**

* Occupation and Affiliation are made non-mandatory fields

1. models.py
- If no value is selected for ```agency_type```, then setting default value as "Other"

2. templates/registration/registration_form.html
- agency_type and affiliation fields are made non-mandatory

**Bug fixes and Other Improvements**

1. settings.py
- **GSTUDIO_TASK_TYPES** site-wide variable added that holds any one of the following values: "Bug", "Feature", "Support", "UI Feature", "Other"

2. views/notify.py
- ```invite_users()``` and ```invite_admins()``` modified:
- Sorted query by email

3. templates/ndf/node_ajax_view.html
- Condition modified for displaying **sub-group** creation button
- Now **only superuser can create** sub-groups within a group
- Editing policy updated for **group edit**
- Now **along with superuser & creator of the group, group-admins can also edit** a group

4. views/ajax_views.py
- ```set_drawer_widget_for_users()``` modified
- Instead of usernames, now listing email-Ids in subscription's drawer-widget
- ```get_students_for_batches()``` modified (Bug fix)
- Previously only considering group for searching students approved in given course
- Now either considers group or college; because when students were added via csv there group_set field gets updated with MIS_admin group's ObjectId and not by college group's ObjectId

5. templatetags/ndf_tags.py
- ```get_all_user_groups()``` modified
- Query modified which lists Author nodes; now gives a sorted list
- ```get_group_type()``` modified
- Now returns boolean value depending upon url's authenticity

6. templates/ndf/base.html
- Lengthy group names are shortened to 20 characters
- For shortened group name, tool-tip is provided to display their full name
- Valid url-check: If condition modified that checks for boolean value (previously looking for "pass"/"allowed"

7. templates/registration/login.html
- Tab-index set for html-form elements

8. templates/ndf/mis_list.html
- Bug fix: Unnecessary close of anchor tag removed