<commit_before>from django.template import Context, loader
from orgchartapp.models import Employee, ReportingRelationship
from django.http import HttpResponse
from django.db.models import Q
from django.contrib.auth.decorators import login_required

# Create your views here.

def homepage(request):
	t = loader.get_template('orgchart/homepage.html')
	c = Context({
	})
	return HttpResponse(t.render(c))

@login_required
def byEmployee(request):
	employee_list = Employee.objects.all().order_by('full_name')
	t = loader.get_template('orgchart/employees.html')
	c = Context({
	'employee_list': employee_list,
	})
	return HttpResponse(t.render(c))

@login_required
def byReportingRelationship(request, manager_id):
	reporting_relationship_list = ReportingRelationship.objects.filter(Q(supervisor_id = manager_id) | Q(employee_id = manager_id)).order_by('dotted', 'employee__full_name')
	primary_supervisor_id = ReportingRelationship.objects.filter(Q(employee_id = manager_id))[0].supervisor_id
	t = loader.get_template('orgchart/chart.html')
	c = Context({
	'primary_supervisor_id': primary_supervisor_id,
	'reporting_relationship_list': reporting_relationship_list,
	})
	return HttpResponse(t.render(c))<commit_msg>minor bugfix to deal with person who has no supervisor.<commit_after>from django.template import Context, loader
from orgchartapp.models import Employee, ReportingRelationship
from django.http import HttpResponse
from django.db.models import Q
from django.contrib.auth.decorators import login_required

# Create your views here.

def homepage(request):
	t = loader.get_template('orgchart/homepage.html')
	c = Context({
	})
	return HttpResponse(t.render(c))

@login_required
def byEmployee(request):
	employee_list = Employee.objects.all().order_by('full_name')
	t = loader.get_template('orgchart/employees.html')
	c = Context({
	'employee_list': employee_list,
	})
	return HttpResponse(t.render(c))

@login_required
def byReportingRelationship(request, manager_id):
	reporting_relationship_list = ReportingRelationship.objects.filter(Q(supervisor_id = manager_id) | Q(employee_id = manager_id)).order_by('dotted', 'employee__full_name')
	if (len(reporting_relationship_list) > 1):
		primary_supervisor_id = ReportingRelationship.objects.filter(Q(employee_id = manager_id))[0].supervisor_id
		t = loader.get_template('orgchart/chart.html')
		c = Context({
		'primary_supervisor_id': primary_supervisor_id,
		'reporting_relationship_list': reporting_relationship_list,
		})
		return HttpResponse(t.render(c))
	else:
		return HttpResponse(reporting_relationship_list)
{'fraction_non_alphanumeric': 0.10787737679472255, 'fraction_numerical': 0.0011641443538998836, 'mean_word_length': 7.452459016393442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1835384', 'n_tokens_mistral': 839, 'n_tokens_neox': 787, 'n_words': 154}