How to use the ta.models.CourseDescription 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
from ta.models import CourseDescription, TAPosting, TAApplication, CoursePreference, TAContract, TACourse
    from ta.models import TAKEN_CHOICES, EXPER_CHOICES
    from ra.models import Account, Project, SemesterConfig, RAAppointment
    from ra.models import HIRING_CATEGORY_CHOICES, HIRING_CATEGORY_DISABLED

    # TAs
    d = Person.objects.get(userid='dzhao')
    unit = Unit.objects.get(slug='cmpt')
    r1 = Role(person=d, role='TAAD', unit=unit, expiry=role_expiry)
    r1.save()
    r2 = Role(person=d, role='FUND', unit=unit, expiry=role_expiry)
    r2.save()

    s = Semester.current().next_semester()
    admin = Person.objects.get(userid='dixon')
    CourseDescription(unit=unit, description="Office/Marking", labtut=False).save()
    CourseDescription(unit=unit, description="Office/Marking/Lab", labtut=True).save()

    a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=unit)
    a.save()
    a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=unit)
    a.save()
    a = Account(account_number=12347, position_number=12347, title='External TA', unit=unit)
    a.save()
    a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=unit)
    a.save()

    post = TAPosting(semester=s, unit=unit)
    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])
github sfu-fas / coursys / ta / tests.py View on Github external
def test_application(self):
        p = Person.objects.get(emplid=210012345)
        s = Semester.objects.get(name="1077")
        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")
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
contract.remarks = remarks or ''
        contract.created_by = self.IMPORT_USER
        contract.save()
        
        # create TACourse
        crses = TACourse.objects.filter(course=offering, contract=contract)
        if crses:
            crs = crses[0]
        else:
            crs = TACourse(course=offering, contract=contract)
        
        d = self.TA_DESC_MAP[description.split()[0]]
        try:
            desc = CourseDescription.objects.get(unit=self.UNIT, description=d)
        except CourseDescription.DoesNotExist:
            desc = CourseDescription(unit=self.UNIT, description=d)
            if d == 'Office/Marking/Labs':
                desc.labtut = True
            desc.save()

        crs.description = desc
        crs.bu = bu
        crs.save()
        
        
        # course preferences
        self.db.execute("SELECT course, rank FROM tasearch.dbo.courseranking "
                        "WHERE appId=%s", (appid,))
        for course, rank in self.db:
            if course in ['-', '']:
                continue
            subj, num = course.split()
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
contract.appt_tssu = bool(tssu)
        contract.status = 'SGN' if status=='accepted' else 'CAN'
        contract.remarks = remarks or ''
        contract.created_by = self.IMPORT_USER
        contract.save()
        
        # create TACourse
        crses = TACourse.objects.filter(course=offering, contract=contract)
        if crses:
            crs = crses[0]
        else:
            crs = TACourse(course=offering, contract=contract)
        
        d = self.TA_DESC_MAP[description.split()[0]]
        try:
            desc = CourseDescription.objects.get(unit=self.UNIT, description=d)
        except CourseDescription.DoesNotExist:
            desc = CourseDescription(unit=self.UNIT, description=d)
            if d == 'Office/Marking/Labs':
                desc.labtut = True
            desc.save()

        crs.description = desc
        crs.bu = bu
        crs.save()
        
        
        # course preferences
        self.db.execute("SELECT course, rank FROM tasearch.dbo.courseranking "
                        "WHERE appId=%s", (appid,))
        for course, rank in self.db:
            if course in ['-', '']:
github sfu-fas / coursys / coredata / data_migration / cortez_import.py View on Github external
contract.status = 'SGN' if status=='accepted' else 'CAN'
        contract.remarks = remarks or ''
        contract.created_by = self.IMPORT_USER
        contract.save()
        
        # create TACourse
        crses = TACourse.objects.filter(course=offering, contract=contract)
        if crses:
            crs = crses[0]
        else:
            crs = TACourse(course=offering, contract=contract)
        
        d = self.TA_DESC_MAP[description.split()[0]]
        try:
            desc = CourseDescription.objects.get(unit=self.UNIT, description=d)
        except CourseDescription.DoesNotExist:
            desc = CourseDescription(unit=self.UNIT, description=d)
            if d == 'Office/Marking/Labs':
                desc.labtut = True
            desc.save()

        crs.description = desc
        crs.bu = bu
        crs.save()
        
        
        # course preferences
        self.db.execute("SELECT course, rank FROM tasearch.dbo.courseranking "
                        "WHERE appId=%s", (appid,))
        for course, rank in self.db:
            if course in ['-', '']:
                continue
github sfu-fas / coursys / ta / views.py View on Github external
def assign_bus(request, post_slug, course_slug):
    posting = get_object_or_404(TAPosting, slug=post_slug, unit__in=request.units)
    offering = get_object_or_404(CourseOffering, slug=course_slug)
    instructors = offering.instructors()
    course_prefs = CoursePreference.objects.filter(app__posting=posting, course=offering.course, app__late=False)
    tacourses = TACourse.objects.filter(course=offering)
    all_applicants = TAApplication.objects.filter(posting=posting)
    
    descrs = CourseDescription.objects.filter(unit=posting.unit)
    if not descrs.filter(labtut=True) or not descrs.filter(labtut=False):
        messages.error(request, "Must have at least one course description for TAs with and without labs/tutorials before assigning TAs.")
        return HttpResponseRedirect(reverse('ta:descriptions', kwargs={}))
    
    if request.method == "POST" and 'extra_bu' in request.POST:
        # update extra BU and lab/tutorial setting for course
        response_data = {
            'message': "",
            'error': False,
            'labtas_changed':False,
            'has_labtas':  offering.labtas() }
        
        extra_bu = request.POST['extra_bu']
        if extra_bu != '':
            try:
                extra_bu = decimal.Decimal(extra_bu)
github sfu-fas / coursys / coredata / devdata_importer.py View on Github external
#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
def default_description(self):
        """
        Guess an appropriate CourseDescription object for this contract. Must have self.course filled in first.
        """
        labta = self.course.labtas()
        descs = CourseDescription.objects.filter(unit=self.contract.posting.unit, hidden=False, labtut=labta)
        if descs:
            return descs[0]
        else:
            raise ValueError("No appropriate CourseDescription found")