How to use the ta.models.TACourse function in ta

To help you get started, we’ve selected a few ta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sfu-fas / coursys / coredata / devtest_importer.py View on Github external
will_ta = []
        for i,o in enumerate(random.sample(offerings, 5)):
            t = random.choice(TAKEN_CHOICES)[0]
            e = random.choice(EXPER_CHOICES)[0]
            cp = CoursePreference(app=app, course=o.course, rank=i+1, taken=t, exper=e)
            cp.save()

            if random.random() < 0.07*(5-i):
                will_ta.append(o)

        if will_ta and random.random() < 0.75:
            c = TAContract(status=random.choice(['NEW','OPN','ACC']))
            c.first_assign(app, post)
            c.save()
            for o in will_ta:
                tac = TACourse(course=o, contract=c, bu=app.base_units)
                tac.description = tac.default_description()
                tac.save()

    # RAs
    s = Semester.current()
    superv = list(m.person for m in Member.objects.filter(role='INST').select_related('person'))
    empl = list(itertools.chain(Person.objects.filter(last_name='Grad'),
                                random.sample(list(Person.objects.filter(last_name='Student')), 10)))
    cats = [c for c,d in HIRING_CATEGORY_CHOICES if c not in HIRING_CATEGORY_DISABLED]
    config = SemesterConfig.get_config([unit], s)

    acct = Account(account_number=12349, position_number=12349, title='NSERC RA', unit=unit)
    acct.save()
    proj1 = Project(project_number=987654, fund_number=31, unit=unit)
    proj1.save()
    proj2 = Project(project_number=876543, fund_number=13, unit=unit)
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
contract.pay_per_bu = "%.2f" % (salary/bu)
        contract.scholarship_per_bu = "%.2f" % (schol/bu)
        contract.deadline = posting.deadline()
        contract.appt_cond = bool(cond)
        contract.appt_tssu = bool(tssu)
        contract.status = 'SGN' if status=='accepted' else 'CAN'
        contract.remarks = remarks or ''
        contract.created_by = self.IMPORT_USER
        contract.save()
        
        # create TACourse
        crses = TACourse.objects.filter(course=offering, contract=contract)
        if crses:
            crs = crses[0]
        else:
            crs = TACourse(course=offering, contract=contract)
        
        d = self.TA_DESC_MAP[description.split()[0]]
        try:
            desc = CourseDescription.objects.get(unit=self.UNIT, description=d)
        except CourseDescription.DoesNotExist:
            desc = CourseDescription(unit=self.UNIT, description=d)
            if d == 'Office/Marking/Labs':
                desc.labtut = True
            desc.save()

        crs.description = desc
        crs.bu = bu
        crs.save()
        
        
        # course preferences
github sfu-fas / coursys / grad / views / progress_reports.py View on Github external
def generate_progrep_queries(gs):
    """
    Generate queries for the progrep database
    """
    # funding
    yield "DELETE FROM progrep.finsupport WHERE emplid=%s;\n" % escape_all(gs.person.emplid)
    ta_courses = TACourse.objects.filter(contract__application__person=gs.person, contract__status='SGN') \
                 .select_related('contract__posting__semester')
    for tacrs in ta_courses:
        yield ("INSERT INTO progrep.finsupport (emplid, semester, type, name, amount, bu) VALUES (%s, %s, %s, %s, %s, %s);\n") \
            % escape_all(gs.person.emplid, tacrs.contract.posting.semester.name, 'ta', tacrs.course.name(), "%.2f"%tacrs.pay(), int(tacrs.bu))

    ras = RAAppointment.objects.filter(person=gs.person, deleted=False)
    for ra in ras:
        yield ("INSERT INTO progrep.finsupport (emplid, semester, type, name, amount, bu) VALUES (%s, %s, %s, %s, %s, %s);\n") \
            % escape_all(gs.person.emplid, ra.start_semester().name, 'ra', ra.hiring_faculty.name(), "%.2f"%ra.lump_sum_pay, '')

    scholarships = Scholarship.objects.filter(student=gs, removed=False)
    for schol in scholarships:
        yield ("INSERT INTO progrep.finsupport (emplid, semester, type, name, amount, bu) VALUES (%s, %s, %s, %s, %s, %s);\n") \
            % escape_all(gs.person.emplid, schol.start_semester.name, 'scholarship', schol.scholarship_type.name, "%.2f"%schol.amount, '')

    otherfunding = OtherFunding.objects.filter(student=gs, removed=False)
