How to use the ta.models.TAPosting.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 / tests.py View on Github external
c.login_user('dzhao')
        offering = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)
        ta = Member.objects.filter(offering=offering, role="TA")[0]
        test_views(self, c, 'ta.views.', ['new_tug'], {'course_slug': offering.slug, 'userid': ta.person.userid})

        # create TUG to view/edit
        tug = TUG(member=ta, base_units=5)
        for f in tug.config_meta.keys():
            tug.config[f] = {'weekly': 1, 'total': 13, 'note': 'somenote'}
        tug.save()
        test_views(self, c, 'ta.views.', ['view_tug', 'edit_tug'], {'course_slug': offering.slug, 'userid': ta.person.userid})

        # admin views
        c.login_user('dzhao')
        test_views(self, c, 'ta.views.', ['all_tugs_admin', 'view_postings'], {})
        post = TAPosting.objects.filter(unit__label='CMPT')[0]
        test_views(self, c, 'ta.views.', ['new_application', 'new_application_manual', 'view_all_applications',
                    'print_all_applications', 'print_all_applications_by_course', 'view_late_applications',
                    'assign_tas', 'all_contracts'],
                {'post_slug': post.slug})
        test_views(self, c, 'ta.views.', ['assign_bus'],
                {'post_slug': post.slug, 'course_slug': offering.slug})

        contr = TAContract.objects.filter(posting=post)[0]
        test_views(self, c, 'ta.views.', ['edit_application', 'view_application', 'preview_offer', 'view_contract',
                                          'edit_contract'],
                   {'post_slug': post.slug, 'userid': contr.application.person.userid})

        # applicant views
        c.login_user(contr.application.person.userid)
        test_views(self, c, 'ta.views.', ['accept_contract'],
                   {'post_slug': post.slug, 'userid': contr.application.person.userid})
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
asm = 1

            start = datetime.date(asy, asm, asd)
            end = datetime.date(aey, aem, aed)
            try:
                applic = datetime.datetime.strptime(applic, "%B %d, %Y").date()
            except ValueError:
                applic = start
            try:
                accept = datetime.datetime.strptime(accept, "%B %d, %Y").date()
            except ValueError:
                accept = start

            semester = get_or_create_semester(strm)
            semester.save()
            postings = TAPosting.objects.filter(unit=self.UNIT, semester=semester)
            if postings:
                posting = postings[0]
            else:
                posting = TAPosting(unit=self.UNIT, semester=semester)

            posting.opens = applic
            posting.closes = applic
            posting.config['salary'] = salary
            posting.config['scholarship'] = schol
            posting.config['start'] = start
            posting.config['end'] = end
            posting.config['deadline'] = accept
            posting.config['contact'] = self.TA_CONTACT.id
            posting.config['accounts'] = positions
            posting.config['payperiods'] = "%.1f" % (self.total_seconds(end-start)/3600/24/14,) # close enough for the import
            posting.save()
github sfu-fas / coursys / coredata / data_migration / cortez_fix_tastatus.py View on Github external
asm = 1

            start = datetime.date(asy, asm, asd)
            end = datetime.date(aey, aem, aed)
            try:
                applic = datetime.datetime.strptime(applic, "%B %d, %Y").date()
            except ValueError:
                applic = start
            try:
                accept = datetime.datetime.strptime(accept, "%B %d, %Y").date()
            except ValueError:
                accept = start

            semester = get_or_create_semester(strm)
            semester.save()
            postings = TAPosting.objects.filter(unit=self.UNIT, semester=semester)
            if postings:
                posting = postings[0]
            else:
                posting = TAPosting(unit=self.UNIT, semester=semester)

            posting.opens = applic
            posting.closes = applic
            posting.config['salary'] = salary
            posting.config['scholarship'] = schol
            posting.config['start'] = start
            posting.config['end'] = end
            posting.config['deadline'] = accept
            posting.config['contact'] = self.TA_CONTACT.id
            posting.config['accounts'] = positions
            posting.config['payperiods'] = "%.1f" % (self.total_seconds(end-start)/3600/24/14,) # close enough for the import
            posting.save()
github sfu-fas / coursys / ta / views.py View on Github external
def view_postings(request):
    roles = Role.objects_fresh.filter(role="TAAD", person__userid=request.user.username)
    units = [r.unit for r in roles]
    today = datetime.date.today()
    postings = TAPosting.objects.filter(opens__lte=today, closes__gte=today).order_by('-semester', 'unit')
    owned = TAPosting.objects.filter(unit__in=units).order_by('-semester', 'unit')
    context = {
            'postings': postings,
            'owned': owned,
            'is_admin': bool(roles),
            }
    return render(request, 'ta/view_postings.html', context)
github sfu-fas / coursys / ta / views.py View on Github external
excluded_choices.sort()
    excluded_choices = [(cid,label) for label,cid in excluded_choices]

    if post_slug:
        # editing existing
        posting = get_object_or_404(TAPosting, slug=post_slug, unit__in=request.units)
        if posting.unit not in request.units:
            ForbiddenResponse(request, 'You cannot access this posting')
        editing = True
    else:
        # creating new
        posting = TAPosting()
        editing = False

        # populate from previous semester if possible
        old_postings = TAPosting.objects.filter(unit__in=request.units).order_by('-semester')
        if old_postings:
            old = old_postings[0]
            _copy_posting_defaults(old, posting)
        else:
            # heuristic default: non-lecture sections, except distance, are excluded
            default_exclude = set((o.course_id for o in offerings.filter(component="SEC").exclude(section__startswith="C")))
            posting.config['excluded'] = default_exclude
            posting.config['contact'] = Person.objects.get(userid=request.user.username).id

    contact_choices = [(r.person.id, r.person.name()) for r in Role.objects_fresh.filter(unit__in=request.units)]
    current_contact = posting.contact()
    if current_contact:
        contact_choices.append((current_contact.id, current_contact.name()))
    contact_choices = list(set(contact_choices))
    # Let's sort these choices by name at least.
    contact_choices = sorted(contact_choices, key=lambda name: name[1])