How to use the ta.models.SkillLevel.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 / coredata / data_migration / cortez_import.py View on Github external
for skillname, level in self.db:
            if not skillname:
                continue
            skills = Skill.objects.filter(posting=posting, name=skillname)
            if skills:
                skill = skills[0]
            else:
                maxpos = Skill.objects.filter(posting=posting).aggregate(max_pos=Max('position'))['max_pos']
                if maxpos:
                    pos = maxpos+1
                else:
                    pos = 1
                skill = Skill(posting=posting, name=skillname, position=pos)
                skill.save()
            
            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]
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
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:
                        course = existing_crs[0]
                        #course.exper = form.cleaned_data['exper']
                        #course.taken = form.cleaned_data['taken']
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)