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


Python models.Semester类代码示例

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


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

示例1: create_fake_semester

def create_fake_semester(strm):
    """
    Create a close-enough Semester object for testing
    """
    strm = str(strm)
    if Semester.objects.filter(name=strm):
        return
    s = Semester(name=strm)
    yr = int(strm[0:3]) + 1900
    if strm[3] == '1':
        mo = 1
    elif strm[3] == '4':
        mo = 5
    elif strm[3] == '7':
        mo = 9

    s.start = datetime.date(yr,mo,5)
    s.end = datetime.date(yr,mo+3,1)
    s.save()

    sw = SemesterWeek(semester=s, week=1)
    mon = s.start
    while mon.weekday() != 0:
        mon -= datetime.timedelta(days=1)
    sw.monday = mon
    sw.save()

    return s
开发者ID:avacariu,项目名称:coursys,代码行数:28,代码来源:testing.py

示例2: get_or_create_semester

def get_or_create_semester(strm):
    if not (isinstance(strm, basestring) and strm.isdigit() and len(strm)==4):
        raise ValueError, "Bad strm: " + repr(strm)
    oldsem = Semester.objects.filter(name=strm)
    if oldsem:
        return oldsem[0]

    db = SIMSConn()
    db.execute("SELECT strm, term_begin_dt, term_end_dt FROM ps_term_tbl WHERE strm=%s", (strm,))
    row = db.fetchone()
    if row is None:
        raise ValueError, "Not Found: %r" % (strm)
    strm, st, en = row
    
    # create Semester object
    st = datetime.datetime.strptime(st, "%Y-%m-%d").date()
    en = datetime.datetime.strptime(en, "%Y-%m-%d").date()
    sem = Semester(name=strm, start=st, end=en)
    sem.save()
    
    # also create SemesterWeek object for the first week
    first_monday = st
    while first_monday.weekday() != 0:
        first_monday += datetime.timedelta(days=1)    
    wk = SemesterWeek(semester=sem, week=1, monday=first_monday)
    wk.save()
    
    return sem
开发者ID:avacariu,项目名称:coursys,代码行数:28,代码来源:queries.py

示例3: __init__

    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,代码行数:9,代码来源:forms.py

示例4: run

    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,代码行数:51,代码来源:gender_diversity_accept_vs_enroll.py

示例5: run

 def run(self):
     sems = Semester.objects.filter(name__gte='1001', name__lte=Semester.next_starting().name)
     u = Unit.objects.get(label='ENSC')
     courses = CourseOffering.objects.prefetch_related('meeting_time').filter(semester__in=sems, owner=u,
                                                                              graded=True).exclude(
         flags=CourseOffering.flags.combined).exclude(subject='DDP').order_by('semester', 'subject', 'number')
     course_history = Table()
     course_history.append_column('Semester')
     course_history.append_column('Course')
     course_history.append_column('Instructor')
     course_history.append_column('Enrolment')
     course_history.append_column('Campus')
     course_history.append_column('Joint With')
     course_history.append_column('Lecture Times')
     course_history.append_column('Instructor(s) Rank(s)')
     for course in courses:
         semester = course.semester.label()
         label = course.name()
         instr = course.instructors_printing_str()
         enrl = '%i/%i' % (course.enrl_tot, course.enrl_cap)
         if course.campus in CAMPUSES_SHORT:
             campus = CAMPUSES_SHORT[course.campus]
         else:
             campus = 'Unknown'
         if course.config.get('joint_with'):
             joint = str(', '.join(course.config.get('joint_with')))
         else:
             joint = ''
         meeting_times = ''
         mt = [t for t in course.meeting_time.all() if t.meeting_type == 'LEC']
         if mt:
             meeting_times = ', '.join(str("%s %s-%s" % (WEEKDAYS[t.weekday], t.start_time, t.end_time)) for t in mt)
         ranks = "; ".join(CareerEvent.ranks_as_of_semester(p.id, course.semester) for p in course.instructors())
         course_history.append_row([semester, label, instr, enrl, campus, joint, meeting_times, ranks])
     self.artifacts.append(course_history)
开发者ID:sfu-fas,项目名称:coursys,代码行数:35,代码来源:ensc_course_history.py

示例6: manage_promises

def manage_promises(request, grad_slug):
    grad = get_object_or_404(GradStudent, slug = grad_slug)
    promises = Promise.objects.filter(student=grad).order_by('start_semester__name')
    
    if request.method == 'POST':
        form = PromiseForm(request.POST)
        if form.is_valid():
            try:
                promise = promises.get(end_semester=form.cleaned_data['end_semester'], removed=False)
            except Promise.DoesNotExist:
                promise = None

            if promise != None:
                form._errors['end_semester'] = ErrorList([u"A Promise for this semester already exists."])
            else:
                promise = form.save(commit=False)
                promise.student = grad
                promise.save()
                messages.success(request, "Promise for %s sucessfully saved." % (grad))
                l = LogEntry(userid=request.user.username, 
                  description="added promise of $%f for %s" % (promise.amount, grad.slug),
                  related_object=promise )
                l.save()
                
                return HttpResponseRedirect(reverse('grad.views.manage_promises', kwargs={'grad_slug':grad.slug}))
    else:
        form = PromiseForm(initial={'student':grad, 'start_semester':Semester.get_semester(), 'end_semester':Semester.get_semester(), 'amount':'0.00'})
    
    context = {
                'grad':grad,
                'form': form,
                'promises': promises,
              }
    return render(request, 'grad/manage_promises.html', context)
开发者ID:avacariu,项目名称:coursys,代码行数:34,代码来源:manage_promises.py

示例7: make_entry_field

    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,代码行数:34,代码来源:other.py

