# 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
        self.build_to_eus()

        # Verify that all elements start out private.
        element_lists = [self.test_sas, self.test_sdas, self.test_cas, self.test_eus]
        for element_list in element_lists:
            for element in element_list:
                self.assertFalse(element.public)

        # Set each org public, and cascade public down for each org.
        for org in self.test_organizations:
            org.public = True
            org.save()
            # Calling utils.cvd() saves to db, but doesn't modify original objects.
            utils.cascade_visibility_down(org, 'public')

        # Test that all orgs are public.
        for org in self.test_organizations:
            self.assertTrue(org.public)

        # Test that all related elements in the db are public.
        for element_list in element_lists:
            db_elements = element_list[0].__class__.objects.all()
            for db_element in db_elements:
                self.assertTrue(db_element.public)

        # Set each org private, and cascade private down for each org.
        for org in self.test_organizations:
            org.public = False
            org.save()
            # Calling utils.cvd() saves to db, but doesn't modify original objects.

# 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

        self.build_to_eus()

        # Verify that all elements start out private.
        element_lists = [self.test_sas, self.test_sdas, self.test_cas, self.test_eus]
        for element_list in element_lists:
            for element in element_list:
                self.assertFalse(element.public)

        # Set each org public, and cascade public down for each org.
        for org in self.test_organizations:
            org.public = True
            org.save()
            # Calling utils.cvd() saves to db, but doesn't modify original objects.
            utils.cascade_visibility_down(org, 'public')

        # Test that all orgs are public.
        for org in self.test_organizations:
            self.assertTrue(org.public)

        # Test that all related elements in the db are public.
        for element_list in element_lists:
            db_elements = element_list[0].__class__.objects.all()
            for db_element in db_elements:
                self.assertTrue(db_element.public)

        # Set each org private, and cascade private down for each org.
        for org in self.test_organizations:
            org.public = False
            org.save()
            # Calling utils.cvd() saves to db, but doesn't modify original objects.

            utils.cascade_visibility_down(org, 'private')