当前位置: 首页>>代码示例>>Python>>正文


Python Semester.current方法代码示例

本文整理汇总了Python中coredata.models.Semester.current方法的典型用法代码示例。如果您正苦于以下问题:Python Semester.current方法的具体用法?Python Semester.current怎么用?Python Semester.current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coredata.models.Semester的用法示例。


在下文中一共展示了Semester.current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def __init__(self, *args, **kwargs):
        flags = kwargs.pop('flags', [])
        super(CourseAccreditationForm, self).__init__(*args, **kwargs)

        if 'start_semester' not in self.data:
            self.data['start_semester'] = Semester.current().name
        if 'end_semester' not in self.data:
            self.data['end_semester'] = Semester.current().name
        self.fields['flag'].choices = flags
开发者ID:avacariu,项目名称:coursys,代码行数:11,代码来源:forms.py

示例2: run

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def run(self):
        AcceptedStudentsQuery = AcceptedQuery({'strm': Semester.current().offset_name(1), 'acad_plans':
                                               ['CMPTMAJ', 'DCMPT', 'CMPTMIN', 'CMPTHON', 'CMPTJMA', 'CMPTJHO',
                                                'SOSYMAJ', 'ZUSFU']})
        AcceptedStudents = AcceptedStudentsQuery.result()
        EnrolledStudentsQuery = EnrolledQuery({'strm': Semester.current().offset_name(1), 'acad_progs':
                                               ['CMPT', 'CMPT2']})
        EnrolledStudents = EnrolledStudentsQuery.result()

        # Let's calculate our totals so we can display those numbers as well.
        accepted_list = AcceptedStudents.column_as_list("SEX")
        accepted_total = len(accepted_list)
        accepted_m_count = len([i for i in accepted_list if i=='M'])
        accepted_f_count = len([i for i in accepted_list if i=='F'])
        accepted_u_count = len([i for i in accepted_list if i=='U'])

        enrolled_list = EnrolledStudents.column_as_list("SEX")
        enrolled_total = len(enrolled_list)
        enrolled_m_count = len([i for i in enrolled_list if i == 'M'])
        enrolled_f_count = len([i for i in enrolled_list if i == 'F'])
        enrolled_u_count = len([i for i in enrolled_list if i == 'U'])

        # Let's create two new tables to display these results.
        accepted_totals = Table()
        accepted_totals.append_column('TOTAL_COUNT')
        accepted_totals.append_column('M_COUNT')
        accepted_totals.append_column('M_PERCENT')
        accepted_totals.append_column('F_TOTAL')
        accepted_totals.append_column('F_PERCENT')
        accepted_totals.append_column('U_COUNT')
        accepted_totals.append_column('U_PERCENT')
        accepted_totals.append_row([accepted_total, accepted_m_count, 100.0 * accepted_m_count/accepted_total,
                                   accepted_f_count, 100.0 * accepted_f_count/accepted_total, accepted_u_count, 
                                   100.0 * accepted_u_count/accepted_total])

        enrolled_totals = Table()
        enrolled_totals.append_column('TOTAL_COUNT')
        enrolled_totals.append_column('M_COUNT')
        enrolled_totals.append_column('M_PERCENT')
        enrolled_totals.append_column('F_TOTAL')
        enrolled_totals.append_column('F_PERCENT')
        enrolled_totals.append_column('U_COUNT')
        enrolled_totals.append_column('U_PERCENT')
        enrolled_totals.append_row([enrolled_total, enrolled_m_count, 100.0 * enrolled_m_count / enrolled_total,
                                   enrolled_f_count, 100.0 * enrolled_f_count / enrolled_total, enrolled_u_count,
                                   100.0 * enrolled_u_count / enrolled_total])

        self.artifacts.append(AcceptedStudents)
        self.artifacts.append(accepted_totals)
        self.artifacts.append(EnrolledStudents)
        self.artifacts.append(enrolled_totals)
开发者ID:sfu-fas,项目名称:coursys,代码行数:53,代码来源:gender_diversity_accept_vs_enroll.py

