How to use the ta.models.TACourse.objects 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
**payargs)
        ra.set_use_hourly(random.choice([True, False]))
        ra.save()

    return itertools.chain(
        [r1, r2],
        Account.objects.all(),
        Project.objects.all(),
        SemesterConfig.objects.all(),
        RAAppointment.objects.all(),
        TAPosting.objects.all(),
        CourseDescription.objects.all(),
        TAApplication.objects.all(),
        CoursePreference.objects.all(),
        TAContract.objects.all(),
        TACourse.objects.all(),
    )
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
contract.pay_end = payen or offering.semester.end
        contract.appt_category = app.category
        contract.position_number_id = pos_id
        contract.appt = self.INITIAL_MAP[initial]
        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
github sfu-fas / coursys / tacontracts / models.py View on Github external
with transaction.atomic():
            memberships = Member.objects.filter(person=person, offering__semester_id=semester_id)
            memberships = list(memberships)

            # drop any TA memberships that should be re-added below
            for m in memberships:
                if m.role == 'TA' and m.added_reason in ['CTA', 'TAC']:
                    m.role = 'DROP'

            # tacontracts memberships
            tacrses = TACourse.objects.filter(contract__person_id=person, course__semester_id=semester_id)
            for tacrs in tacrses:
                add_membership_for(tacrs, 'TAC', memberships)

            # ta memberships
            tacrses = OldTACourse.objects.filter(contract__application__person_id=person, course__semester_id=semester_id)
            for tacrs in tacrses:
                add_membership_for(tacrs, 'CTA', memberships)

            # save whatever just happened
            for m in memberships:
                m.save_if_dirty()
