How to use the ta.models.TAApplication 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
post.opens = s.start - datetime.timedelta(100)
    post.closes = s.start - datetime.timedelta(20)
    post.set_salary([972,972,972,972])
    post.set_scholarship([135,340,0,0])
    post.set_accounts([Account.objects.get(account_number=12345).id, Account.objects.get(account_number=12346).id, Account.objects.get(account_number=12347).id, Account.objects.get(account_number=12348).id])
    post.set_start(s.start)
    post.set_end(s.end)
    post.set_deadline(s.start - datetime.timedelta(10))
    post.set_payperiods(7.5)
    post.set_contact(admin.id)
    post.set_offer_text("This is **your** TA öffer.\n\nThere are various conditions that are töö numerous to list here.")
    post.save()
    offerings = list(post.selectable_offerings())

    for p in Person.objects.filter(last_name='Grad'):
        app = TAApplication(posting=post, person=p, category=random.choice(['GTA1','GTA2']), current_program='CMPT', sin='123456789',
                            base_units=random.choice([3,4,5]))
        app.save()
        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()
github sfu-fas / coursys / coredata / devtest_importer.py View on Github external
ra = RAAppointment(person=p, sin=123456789, hiring_faculty=s, unit=unit, hiring_category=c,
                           project=random.choice([proj1,proj2]), account=acct, pay_frequency=freq,
                           start_date=config.start_date(), end_date=config.end_date(),
                           **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 / ta / tests.py View on Github external
unit = Unit.objects.get(label="CMPT")
        d = CourseDescription(unit=unit, description="Lab TA", labtut=True)
        d.save()
        d = CourseDescription(unit=unit, description="Office Hours", labtut=False)
        d.save()

        #Create posting that closes in a long time so no applications are late
        posting = TAPosting(semester=s, unit=unit,opens=date(2007,9,4), closes=date(2099,9,4))
        posting.config['accounts'] = [a.id for a in Account.objects.all()]
        posting.config['start'] = date(2100,10,10)
        posting.config['end'] = date(2101,10,10)
        posting.config['deadline'] = date(2099,9,20)
        posting.save() 

        #Create application for posting as well as campus and course preferences
        app = TAApplication(posting=posting, person=p, category="UTA", base_units=2, sin="123123123", course_load="No Other Courses")
        app.save()

        cp1 = CampusPreference(app=app, campus="BRNBY", pref="PRF")
        cp2 = CampusPreference(app=app, campus="SURRY", pref="NOT")
        cp1.save()
        cp2.save()

        c1 = Course.objects.get(subject="CMPT", number="120")
        
        course1 = CoursePreference(app=app, course=c1, taken="YES", exper="FAM", rank=1)
        course1.save()

        #Login a ta admin
        client = Client()
        userid = Role.objects.filter(role="TAAD")[0].person.userid
        client.login_user(userid)
github sfu-fas / coursys / coredata / data_migration / cortez_fix_tastatus.py View on Github external
if bu == 0:
            return
        if not(emplid.isdigit() and len(emplid)==9):
            # there's only one, from 2004. Ignore.
            return
        if off_id not in self.offeringid_map:
            # Where did these offerings go? I'm troubled.
            print "missing offering_id:", off_id
            return
        offering = self.offeringid_map[off_id]
        p = get_person(emplid, commit=True)
        
        posting = TAPosting.objects.get(unit=self.UNIT, semester=offering.semester)
        
        # create TAApplication
        apps = TAApplication.objects.filter(posting=posting, person=p)
        app = apps[0]
        
        # create TAContract
        contracts = TAContract.objects.filter(posting=posting, application=app)
        contract = contracts[0]

        # distinct values are ['waitlist', 'accepted', None]; most are None
        contract.status = 'CAN' if status=='waitlist' else 'SGN'
        contract.save()
github sfu-fas / coursys / ta / views.py View on Github external
def view_late_applications(request,post_slug):
    posting = get_object_or_404(TAPosting, slug=post_slug, unit__in=request.units)
    applications = TAApplication.objects.filter(posting__slug=post_slug, late=True)
    context = {
        'posting': posting,
        'applications':applications,
    }
    return render(request, 'ta/late_applications.html', context)
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
# there's only one, from 2004. Ignore.
            return
        if off_id not in self.offeringid_map:
            # Where did these offerings go? I'm troubled.
            print "missing offering_id:", off_id
            return
        offering = self.offeringid_map[off_id]
        p = get_person(emplid, commit=True)
        
        try:
            posting = TAPosting.objects.get(unit=self.UNIT, semester=offering.semester)
        except TAPosting.DoesNotExist:
            posting = self.create_fake_posting(offering.semester)
        
        # create TAApplication
        apps = TAApplication.objects.filter(posting=posting, person=p)
        if apps:
            app = apps[0]
        else:
            app = TAApplication(posting=posting, person=p)
        
        app.category = self.CATEGORY_MAP[cat]
        app.base_units = app_bu or 0
        app.sin = sin
        app.save()
        
        # create TAContract
        contracts = TAContract.objects.filter(posting=posting, application=app)
        if contracts:
            contract = contracts[0]
        else:
            contract = TAContract(posting=posting, application=app)
github sfu-fas / coursys / coredata / devdata_importer.py View on Github external
#SemesterPlan.objects.all(),
            #PlannedOffering.objects.all(),
            #PlanningCourse.objects.all(),
            #TeachingEquivalent.objects.all(),
            #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 / ta / models.py View on Github external
("CAN","Cancelled"),
    )
