# 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

        # Empty lists of elements.
        self.test_organizations = []
        self.test_sas, self.test_sdas = [], []
        self.test_cas, self.test_eus = [], []

        # Increment for every element created.
        #   Ensures a unique name for every element, which makes testing some behaviors easier.
        self.element_number = 0

    def build_to_organizations(self):
        """Build out system to the organization level."""
        # Build a test organization that user 0 is associated with,
        #  and one that user 1 is associated with.
        # If a test only needs one org, it can set self.num_orgs = 1.
        for organization_num in range(2):
            name = "Test Organization %d" % organization_num
            if organization_num < self.num_orgs/2:
                new_organization = Organization.objects.create(name=name, owner=self.test_user_0)
                new_organization.editors.add(self.test_user_0)
            else:
                new_organization = Organization.objects.create(name=name, owner=self.test_user_1)
                new_organization.editors.add(self.test_user_1)
            self.test_organizations.append(new_organization)

    def build_to_sas(self):
        """Build out system to the subject area level."""
        self.build_to_organizations()

        # Create num_elements subject areas for each organization.

# 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


        # Empty lists of elements.
        self.test_organizations = []
        self.test_sas, self.test_sdas = [], []
        self.test_cas, self.test_eus = [], []

        # Increment for every element created.
        #   Ensures a unique name for every element, which makes testing some behaviors easier.
        self.element_number = 0

    def build_to_organizations(self):
        """Build out system to the organization level."""
        # Build a test organization that user 0 is associated with,
        #  and one that user 1 is associated with.
        # If a test only needs one org, it can set self.num_orgs = 1.
        for organization_num in range(2):
            name = "Test Organization %d" % organization_num
            if organization_num < self.num_orgs/2:
                new_organization = Organization.objects.create(name=name, owner=self.test_user_0)
                new_organization.editors.add(self.test_user_0)
            else:
                new_organization = Organization.objects.create(name=name, owner=self.test_user_1)
                new_organization.editors.add(self.test_user_1)
            self.test_organizations.append(new_organization)

    def build_to_sas(self):
        """Build out system to the subject area level."""
        self.build_to_organizations()

        # Create num_elements subject areas for each organization.

        for organization_num, organization in enumerate(self.test_organizations):