示例#1
0
def all_soloists(request):
    curSeason = get_current_season()
    
    events = curSeason.event_set.all()

    #get all of the non-piece soloists
    s = [event.soloists.all() for event in events if event.soloists]
    #unpack
    s = [soloist for sub in s for soloist in sub]

    #get all of the pieces in events if there are any
    pieces = [event.pieces.all() for event in events if event.pieces]
    
    #unpack the subarrays
    pieces = [piece for subarray in pieces for piece in subarray]

    #get all of the soloists for pieces if there are any
    soloists = [piece.soloist.all() for piece in pieces if piece.soloist.all()]

    #unpack the subarrays again
    soloists = [soloist for subarray in soloists for soloist in subarray]

    #add event.soloists to piece.soloists
    soloists.extend(s)
    soloists.sort(reverse=True)
    
    return render_to_response('soloists.html', { 'soloists': soloists, 'season': curSeason })
示例#2
0
文件: views.py 项目: edwelker/orch
def get_season():
    season = cache.get('season')

    if season:
        return season

    season = get_current_season()

    cache.set('season', season, CACHE_TIME )
    return season