當前位置: 首頁>>代碼示例>>Python>>正文


Python Member.config['bu']方法代碼示例

本文整理匯總了Python中coredata.models.Member.config['bu']方法的典型用法代碼示例。如果您正苦於以下問題:Python Member.config['bu']方法的具體用法?Python Member.config['bu']怎麽用?Python Member.config['bu']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在coredata.models.Member的用法示例。


在下文中一共展示了Member.config['bu']方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_grades

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import config['bu'] [as 別名]
def create_grades():
    """
    Test data for grades, marking, submission, groups
    """
    undergrads = list(Person.objects.filter(last_name='Student'))
    grads = list(Person.objects.filter(last_name='Grad').exclude(userid='0ggg0'))
    for o in CourseOffering.objects.all():
        # TA
        m = Member(person=random.choice(grads), role='TA', offering=o, credits=0, career='NONS', added_reason='TAC')
        m.config['bu'] = 5
        m.save()

        # students
        if o.slug == TEST_COURSE_SLUG:
            # there are some specific students we need in this offering for the marking/testfiles/* imports
            students = set(random.sample(undergrads, 6) + list(Person.objects.filter(userid__in=['0aaa0', '0aaa1', '0aaa2'])))
        else:
            students = random.sample(undergrads, 4)

        for p in students:
            Member.objects.get_or_create(person=p, role='STUD', offering=o, credits=3, career='UGRD', added_reason='AUTO')

    return itertools.chain(
        Holiday.objects.filter(semester__name__gt=SEMESTER_CUTOFF),
        MeetingTime.objects.all(),
        Member.objects.filter(role__in=['TA', 'STUD']),
        create_test_offering(),
    )
開發者ID:tedkirkpatrick,項目名稱:coursys,代碼行數:30,代碼來源:devtest_importer.py

示例2: add_membership_for

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import config['bu'] [as 別名]
        def add_membership_for(tacrs, reason, memberships):
            if not tacrs.contract.should_be_added_to_the_course or tacrs.total_bu <= 0:
                return

            # Find existing membership for this person+offering if it exists
            # (Behaviour here implies you can't be both TA and other role in one offering: I'm okay with that.)
            for m in memberships:
                if m.person == person and m.offering == tacrs.course:
                    break
            else:
                # there was no membership: create
                m = Member(person=person, offering=tacrs.course)
                memberships.append(m)

            m.role = 'TA'
            m.credits = 0
            m.career = 'NONS'
            m.added_reason = reason
            m.config['bu'] = str(tacrs.total_bu)
開發者ID:tedkirkpatrick,項目名稱:coursys,代碼行數:21,代碼來源:models.py

示例3: save

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import config['bu'] [as 別名]
    def save(self, *args, **kwargs):
        super(TAContract, self).save(*args, **kwargs)

        # set SIN field on any GradStudent objects for this person
        from grad.models import GradStudent
        for gs in GradStudent.objects.filter(person=self.application.person):
            dummy_sins = ['999999999', '000000000', '123456789']
            if (('sin' not in gs.config 
                or ('sin' in gs.config and gs.config['sin'] in dummy_sins)) 
                and not self.sin in dummy_sins ):
                gs.person.set_sin(self.sin)
                gs.person.save()

        # if signed, create the Member objects so they have access to the courses.
        courses = TACourse.objects.filter(contract=self)
        for crs in courses:
            members = Member.objects.filter(person=self.application.person, offering=crs.course).exclude(role='DROP')
            # assert( len(members) <= 1 )
            dropped_members = Member.objects.filter(person=self.application.person, offering=crs.course, role='DROP')
            # Should Member just have an optional FK to TACourse rather than getting a copy of the BU? 
            if (self.status in ['SGN', 'ACC'] and crs.bu > 0) and not members:
                if dropped_members:
                    m = dropped_members[0]
                    # if this student was added/dropped by the prof, then added_reason might not be CTA
                    m.added_reason='CTA'
                    m.role = "TA"
                else:
                    # signed, but not a member: create
                    m = Member(person=self.application.person, offering=crs.course, role='TA',
                           added_reason='CTA', credits=0, career='NONS')
                m.config['bu'] = crs.total_bu
                m.save()
            elif (self.status in ['SGN', 'ACC'] and crs.bu > 0 ) and members:
                # change in BU -> change in BU for Member
                m = members[0]
                if not 'bu' in m.config or m.config['bu'] != crs.total_bu:
                    # if this student was added by the prof, then added_reason might not be CTA
                    m.config['bu'] = crs.total_bu
                    m.added_reason='CTA'
                    m.save()
            elif ( (not self.status in ['SGN', 'ACC']) or crs.bu == 0) and members:
                # already in course, but status isn't signed: remove
                m = members[0]
                if m.role == 'TA' and m.added_reason == 'CTA':
                    m.role = 'DROP'
                    m.save()
            else: 
                # (self.status not in ['SGN', 'ACC'] or crs.bu == 0) and not members
                # there is no contract and this student doesn't exist as a Member in the course
                pass
            
            if self.status in ('CAN', 'REJ'):
                # These students should be removed from their courses. 
                crs.bu = 0
                crs.save()

            # If this course has 0 BUs and a course Member record, clear that record. 
            if crs.bu == 0 and members:
                m = members[0]
                if m.role == 'TA' and m.added_reason == 'CTA':
                    m.role = 'DROP'
                    m.save()

        # If they are CTA-added members of any other course this semester, they probably shouldn't be
        members = Member.objects.filter(person=self.application.person, role='TA', added_reason='CTA', offering__semester=self.posting.semester )
        courseofferings = [crs.course for crs in courses if crs.bu > 0]
        for member in members:
            if member.offering not in courseofferings:
                member.role = 'DROP'
                member.save()
