views.py File Reference

File documentation. More...

## Functions

def | discussion.views.login (request)
| This function is used for login. More...
def | discussion.views.logout (request)
| This function is used for logout. More...
def | discussion.views.signup (request)
| This function is used for signup. More...
def | discussion.views.default (request)
| This function is used for setting context if the user is professor.
def | discussion.views.prof_home (request)
| This function is used for rendering the homepage of Professor.
def | discussion.views.prof_subjects (request)
| This function is used for displaying the subject cnd adding new subjects. More...
def | discussion.views.student_list (request, sub_code)
| This function is used for displaying the list of students. More...
def | discussion.views.accept_student (request, sub_code, pid)
| This function is used by Professor to accept student's Requests. More...
def | discussion.views.request_subject (request, sub_code)
| This function is used by Student to request for a Subject. More...
def | discussion.views.reject_student (request, sub_code, pid)
| This function is used by Professor to reject student's Requests or remove the accepted students. More...
def | discussion.views.reject_subject (request, sub_code)
| This function is used by Student to reject existing Requests. More...
def | discussion.views.withdraw_subject (request, sub_code)
| This function is used by Student to withdraw the registered subject. More...
def | discussion.views.show_subjects (request)
| This function is used by Student to list accepted subjects corresponding to student. More...
def | discussion.views.show_all_subjects (request)
| This function is used by Student to list all available subjects. More...
def | discussion.views.show_pending_subjects (request)
| This function is used by Student to list pending subject corresponding to student. More...
def | discussion.views.show_topics (request, id)
| This function is used by both Student and Professor to list Topics of corresponding Subject. More...
def | discussion.views.show_threads (request, id)
| This function is used by both Student and Professor to list Threads in particular Topics of a Subject. More...
def | discussion.views.update_thread_like_count (request, thread_id, topic_id)
| This function is used by Student to like a thread. More...
def | discussion.views.update_thread_dislike_count (request, thread_id, topic_id)
| This function is used by Studentto dislike a thread. More...

## Detailed Description

File documentation.

## Function Documentation

## accept_student()

def discussion.views.accept_student | ( |  | request,
|  |  | sub_code,
|  |  | pid
| ) |  |

This function is used by Professor to accept student's Requests.

    This function update the entry in the Subject_Student table i.e. is_accepted=True

Parameters

  sub_code | This varible store the subject code of subject for which students has applied
  pid | This contain the id of Person whos has applied for ths course

## login()

def discussion.views.login | ( |  | request | ) |

This function is used for login.

    This is the function which we call form the login page, here we validate the user for Person table in database ad redirect as
    per the user that is, if user is proessor we will redirect it to proper webpage

## logout()

def discussion.views.logout | ( |  | request | ) |

This function is used for logout.

    This function is use to logout the current session

## prof_subjects()

def discussion.views.prof_subjects | ( |  | request | ) |

This function is used for displaying the subject cnd adding new subjects.

    This function is used show the corresponding subjects of the Professor and Also provide him option to add  new subjects

## reject_student()

def discussion.views.reject_student | ( |  | request,
|  |  | sub_code,
|  |  | pid
| ) |  |

This function is used by Professor to reject student's Requests or remove the accepted students.

    This function deletes the entry in the Subject_Student table i.e. corrosponding to student with given pid and subject code

Parameters

  sub_code | This varible store the subject code of subject for which students has applied or get accepted
  pid | This contain the id of Person whos has applied for ths course or get accepted in the course

## reject_subject()

def discussion.views.reject_subject | ( |  | request,
|  |  | sub_code
| ) |  |

This function is used by Student to reject existing Requests.

    This function deletes the entry in the Subject_Student table i.e. corrosponding to student with given context and subject code

Parameters

  sub_code | This varible store the subject code of subject for which students has pending request

## request_subject()

def discussion.views.request_subject | ( |  | request,
|  |  | sub_code
| ) |  |

This function is used by Student to request for a Subject.

    This function adds a entry in the Subject_Student table with the field is_accepted=False

Parameters

  sub_code | This varible store the subject code of subject for which students has applied

## show_all_subjects()

def discussion.views.show_all_subjects | ( |  | request | ) |

This function is used by Student to list all available subjects.

    This function filter the subjects for which student has already requested

## show_pending_subjects()

def discussion.views.show_pending_subjects | ( |  | request | ) |

This function is used by Student to list pending subject corresponding to student.

    Here in this function we fetch all the requests made by the student and requests are pending.

## show_subjects()

def discussion.views.show_subjects | ( |  | request | ) |

This function is used by Student to list accepted subjects corresponding to student.

    Here in this function we fetch all the requests made by the student and get accepted.

## show_threads()

def discussion.views.show_threads | ( |  | request,
|  |  | id
| ) |  |

This function is used by both Student and Professor to list Threads in particular Topics of a Subject.

    In this function we fetch threads from Thread table filtering as per the Topic

Parameters

  sub_code | This varible store the Topic id of Topic for which we wants threads

## show_topics()

def discussion.views.show_topics | ( |  | request,
|  |  | id
| ) |  |

This function is used by both Student and Professor to list Topics of corresponding Subject.

    In this function we check if the request came from Professor. I yes then we hide the topics in which professor is not included.
    To Students we provide while list.Allow user to add new Topics.
    Again Students have right to exclude the Professor.But Professor doesnot have such option

Parameters

  id | This varible store the subject code of subject

## signup()

def discussion.views.signup | ( |  | request | ) |

This function is used for signup.

    This function is used for signup, here we redirct to the the login page if successfulll done the signup

## student_list()

def discussion.views.student_list | ( |  | request,
|  |  | sub_code
| ) |  |

This function is used for displaying the list of students.

    This list is made availabe to the Professor so that he can see which student's requsts are accepted and, which have pending status

Parameters

  sub_code | This varible store the subject code of subject for which Professor has to see the Student List

## update_thread_dislike_count()

def discussion.views.update_thread_dislike_count | ( |  | request,
|  |  | thread_id,
|  |  | topic_id
| ) |  |

This function is used by Studentto dislike a thread.

    Here we maintain the like table that stores the like and dislikes per thread, Here we increment the disike count
    and decrement the like count if already disliked

Parameters

  thread_id | This stores the id of thread of which we want to dislike

  topic_id

  This stores the id of topic of which the thread belong,This is use to redirect

      If already disliked then no change occurs

## update_thread_like_count()

def discussion.views.update_thread_like_count | ( |  | request,
|  |  | thread_id,
|  |  | topic_id
| ) |  |

This function is used by Student to like a thread.

    Here we maintain the like table that stores the like and dislikes per thread, Here we increment the like count
    and decrement the dislike count if already liked

Parameters

  thread_id | This stores the id of thread of which we want to like

  topic_id

  This stores the id of topic of which the thread belong,This is use to redirect

      If already liked then no change occurs

## withdraw_subject()

def discussion.views.withdraw_subject | ( |  | request,
|  |  | sub_code
| ) |  |

This function is used by Student to withdraw the registered subject.

    This function deletes the entry in the Subject_Student table i.e. corrosponding to student with given context and subject code

Parameters

  sub_code | This varible store the subject code of subject for which students has been accepted and student wants to withdraw the same