# Path: course/views/index.py
# def index(request):
#     return render(
#         request,
#         'index.html',
#         {
#             'title': _('Welcome'),
#             'news': news.News.objects.order_by('-id')
#         }
#     )
# 
# Path: course/views/subject.py
# def course_overview(request, subjectname):
# def subject_overview(request):
# def create(request):
# def edit(request, subjectname):
# def delete(request, subjectname):
# 
# Path: course/views/course.py
# def course(request: HttpRequest, course_id: str):
#     """
#     Controller for single course info page
# 
#     :param request: request object
#     :param course_id: id for the course
#     :return:
#     """
#     try:
#         current_course = Course.objects.get(id=course_id)
# 
#         if hasattr(request.user, 'userinformation'):
#             user = request.user.userinformation
# 
#             if isinstance(user, UserInformation):
#                 context = current_course.as_context(user)
#             else:
#                 context = current_course.as_context()
#         else:
#             context = current_course.as_context()
# 
#         session = request.session
#         if 'enroll-error' in session:
#             context['error'] = session['enroll-error']
#             del session['enroll-error']
# 
#         return render(
#             request,
#             'course/info.html',
#             context
#         )
#     except Course.DoesNotExist:
#         return db_error(_('Requested course does not exist.'))
# 
# Path: course/views/enroll.py
# def add(request, course_id):
# def remove(request, course_id):
# 
# Path: course/views/time.py
# def edit_slot(request: HttpRequest, course_id):
# def remove_slot(request, course_id, slot_id):
# 
# Path: course/views/news.py
# def create(request):
# def edit(request: HttpRequest, news_id: str):
# def delete(request: HttpRequest, news_id: str):


from django.urls import include, path, re_path
from django.contrib import admin
from course.views import index, subject, course, enroll, time, news


handler404 = 'course.views.index.handler404'
handler500 = 'course.views.index.handler500'

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^$', index.index, name='index'),
    re_path(r'^subject/', include([
        # If you want to add new urls for subjects, you have to add them
        # before the generic subject url (last entry).
        # Also add the string in question to the SUBJECT_DISALLOWED_NAMES in
        # 'forms.py'.
        re_path(r'^overview/$', subject.subject_overview, name='subject-overview'),
        re_path(r'^new/$', subject.create, name='create-subject'),
        re_path(r'^(?P<subjectname>[^/?]+)/', include([
            re_path(r'^$', subject.course_overview, name='subject'),
            re_path(r'^edit/$', subject.edit, name='edit-subject'),

# Path: course/views/index.py
# def index(request):
#     return render(
#         request,
#         'index.html',
#         {
#             'title': _('Welcome'),
#             'news': news.News.objects.order_by('-id')
#         }
#     )
# 
# Path: course/views/subject.py
# def course_overview(request, subjectname):
# def subject_overview(request):
# def create(request):
# def edit(request, subjectname):
# def delete(request, subjectname):
# 
# Path: course/views/course.py
# def course(request: HttpRequest, course_id: str):
#     """
#     Controller for single course info page
# 
#     :param request: request object
#     :param course_id: id for the course
#     :return:
#     """
#     try:
#         current_course = Course.objects.get(id=course_id)
# 
#         if hasattr(request.user, 'userinformation'):
#             user = request.user.userinformation
# 
#             if isinstance(user, UserInformation):
#                 context = current_course.as_context(user)
#             else:
#                 context = current_course.as_context()
#         else:
#             context = current_course.as_context()
# 
#         session = request.session
#         if 'enroll-error' in session:
#             context['error'] = session['enroll-error']
#             del session['enroll-error']
# 
#         return render(
#             request,
#             'course/info.html',
#             context
#         )
#     except Course.DoesNotExist:
#         return db_error(_('Requested course does not exist.'))
# 
# Path: course/views/enroll.py
# def add(request, course_id):
# def remove(request, course_id):
# 
# Path: course/views/time.py
# def edit_slot(request: HttpRequest, course_id):
# def remove_slot(request, course_id, slot_id):
# 
# Path: course/views/news.py
# def create(request):
# def edit(request: HttpRequest, news_id: str):
# def delete(request: HttpRequest, news_id: str):


# Path: course/urls.py
from django.urls import include, path, re_path
from django.contrib import admin
from course.views import index, subject, course, enroll, time, news



handler404 = 'course.views.index.handler404'
handler500 = 'course.views.index.handler500'

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^$', index.index, name='index'),
    re_path(r'^subject/', include([
        # If you want to add new urls for subjects, you have to add them
        # before the generic subject url (last entry).
        # Also add the string in question to the SUBJECT_DISALLOWED_NAMES in
        # 'forms.py'.
        re_path(r'^overview/$', subject.subject_overview, name='subject-overview'),
        re_path(r'^new/$', subject.create, name='create-subject'),
        re_path(r'^(?P<subjectname>[^/?]+)/', include([
            re_path(r'^$', subject.course_overview, name='subject'),
            re_path(r'^edit/$', subject.edit, name='edit-subject'),

            re_path(r'^delete/$', subject.delete, name='delete-subject'),