# Path: cjp/settings/base.py
# CJP_ROOT = '/'


from cjp.settings.base import CJP_ROOT      # TODO: don't rely on this
from django.shortcuts import render, redirect
from django.template import RequestContext
from django.contrib.auth.models import User
from django import forms
        return redirect(CJP_ROOT)

    addUserForm = AddUserForm()

    if action == 'addUser' and request.POST:
        addUserForm = AddUserForm(request.POST)
        if addUserForm.is_valid():
            cleanedData = addUserForm.cleaned_data
            user = User(
                username = cleanedData.get('username').strip(),
                first_name = cleanedData.get('firstName').strip(),
                last_name = cleanedData.get('lastName').strip(),
                email = cleanedData.get('email').strip(),
                is_staff = False,
                is_active = True,
                is_superuser = False,
            )
            user.set_password(cleanedData.get('password'))
            user.save()
            addUserForm = AddUserForm()

    users = User.objects.all().order_by('username')

    data = {'users' : users,
            'userCreationForm': addUserForm}
    return render(request, 'registration/users.html', data)


def userUpdate(request, userId):
    if not (request.user.is_authenticated() and request.user.is_superuser):

# Path: cjp/settings/base.py
# CJP_ROOT = '/'


# Path: cjpusers/views.py
from cjp.settings.base import CJP_ROOT      # TODO: don't rely on this
from django.shortcuts import render, redirect
from django.template import RequestContext
from django.contrib.auth.models import User
from django import forms

        return redirect(CJP_ROOT)

    addUserForm = AddUserForm()

    if action == 'addUser' and request.POST:
        addUserForm = AddUserForm(request.POST)
        if addUserForm.is_valid():
            cleanedData = addUserForm.cleaned_data
            user = User(
                username = cleanedData.get('username').strip(),
                first_name = cleanedData.get('firstName').strip(),
                last_name = cleanedData.get('lastName').strip(),
                email = cleanedData.get('email').strip(),
                is_staff = False,
                is_active = True,
                is_superuser = False,
            )
            user.set_password(cleanedData.get('password'))
            user.save()
            addUserForm = AddUserForm()

    users = User.objects.all().order_by('username')

    data = {'users' : users,
            'userCreationForm': addUserForm}
    return render(request, 'registration/users.html', data)


def userUpdate(request, userId):
    if not (request.user.is_authenticated() and request.user.is_superuser):

        return redirect(CJP_ROOT)