本文整理汇总了Python中coredata.models.Semester.next_starting方法的典型用法代码示例。如果您正苦于以下问题:Python Semester.next_starting方法的具体用法?Python Semester.next_starting怎么用?Python Semester.next_starting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coredata.models.Semester
的用法示例。
在下文中一共展示了Semester.next_starting方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def new(request):
scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices =_appointment_defaults(request.units)
if request.method == 'POST':
data = request.POST.copy()
if data['pay_frequency'] == 'L':
# force legal values into the non-submitted (and don't-care) fields for lump sum pay
data['biweekly_pay'] = 1
data['hourly_pay'] = 1
data['hours'] = 1
data['pay_periods'] = 1
raform = RAForm(data)
raform.fields['hiring_faculty'].choices = hiring_faculty_choices
raform.fields['unit'].choices = unit_choices
raform.fields['project'].choices = project_choices
raform.fields['account'].choices = account_choices
if raform.is_valid():
userid = raform.cleaned_data['person'].userid_or_emplid()
appointment = raform.save(commit=False)
appointment.set_use_hourly(raform.cleaned_data['use_hourly'])
appointment.save()
messages.success(request, 'Created RA Appointment for ' + appointment.person.name())
return HttpResponseRedirect(reverse(student_appointments, kwargs=({'userid': userid})))
else:
semester = Semester.next_starting()
semesterconfig = SemesterConfig.get_config(request.units, semester)
raform = RAForm(initial={'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 })
raform.fields['scholarship'].choices = scholarship_choices
raform.fields['hiring_faculty'].choices = hiring_faculty_choices
raform.fields['unit'].choices = unit_choices
raform.fields['project'].choices = project_choices
raform.fields['account'].choices = account_choices
return render(request, 'ra/new.html', { 'raform': raform })
示例2: XXX_import_applic
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
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)
示例3: run
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
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)
示例4: all_promises
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def all_promises(request, semester_name=None):
if semester_name is None:
semester = Semester.next_starting()
else:
semester = get_object_or_404(Semester, name=semester_name)
promises = Promise.objects.filter(end_semester=semester,
student__program__unit__in=request.units)
context = {'promises': promises, 'semester': semester}
return render(request, 'grad/all_promises.html', context)
示例5: funding_report
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def funding_report(request, semester_name=None):
if semester_name is None:
semester = Semester.next_starting()
else:
semester = get_object_or_404(Semester, name=semester_name)
programs = GradProgram.objects.filter(unit__in=request.units, hidden=False).order_by('label')
programs = _build_funding_totals(semester, programs, request.units)
these_units = ', '.join(u.name for u in request.units)
context = {'semester': semester, 'programs': programs, 'these_units': these_units}
return render(request, 'grad/funding_report.html', context)
示例6: reappoint
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def reappoint(request, ra_slug):
appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False)
semester = Semester.next_starting()
semesterconfig = SemesterConfig.get_config(request.units, semester)
raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'reappointment': True,
'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80,
'use_hourly': appointment.use_hourly() })
raform.fields['hiring_faculty'].choices = possible_supervisors(request.units)
scholarship_choices = [("", "---------")]
for s in Scholarship.objects.filter(student__person__emplid = appointment.person.emplid):
scholarship_choices.append((s.pk, s.scholarship_type.unit.label + ": " + s.scholarship_type.name + " (" + s.start_semester.name + " to " + s.end_semester.name + ")"))
raform.fields['scholarship'].choices = scholarship_choices
raform.fields['unit'].choices = [(u.id, u.name) for u in request.units]
raform.fields['project'].choices = [(p.id, unicode(p.project_number)) for p in Project.objects.filter(unit__in=request.units)]
raform.fields['account'].choices = [(a.id, u'%s (%s)' % (a.account_number, a.title)) for a in Account.objects.filter(unit__in=request.units)]
return render(request, 'ra/new.html', { 'raform': raform, 'appointment': appointment })
示例7: reappoint
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def reappoint(request, ra_slug):
appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False, unit__in=request.units)
semester = Semester.next_starting()
semesterconfig = SemesterConfig.get_config(request.units, semester)
raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'reappointment': True,
'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80,
'use_hourly': appointment.use_hourly() })
scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices, program_choices = \
_appointment_defaults(request.units, emplid=appointment.person.emplid)
raform.fields['hiring_faculty'].choices = hiring_faculty_choices
raform.fields['scholarship'].choices = scholarship_choices
raform.fields['unit'].choices = unit_choices
raform.fields['project'].choices = project_choices
raform.fields['account'].choices = account_choices
raform.fields['program'].choices = program_choices
return render(request, 'ra/new.html', { 'raform': raform, 'appointment': appointment })
示例8: testApplication
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def testApplication(self):
p = Person.objects.get(emplid=210012345)
# Create three visas, one that should be expired, one that will soon, and one that is valid.
v1 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=date(2000,01,01))
v2 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=date(2099,01,01))
next_semester = Semester.next_starting()
almost_expired_date = next_semester.end - timedelta(days=5)
v3 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=almost_expired_date)
self.assertEqual(v1.is_valid(), False)
self.assertEqual(v1.is_expired(), True)
self.assertEqual(v1.is_almost_expired(), False)
self.assertEqual(v2.is_valid(), True)
self.assertEqual(v2.is_expired(), False)
self.assertEqual(v2.is_almost_expired(), False)
self.assertEqual(v3.is_valid(), True)
self.assertEqual(v3.is_expired(), False)
self.assertEqual(v3.is_almost_expired(), True)
示例9: new_student
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def new_student(request, userid):
person = get_object_or_404(Person, find_userid_or_emplid(userid))
semester = Semester.next_starting()
semesterconfig = SemesterConfig.get_config(request.units, semester)
student = get_object_or_404(Person, find_userid_or_emplid(userid))
initial = {'person': student.emplid, 'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 }
scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices =_appointment_defaults(request.units, emplid=student.emplid)
gss = GradStudent.objects.filter(person=student)
if gss:
gradstudent = gss[0]
initial['sin'] = gradstudent.person.sin()
raform = RAForm(initial=initial)
raform.fields['person'] = forms.CharField(widget=forms.HiddenInput())
raform.fields['scholarship'].choices = scholarship_choices
raform.fields['hiring_faculty'].choices = hiring_faculty_choices
raform.fields['unit'].choices = unit_choices
raform.fields['project'].choices = project_choices
raform.fields['account'].choices = account_choices
return render(request, 'ra/new.html', { 'raform': raform, 'person': person })
示例10: semester_config
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def semester_config(request, semester_name=None):
if semester_name:
semester = get_object_or_404(Semester, name=semester_name)
else:
semester = Semester.next_starting()
unit_choices = [(u.id, u.name) for u in request.units]
if request.method == 'POST':
form = SemesterConfigForm(request.POST)
form.fields['unit'].choices = unit_choices
if form.is_valid():
config = SemesterConfig.get_config(units=[form.cleaned_data['unit']], semester=semester)
config.set_start_date(form.cleaned_data['start_date'])
config.set_end_date(form.cleaned_data['end_date'])
config.save()
messages.success(request, 'Updated semester configuration for %s.' % (semester.name))
return HttpResponseRedirect(reverse('ra.views.search'))
else:
config = SemesterConfig.get_config(units=request.units, semester=semester)
form = SemesterConfigForm(initial={'start_date': config.start_date(), 'end_date': config.end_date()})
form.fields['unit'].choices = unit_choices
return render(request, 'ra/semester_config.html', {'semester': semester, 'form': form})
示例11: download_promises
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def download_promises(request, semester_name=None):
if semester_name is None:
semester = Semester.next_starting()
else:
semester = get_object_or_404(Semester, name=semester_name)
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'inline; filename="promises-%s-%s.csv"' % (semester.name,
datetime.now().strftime('%Y%m%d'))
writer = csv.writer(response)
writer.writerow(['Student', 'Program', 'Start Semester', 'Status', 'Promised', 'Received', 'Difference'])
promises = Promise.objects.filter(end_semester=semester,
student__program__unit__in=request.units)
for p in promises:
student = p.student.person.sortname()
program = p.student.program.label
start = p.student.start_semester.label()
status = p.student.get_current_status_display()
promised = p.amount
received = p.received()
difference = p.difference()
writer.writerow([student, program, start, status, promised, received, difference])
return response
示例12: is_almost_expired
# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import next_starting [as 别名]
def is_almost_expired(self):
next_semester = Semester.next_starting()
return (self.is_valid()) and (self.end_date is not None and self.end_date < next_semester.end)