# Path: competencies/views.py
# def organization(request, organization_id):
#     """Displays subject areas and subdiscipline areas for a given organization."""
#     organization = Organization.objects.get(id=organization_id)
#     editors = organization.editors.all()
#     if organization.subjectarea_set.all():
#         can_fork = False
#     else:
#         can_fork = True
#     kwargs = get_visibility_filter(request.user, organization)
#     sas = organization.subjectarea_set.filter(**kwargs)
#     sdas = [sda for sa in sas for sda in sa.subdisciplinearea_set.filter(**kwargs)]    
#     return render_to_response('competencies/organization.html',
#                               {'organization': organization, 'subject_areas': sas,
#                                'sdas': sdas, 'can_fork': can_fork,
#                                'editors': editors,
#                                },
#                               context_instance=RequestContext(request))
# 
# 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/models.py
# class UserProfile(models.Model):
#     """Was here to manage m2m relation to Organization."""
#     # Keeping this, because I'll store more information about users at some point.
#     user = models.OneToOneField(User)


from random import choice
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from competencies.models import *
from competencies.views import organization
from competencies import my_admin, utils
from users.models import UserProfile
        """Build out a system to the essential understanding level."""
        self.build_to_cas()
        
        for ca in self.test_cas:
            # Create num_elements eus for each grad std.
            for eu_num in range(self.num_elements):
                eu_body = "Test EU %d %d" % (eu_num, self.element_number)
                new_eu = EssentialUnderstanding.objects.create(essential_understanding=eu_body,
                                                             competency_area=ca)
                self.test_eus.append(new_eu)
                self.element_number += 1


    def test_index_view(self):
        """Index page is a static page for now, so just check status."""
        response = self.client.get(reverse('competencies:index'))
        self.assertEqual(response.status_code, 200)

    def test_organizations_view(self):
        """Organizations page lists all orgs user owns, can edit, and public organizations;
           links to detail view of that organization."""
        self.build_to_organizations()

        test_url = reverse('competencies:organizations')

        # Test for anonymous users, my_orgs and editor_orgs are empty.
        #  Also test that private orgs not in public_orgs.
        self.client.logout()
        response = self.client.get(test_url)
        self.assertEqual(response.status_code, 200)

# Path: competencies/views.py
# def organization(request, organization_id):
#     """Displays subject areas and subdiscipline areas for a given organization."""
#     organization = Organization.objects.get(id=organization_id)
#     editors = organization.editors.all()
#     if organization.subjectarea_set.all():
#         can_fork = False
#     else:
#         can_fork = True
#     kwargs = get_visibility_filter(request.user, organization)
#     sas = organization.subjectarea_set.filter(**kwargs)
#     sdas = [sda for sa in sas for sda in sa.subdisciplinearea_set.filter(**kwargs)]    
#     return render_to_response('competencies/organization.html',
#                               {'organization': organization, 'subject_areas': sas,
#                                'sdas': sdas, 'can_fork': can_fork,
#                                'editors': editors,
#                                },
#                               context_instance=RequestContext(request))
# 
# 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/models.py
# class UserProfile(models.Model):
#     """Was here to manage m2m relation to Organization."""
#     # Keeping this, because I'll store more information about users at some point.
#     user = models.OneToOneField(User)


# Path: competencies/tests/test_views.py
from random import choice
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from competencies.models import *
from competencies.views import organization
from competencies import my_admin, utils
from users.models import UserProfile

        """Build out a system to the essential understanding level."""
        self.build_to_cas()
        
        for ca in self.test_cas:
            # Create num_elements eus for each grad std.
            for eu_num in range(self.num_elements):
                eu_body = "Test EU %d %d" % (eu_num, self.element_number)
                new_eu = EssentialUnderstanding.objects.create(essential_understanding=eu_body,
                                                             competency_area=ca)
                self.test_eus.append(new_eu)
                self.element_number += 1


    def test_index_view(self):
        """Index page is a static page for now, so just check status."""
        response = self.client.get(reverse('competencies:index'))
        self.assertEqual(response.status_code, 200)

    def test_organizations_view(self):
        """Organizations page lists all orgs user owns, can edit, and public organizations;
           links to detail view of that organization."""
        self.build_to_organizations()

        test_url = reverse('competencies:organizations')

        # Test for anonymous users, my_orgs and editor_orgs are empty.
        #  Also test that private orgs not in public_orgs.
        self.client.logout()
        response = self.client.get(test_url)
        self.assertEqual(response.status_code, 200)

        self.assertEqual(len(response.context['my_organizations']), 0)