# Path: competencies/my_admin.py
# def add_userprofile(user):
# def initialize_data():
# def build_test_schools(num_elements=2):
# 
# Path: competencies/utils.py
# def cascade_visibility_down(element, visibility_mode):
# def cascade_public_up(element):
# def fork_organization(forking_org, original_org):


from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth import logout, login, authenticate
from django.contrib.auth.views import password_change
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.decorators import login_required
from competencies.models import *
from competencies import my_admin
from competencies import utils
from users.models import *


# Authentication views
def logout_view(request):
    logout(request)
    # Redirect to home page for now. Later, maybe stay on same page.
    return redirect('/')

@login_required
def profile(request):
    editor_orgs = request.user.organization_set.all()
    return render_to_response('users/profile.html',
                              {'editor_orgs': editor_orgs},
                              context_instance=RequestContext(request))

def password_change_form(request):
    if request.method == 'POST':
        return password_change(request, post_change_redirect='/password_change_successful')
    else:

# Path: competencies/my_admin.py
# def add_userprofile(user):
# def initialize_data():
# def build_test_schools(num_elements=2):
# 
# Path: competencies/utils.py
# def cascade_visibility_down(element, visibility_mode):
# def cascade_public_up(element):
# def fork_organization(forking_org, original_org):


# Path: users/views.py
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth import logout, login, authenticate
from django.contrib.auth.views import password_change
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.decorators import login_required
from competencies.models import *
from competencies import my_admin
from competencies import utils
from users.models import *



# Authentication views
def logout_view(request):
    logout(request)
    # Redirect to home page for now. Later, maybe stay on same page.
    return redirect('/')

@login_required
def profile(request):
    editor_orgs = request.user.organization_set.all()
    return render_to_response('users/profile.html',
                              {'editor_orgs': editor_orgs},
                              context_instance=RequestContext(request))

def password_change_form(request):
    if request.method == 'POST':
        return password_change(request, post_change_redirect='/password_change_successful')
    else:

        return render_to_response('users/password_change_form.html',