STATUS = dict(STATUS_CHOICES)
STATUSES_NOT_TAING = ['NEW', 'REJ', 'CAN'] # statuses that mean "not actually TAing"

DEFAULT_EMAIL_TEXT = "Please find attached a copy of your TA contract."
DEFAULT_EMAIL_SUBJECT = "Your TA contract."


class TAContract(models.Model):
    """    
    TA Contract, filled in by TAAD
    """
    status  = models.CharField(max_length=3, choices=STATUS_CHOICES, verbose_name="Appointment Status", default="NEW")
    posting = models.ForeignKey(TAPosting, on_delete=models.PROTECT)
    application = models.ForeignKey(TAApplication, on_delete=models.PROTECT)
    sin = models.CharField(max_length=30, verbose_name="SIN",help_text="Social insurance number")
    appointment_start = models.DateField(null=True, blank=True)
    appointment_end = models.DateField(null=True, blank=True)
    pay_start = models.DateField()
    pay_end = models.DateField()
    appt_category = models.CharField(max_length=4, choices=CATEGORY_CHOICES, verbose_name="Appointment Category", default="GTA1")
    position_number = models.ForeignKey(Account, on_delete=models.PROTECT)
    appt = models.CharField(max_length=4, choices=APPOINTMENT_CHOICES, verbose_name="Appointment", default="INIT")
    pay_per_bu = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Pay per Base Unit Semester Rate.",)
    scholarship_per_bu = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Scholarship per Base Unit Semester Rate.",)
    appt_cond = models.BooleanField(default=False, verbose_name="Conditional")
    appt_tssu = models.BooleanField(default=True, verbose_name="Appointment in TSSU")
    deadline = models.DateField(verbose_name="Acceptance Deadline", help_text='Deadline for the applicant to accept/decline the offer')
    remarks = models.TextField(blank=True)
    
    created_by = models.CharField(max_length=8, null=False)
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
print "missing offering_id:", off_id
            return
        offering = self.offeringid_map[off_id]
        p = get_person(emplid, commit=True)
        
        try:
            posting = TAPosting.objects.get(unit=self.UNIT, semester=offering.semester)
        except TAPosting.DoesNotExist:
            posting = self.create_fake_posting(offering.semester)
        
        # create TAApplication
        apps = TAApplication.objects.filter(posting=posting, person=p)
        if apps:
            app = apps[0]
        else:
            app = TAApplication(posting=posting, person=p)
        
        app.category = self.CATEGORY_MAP[cat]
        app.base_units = app_bu or 0
        app.sin = sin
        app.save()
        
        # create TAContract
        contracts = TAContract.objects.filter(posting=posting, application=app)
        if contracts:
            contract = contracts[0]
        else:
            contract = TAContract(posting=posting, application=app)

        try:
            pos_id = self.positions[posnum]
        except KeyError:
github sfu-fas / coursys / ta / views.py View on Github external
else:
            return ForbiddenResponse(request)

    course_choices = [(c.id, str(c) + " (" + c.title + ")") for c in posting.selectable_courses()]
    course_choices = [(None, '\u2014')] + course_choices
    used_campuses = set((vals['campus'] for vals in posting.selectable_offerings().order_by('campus').values('campus').distinct()))
    skills = Skill.objects.filter(posting=posting)    
    max_courses = posting.max_courses()
    min_courses = posting.min_courses()
    CoursesFormSet = formset_factory(CoursePreferenceForm, min_num=max_courses, max_num=max_courses)

    sin = None
    # build basic objects, whether new or editing application
    if editing:
        person = Person.objects.get(userid=userid)
        application = get_object_or_404(TAApplication, posting=posting, person__userid=userid)
        old_coursepref = CoursePreference.objects.filter(app=application).exclude(rank=0).order_by('rank')
    else:
        application = None
    
    if not manual:
        """
        Don't change the person in the case of a TA Admin editing, as we don't want to save this application as the
        Admin's, but as the original user's.
        """
        if not is_ta_admin:
            try:
                person = ensure_person_from_userid(request.user.username)
            except SIMSProblem:
                return HttpError(request, status=503, title="Service Unavailable", error="Currently unable to handle the request.", errormsg="Problem with SIMS connection while trying to find your account info")

        if not person: