from django.urls import include, path
from rest_framework import routers
from rest_framework.authtoken import views
from ces_fall_rest_api.views.major_view import MajorViewSet
from ces_fall_rest_api.views.semester_view import SemesterViewSet
from ces_fall_rest_api.views.faculty_view import FacultyViewSet
from ces_fall_rest_api.views.course_view import CourseViewSet
from ces_fall_rest_api.views.gen_question_view import GenQuestionViewSet
from ces_fall_rest_api.views.outcome_view import OutcomeViewSet
from ces_fall_rest_api.views.responses_view import ResponsesViewSet
from ces_fall_rest_api.views.section_view import SectionViewSet
from ces_fall_rest_api.views.student_in_section_view import StudentInSectionViewSet
from ces_fall_rest_api.views.user_view import UserViewSet
from ces_fall_rest_api.views.student_view import StudentViewSet
from ces_fall_rest_api.views.subject_area_view import SubjectAreaViewSet
from ces_fall_rest_api.views.major_question_view import MajorQuestionViewSet

# Use this urls file to attach every url to the views rather than the
# the main project urls file.

router = routers.DefaultRouter()
router.register(r'faculty', FacultyViewSet, basename='faculty')
router.register(r'outcomes', OutcomeViewSet, basename='outcomes')
router.register(r'responses', ResponsesViewSet, basename='responses')
router.register(r'sections', SectionViewSet, basename='sections')
router.register(r'courses', CourseViewSet, basename='courses')
router.register(r'gen_questions', GenQuestionViewSet, basename='gen_questions')
router.register(r'users', UserViewSet, basename='users')
router.register(r'students_in_sections', StudentInSectionViewSet,
                basename='students_in_sections')
router.register(r'students', StudentViewSet, basename='students')
router.register(r'subject_areas', SubjectAreaViewSet, basename='subject_areas')
router.register(r'major_questions', MajorQuestionViewSet,
                basename='major_questions')
router.register(r'semesters', SemesterViewSet, basename='semesters')
router.register(r'majors', MajorViewSet, basename='majors')

urlpatterns = [
    path('sections/<int:reference>/<int:year>/<int:month>/',
         SectionViewSet.as_view({'get': 'retrieve', })),
    path('sections/section_with_course/<int:section_id>/',
         SectionViewSet.as_view({'get': 'section_with_course'})),

    path('faculty/<str:pk>/view_individual_responses/<int:reference>/<int:year>/<int:month>/',
         FacultyViewSet.as_view({'get': 'view_individual_responses'})),
    path('faculty/<str:pk>/view_all_responses/',
         FacultyViewSet.as_view({'get': 'view_all_responses'})),
    path('faculty/<str:pk>/view_annual_responses/<int:year>/<int:course>/',
         FacultyViewSet.as_view({'get': 'view_annual_responses'})),
    path('faculty/<str:pk>/view_semester_responses/<int:year>/<int:month>/',
         FacultyViewSet.as_view({'get': 'view_semester_responses'})),
    path('faculty/<str:pk>/get_sections/<int:year>/<int:month>/',
         FacultyViewSet.as_view({'get': 'get_sections'})),
    path('faculty/<str:pk>/subject_area_year_responses/<int:year>/<str:degree>/',
         FacultyViewSet.as_view({'get': 'subject_area_year_responses'})),
    path('faculty/<str:pk>/subject_area_semester_responses/<int:year>/<int:month>/<str:degree>/',
         FacultyViewSet.as_view({'get': 'subject_area_semester_responses'})),
    path('faculty/<str:pk>/subject_area_individual_responses/<int:reference>/<int:year>/<int:month>/<str:degree>/',
         FacultyViewSet.as_view({'get': 'subject_area_individual_responses'})),

    path('outcomes/course_outcomes/<int:id>/',
         OutcomeViewSet.as_view({'get': 'course_outcomes'})),
    path('outcomes/<str:heading>/<int:year>/<int:month>/',
         OutcomeViewSet.as_view({'get': 'retrieve'})),

    path('gen_questions/genquestions_by_semester/<int:year>/<int:month>/',
         GenQuestionViewSet.as_view({'get': 'genquestions_by_semester'})),
    path('gen_questions/gen_question_per_semester/<int:id>',
         GenQuestionViewSet.as_view({'get': 'gen_question_per_semester'})),

    path('major_questions/<int:pk>/<int:semester_id>/',
         MajorQuestionViewSet.as_view({'get': 'retrieve'})),
    path('major_questions/major_questions_per_semester_id/<int:id>/',
         MajorQuestionViewSet.as_view({'get': 'major_questions_per_semester_id'})),
    path('major_questions/major_questions_per_semester/<int:year>/<int:month>/<int:major>/',
         MajorQuestionViewSet.as_view({'get': 'major_questions_per_semester'})),

    path('students_in_sections/student_evaluated/<str:student>/<str:section>',
         StudentInSectionViewSet.as_view({'get': 'student_evaluated'})),

    path('courses/<str:number>/<int:year>/<int:month>/',
         CourseViewSet.as_view({'get': 'retrieve'})),

    path('semesters/<int:year>/<int:month>/',
         SemesterViewSet.as_view({'get': 'retrieve'})),

    path('majors/<str:degree>/<str:subject_area>/',
         MajorViewSet.as_view({'get': 'retrieve'})),

    path('', include(router.urls)),
    path('get-token/', views.obtain_auth_token, name='get-token'),
]