示例8: create_reminder_messages

    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,代码行数:35,代码来源:models.py

示例9: manage_program

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,代码行数:35,代码来源:manage_program.py

示例10: XXX_import_applic

def XXX_import_applic(request):
    unit_choices = [(u.id, u.name) for u in request.units]
    semester_choices = [(s.id, s.label()) for s in Semester.objects.filter()]
    if request.method == 'POST':
        form = UploadApplicantsForm(data=request.POST, files=request.FILES)
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices
        if form.is_valid():
            data = form.cleaned_data['csvfile'].read()
            unit_id = form.cleaned_data['unit']
            semester_id = form.cleaned_data['semester']
            user = Person.objects.get(userid=request.user.username)
            if settings.USE_CELERY:
                from grad.tasks import process_pcs_task
                process_pcs_task.delay(data, unit_id, semester_id, user)
                messages.success(request, "Importing applicant data. You will receive an email with the results in a few minutes.")
            else:
                from grad.forms import process_pcs_export
                res = process_pcs_export(data, unit_id, semester_id, user)
                messages.success(request, "Imported applicant data.")
                return HttpResponse('<pre>'+res+'</pre>')       

            return HttpResponseRedirect(reverse(index))
    else:
        next_sem = Semester.next_starting()
        form = UploadApplicantsForm(initial={'semester': next_sem.id})
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices

    context = {
               'form': form,
               }
    return render(request, 'grad/import_applic.html', context)
开发者ID:avacariu,项目名称:coursys,代码行数:33,代码来源:import_applic.py

示例11: run

    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,代码行数:27,代码来源:fas_international.py

示例12: run

    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,代码行数:34,代码来源:bad_gpas.py

示例13: manage_otherfunding

def manage_otherfunding(request, grad_slug):
    grad = get_object_or_404(GradStudent, slug = grad_slug)
    otherfunding = OtherFunding.objects.filter(student=grad).order_by('semester__name')
    
    if request.method == 'POST':
        form = OtherFundingForm(request.POST)
        if form.is_valid():
            fund = form.save(commit=False)
            fund.student = grad
            fund.save()
            messages.success(request, "Other funding for %s sucessfully saved." % (grad))
            l = LogEntry(userid=request.user.username, 
              description="added other funding \"%s\" for %s" % (fund.description, grad.slug),
              related_object=fund )
            l.save()

            
            return HttpResponseRedirect(reverse('grad.views.manage_otherfunding', kwargs={'grad_slug':grad.slug}))
    else:
        form = OtherFundingForm(initial={'student':grad, 'semester':Semester.get_semester(), 'amount':'0.00'})
    
    context = {
                'grad':grad,
                'form': form,
                'otherfunding': otherfunding,
              }
    return render(request, 'grad/manage_otherfunding.html', context)
开发者ID:avacariu,项目名称:coursys,代码行数:27,代码来源:manage_otherfunding.py

示例14: manage_requirements

def manage_requirements(request, grad_slug):
    grad = get_object_or_404(GradStudent, slug=grad_slug, program__unit__in=request.units)    
    
    # find completed/missing requirements
    completed_req = CompletedRequirement.objects.filter(student=grad)
    completed_gradreq_id = [cr.requirement_id for cr in completed_req if cr.removed==False]
    req = GradRequirement.objects.filter(program=grad.program, hidden=False)
    missing_req = req.exclude(id__in=completed_gradreq_id)
    req_choices = [(u'', u'\u2014')] + [(r.id, r.description) for r in missing_req]
    
    if request.method == 'POST':
        form = CompletedRequirementForm(request.POST)
        form.fields['requirement'].choices = req_choices
        if form.is_valid():
            req = form.save(commit=False)
            req.student = grad
            req.save()
            messages.success(request, "Completed requirement for %s sucessfully saved." % (grad))
            l = LogEntry(userid=request.user.username, 
              description="added completed requirement of %s for %s" % (req.requirement.description, grad.slug),
              related_object=req )
            l.save()
            
            return HttpResponseRedirect(reverse('grad.views.manage_requirements', kwargs={'grad_slug':grad.slug}))
    else:
        form = CompletedRequirementForm(initial={'student':grad, 'semester':Semester.get_semester()})
        form.fields['requirement'].choices = req_choices
    
    context = {
                'grad':grad,
                'form': form,
                'completed_req': completed_req,
                'missing_req': missing_req,
              }
    return render(request, 'grad/manage_requirements.html', context)
开发者ID:avacariu,项目名称:coursys,代码行数:35,代码来源:manage_requirements.py

示例15: manage_financialcomments

def manage_financialcomments(request, grad_slug):
    grad = get_object_or_404(GradStudent, slug = grad_slug)
    financial_comments = FinancialComment.objects.filter(student=grad, removed=False).order_by('semester__name')
    
    if request.method == 'POST':
        form = FinancialCommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.student = grad
            comment.created_by = request.user.username
            comment.save()
            messages.success(request, "Financial Comment for %s sucessfully saved." % (grad))
            l = LogEntry(userid=request.user.username, 
              description="added financial comment \"%s\" for %s" % (str(comment), grad.slug),
              related_object=comment )
            l.save()
            
            return HttpResponseRedirect(reverse('grad:manage_financialcomments', kwargs={'grad_slug':grad.slug}))
    else:
        form = FinancialCommentForm(initial={
                'student':grad, 
                'semester':Semester.get_semester(), 
                'created_by':request.user.username })
    
    context = {
                'grad':grad,
                'form': form,
                'financial_comments': financial_comments,
              }
    return render(request, 'grad/manage_financialcomments.html', context)
开发者ID:sfu-fas,项目名称:coursys,代码行数:30,代码来源:manage_financialcomments.py


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