示例3: make_entry_field

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def make_entry_field(self, fieldsubmission=None):
        queryset = Semester.objects.all().order_by('name')
        allowed = self.config.get('allowed_semesters', 'AL')
        current = Semester.current().name
        if allowed == 'AL':
            pass
        elif allowed == 'LT':
            queryset = queryset.filter(name__lt=current).order_by('-name')
        elif allowed == 'LE':
            queryset = queryset.filter(name__lte=current).order_by('-name')
        elif allowed == 'GT':
            queryset = queryset.filter(name__gt=current)
        elif allowed == 'GE':
            queryset = queryset.filter(name__gte=current)

        the_choices = [(s.name, s.label()) for s in queryset]

        widget = forms.Select
        if self.config.get('format', 'D') == 'R':
            widget = forms.RadioSelect

        c = forms.ChoiceField(required=self.config['required'],
            label=self.config['label'],
            help_text=self.config['help_text'],
            choices=the_choices,
            widget=widget,)

        if fieldsubmission:
            c.initial = fieldsubmission.data['info']

        if not self.config['required']:
            c.choices.insert(0, ('', u'\u2014'))

        return c
开发者ID:avacariu,项目名称:coursys,代码行数:36,代码来源:other.py

示例4: run

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def run(self):
        current_semester = Semester.current()
        semesters = [current_semester.name, current_semester.offset_name(-1), current_semester.offset_name(-2)]

        cmpt_acad_progs = AcadProgsOwnedByUnit({'acad_org': 'COMP SCI'}) \
            .result() \
            .column_as_list('ACAD_PROG')

        eng_acad_progs = DegreeAcadProgs() \
            .result() \
            .column_as_list('ACAD_PROG')

        cmpt_gpas = self.bad_gpa_for(cmpt_acad_progs, semesters, '2.4')
        eng_gpas = self.bad_gpa_for(eng_acad_progs, semesters, '2.5')

        bad_gpas = cmpt_gpas
        for r in (eng_gpas.rows):
            bad_gpas.append_row(r)

        name_query = NameQuery()
        names = name_query.result()

        email_query = EmailQuery()
        email = email_query.result()
        email.filter( EmailQuery.preferred_email )

        bad_gpas.left_join( names, "EMPLID" )
        bad_gpas.left_join( email, "EMPLID" )

        bad_gpas.remove_column('E_ADDR_TYPE')
        bad_gpas.remove_column('PREF_EMAIL_FLAG')


        self.artifacts.append(bad_gpas)
开发者ID:avacariu,项目名称:coursys,代码行数:36,代码来源:bad_gpas.py

示例5: create_reminder_messages

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def create_reminder_messages(self, start_date=None, end_date=None, allow_stale=True):
        """
        Create any ReminderMessages that don't already exist, between startdate and enddate.

        Idempotent.
        """
        if self.status == 'D':
            return

        if not start_date or not end_date:
            start_date, end_date = self.reminder_message_range(allow_stale=allow_stale)

        if self.date_type == 'YEAR':
            next1 = datetime.date(year=start_date.year, month=int(self.month), day=self.day)
            next2 = datetime.date(year=start_date.year+1, month=int(self.month), day=self.day)
            self.create_reminder_on(next1, start_date, end_date)
            self.create_reminder_on(next2, start_date, end_date)

        elif self.date_type == 'SEM':
            if self.reminder_type == 'INST':
                # limit to semesters actually teaching
                instructors = Member.objects.filter(role='INST', person=self.person, offering__course=self.course) \
                    .exclude(offering__component='CAN').select_related('offering__course')
                semesters = {m.offering.semester for m in instructors}
            else:
                semesters = None

            this_sem = Semester.current()
            for sem in [this_sem.previous_semester(), this_sem, this_sem.next_semester()]:
                if semesters is None or sem in semesters:
                    next = sem.duedate(self.week, int(self.weekday), time=None)
                    self.create_reminder_on(next, start_date, end_date)

        else:
            raise ValueError()
开发者ID:sfu-fas,项目名称:coursys,代码行数:37,代码来源:models.py

