Exemplo n.º 1
0
 def albums(self):
     albums = self.m.all().fetch(10)
     albums = utils.to_dicts(albums)
     for item in albums:
         item['date'] = datetime.fromtimestamp(item['date']).strftime('%Y')
         item['artwork'] = images.get_serving_url(item['artwork'], 104, crop=True)
     return albums
Exemplo n.º 2
0
 def articles(self):
     items = self.m.all().fetch(10)
     itemsd = utils.to_dicts(items)
     for item in itemsd:
         item['text'] = ''
         item['img'] = ''
     return itemsd
Exemplo n.º 3
0
 def get_options(self):
     ref_model = getattr(self.model.model, self.name).reference_class
     items = ref_model.all().fetch(10)
     items_dict = utils.to_dicts(items)
     for item in items_dict:
         self.check_if_selected(item)
     return items_dict
Exemplo n.º 4
0
 def photos(self):
     photos = self.m.all().fetch(10)
     photosd = utils.to_dicts(photos)
     for item in photosd:
         item['photos'] = []
         item['img'] = images.get_serving_url(item['img'], 80, True)
     return photosd
Exemplo n.º 5
0
 def prepare(self, data=None):
     if not data: return None
     for k,v in data.iteritems():
         if isinstance(v, db.Model):
             data[k] = utils.to_dict(v)
         elif isinstance(v, list) and len(v) and isinstance(v[0], db.Model):
             data[k] = utils.to_dicts(v)
     return data
Exemplo n.º 6
0
 def get(self):
     mess = models.Guestbook.all().fetch(100)
     if mess:
         messd = utils.to_dicts(mess)
         messd = sorted(messd, lambda x,y: cmp(x['id'], y['id']), reverse=True)
     else:
         messd = {}
     self.renderjson('guestbook.html', {
         'mess': messd
     })
Exemplo n.º 7
0
 def albums(self):
     albums = self.m.all().fetch(5)
     albums = utils.to_dicts(albums)
     for item in albums:
         # TODO: FIX DATE
         # item['date'] = datetime.fromtimestamp(item['date']).strftime('%Y')
         try:
             item['artwork'] = images.get_serving_url(item['artwork'], 104, crop=True)
         except images.BlobKeyRequiredError:
             item['artwork'] = ''
     return albums
Exemplo n.º 8
0
 def get(self, id):
     id = int(id or 0)
     try:
         self.q = models.Album.gql('WHERE title = :1', 'Tomber les Masques').get().song_set
         self.q.order('track')
         data = {
             'texts': utils.to_dicts(self.q),
             'text': self.text(id)
         }
     except AttributeError:
         data = {'songs': [], 'song': False}
     self.renderjson('texts.html', data)
Exemplo n.º 9
0
 def links(self):
     links = models.Lien.all().fetch(10)
     return utils.to_dicts(links)
Exemplo n.º 10
0
 def agenda(self):
     agenda = models.Agenda.all().filter('date >=', datetime.now()).fetch(100)
     agendad = utils.to_dicts(agenda)
     for item in agendad:
         item['date'] = datetime.fromtimestamp(item['date']).strftime('%Y/%m/%d %H:%M')
     return agendad
Exemplo n.º 11
0
 def videos(self):
     videos = self.m.all().fetch(10)
     videosd = utils.to_dicts(videos)
     for item in videosd:
         item['content'] = ''
     return videosd
Exemplo n.º 12
0
 def songs(self, album):
     songs = album.song_set
     return utils.to_dicts(songs)
Exemplo n.º 13
0
 def contacts(self):
     contacts = models.Contact.all().fetch(10)
     return utils.to_dicts(contacts)
Exemplo n.º 14
0
 def __init__(self, model, modelname, refs):
     self.model = model
     self.modelname = modelname
     self.refs = utils.to_dicts(refs)