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


Python AcademicTerm.save方法代码示例

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


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

示例1: get_previous_full_term

# 需要导入模块: from mig_main.models import AcademicTerm [as 别名]
# 或者: from mig_main.models.AcademicTerm import save [as 别名]
def get_previous_full_term(term):
    new_type = None
    new_year = 0;
    if term.semester_type.name=='Winter':
        new_year=term.year-1
        new_type = SemesterType.objects.get(name='Fall')
    else:
        new_year = term.year
        new_type = SemesterType.objects.get(name='Winter')
    if AcademicTerm.objects.filter(year=new_year,semester_type=new_type).exists():
        return AcademicTerm.objects.get(year=new_year,semester_type=new_type)
    else:
        a = AcademicTerm(year=new_year,semester_type=new_type)
        a.save()
        return a
开发者ID:pritpaul,项目名称:mig-website,代码行数:17,代码来源:utility.py

示例2: get_next_full_term

# 需要导入模块: from mig_main.models import AcademicTerm [as 别名]
# 或者: from mig_main.models.AcademicTerm import save [as 别名]
def get_next_full_term(term):
    new_type = None
    new_year = 0
    if term.semester_type.name == "Fall":
        new_year = term.year + 1
        new_type = SemesterType.objects.get(name="Winter")
    else:
        new_year = term.year
        new_type = SemesterType.objects.get(name="Fall")
    if AcademicTerm.objects.filter(year=new_year, semester_type=new_type).exists():
        return AcademicTerm.objects.get(year=new_year, semester_type=new_type)
    else:
        a = AcademicTerm(year=new_year, semester_type=new_type)
        a.save()
        return a
开发者ID:kylelady,项目名称:mig-website,代码行数:17,代码来源:utility.py

示例3: initializedb

# 需要导入模块: from mig_main.models import AcademicTerm [as 别名]
# 或者: from mig_main.models.AcademicTerm import save [as 别名]
def initializedb():

    #Governing Document types
    for doc in GOVERNING_DOC_TYPE:
        if len(GoverningDocumentType.objects.filter(name=doc["name"]))==0:
            d = GoverningDocumentType(name=doc['name'])
            d.save()
        else:
            print "Document Type: "+doc["name"]+" already exists."


    # Google Calendars.
    for calendar in GOOGLE_CALENDARS:
        if len(GoogleCalendar.objects.filter(name=calendar["name"]))==0:
            g = GoogleCalendar()
            g.name = calendar["name"]
            g.calendar_id = calendar["calendar_id"]
            g.save()
        else:
            print "Calendar: "+calendar["name"]+" already exists."
    # Semester Type
    for semester in SEMESTER_TYPES:
        if len(SemesterType.objects.filter(name=semester["name"]))==0:
            s = SemesterType(name = semester["name"])
            s.save()
        else:
            print "Semester: "+semester["name"]+" already exists."
    # Academic Terms
    for term_year in range(1998,date.today().year+2):
        for semester in SemesterType.objects.all():
        
            if len(AcademicTerm.objects.filter(year=term_year).filter(semester_type=semester))==0:
                a = AcademicTerm()
                a.year=term_year
                a.semester_type = semester
                a.save()
            else:
                print "AcademicTerm: "+semester.name+" "+str(term_year)+" already exists."

    if not CurrentTerm.objects.all().exists():
        c = CurrentTerm(current_term=AcademicTerm.objects.get(year=2014,semester_type__name='Winter'))
        c.save()
    #TBP Chapters
    for state in TBP_CHAPTERS:
        for chapter in state["chapters"]:
            if len(TBPChapter.objects.filter(state__exact=state["state"]).filter(letter__exact=chapter["letter"]))==0:
                c = TBPChapter()
                c.state = state["state"]
                c.letter = chapter["letter"]
                c.school = chapter["school"]
                c.save()
            else:
                print "Chapter "+state["state"]+'-'+chapter["letter"]+" already exists."
    
    # Officer Positions
    for position in OFFICER_POSITIONS:
        if len(OfficerPosition.objects.filter(name=position["name"]))==0:
            p = OfficerPosition()
            p.name=position["name"]
            p.description=position["description"]
            p.email=position["email"]
            p.save()
        else:
            print position["name"]+" already exisits."
            
    # Standing
    for standing in STANDINGS:
        if len(Standing.objects.filter(name=standing))==0:
            s=Standing(name=standing)
            s.save()
        else:
            print "Standing "+standing+" already exists."
            
    #Status
    for status in STATUSES:
        if len(Status.objects.filter(name=status))==0:
            s=Status(name=status)
            s.save()
        else:
            print "Status "+status+" already exists."
    #Shirt Size
    for size in SHIRT_SIZES:
        if len(ShirtSize.objects.filter(name=size["name"]))==0:
            s=ShirtSize(name=size["name"],acronym=size["acronym"])
            s.save()
        else:
            print "Size "+size["name"]+" already exists."
            
    #Majors
    for major in MAJORS:
        if len(Major.objects.filter(acronym=major["acronym"]))==0:
            m = Major(name=major["name"],acronym=major["acronym"])
            m.save()
            for standing in major["standing_type"]:
                m.standing_type.add(Standing.objects.get(name=standing))
            m.save()
        else:
            print "Major: "+major["acronym"]+" already exists."
    
    #Officer Teams
#.........这里部分代码省略.........
开发者ID:dadrian,项目名称:mig-website,代码行数:103,代码来源:initializeDB.py


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