# Path: user/views/user.py
# def modify(request):
# def profile(request, user_id=None):
# def privacy_consent(request):
# def delete_account(request):
# 
# Path: user/views/register.py
# @sensitive_post_parameters('password1', 'password2')
# @sensitive_variables('password1', 'password2')
# def register(request):
#     if request.user.is_authenticated:
#         return redirect('index')
# 
#     if request.method == 'POST':
#         user_form = UserForm(request.POST)
#         userinformation_form = UserInformationForm(request.POST)
#         if (user_form.is_valid()
#                 and userinformation_form.is_valid()):
# 
#             created_user = user_form.save(commit=False)
#             created_user.is_active = False
#             created_user.save()
# 
#             created_user_information = userinformation_form.save(
#                 commit=False)
# 
#             created_user_information.user = created_user
# 
#             created_user_information.save()
# 
#             verification_mail(created_user, 'email',
#                                 created_user.email, request)
# 
#             acc = created_user.email
# 
#             return render(
#                 request,
#                 'registration/success.html',
#                 {
#                     'title': _('Registration successfull'),
#                     'mail': acc
#                 }
#             )
#         else:
#             print('validation failed')
#     else:
#         user_form = UserForm()
#         userinformation_form = UserInformationForm()
# 
#     return render(
#         request,
#         'registration/register.html',
#         {
#             'title': _('Registration'),
#             'user_form': user_form,
#             'userinformation_form': userinformation_form,
#         }
#     )
# 
# Path: user/views/verify.py
# def verify(request, type_):
# 
#     if 'token' not in request.GET or type_.lower() not in VERIFICATIONS:
#         try:
#             return VERIFICATIONS[type_.lower()].view(request)
#         except KeyError:
#             return render(
#                 request,
#                 'view-error.html',
#                 { 'message': _('This verification does not exist') }
#             )
#     else:
#         try:
#             db_entry = Activation.objects.get(token=request.GET['token'], type=ACTIVATION_TYPES[type_])
#         except Activation.DoesNotExist:
#             return render(
#                 request,
#                 'view-error.html',
#                 { 'message': _('The token you provided is invalid.') }
#             )
# 
#         VERIFICATIONS[type_.lower()].action(db_entry.user)
#         db_entry.delete()
#         return render(
#             request,
#             'user/activate.html',
#             {
#                 'title': _('Activation Succeded'),
#                 'no_login_redirect': True,
#             }
#         )
# 
# Path: user/views/contact.py
# CONTACT_FOOTER = """
# -------------------
# This message has been sent via the Course Mangement System.
# Sent by: """
# def contact_form(request: HttpRequest, user_id: int):


from django.urls import include, re_path, path
from django.contrib.auth import views as auth_views
from django.contrib.auth import urls as auth_urls
from .views import user, register, verify, contact


urlpatterns = [
    re_path(r'^register/$', register.register, name='register'),
    re_path(r'^edit/$', user.modify, name='modify-user'),
    re_path(r'^privacy-policy/$', user.privacy_consent, name='privacy-policy-updated'),
    re_path(r'^delete/$', user.delete_account, name='delete-account'),
    re_path(r'^profile/$', user.profile, name='user-profile'),
    re_path(r'^profile/(?P<user_id>[0-9]+)/$', user.profile, name='user-profile'),

# Path: user/views/user.py
# def modify(request):
# def profile(request, user_id=None):
# def privacy_consent(request):
# def delete_account(request):
# 
# Path: user/views/register.py
# @sensitive_post_parameters('password1', 'password2')
# @sensitive_variables('password1', 'password2')
# def register(request):
#     if request.user.is_authenticated:
#         return redirect('index')
# 
#     if request.method == 'POST':
#         user_form = UserForm(request.POST)
#         userinformation_form = UserInformationForm(request.POST)
#         if (user_form.is_valid()
#                 and userinformation_form.is_valid()):
# 
#             created_user = user_form.save(commit=False)
#             created_user.is_active = False
#             created_user.save()
# 
#             created_user_information = userinformation_form.save(
#                 commit=False)
# 
#             created_user_information.user = created_user
# 
#             created_user_information.save()
# 
#             verification_mail(created_user, 'email',
#                                 created_user.email, request)
# 
#             acc = created_user.email
# 
#             return render(
#                 request,
#                 'registration/success.html',
#                 {
#                     'title': _('Registration successfull'),
#                     'mail': acc
#                 }
#             )
#         else:
#             print('validation failed')
#     else:
#         user_form = UserForm()
#         userinformation_form = UserInformationForm()
# 
#     return render(
#         request,
#         'registration/register.html',
#         {
#             'title': _('Registration'),
#             'user_form': user_form,
#             'userinformation_form': userinformation_form,
#         }
#     )
# 
# Path: user/views/verify.py
# def verify(request, type_):
# 
#     if 'token' not in request.GET or type_.lower() not in VERIFICATIONS:
#         try:
#             return VERIFICATIONS[type_.lower()].view(request)
#         except KeyError:
#             return render(
#                 request,
#                 'view-error.html',
#                 { 'message': _('This verification does not exist') }
#             )
#     else:
#         try:
#             db_entry = Activation.objects.get(token=request.GET['token'], type=ACTIVATION_TYPES[type_])
#         except Activation.DoesNotExist:
#             return render(
#                 request,
#                 'view-error.html',
#                 { 'message': _('The token you provided is invalid.') }
#             )
# 
#         VERIFICATIONS[type_.lower()].action(db_entry.user)
#         db_entry.delete()
#         return render(
#             request,
#             'user/activate.html',
#             {
#                 'title': _('Activation Succeded'),
#                 'no_login_redirect': True,
#             }
#         )
# 
# Path: user/views/contact.py
# CONTACT_FOOTER = """
# -------------------
# This message has been sent via the Course Mangement System.
# Sent by: """
# def contact_form(request: HttpRequest, user_id: int):


# Path: user/urls.py
from django.urls import include, re_path, path
from django.contrib.auth import views as auth_views
from django.contrib.auth import urls as auth_urls
from .views import user, register, verify, contact



urlpatterns = [
    re_path(r'^register/$', register.register, name='register'),
    re_path(r'^edit/$', user.modify, name='modify-user'),
    re_path(r'^privacy-policy/$', user.privacy_consent, name='privacy-policy-updated'),
    re_path(r'^delete/$', user.delete_account, name='delete-account'),
    re_path(r'^profile/$', user.profile, name='user-profile'),
    re_path(r'^profile/(?P<user_id>[0-9]+)/$', user.profile, name='user-profile'),

    re_path(r'^verify/(?P<type_>[\w\d_-]+)/$', verify.verify, name='verify'),