Changeset 52158b1


Ignore:
Timestamp:
Oct 27, 2011 11:48:12 AM (3 years ago)
Author:
yomguy <yomguy@…>
Branches:
master, crem, crem2, dev, dev2, diadems, feature/breadcrumbs, feature/ts-0.5, feature/ts-0.5.4, feature/writecache, forma, generic, instru_search, lam, lam2, mapsv3, merge, nlivemulti, production, release/1.4.4, sabiod, security, server, social, storage, telecaster, test, video
Children:
ae04490
Parents:
fda0645
git-author:
yomguy <yomguy@…> (27/10/2011 11:48:12)
git-committer:
yomguy <yomguy@…> (27/10/2011 11:48:12)
Message:

fix sound_pub_items lists in index

Location:
telemeta
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • telemeta/templates/telemeta_default/index.html

    rfda0645 r52158b1  
    1515</div> 
    1616 
     17{% if sound_pub_item %} 
    1718<div id="module" class="module"> 
    1819    <h3><img src="{% url telemeta-images "module_playlist.png" %}" alt="playlist" style="vertical-align:middle" /> 
     
    2425    </ul> 
    2526</div> 
     27{% endif %} 
    2628 
    2729{% include "telemeta/inc/module_revisions.html" %} 
     
    3638</div> 
    3739 
     40{% if sound_pub_items %} 
    3841<div style="margin-top: 1ex;"> 
    3942<h1><img src="{% url telemeta-images "playlist_title.png" %}" alt="playlists" style="vertical-align:middle" /> 
    4043    {% trans "Musical selection" %}</h1> 
    4144<table style="font-size: 90%"><tr> 
    42 {% for item in sound_items %} 
    43 <td width="390"><a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>{% if item.alt_title %} ({{ item.alt_title }}){% endif %}<br /><span style="font-size: 90%">{{ item.location.fullnames|to_string }}</span><br /> 
     45{% for item in sound_pub_items %} 
     46<td width="390"><a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>{% if item.alt_title %} ({{ item.alt_title }}){% endif %}<br /><span style="font-size: 80%">{{ item.location.fullnames|to_string }}</span><br /> 
    4447<iframe width='376' height='215' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='/items/{{item.public_id }}/player/362x130/'></iframe></td> 
    4548{% endfor %} 
     
    4750</table> 
    4851</div> 
     52{% endif %} 
    4953 
    5054</div> 
  • telemeta/web/base.py

    rfda0645 r52158b1  
    176176        if not request.user.is_authenticated(): 
    177177            template = loader.get_template('telemeta/index.html') 
    178             ids = [id for id in MediaItem.objects.all().values_list('id', flat=True).order_by('?')[0:3]] 
    179             items = MediaItem.objects.enriched().filter(pk__in=ids) 
    180              
     178#            ids = [id for id in MediaItem.objects.all().values_list('id', flat=True).order_by('?')[0:3]] 
     179#            items = MediaItem.objects.enriched().filter(pk__in=ids) 
     180#             
    181181            sound_items = MediaItem.objects.sound() 
    182182            sound_pub_items = [] 
     
    186186                    sound_pub_items.append(item) 
    187187             
    188             sound_pub_item = sound_pub_items[0] 
    189188            random.shuffle(sound_pub_items) 
    190             if len(sound_pub_items) >= 2: 
    191                 sound_pub_items = sound_pub_items[0:2] 
    192              
     189            if len(sound_pub_items) != 0: 
     190                sound_pub_item = sound_pub_items[0] 
     191            else: 
     192                sound_pub_item = None 
     193            if len(sound_pub_items) == 2: 
     194                sound_pub_items = sound_pub_items[1] 
     195            if len(sound_pub_items) > 2: 
     196                sound_pub_items = sound_pub_items[1:3] 
     197                 
    193198            revisions = get_revisions(4) 
    194199            context = RequestContext(request, { 
    195200                        'page_content': pages.get_page_content(request, 'home', ignore_slash_issue=True), 
    196                         'items': items, 'revisions': revisions,  'sound_items': sound_pub_items,  
     201                        'revisions': revisions,  'sound_pub_items': sound_pub_items,  
    197202                        'sound_pub_item': sound_pub_item }) 
    198203            return HttpResponse(template.render(context)) 
Note: See TracChangeset for help on using the changeset viewer.