How to use the ta.models.CampusPreference.objects.filter 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 / views.py View on Github external
app.resume_mediatype = resume_file_type

                if request.FILES and 'ta-transcript' in request.FILES:
                    transcript = request.FILES['ta-transcript']
                    transcript_file_type = transcript.content_type
                    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
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
lvls = SkillLevel.objects.filter(skill=skill, app=app)
            if lvls:
                lvl = lvls[0]
            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()
github sfu-fas / coursys / ta / views.py View on Github external
all_offerings = CourseOffering.objects.filter(semester=posting.semester, owner=posting.unit).select_related('course')
    excl = set(posting.excluded())
    offerings = [o for o in all_offerings if o.course_id not in excl]
    
    # collect all course preferences in a sensible way
    prefs = CoursePreference.objects.filter(app__posting=posting).exclude(rank=0).order_by('app__person').select_related('app', 'course')
    
    for offering in offerings: 
        offering.applications = []
        applications_for_this_offering = [pref.app for pref in prefs if 
            (pref.course.number == offering.course.number and pref.course.subject == offering.course.subject)]
        for application in applications_for_this_offering:
            if not hasattr(application, 'extra_data_done'):
                application.courses = CoursePreference.objects.filter(app=application).exclude(rank=0).order_by('rank')
                application.skills = SkillLevel.objects.filter(app=application).select_related('skill')
                application.campuses = CampusPreference.objects.filter(app=application)
                application.contracts = TAContract.objects.filter(application=application)
                application.previous_experience = TACourse.objects.filter(contract__application__person=application.person) \
                    .exclude(contract__application=application).select_related('course__semester')
                application.grad_programs = GradStudent.objects \
                     .filter(program__unit__in=request.units, person=application.person)
                application.extra_data_done = True

            offering.applications.append(application)

    context = {
            'offerings': offerings,
            'posting': posting,
            }
    return render(request, 'ta/print_all_applications_by_course.html', context)
github sfu-fas / coursys / ta / views.py View on Github external
def print_all_applications(request,post_slug):
    posting = get_object_or_404(TAPosting, slug=post_slug, unit__in=request.units)
    applications = TAApplication.objects.filter(posting=posting).order_by('person')

    for application in applications:
        application.courses = CoursePreference.objects.filter(app=application).exclude(rank=0).order_by('rank')
        application.skills = SkillLevel.objects.filter(app=application).select_related('skill')
        application.campuses = CampusPreference.objects.filter(app=application)
        application.contracts = TAContract.objects.filter(application=application)
        application.previous_experience = TACourse.objects.filter(contract__application__person=application.person) \
            .exclude(contract__application=application).select_related('course__semester')
        application.grad_programs = GradStudent.objects \
             .filter(program__unit__in=request.units, person=application.person)

    context = {
            'applications': applications,
            'posting': posting,
            }
    return render(request, 'ta/print_all_applications.html', context)
github sfu-fas / coursys / ta / views.py View on Github external
def view_application(request, post_slug, userid):
    application = get_object_or_404(TAApplication, posting__slug=post_slug, person__userid=userid)
    is_ta_admin = Role.objects_fresh.filter(role="TAAD", person__userid=request.user.username,
                                      unit=application.posting.unit).count() > 0

    # Only TA Administrator or owner of application can view it
    if application.person.userid != request.user.username and not is_ta_admin:
        return ForbiddenResponse(request, 'You cannot access this application')

    units = [application.posting.unit]
   
    application.courses = CoursePreference.objects.filter(app=application).exclude(rank=0).order_by('rank')
    application.skills = SkillLevel.objects.filter(app=application).select_related('skill')
    application.campuses = CampusPreference.objects.filter(app=application)
    application.contracts = TAContract.objects.filter(application=application)
    application.previous_experience = TACourse.objects.filter(contract__application__person=application.person) \
            .exclude(contract__application=application).select_related('course__semester')
    application.grad_programs = GradStudent.objects \
                 .filter(program__unit__in=units, person=application.person)

    if is_ta_admin and application.courses:
        contract = application.courses[0]
    else:
        contract = None

    context = {
            'application':application,
            'contract': contract,
            'is_ta_admin': is_ta_admin,
            }
github sfu-fas / coursys / ta / views.py View on Github external
gs = gradstudents[0]
            system_program = gs.program.label
            status = gs.get_current_status_display()
            unit = gs.program.unit.label
            if gs.start_semester:
                startsem = gs.start_semester.name
            else:
                startsem = ''
        elif len(gradstudents) > 1:
            system_program = "Multiple"
            status = "*"
            unit = "*"
            startsem = "*"
        
        campuspref = ''
        for cp in CampusPreference.objects.filter(app=app):
            if cp.pref == 'PRF':
                campuspref += cp.campus[0].upper()
            elif cp.pref == 'WIL':
                campuspref += cp.campus[0].lower()

        # Get all TAContracts that match this posting and application, then the matching TACourses
        # so we can find out if a course/courses have been assigned to this TA

        assigned_courses = ''
        assigned_bus = ''
        ta_contracts = TAContract.objects.filter(posting=posting, application=app).exclude(status__in=['CAN', 'REJ'])
        if len(ta_contracts) > 0:
            ta_courses = TACourse.objects.filter(contract__in=ta_contracts)
            if len(ta_courses) > 0:
                assigned_courses = ', '.join([tacourse.course.name() for tacourse in ta_courses])
                assigned_bus = sum([t.total_bu for t in ta_courses])