示例6: manage_program

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def manage_program(request, grad_slug):
    grad = get_object_or_404(GradStudent, slug=grad_slug, program__unit__in=request.units)
    programs = GradProgram.objects.filter(unit__in=request.units)
    # If you have access to programs from different units, display them.
    if len(request.units) > 1:
        program_choices = [(p.id, str(p) + " (" + p.unit.label + ")") for p in programs]
    else:
        program_choices = [(p.id, str(p)) for p in programs]
    programhistory = GradProgramHistory.objects.filter(student=grad, program__unit__in=request.units).order_by('starting')
    
    if request.method == 'POST':
        form = GradProgramHistoryForm(request.POST)
        form.fields['program'].choices = program_choices
        if form.is_valid():
            gph = form.save(commit=False)
            gph.student = grad
            gph.save()
            grad.update_status_fields()

            messages.success(request, "Updated program info for %s." % (grad.person))
            l = LogEntry(userid=request.user.username,
                  description="Updated grad program for %s." % (grad),
                  related_object=gph)
            l.save()    
            return HttpResponseRedirect(reverse('grad:view', kwargs={'grad_slug':grad.slug}))
    else:
        form = GradProgramHistoryForm(initial={'program': grad.program, 'semester': Semester.current()})
        form.fields['program'].choices = program_choices

    context = {
               'form': form,
               'grad': grad,
               'programhistory': programhistory,
               }
    return render(request, 'grad/manage_program.html', context)
开发者ID:sfu-fas,项目名称:coursys,代码行数:37,代码来源:manage_program.py

示例7: run

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def run(self):
        cmpt_progs, eng_progs = get_fas_programs()
        fas_progs = cmpt_progs + eng_progs

        # collect student data for every semester in the last year.
        # Do it here because I'm not smart enough to do it in SQL.
        semester = Semester.current()
        last_yr = [semester.offset_name(-2), semester.offset_name(-1), semester.name]
        student_data = {}
        for strm in last_yr:
            students = InternationalGPAQuery({
                'acad_progs': fas_progs,
                'strm': strm,
            }).result()

            for r in students.rows:
                emplid = r[0]
                student_data[emplid] = r

        students.rows = student_data.values()

        visits = AdvisorVisits(unit_slugs=['apsc']).result()
        notes = AdvisorNotes(unit_slugs=['apsc']).result()

        students.left_join(visits, 'EMPLID')
        students.left_join(notes, 'EMPLID')
        self.artifacts.append(students)
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:29,代码来源:fas_international.py

示例8: run

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def run(self):
        current_semester = Semester.current()
        semesters = [current_semester.name, current_semester.offset_name(-1), current_semester.offset_name(-2)]

        cmpt_acad_progs, eng_acad_progs = get_fas_programs()

        cmpt_gpas = self.bad_gpa_for(cmpt_acad_progs, semesters, '2.4')
        eng_gpas = self.bad_gpa_for(eng_acad_progs, semesters, '2.5')

        bad_gpas = cmpt_gpas
        for r in (eng_gpas.rows):
            bad_gpas.append_row(r)

        name_query = NameQuery()
        names = name_query.result()

        email_query = EmailQuery()
        email = email_query.result()
        email.filter( EmailQuery.preferred_email )

        bad_gpas.left_join( names, "EMPLID" )
        bad_gpas.left_join( email, "EMPLID" )

        bad_gpas.remove_column('E_ADDR_TYPE')
        bad_gpas.remove_column('PREF_EMAIL_FLAG')

        self.artifacts.append(bad_gpas)
开发者ID:sfu-fas,项目名称:coursys,代码行数:29,代码来源:bad_gpas.py

示例9: course_home_pages

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def course_home_pages(request):
    semester = Semester.current()
    units = Unit.objects.all().order_by('label')
    units = [u for u in units if _has_homepages(u.id, semester.id)]
    context = {
        'semester': semester,
        'units': units,
    }
    return render(request, "coredata/course_home_pages.html", context)
开发者ID:avacariu,项目名称:coursys,代码行数:11,代码来源:views.py

