This commit is contained in:
sanj 2010-12-02 17:19:52 +01:00
parent 31570f7484
commit 97979c7570
3 changed files with 50 additions and 1 deletions

View File

@ -7,6 +7,9 @@ try:
except:
import simplejson as json
from oxweb import youtube
from settings import MEDIA_URL
from os.path import join
flickr.API_KEY = settings.FLICKR_API_KEY
flickr.SECRET = settings.FLICKR_SECRET
@ -159,6 +162,18 @@ class Audio(models.Model):
def __unicode__(self):
return self.caption + " - " + self.category.name
def get_dict(self):
path = join(MEDIA_URL, self.fil.url)
info = dict(title=self.caption, url=path)
return {
'info': info,
'flyover': {
'id': self.flyover.id,
'name': self.flyover.name
}
}
class AudioCategory(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
@ -166,6 +181,20 @@ class AudioCategory(models.Model):
def __unicode__(self):
return self.name
def get_dict(self):
audios = []
flyovers = []
for a in Audio.objects.filter(category=self):
audios.append(a.get_dict())
flyovers.append(a.flyover.geojson_as_dict())
return {
'audios': audios,
'flyovers': {
'type': 'FeatureCollection',
'features': flyovers
}
}
class Text(models.Model):
# url = models.URLField("FlickR URL")
text = models.TextField()

View File

@ -218,6 +218,10 @@ $(function() {
var html = tmpl("tmpl_texts", {'texts': json.texts});
$('#media').html(html);
case "audio":
var html = tmpl("tmpl_audios", {'audios': json.audios});
$('#media').html(html);
default:
$.noop();
}

View File

@ -54,6 +54,22 @@
</div>
</script>
<script type="text/html" id="tmpl_audios">
<div class="audiosWrapper">
<% for (var i=0; i<audios.length;i++) { var audio = audios[i]; %>
<div class="audioWrapper" data-id="<%= audio.flyover.id %>">
<audio src="<%= audio.info.url %>" controls="controls">
<a href="<%= audio.info.url %>" target="_blank" title="<%= audio.info.title %>" class="audioFail">Right-click and Save-As to download</a>
</audio>
<%= audio.info.title %>
</a>
<div>
<% } %>
</div>
</script>
<script type="text/html" id="tmpl_about">
<div class="navContent" id="about">
<div class="contentWrapper about">
@ -148,7 +164,7 @@ University College London.</p>
<td class="imageCategory" data-type="image" data-id="5" data-lang_hi="कार्यकाल तले">Life underneath</td>
<td class="imageCategory" data-type="image" data-id="3" data-lang_hi="संचय/विक्रय">Storing / Selling</td>
<td class="videoCategory" data-type="video" data-id="3" data-lang_hi="भभका तले">Stills underneath</td>
<td class="audioCategory" data-type="audio" data-id="" data-lang_hi="भूमि ध्वनि">Ground Sounds</td>
<td class="audioCategory" data-type="audio" data-id="1" data-lang_hi="भूमि ध्वनि">Ground Sounds</td>
</tr>
</table>
</div>