# Path: user/forms.py
# class UserForm(UserCreationForm):
#     class Meta(UserCreationForm.Meta):
#         fields = UserCreationForm.Meta.fields + \
#             ('email', 'first_name', 'last_name')
#         labels = {
#             'email': _('E-Mail address'),
#             'first_name': _('First Name'),
#             'last_name': _('Last Name'),
#             'username': _('Username')
#         }
#         help_texts = {
#             'email': _('An email adress where you can be reached. '
#                        'The verification mail will be sent to this adress.'),
#             'first_name': _('First part of your public name, which should be your genuine first name. '
#                             'If you become a teacher this will be visible to any site visitor. '
#                             'Can be modified later.'),
#             'last_name': _('Second part of your public name, which should be your genuine familyname. '
#                            'If you become a teacher this will be visible to any site visitor. '
#                            'Can be modified later'),
#             'username': _('Unique username. Used for login. (cannot be changed later).')
#         }
# 
# class UserInformationForm(ModelForm):
#     description = forms.CharField(widget=forms.Textarea, required=False)
# 
#     class Meta:
#         model = UserInformation
#         fields = ('public_profile', 'description', 'accepted_privacy_policy')
#         labels = {
#             'public_profile': _('Public Profile'),
#             'description': _('Description'),
#             'accepted_privacy_policy': _('Privacy Policy')
#         }
#         help_texts = {
#             'description': _('Tell something about yourself. (Markdown enabled) Links are allowed.'),
#             'accepted_privacy_policy': _('You have read our <a href="/privacy-policy/" style="color:#9ACC00 !important;">Privacy Policy</a> and consent to it.')
#         }
# 
# class UserEditForm(ModelForm):
#     class Meta:
#         model = User
#         fields = ('first_name', 'last_name', 'email')
#         labels = {
#             'first_name': _('First Name'),
#             'last_name': _('Last Name'),
#             'email': _("Mail address")
#         }
#         help_texts = {
#             'first_name': _('First part of your public name, which should be your genuine first name. '
#                             'If you become a teacher this will be visible to any site visitor. '
#                             'Can be modified later.'),
#             'last_name': _('Second part of your public name, which should be your genuine familyname. '
#                            'If you become a teacher this will be visible to any site visitor. '
#                            'Can be modified later'),
#             'email': _('Your mail address'),
#         }
# 
# class PrivacyAgreementForm(ModelForm):
#     class Meta:
#         model = UserInformation
#         fields = ('accepted_privacy_policy',)
#         labels = {
#             'accepted_privacy_policy': ''
#         }
#         help_texts = {
#             'accepted_privacy_policy': _('I have read the Privacy Policy and consent to it.')
#         }
# 
# Path: util/error/reporting.py
# def db_error(message):
#     """
#     Report a database error in a view.
#     """
#     return render_to_response('error/db.html', {'error': message})


from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.views.decorators.debug import sensitive_post_parameters
from user.forms import UserForm, UserInformationForm, UserEditForm, PrivacyAgreementForm
from util.error.reporting import db_error
        request,
        template,
        {
            'course_list_show_subject': True,
            'profiled_user': user,
            'is_own': is_own,
            'attend': attend,
            'title': '{} {}'.format(user.first_name, user.last_name)
        }
    )


@login_required
def privacy_consent(request):
    user = request.user
    user_info = user.userinformation

    # users who have consented already are not in scope for this
    if user_info.accepted_privacy_policy:
        return redirect('user-profile')

    if request.method == "POST":
        # validate the form
        agreement_form = PrivacyAgreementForm(
            request.POST, instance=request.user.userinformation)

        if agreement_form.is_valid():
            user_info.save()
            return redirect('user-profile')
    else:

# Path: user/forms.py
# class UserForm(UserCreationForm):
#     class Meta(UserCreationForm.Meta):
#         fields = UserCreationForm.Meta.fields + \
#             ('email', 'first_name', 'last_name')
#         labels = {
#             'email': _('E-Mail address'),
#             'first_name': _('First Name'),
#             'last_name': _('Last Name'),
#             'username': _('Username')
#         }
#         help_texts = {
#             'email': _('An email adress where you can be reached. '
#                        'The verification mail will be sent to this adress.'),
#             'first_name': _('First part of your public name, which should be your genuine first name. '
#                             'If you become a teacher this will be visible to any site visitor. '
#                             'Can be modified later.'),
#             'last_name': _('Second part of your public name, which should be your genuine familyname. '
#                            'If you become a teacher this will be visible to any site visitor. '
#                            'Can be modified later'),
#             'username': _('Unique username. Used for login. (cannot be changed later).')
#         }
# 
# class UserInformationForm(ModelForm):
#     description = forms.CharField(widget=forms.Textarea, required=False)
# 
#     class Meta:
#         model = UserInformation
#         fields = ('public_profile', 'description', 'accepted_privacy_policy')
#         labels = {
#             'public_profile': _('Public Profile'),
#             'description': _('Description'),
#             'accepted_privacy_policy': _('Privacy Policy')
#         }
#         help_texts = {
#             'description': _('Tell something about yourself. (Markdown enabled) Links are allowed.'),
#             'accepted_privacy_policy': _('You have read our <a href="/privacy-policy/" style="color:#9ACC00 !important;">Privacy Policy</a> and consent to it.')
#         }
# 
# class UserEditForm(ModelForm):
#     class Meta:
#         model = User
#         fields = ('first_name', 'last_name', 'email')
#         labels = {
#             'first_name': _('First Name'),
#             'last_name': _('Last Name'),
#             'email': _("Mail address")
#         }
#         help_texts = {
#             'first_name': _('First part of your public name, which should be your genuine first name. '
#                             'If you become a teacher this will be visible to any site visitor. '
#                             'Can be modified later.'),
#             'last_name': _('Second part of your public name, which should be your genuine familyname. '
#                            'If you become a teacher this will be visible to any site visitor. '
#                            'Can be modified later'),
#             'email': _('Your mail address'),
#         }
# 
# class PrivacyAgreementForm(ModelForm):
#     class Meta:
#         model = UserInformation
#         fields = ('accepted_privacy_policy',)
#         labels = {
#             'accepted_privacy_policy': ''
#         }
#         help_texts = {
#             'accepted_privacy_policy': _('I have read the Privacy Policy and consent to it.')
#         }
# 
# Path: util/error/reporting.py
# def db_error(message):
#     """
#     Report a database error in a view.
#     """
#     return render_to_response('error/db.html', {'error': message})


# Path: user/views/user.py
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.views.decorators.debug import sensitive_post_parameters
from user.forms import UserForm, UserInformationForm, UserEditForm, PrivacyAgreementForm
from util.error.reporting import db_error

        request,
        template,
        {
            'course_list_show_subject': True,
            'profiled_user': user,
            'is_own': is_own,
            'attend': attend,
            'title': '{} {}'.format(user.first_name, user.last_name)
        }
    )


@login_required
def privacy_consent(request):
    user = request.user
    user_info = user.userinformation

    # users who have consented already are not in scope for this
    if user_info.accepted_privacy_policy:
        return redirect('user-profile')

    if request.method == "POST":
        # validate the form
        agreement_form = PrivacyAgreementForm(
            request.POST, instance=request.user.userinformation)

        if agreement_form.is_valid():
            user_info.save()
            return redirect('user-profile')
    else:

        agreement_form = PrivacyAgreementForm()