開發者ID:avacariu,項目名稱:coursys,代碼行數:72,代碼來源:models.py

示例4: sync_course_member

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import config['bu'] [as 別名]
    def sync_course_member(self):
        """
        Once a contract is Signed, we should create a Member object for them.
        If a contract is Cancelled, we should DROP the Member object. 

        This operation should be idempotent - run it as many times as you
        want, the result should always be the same. 
        """
        # if signed, create the Member objects so they have access to the courses.
        courses = self.course.all()
        for crs in courses:
            members = Member.objects.filter(person=self.person, 
                                            role='TA',
                                            offering=crs.course)
            # the student should either be in the course (1) or not (0)
            # any other number of responses is unacceptable. 
            assert( len(members) == 1 or len(members) == 0 )


            dropped_members = Member.objects.filter(person=self.person, 
                                                    offering=crs.course, 
                                                    role='DROP')
            
            assert( len(dropped_members) == 1 or len(dropped_members) == 0)

            # this shouldn't be. 
            if members and dropped_members:
                d = dropped_members[0]
                d.delete()
                dropped_members = []
           
            # the student must be in one of these three states
            exists_and_is_in_the_course = len(members) > 0
            exists_and_is_dropped = len(dropped_members) > 0
            does_not_exist = len(members) == 0 and len(dropped_members) == 0
            
            assert(exists_and_is_in_the_course or exists_and_is_dropped or does_not_exist)            
            assert(not(exists_and_is_in_the_course and exists_and_is_dropped))
            assert(not(exists_and_is_dropped and does_not_exist))
            assert(not(exists_and_is_in_the_course and does_not_exist))
            assert(len(dropped_members) < 2)
            assert(len(members) < 2)

            if self.should_be_added_to_the_course:
                if exists_and_is_dropped:
                    m = dropped_members[0]
                elif exists_and_is_in_the_course:
                    m = members[0]
                elif does_not_exist:
                    m = Member(person=self.person, 
                               offering=crs.course, 
                               role='TA',
                               added_reason='TAC',
                               credits=0, 
                               career='NONS')
                else:
                    assert(False)
                m.added_reason='TAC'
                m.role = 'TA'
                m.config['bu'] = crs.total_bu
                m.save()
                crs.member = m
                crs.save(always_allow=True)
            else:
                if exists_and_is_dropped:
                    pass
                elif exists_and_is_in_the_course:
                    m = members[0]
                    if m.added_reason == 'TAC':
                        m.role = 'DROP'
                        m.save()
                    crs.member = None
                    crs.save(always_allow=True)
                elif does_not_exist:
                    pass

        # If they are TAC-added members of any other course this semester,
        #    they probably shouldn't be.
        members = Member.objects.filter(person=self.person, 
                                        role='TA', 
                                        added_reason='TAC',
                                        offering__semester=self.category.hiring_semester.semester)
        
        courseofferings = [crs.course for crs in courses]
        for member in members:
            if member.offering not in courseofferings:
                member.role = 'DROP'
                member.save()
開發者ID:avacariu,項目名稱:coursys,代碼行數:90,代碼來源:models.py


注:本文中的coredata.models.Member.config['bu']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。