github sfu-fas / coursys / ta / models.py View on Github external
def all_total(self):
        """
        BU's and Payments for all tacourses associated with all offerings 
        """
        pay = 0
        bus = 0
        tac = TAContract.objects.filter(posting=self).exclude(status__in=['REJ', 'CAN']).count()
        tacourses = TACourse.objects.filter(contract__posting=self).exclude(contract__status__in=['REJ', 'CAN'])
        for course in tacourses:
            pay += course.pay()
            bus += course.total_bu
        return (bus, pay, tac)
github sfu-fas / coursys / ta / views.py View on Github external
num = 0
        else:
            num = num - contract.tacourse_set.all().count()
        old_status = contract.get_status_display()
        if contract.status not in ['NEW', 'OPN']:
            # after editing, revert to open
            contract.status = 'OPN'
        editing = True
    else:
        # creating new contract
        contract = TAContract()
        application = TAApplication.objects.get(person__userid=userid, posting=posting)
        old_status = None
        editing = False
    
    TACourseFormset = inlineformset_factory(TAContract, TACourse, extra=num, can_delete=editing, form=TACourseForm, formset=BaseTACourseFormSet)
    formset = TACourseFormset(instance=contract)
    if request.method == "POST":
        form = TAContractForm(request.POST, instance=contract)
        
        if request.is_ajax():
            if('appt_cat' in request.POST):
                index = posting.cat_index(request.POST['appt_cat'])
                results = posting.salary()[index] + ',' + posting.scholarship()[index] + ',' + str(posting.accounts()[index])
                return HttpResponse(results)
            if('course' in request.POST):
                course = request.POST['course']
                co = get_object_or_404(CourseOffering, pk=course)
                req_bu = posting.required_bu(co)
                assigned_bu = posting.assigned_bu(co)
                #subtracting assigned_bu from req_bu
                if(assigned_bu > req_bu):
github sfu-fas / coursys / ta / views.py View on Github external
def __get_contract_info(member):
    """
    Find TUG-related information about this contract (if we can)
    """
    crses = list(TACourse.objects.filter(course=member.offering, contract__application__person=member.person).exclude(contract__status='CAN')) \
        + list(NewTACourse.objects.filter(course=member.offering, contract__person=member.person).exclude(contract__status='CAN'))
    if crses:
        return crses[0]
    else:
        return None
github sfu-fas / coursys / ta / views.py View on Github external
applicant.save()
                
                if not applicant.assigned_course: 
                    #create new TACourse if bu field is nonempty
                    if formset[i]['bu'].value() != '' and formset[i]['bu'].value() != '0':
                        #create new TAContract if there isn't one
                        contracts = TAContract.objects.filter(application=applicants[i], posting=posting)
                        if contracts.count() > 0: #count is 1
                            # if we've added to the contract, we've invalidated it. 
                            contract = contracts[0]
                            contract.status = "NEW"
                        else:
                            contract = TAContract(created_by=request.user.username)
                            contract.first_assign(applicants[i], posting)
                        bu = formset[i]['bu'].value()
                        tacourse = TACourse(course=offering, contract=contract, bu=bu)
                        try:
                            tacourse.description = tacourse.default_description()
                        except ValueError:
                            # handle the case where no appropriate default CourseDescription object can be found
                            descr_error = True
                            formset[i]._errors['bu'] = formset[i].error_class(["Can't find a contract description to assign to the contract."])
                        else:
                            tacourse.save()
                            contract.save()
                else: 
                    #update bu for existing TACourse
                    if formset[i]['bu'].value() != '' and formset[i]['bu'].value() != '0':
                        old_bu = decimal.Decimal(formset[i]['bu'].value())
                        new_bu = applicant.assigned_course.bu
                        if old_bu != new_bu:
                            applicant.assigned_course.bu = formset[i]['bu'].value()