# Path: course/forms/forms.py
# class CaptchaPasswordResetForm(PasswordResetForm):
# 	captcha = (
# 		ReCaptchaField() 
# 		if settings.RECAPTCHA_PUBLIC_KEY != '' and settings.RECAPTCHA_PRIVATE_KEY != ''
# 		else None
# 	)
# 
# 	def __init__(self, *args, **kwargs):
# 		super().__init__(*args, **kwargs)
# 		self.fields['email'].widget.attrs.update({'autofocus': 'autofocus'})
# 
# 	def get_users(self, email):
# 		# removed check verifying if password is unusable
# 		user_model = get_user_model()
# 		active_users = user_model._default_manager.filter(**{
#             '%s__iexact' % user_model.get_email_field_name(): email,
#             'is_active': True,
#         })
# 
# 		return active_users
# 
# class UsernameOrEmailAuthenticationForm(AuthenticationForm):
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.fields['username'].label = _("Username / Email")
# 
# Path: course/views.py
# def error_page(request):
# def index(request):
# def login(request, **kwargs):
# def classes(request):
# def home(request, course_code, class_code):
# def assignments (request, course_code, class_code, student_id=None):
# def get_enrollment(student_user_id, course_code, class_code):
# def get_class_instructor(request, course_code, class_code):
# def filter_past_classes(query):
# def filter_current_classes(query):
# def filter_future_classes(query):
# def get_ranking_data(course_class, ranking_size):
# def get_students_data(course_class):
# def get_assignments_data(enrollment):
# def get_tasks_data(assignment, enrollment):
# def get_achievements_data(enrollment):


from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views
from course.forms.forms import CaptchaPasswordResetForm, UsernameOrEmailAuthenticationForm
from course import views
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(
        r'^login/?$',
        views.login,
        {'authentication_form': UsernameOrEmailAuthenticationForm},
        name='login'
    ),
    url(r'^logout/?$', auth_views.logout, name='logout'),
    url(r'', include('course.urls')),
]

if settings.DEBUG:
	urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.EMAIL_HOST != '':
    urlpatterns += [
        url(
            r'^password_reset/$',
            auth_views.password_reset,
            {

# Path: course/forms/forms.py
# class CaptchaPasswordResetForm(PasswordResetForm):
# 	captcha = (
# 		ReCaptchaField() 
# 		if settings.RECAPTCHA_PUBLIC_KEY != '' and settings.RECAPTCHA_PRIVATE_KEY != ''
# 		else None
# 	)
# 
# 	def __init__(self, *args, **kwargs):
# 		super().__init__(*args, **kwargs)
# 		self.fields['email'].widget.attrs.update({'autofocus': 'autofocus'})
# 
# 	def get_users(self, email):
# 		# removed check verifying if password is unusable
# 		user_model = get_user_model()
# 		active_users = user_model._default_manager.filter(**{
#             '%s__iexact' % user_model.get_email_field_name(): email,
#             'is_active': True,
#         })
# 
# 		return active_users
# 
# class UsernameOrEmailAuthenticationForm(AuthenticationForm):
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.fields['username'].label = _("Username / Email")
# 
# Path: course/views.py
# def error_page(request):
# def index(request):
# def login(request, **kwargs):
# def classes(request):
# def home(request, course_code, class_code):
# def assignments (request, course_code, class_code, student_id=None):
# def get_enrollment(student_user_id, course_code, class_code):
# def get_class_instructor(request, course_code, class_code):
# def filter_past_classes(query):
# def filter_current_classes(query):
# def filter_future_classes(query):
# def get_ranking_data(course_class, ranking_size):
# def get_students_data(course_class):
# def get_assignments_data(enrollment):
# def get_tasks_data(assignment, enrollment):
# def get_achievements_data(enrollment):


# Path: gamifiededucation/urls.py
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views
from course.forms.forms import CaptchaPasswordResetForm, UsernameOrEmailAuthenticationForm
from course import views

Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(
        r'^login/?$',
        views.login,
        {'authentication_form': UsernameOrEmailAuthenticationForm},
        name='login'
    ),
    url(r'^logout/?$', auth_views.logout, name='logout'),
    url(r'', include('course.urls')),
]

if settings.DEBUG:
	urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.EMAIL_HOST != '':
    urlpatterns += [
        url(
            r'^password_reset/$',
            auth_views.password_reset,
            {

                'password_reset_form': CaptchaPasswordResetForm,