示例10: create_grads

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def create_grads():
    """
    Put the grad students created before into GradStudent records.
    """
    gp = GradProgram(unit=Unit.objects.get(slug='cmpt'), label='MSc Project', description='MSc Project option')
    gp.save()
    req = GradRequirement(program=gp, description='Formed Committee')
    req.save()
    gp = GradProgram(unit=Unit.objects.get(slug='cmpt'), label='MSc Thesis', description='MSc Thesis option')
    gp.save()
    req = GradRequirement(program=gp, description='Formed Committee')
    req.save()
    gp = GradProgram(unit=Unit.objects.get(slug='cmpt'), label='PhD', description='PhD')
    gp.save()
    req = GradRequirement(program=gp, description='Defended Thesis')
    req.save()
    req = GradRequirement(program=gp, description='Formed Committee')
    req.save()
    gp = GradProgram(unit=Unit.objects.get(slug='ensc'), label='MEng', description='Masters in Engineering')
    gp.save()
    gp = GradProgram(unit=Unit.objects.get(slug='ensc'), label='PhD', description='PhD')
    gp.save()
    st = ScholarshipType(unit=Unit.objects.get(slug='cmpt'), name="Some Scholarship")
    st.save()
    gf = GradFlag(unit=Unit.objects.get(slug='cmpt'), label='Special Specialist Program')
    gf.save()

    programs = list(GradProgram.objects.all())
    supervisors = list(set([m.person for m in Member.objects.filter(offering__owner__slug='cmpt', role='INST')]))
    for p in Person.objects.filter(userid__endswith='grad'):
        gp = random.choice(programs)
        campus = random.choice(list(CAMPUSES))
        gs = GradStudent(person=p, program=gp, campus=campus)
        gs.save()

        startsem = random.choice(list(Semester.objects.filter(name__lt=Semester.current().name)))
        st = GradStatus(student=gs, status='COMP', start=startsem)
        st.save()
        st = GradStatus(student=gs, status=random.choice(['ACTI', 'ACTI', 'LEAV']), start=startsem.next_semester())
        st.save()
        if random.random() > 0.5:
            st = GradStatus(student=gs, status=random.choice(['GRAD', 'GRAD', 'WIDR']), start=startsem.next_semester().next_semester().next_semester())
            st.save()

        if random.random() > 0.25:
            sup = Supervisor(student=gs, supervisor=random.choice(supervisors), supervisor_type='SEN')
            sup.save()
            sup = Supervisor(student=gs, supervisor=random.choice(supervisors), supervisor_type='COM')
            sup.save()
            if random.random() > 0.5:
                sup = Supervisor(student=gs, supervisor=random.choice(supervisors), supervisor_type='COM')
                sup.save()
            else:
                sup = Supervisor(student=gs, external="Some External Supervisor", supervisor_type='COM', config={'email': '[email protected]'})
                sup.save()
开发者ID:sfu-fas,项目名称:coursys,代码行数:57,代码来源:demodata_importer.py

示例11: update_grads

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def update_grads():
    """
    Update any currently-relevant grad students
    """
    active = GradStudent.objects.filter(current_status__in=STATUS_ACTIVE).select_related('person')
    applicants = GradStudent.objects.filter(current_status__in=STATUS_APPLICANT,
                 updated_at__gt=datetime.datetime.now()-datetime.timedelta(days=7)).select_related('person')
    s = Semester.current().offset(1)
    far_applicants = GradStudent.objects.filter(start_semester__name__gte=s.name).select_related('person')
    for gs in set(itertools.chain(active, applicants, far_applicants)):
        get_person_grad(gs.person.emplid)
开发者ID:sfu-fas,项目名称:coursys,代码行数:13,代码来源:importer.py

示例12: progress_reports

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def progress_reports(request):
    last_semester = Semester.current().previous_semester()
    CS_UNIT=Unit.objects.get(label='CMPT')
    grads = GradStudent.objects.filter(program__unit=CS_UNIT, start_semester__name__lte=last_semester.name,
    #grads = GradStudent.objects.filter(program__unit__in=request.units, start_semester__name__lte=last_semester.name,
                end_semester=None, current_status__in=['ACTI', 'LEAV', 'PART']) \
                .select_related('person', 'program__unit').order_by('person')
    #grads = grads[:50]
    query_text = generate_queries(['queried students starting in %s or before: %i students'%(last_semester.name, grads.count())], grads)
    query_text = ''.join(query_text)
    return HttpResponse(query_text, content_type='text/plain')
