How to use the ta.models.CampusPreference 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 / ta / tests.py View on Github external
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)     

        #Check that assign_tas page has two courses in it, one with someone who has applied
        url = reverse('ta.views.assign_tas', kwargs={'post_slug': posting.slug,})
        response = basic_page_tests(self, client, url)
github sfu-fas / coursys / ta / tests.py View on Github external
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)     

        #Check that assign_tas page has two courses in it, one with someone who has applied
        url = reverse('ta.views.assign_tas', kwargs={'post_slug': posting.slug,})
github sfu-fas / coursys / ta / views.py View on Github external
if transcript.charset:
                        transcript_file_type += "; charset=" + transcript.charset
                    app.transcript = transcript
                    app.transcript_mediatype = transcript_file_type


                app.save()
                ta_form.save_m2m()
                
                # extract campus and skill values; create objects
                CampusPreference.objects.filter(app=app).delete()
                for c in used_campuses:
                    val = request.POST.get('campus-'+c, None)
                    if val not in PREFERENCES:
                        val = 'WIL'
                    cp = CampusPreference(app=app, campus=c, pref=val)
                    cp.save()
                
                SkillLevel.objects.filter(app=app).delete()
                for s in skills:
                    val = request.POST.get('skill-'+str(s.position), None)
                    if val not in LEVELS:
                        val = 'NONE'
                    sl = SkillLevel(skill=s, app=app, level=val)
                    sl.save()
                
                # save course preferences: update existing or create new, as needed
                old_pref = set(CoursePreference.objects.filter(app=app))
                used_pref = set()
                for (rank,form) in enumerate(courses_formset):
                    existing_crs = CoursePreference.objects.filter(app=app, course=form.cleaned_data['course'])
                    if existing_crs:
github sfu-fas / coursys / ta / views.py View on Github external
if application.resume:
            ta_form.fields['resume'].required = False
        if application.transcript:
            ta_form.fields['transcript'].required = False
        ta_form.add_extra_questions(posting)
        cp_init = [{'course': cp.course, 'taken': cp.taken, 'exper':cp.exper} for cp in old_coursepref]
        search_form = None
        courses_formset = CoursesFormSet(initial=cp_init)
        for f in courses_formset:
            f.fields['course'].choices = course_choices

        # build values for template with entered values
        campus_preferences = []
        for c in used_campuses:
            try:
                val = CampusPreference.objects.get(app=application, campus=c).pref
            except CampusPreference.DoesNotExist:
                val = 'WIL'
            if val not in PREFERENCES:
                val = 'WIL'
            campus_preferences.append((c, CAMPUSES[c], val))
        skill_values = []
        for s in skills:
            try:
                val = SkillLevel.objects.get(app=application, skill=s).level
            except SkillLevel.DoesNotExist:
                val = 'WIL'
            if val not in LEVELS:
                val = 'NONE'
            skill_values.append((s.position, s.name, val))
    else:
        # new application
github sfu-fas / coursys / ta / views.py View on Github external
for applicant in all_applicants:
        applicant.course_rank = 99
        if applicant not in applicants:
            applicants.append(applicant)

    for applicant in applicants:
        # Determine Current Grad Status
        applicant.active_gs = GradStudent.objects.filter(person=applicant.person, current_status__in=STATUS_REAL_PROGRAM) \
                .select_related('program__unit')
        
        # Determine Campus Preference
        try:
            campus_preference = CampusPreference.objects.get(app=applicant, campus=offering.campus)
        except CampusPreference.DoesNotExist:
            # temporary fake object: shouldn't happen, but don't die if it does.
            campus_preference = CampusPreference(app=applicant, campus=offering.campus, pref="NOT")
        applicant.campus_preference = campus_preference

        #Find BU assigned to this applicant through contract
        course_assignments = tacourses.filter(contract__application=applicant)
        if course_assignments.count() == 1:
            assignment_for_this_course = course_assignments[0]
            applicant.assigned_course = assignment_for_this_course
        else:
            applicant.assigned_course = None

        # Set initial values for Formset
        init = {}
        if applicant.assigned_course:
            assignment_for_this_course = course_assignments[0]
            init['bu'] = assignment_for_this_course.bu
        init['rank'] = applicant.rank
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
else:
                lvl = SkillLevel(skill=skill, app=app)
            
            lvl.level = self.SKILL_LEVEL_MAP[level]
            lvl.save()
        
        # campus preferences
        if campuspref:
            for c in campuspref:
                if c in self.CAMPUS_PREF_MAP:
                    campus, pref = self.CAMPUS_PREF_MAP[c]
                    cps = CampusPreference.objects.filter(app=app, campus=campus)
                    if cps:
                        cp = cps[0]
                    else:
                        cp = CampusPreference(app=app, campus=campus)
                    
                    if cp.pref != pref:
                        cp.pref = pref
                        cp.save()