github sfu-fas / coursys / grad / models.py View on Github external
}
        }
        Each of the objects in the lists are annotated with
          object.semlength: number of semesters this funding thing lasts for
          object.semvalue: the dollar amount for one semester
          object.promiseeligible: is eligible to count towards a promise?
        """
        from ta.models import TACourse
        from ra.models import RAAppointment
        
        semesters = {}
        for sem in Semester.objects.filter(name__gte=start.name, name__lte=end.name):
            semesters[sem] = {'ta': [], 'ra': [], 'scholarship': [], 'other': []}
        
        # TAs
        tas = TACourse.objects.filter(contract__application__person=self.person,
                                      contract__posting__semester__name__lte=end.name, contract__posting__semester__name__gte=start.name)
        for tacrs in tas:
            tacrs.semlength = 1
            tacrs.semvalue = tacrs.pay()
            tacrs.promiseeligible = True
            semesters[tacrs.contract.posting.semester]['ta'].append(tacrs)
        
        # RAs
        ras = RAAppointment.objects.filter(person=self.person, deleted=False)
        for ra in ras:
            # RAs are by date, not semester, so have to filter more here...
            st = ra.start_semester()
            en = ra.end_semester()
            ra.semlength = ra.semester_length()
            ra.semvalue = ra.lump_sum_pay / ra.semlength
            ra.promiseeligible = True
github sfu-fas / coursys / grad / views / financials.py View on Github external
for ph in program_history:
            if ph.start_semester == semester:
                program = ph
        
        # financial comments
        comments = []
        for c in financial_comments:
            if c.semester == semester:
                comments.append(c)
        
        # TAs
        amount = 0
        courses = []
        for contract in contracts:
            if contract.posting.semester == semester:
                for course in TACourse.objects.filter(contract=contract).exclude(bu=0).select_related('course'):
                    amount += course.pay()
                    if contract.status == 'SGN':
                        text = "%s (%s BU)" % (course.course.name(), course.bu)
                    else:
                        text = "%s (%s BU, current status: %s)" \
                             % (course.course.name(), course.bu, contract.get_status_display().lower())
                    courses.append({'course': text,'amount': course.pay()})
        ta = {'courses':courses,'amount':amount}
        semester_total += amount

        # RAs
        amount = 0
        appt = []
        for appointment in appointments:
            app_start_sem = appointment.start_semester()
            app_end_sem = appointment.end_semester()
github sfu-fas / coursys / coredata / devdata_importer.py View on Github external
#TeachingIntention.objects.all(),
            #TeachingCapability.objects.all(),
            FormGroup.objects.all(),
            FormGroupMember.objects.all(),
            Form.objects.all(),
            Sheet.objects.all(),
            Field.objects.all(),
            FormSubmission.objects.all(),
            SheetSubmission.objects.all(),
            FieldSubmission.objects.all(),
            TAPosting.objects.all(),
            TAApplication.objects.all(),
            CoursePreference.objects.all(),
            CourseDescription.objects.all(),
            TAContract.objects.all(),
            TACourse.objects.all(),
            RAAppointment.objects.all(),
            Project.objects.all(),
            SemesterConfig.objects.all(),
            )
    
    data = serializers.serialize("json", objs, sort_keys=True, indent=1)
    fh = open(filename, "w")
    fh.write(data)
    fh.close()
github sfu-fas / coursys / grad / models.py View on Github external
schols = Scholarship.objects.filter(student=self).order_by('start_semester__name').select_related('start_semester')
        if tas and ras:
            if tas[0].application.posting.semester.name > ras[0].start_semester().name:
                recent_empl = 'teaching assistant'
            else:
                recent_empl = 'research assistant'
        elif tas:
            recent_empl = 'teaching assistant'
        elif ras:
            recent_empl = 'research assistant'
        else:
            recent_empl = 'UNKNOWN'

        # TAing
        tafunding = ''
        tacourses = TACourse.objects.filter(contract__application__person=self.person) \
                    .order_by('contract__posting__semester__name') \
                    .select_related('contract__posting__semester', 'course')
        for tacrs in tacourses:
            tafunding += "||%s (%s)|%s %s|$%.2f|%i hours/term\n" % (
                    tacrs.contract.posting.semester.label(), tacrs.contract.posting.semester.months(),
                    tacrs.course.subject, tacrs.course.number,
                    tacrs.pay(), tacrs.bu*HOURS_PER_BU)
        
        # RAing
        rafunding = ''
        ras = list(ras)
        ras.reverse()
        for ra in ras:
            rafunding += "||%s-%s|$%.2f|%i hours/week\n" % (
                    ra.start_date.strftime("%b %Y"), ra.end_date.strftime("%b %Y"), ra.lump_sum_pay, ra.hours/2)
github sfu-fas / coursys / ta / models.py View on Github external
def bu(self):
        courses = TACourse.objects.filter(contract=self)
        if self.status in ('CAN', 'REJ'):
            return 0
        return sum([course.bu for course in courses])
github sfu-fas / coursys / ta / views.py View on Github external
response_data['labtas_changed'] = True
                response_data['has_labtas'] = True
        else:
            if offering.labtas() != False:
                offering.config['labtas'] = False
                response_data['labtas_changed'] = True
                response_data['has_labtas'] = False

        if response_data['message'] == '':
            response_data['message'] = "Success!"

        offering.save()
        
        # if the course's Lab (+0.17) status has changed, change all TA contracts to conform to the new Lab (+0.17) status.
        if response_data['labtas_changed']:
            for ta_course in TACourse.objects.filter( course=offering ):
                if ta_course.contract.posting == posting and ta_course.description != ta_course.default_description():
                    # change the description
                    ta_course.description = ta_course.default_description()
                    ta_course.save()
                    # this requires that the contract be re-signed
                    ta_course.contract.status = 'NEW'
                    ta_course.contract.save()

        return HttpResponse(json.dumps(response_data), content_type='application/json')

    applicants = []
    assigned_ta = []
    initial = [] # used to initialize formset

    # First, people who have assigned BUs
    for ta_course in tacourses:
github sfu-fas / coursys / grad / views / funding_report.py View on Github external
programs = list(programs)
    non_grad = _FakeProgram(label="Non Grad *", pid=-1)
    programs.append(non_grad)
    total = _FakeProgram(label="Total **", pid=-2)
    programs.append(total)
    for prog in programs:
        prog.funding_ta = decimal.Decimal(0)
        prog.funding_ra = decimal.Decimal(0)
        prog.funding_schol = decimal.Decimal(0)
        prog.funding_other = decimal.Decimal(0)
    
    prog_lookup = dict((prog.id, prog) for prog in programs)
    
    # TA funding
    tacourses = TACourse.objects.filter(contract__posting__semester=semester,
                                        contract__posting__unit__in=units,
                                        contract__status='SGN') \
                        .select_related('contract__application')
    for crs in tacourses:
        person_id = crs.contract.application.person_id
        if person_id in student_programs:
            prog_id = student_programs[person_id]
            prog = prog_lookup[prog_id]
        else:
            prog = non_grad
        pay = crs.pay()
        prog.funding_ta += pay
        total.funding_ta += pay
    
    # RA funding
    sem_st, sem_en = RAAppointment.start_end_dates(semester)