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
def articles(self): items = self.m.all().fetch(10) itemsd = utils.to_dicts(items) for item in itemsd: item['text'] = '' item['img'] = '' return itemsd
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
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
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
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 })
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
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)
def links(self): links = models.Lien.all().fetch(10) return utils.to_dicts(links)
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
def videos(self): videos = self.m.all().fetch(10) videosd = utils.to_dicts(videos) for item in videosd: item['content'] = '' return videosd
def songs(self, album): songs = album.song_set return utils.to_dicts(songs)
def contacts(self): contacts = models.Contact.all().fetch(10) return utils.to_dicts(contacts)
def __init__(self, model, modelname, refs): self.model = model self.modelname = modelname self.refs = utils.to_dicts(refs)