当前位置: 首页>>代码示例>>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;未经允许,请勿转载。