本文整理汇总了Python中coredata.models.Unit.save方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.save方法的具体用法?Python Unit.save怎么用?Python Unit.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coredata.models.Unit
的用法示例。
在下文中一共展示了Unit.save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_units
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def create_units():
univ, _ = Unit.objects.get_or_create(label='UNIV', name='Simon Fraser University')
fas = Unit(label='FAS', name='Faculty of Applied Sciences', parent=univ).save()
ensc = Unit(label='ENSC', name='School of Engineering Science', parent=fas, acad_org='ENG SCI').save()
cmpt = Unit(label='CMPT', name='School of Computing Science', parent=fas, acad_org='COMP SCI')
cmpt.set_address(['9971 Applied Sciences Building', '8888 University Drive, Burnaby, BC', 'Canada V5A 1S6'])
cmpt.set_email('[email protected]')
cmpt.set_web('http://www.cs.sfu.ca/')
cmpt.set_tel('778-782-4277')
cmpt.set_fax('778-782-3045')
cmpt.set_informal_name('Computing Science')
cmpt.config['sessional_pay'] = 10000
cmpt.set_deptid('12345')
cmpt.save()
示例2: create_true_core
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def create_true_core():
"""
Just enough data to bootstrap a minimal environment.
"""
import_semester_info(dry_run=False, verbose=False, long_long_ago=True, bootstrap=True)
p = find_person('ggbaker')
p.emplid = '200000100'
p.save()
u = Unit(label='UNIV', name='Simon Fraser University')
u.save()
r = Role(person=p, role='SYSA', unit=u)
r.save()
return itertools.chain(
Semester.objects.filter(name__gt=SEMESTER_CUTOFF),
Person.objects.filter(userid='ggbaker'),
Unit.objects.all(),
Role.objects.all(),
)
示例3: get_unit
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def get_unit(acad_org, create=False):
"""
Get the corresponding Unit
"""
# there are some inconsistent acad_org values: normalize.
if acad_org == 'GERON':
acad_org = 'GERONTOL'
elif acad_org == 'GEOG':
acad_org = 'GEOGRAPH'
elif acad_org == 'BUS':
acad_org = 'BUS ADMIN'
elif acad_org == 'HUM':
acad_org = 'HUMANITIES'
elif acad_org == 'EVSC':
acad_org = 'ENVIRO SCI'
try:
unit = Unit.objects.get(acad_org=acad_org)
except Unit.DoesNotExist:
db = SIMSConn()
db.execute("SELECT descrformal FROM ps_acad_org_tbl "
"WHERE eff_status='A' and acad_org=%s", (acad_org,))
name, = db.fetchone()
if acad_org == 'COMP SCI': # for test/demo imports
label = 'CMPT'
elif acad_org == 'ENG SCI': # for test/demo imports
label = 'ENSC'
elif acad_org == 'ENVIRONMEN': # for test/demo imports
label = 'FENV'
elif acad_org == 'DEAN GRAD': # for test/demo imports
label = 'GRAD'
else:
label = acad_org[:4].strip()
if create:
unit = Unit(acad_org=acad_org, label=label, name=name, parent=None)
unit.save()
else:
raise KeyError("Unknown unit: acad_org=%s, label~=%s, name~=%s." % (acad_org, label, name))
return unit
示例4: create_test_offering
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def create_test_offering():
"""
Create a CourseOffering (and related stuff) that can be used in tests with no fixtures
"""
s = create_fake_semester('1144')
u = Unit(label='BABL', name="Department of Babbling")
u.save()
o = CourseOffering(subject='BABL', number='123', section='F104', semester=s, component='LEC', owner=u,
title='Babbling for Baferad Ferzizzles', enrl_cap=100, enrl_tot=5, wait_tot=0)
o.save()
i = Person(first_name='Insley', last_name='Instructorberg', emplid=20000009, userid='instr')
i.save()
s = Person(first_name='Stanley', last_name='Studentson', emplid=20000010, userid='student')
s.save()
Member(offering=o, person=i, role='INST').save()
Member(offering=o, person=s, role='STUD').save()
return o
示例5: create_units
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def create_units():
univ = Unit.objects.get(slug='univ')
fas = Unit(label='FAS', name='Faculty of Applied Sciences', parent=univ)
fas.save()
ensc = Unit(label='ENSC', name='School of Engineering Science', parent=fas, acad_org='ENG SCI')
ensc.save()
mse = Unit(label='MSE', name='School of Mechatronic Systems Engineering', parent=fas, acad_org='MECH SYS')
mse.save()
cmpt = Unit(label='CMPT', name='School of Computing Science', parent=fas, acad_org='COMP SCI')
cmpt.set_address(['9971 Applied Sciences Building', '8888 University Drive, Burnaby, BC', 'Canada V5A 1S6'])
cmpt.set_email('[email protected]')
cmpt.set_web('http://www.cs.sfu.ca/')
cmpt.set_tel('778-782-4277')
cmpt.set_fax('778-782-3045')
cmpt.set_informal_name('Computing Science')
cmpt.set_deptid('12345')
cmpt.save()
示例6: create_unit
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def create_unit():
unit = Unit(label="UNIV", name="Testington University")
unit.save()
return unit
示例7: setUp
# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import save [as 别名]
def setUp(self):
"""
Build a TACategory, TAContract, and two TACourses
"""
unit = Unit(label="TEST", name="A Fake Unit for Testing")
unit.save()
person = Person(emplid="300000000",
userid="testy",
first_name="Testy",
last_name="Testerson")
person.save()
semester = Semester(name="1147",
start=datetime.date.today(),
end=datetime.date.today())
semester.save()
course1 = Course(subject="TEST",
number="100",
title="Intro to Testing")
course1.save()
course2 = Course(subject="TEST",
number="200",
title="Advanced Testing")
course2.save()
courseoffering1 = CourseOffering(subject="TEST",
number="100",
section="D100",
semester=semester,
component="LEC",
owner=unit,
title="Intro to Testing",
campus="BRNBY",
enrl_cap=100,
enrl_tot=100,
wait_tot=50,
course=course1)
courseoffering1.save()
courseoffering2 = CourseOffering(subject="TEST",
number="200",
section="D200",
semester=semester,
component="LEC",
owner=unit,
title="Advanced Testing",
campus="BRNBY",
enrl_cap=100,
enrl_tot=100,
wait_tot=50,
course=course2)
courseoffering2.save()
account = Account(unit=unit,
account_number=1337,
position_number=5,
title="A Fake Account for Testing")
account.save()
four_weeks_later = datetime.date.today() + datetime.timedelta(days=28)
hiring_semester = HiringSemester(semester=semester,
unit=unit,
deadline_for_acceptance=datetime.date.today(),
pay_start=datetime.date.today(),
pay_end=four_weeks_later,
payperiods=2.5)
hiring_semester.save()
category = TACategory(account=account,
hiring_semester=hiring_semester,
code="TST",
title="Test Contract Category",
hours_per_bu=decimal.Decimal("42"),
holiday_hours_per_bu=decimal.Decimal("1.1"),
pay_per_bu=decimal.Decimal("100.00"),
scholarship_per_bu=decimal.Decimal("25.00"),
bu_lab_bonus=decimal.Decimal("0.17"))
category.save()
contract = TAContract(category=category,
person=person,
status="NEW",
sin="123456789",
deadline_for_acceptance=datetime.date.today(),
pay_start=datetime.date.today(),
pay_end=datetime.date.today() + datetime.timedelta(days=10),
payperiods=2.5,
appointment="INIT",
conditional_appointment=True,
created_by="classam",
tssu_appointment=True)
contract.save()
tacourse = TACourse(course=courseoffering1,
contract=contract,
bu=decimal.Decimal('3.0'),
labtut=True)
tacourse.save()
tacourse2 = TACourse(course=courseoffering2,
contract=contract,
bu=decimal.Decimal('2.0'),
labtut=False)
tacourse2.save()