Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def view_contract(request, post_slug, userid):
#contract = get_object_or_404(TAContract, pk=contract_id)
#ta courses get all courses with contract_id
#courses = TACourse.objects.filter(contract=contract)
#contract.pay_per_bu = format_currency(contract.pay_per_bu)
#contract.scholarship_per_bu = format_currency(contract.scholarship_per_bu)
posting = get_object_or_404(TAPosting, slug=post_slug, unit__in=request.units)
if posting.unit not in request.units:
ForbiddenResponse(request, 'You cannot access this page')
contract = get_object_or_404(TAContract, posting=posting, application__person__userid=userid)
courses = TACourse.objects.filter(contract=contract)
total = contract.total_bu()
bu = contract.bu()
pp = posting.payperiods()
salary_sem = (total*contract.pay_per_bu)
schol_sem = (bu*contract.scholarship_per_bu)
salary_sem_out = _format_currency(salary_sem)
schol_sem_out = _format_currency(schol_sem)
salary_bi = _format_currency(salary_sem / pp)
schol_bi = _format_currency(schol_sem / pp)
context = {'posting': posting,
'contract':contract,
'courses':courses,
def total_pay(self, offering):
"""
Payments for all tacourses associated with this offering
"""
total = 0
tacourses = TACourse.objects.filter(course=offering, contract__posting=self).exclude(contract__status__in=['REJ', 'CAN'])
for course in tacourses:
total += course.pay()
return total