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


Python Semester.get_semester方法代码示例

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


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

示例1: manage_promises

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
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,代码行数:36,代码来源:manage_promises.py

示例2: manage_otherfunding

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
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,代码行数:29,代码来源:manage_otherfunding.py

示例3: manage_financialcomments

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
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,代码行数:32,代码来源:manage_financialcomments.py

示例4: manage_requirements

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
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,代码行数:37,代码来源:manage_requirements.py

示例5: create_for_unit

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
 def create_for_unit(cls, unit):
     """
     Populate PlanningCourse objects for this unit, with any Course this unit has offered
     in the last two years.
     """
     old_sem = Semester.get_semester(datetime.date.today()-datetime.timedelta(days=365*2))
     offerings = CourseOffering.objects.filter(owner=unit, semester__name__gte=old_sem.name)
     existing = set((pc.subject, pc.number) for pc in PlanningCourse.objects.filter(owner=unit))
     for crs in set(c.course for c in offerings.select_related('course')):
         if (crs.subject, crs.number) not in existing:
             # found a missing PlanningCourse: add it.
             pc = PlanningCourse(subject=crs.subject, number=crs.number, title=crs.title, owner=unit)
             pc.save()
开发者ID:avacariu,项目名称:coursys,代码行数:15,代码来源:models.py

示例6: populate_from_history

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
 def populate_from_history(cls, person, years=2):
     """
     Create TeachingCapability objects for any courses this person has
     taught in recent years.
     """
     old_sem = Semester.get_semester(datetime.date.today()-datetime.timedelta(days=365*years))
     members = Member.objects.filter(person=person, role='INST', offering__semester__name__gte=old_sem.name)
     courses = set(m.offering.course for m in members.select_related('offering__course'))
     existing = set(tc.course_id for tc in TeachingCapability.objects.filter(instructor=person))
     for crs in courses:
         if crs.id not in existing:
             # found a course that has been taught but not listed as capable
             tc = TeachingCapability(instructor=person, course=crs)
             tc.save()
开发者ID:avacariu,项目名称:coursys,代码行数:16,代码来源:models.py

示例7: view_intentions

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
def view_intentions(request):
    semester = Semester.get_semester()
    semester_list = [semester]
    if (semester.next_semester()):
        semester = semester.next_semester()
        semester_list.append(semester)
    if (semester.next_semester()):
        semester = semester.next_semester()
        semester_list.append(semester)

    intentions = []

    for s in semester_list:
        intentions.append(TeachingIntention.objects.filter(semester=s))

    semesters = Semester.objects.all()

    plans = zip(semester_list, intentions)
    return render_to_response("planning/view_intentions.html", {'plans': plans, 'semesters': semesters}, context_instance=RequestContext(request))
开发者ID:avacariu,项目名称:coursys,代码行数:21,代码来源:view_intentions.py

示例8: view_courses

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
def view_courses(request):
    """
    View to view all courses
    """
    if 'coursesearch' in request.GET and 'course' in request.GET \
            and request.GET['course'] and request.GET['course'].isdigit():
        # handle the search for other courses
        offering = get_object_or_404(Course, id=request.GET['course'])
        return HttpResponseRedirect(reverse('advisornotes.views.view_course_notes', kwargs={'unit_course_slug': offering.slug}))

    # all courses where a recent offering was owned by relevant units
    subunits = Unit.sub_unit_ids(request.units)
    old_sem = Semester.get_semester(datetime.date.today() - datetime.timedelta(days=365 * 2))
    offerings = CourseOffering.objects.filter(owner__in=subunits, semester__name__gte=old_sem.name) \
                                      .values('course').order_by().distinct()

    # all courses where there are notes from relevant units
    notes = ArtifactNote.objects.filter(unit__in=request.units).exclude(course__isnull=True) \
                                .values('course').order_by().distinct()
    
    with_note_ids = set(n['course'] for n in notes)
    course_ids = set(o['course'] for o in offerings)
    course_ids |= with_note_ids

    # all current CourseOfferings with notes: interested in those Courses too
    offering_notes = ArtifactNote.objects.filter(unit__in=request.units, course_offering__semester__name__gte=old_sem.name) \
                                        .values('course_offering__course').order_by().distinct()
    offering_note_ids = set(n['course_offering__course'] for n in offering_notes)
    with_note_ids |= offering_note_ids
    course_ids |= offering_note_ids
    
    courses = Course.objects.filter(id__in=course_ids)
    form = CourseSearchForm()

    return render(request,
        'advisornotes/view_courses.html',
        {'courses': courses, 'with_note_ids': with_note_ids, 'form': form}
    )
开发者ID:avacariu,项目名称:coursys,代码行数:40,代码来源:views.py