开发者ID:avacariu,项目名称:coursys,代码行数:13,代码来源:progress_reports.py

示例13: list_all_semesters

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def list_all_semesters(request):
    semesters = HiringSemester.objects.visible(request.units)

    # if you have access to more than one unit, 
    # you can see more than one unit
    display_units = False
    if len(request.units) > 1:
        display_units = True

    try:
        current_semester = Semester.current()
    except Semester.DoesNotExist:
        current_semester = None
    try:
        next_semester = Semester.current().offset(1)
    except Semester.DoesNotExist:
        next_semester = None
    
    # If the user has multiple request.units, it's possible that they may
    #  have to deal with more than one HiringSemester per Semester

    if current_semester:
        current_hiring_semesters = HiringSemester.objects.semester\
                                          (current_semester.name, request.units)
    else:
        current_hiring_semesters = []

    if next_semester:
        next_hiring_semesters = HiringSemester.objects.semester\
                                             (next_semester.name, request.units)
    else:
        next_hiring_semesters = []

    return render(request, 'tacontracts/list_all_semesters.html', {
        'display_units':display_units,
        'semesters':semesters,
        'current_semester': current_semester,
        'current_hiring_semesters':current_hiring_semesters,
        'next_semester': next_semester,
        'next_hiring_semesters':next_hiring_semesters
    })
开发者ID:avacariu,项目名称:coursys,代码行数:43,代码来源:views.py

示例14: make_entry_field

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
    def make_entry_field(self, fieldsubmission=None):
        current = Semester.current()
        # always limit to 10 years on either side of today: that seems like a reasonable window
        queryset = Semester.objects \
            .filter(name__gte=current.offset_name(-30), name__lte=current.offset_name(30)) \
            .order_by('name')
        allowed = self.config.get('allowed_semesters', 'AL')
        if allowed == 'AL':
            initial = current.name
        elif allowed == 'LT':
            queryset = queryset.filter(name__lt=current.name).order_by('-name')
            initial = current.offset_name(-1)
        elif allowed == 'LE':
            queryset = queryset.filter(name__lte=current.name).order_by('-name')
            initial = current.name
        elif allowed == 'GT':
            queryset = queryset.filter(name__gt=current.name)
            initial = current.offset_name(1)
        elif allowed == 'GE':
            queryset = queryset.filter(name__gte=current.name)
            initial = current.name

        the_choices = [(s.name, s.label()) for s in queryset]

        widget = forms.Select
        if self.config.get('format', 'D') == 'R':
            widget = forms.RadioSelect

        required = self.config['required']
        if not required:
            initial = None

        c = forms.ChoiceField(required=required,
            label=self.config['label'],
            help_text=self.config['help_text'],
            choices=the_choices,
            widget=widget,
            initial=initial)

        if fieldsubmission:
            c.initial = fieldsubmission.data['info']

        if not self.config['required']:
            c.choices.insert(0, ('', '\u2014'))

        return c
开发者ID:sfu-fas,项目名称:coursys,代码行数:48,代码来源:other.py

示例15: update_statuses_to_current

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import current [as 别名]
def update_statuses_to_current():
    """
    Update the denormalized grad status fields to reflect the current time (and catch statuses that were entered in the
    future).

    Doesn't really need to be run daily, but that's easier than catching the missed celery run on the first day of class.
    """
    this_sem = Semester.current()

    # grads who have a status or program that starts this semester
    status_student_ids = GradStatus.objects.filter(start=this_sem).order_by().values_list('student_id', flat=True)
    program_student_ids = GradProgramHistory.objects.filter(start_semester=this_sem).order_by().values_list('student_id', flat=True)
    student_ids = set(status_student_ids) | set(program_student_ids)

    students = set(GradStudent.objects.filter(id__in=student_ids).distinct())

    # make sure it is actually in the status fields
    for gs in students:
        gs.update_status_fields()
开发者ID:avacariu,项目名称:coursys,代码行数:21,代码来源:tasks.py


注:本文中的coredata.models.Semester.current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。