コード例 #1
0
ファイル: utils.py プロジェクト: alextricity25/djattendance
def create_term(season, year, start_date, end_date):
    """ Creates a new term after deactivating the previous term.  This function
    DOES NOT CHECK to see if the data you're passing in is good or not.
    MAKE THE PROPER CHECKS FIRST."""

    deactivate_previous_term()

    try:
        term = Term.objects.get(season=season, year=year)
        term.start = start_date
        term.end = end_date
        term.save()
    except Term.DoesNotExist:
        term = Term(current=currently_in_term(start_date, end_date),
                    season=season,
                    year=year,
                    start=start_date,
                    end=end_date)
        term.save()

    Term.set_current_term(term)
コード例 #2
0
def create_term(season, year, start_date, end_date):
    """ Creates a new term after deactivating the previous term.  This function
    DOES NOT CHECK to see if the data you're passing in is good or not.
    MAKE THE PROPER CHECKS FIRST."""

    # deactivate_previous_term()
    Trainee.objects.all().update(is_active=False, team=None, house=None)
    # TODO: also for workers

    try:
        term = Term.objects.get(season=season, year=year)
        term.start = start_date
        term.end = end_date
        term.save()
    except Term.DoesNotExist:
        term = Term(current=currently_in_term(start_date, end_date),
                    season=season,
                    year=year,
                    start=start_date,
                    end=end_date)
        term.save()

    Term.set_current_term(term)