示例9: view_course_offerings

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
def view_course_offerings(request, semester=None):
    """
    View to view all courses
    """
    if semester:
        semester = get_object_or_404(Semester, name=semester)
        semesters = None
    else:
        semester = Semester.get_semester(date=datetime.date.today() + datetime.timedelta(days=60))
        semesters = Semester.objects.filter(start__lte=datetime.date.today() + datetime.timedelta(days=365)).order_by('-end')[:6]
    
    if 'offeringsearch' in request.GET and request.GET['offeringsearch'] and request.GET['offeringsearch'].isdigit():
        # handle the search for other offerings
        offering = get_object_or_404(CourseOffering, id=request.GET['offering'])
        return HttpResponseRedirect(reverse('advisornotes.views.view_offering_notes', kwargs={'course_slug': offering.slug}))

    subunits = Unit.sub_unit_ids(request.units)
    offerings = CourseOffering.objects.filter(owner__in=subunits, semester=semester)
    form = OfferingSearchForm()
    return render(request,
        'advisornotes/view_course_offerings.html',
        {'offerings': offerings, 'semester': semester, 'semesters': semesters, 'form': form}
    )
开发者ID:avacariu,项目名称:coursys,代码行数:25,代码来源:views.py

示例10: get_timeline

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
def get_timeline(emplid, verbose=False):
    """
        For the student with emplid, 
        Get a list of programs, start and end semester
        [{'program_code':'CPPHD', 'start':1111, 'end':1137, 'on leave':['1121', '1124']) ]
        
        * will include an 'adm_appl_nbr' if an admission record can be found with that program
    """
    programs = get_student_programs(emplid) 
    
    if verbose:
        print "----------"
        for program in programs:
            print program

    # calculate start and end date for programs
    prog_dict = {}
    for program_code, strm, unt_taken in programs: 
        if program_code not in prog_dict:
            prog_dict[program_code] = {'start':'9999', 'end':'1111', 'not_on_leave':[]}
        if int(strm) < int(prog_dict[program_code]['start']):
            prog_dict[program_code]['start'] = strm
        elif int(strm) > int(prog_dict[program_code]['end']):
            prog_dict[program_code]['end'] = strm
        if float(unt_taken) >= 0.1: 
            prog_dict[program_code]['not_on_leave'].append(strm)

    if verbose:
        print "----------"
        for key, val in prog_dict.iteritems():
            print key, val

    # calculate on-leave semesters
    on_leave_semesters = [strm for strm, reason in get_on_leave_semesters(emplid)]

    try:
        for program_code, program_object in prog_dict.iteritems():
            prog_dict[program_code]['on_leave'] = []
            semesters = Semester.range( program_object['start'], program_object['end'] )
            for semester in semesters:
                if (int(semester) <= int(Semester.current().name) and
                    (semester in on_leave_semesters or 
                    semester not in program_object['not_on_leave'])):
                    prog_dict[program_code]['on_leave'].append(semester)
            prog_dict[program_code]['on_leave'].sort()
    except Semester.DoesNotExist:
        print "Semester out of range", program_object['start'], program_object['end']
        return {}

    # put the programs in a list, sorted by start date
    programs = []
    for program_code, program_object in prog_dict.iteritems():
        del program_object['not_on_leave']
        program_object['program_code'] = program_code
        programs.append(program_object) 
    programs = sorted( programs, key= lambda x : int(x['start']) )

    if verbose: 
        print "----------"
        for program in programs:
            print program

    # how did it end?
    for program in programs:
        hdie = get_end_of_degree(emplid, program['program_code'], program['start'])
        if hdie: 
            program['how_did_it_end'] = { 'code':hdie[0], 
                                          'reason':hdie[1],
                                          'date':hdie[2],
                                          'semester': str(Semester.get_semester(hdie[2]).name) } 
            if int(program['how_did_it_end']['semester']) < int(program['end']):
                program['end'] = program['how_did_it_end']['semester']
        
    # for every previous program, create an end-date and cut off all on-leave semesters
    # at the beginning of the next program in the list. 

    for program, next_program in pairs(programs):
        if int(program['end']) > int(next_program['start']):
            program['end'] = next_program['start'] 
        for on_leave in program['on_leave']:
            if int(on_leave) > int(program['end']):
                program['on_leave'].remove(on_leave)
    
    # group the on-leave semesters
    for program in programs:
        on_leave = []
        if len(program['on_leave']) > 0:
            last_group = (program['on_leave'][0], program['on_leave'][0]) 
            last_group_pushed = False
            for semester in program['on_leave']:
                if semester in last_group or int(semester) > int(program['end']):
                    continue
                if semester == lazy_next_semester(last_group[1]):
                    last_group = ( last_group[0], semester )
                    last_group_pushed = False
                else: 
                    on_leave.append(last_group)
                    last_group = (semester, semester) 
                    last_group_pushed = True
            if not last_group_pushed: 
#.........这里部分代码省略.........
开发者ID:avacariu,项目名称:coursys,代码行数:103,代码来源:queries.py

示例11: get_semester

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import get_semester [as 别名]
 def get_semester(date):
     semester_date = max(date, datetime.date(date.year, date.month, 5))
     return Semester.get_semester(semester_date)
开发者ID:avacariu,项目名称:coursys,代码行数:5,代码来源:teaching.py


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