def delete(self,*args): if self.params.key: item = Album.get(self.params.key) if item: item.delete() self.status ='Album is deleted!' else: self.status='Album does not exist' else: self.status = 'Key was not Provided!' self.redirect(AlbumController.get_url())
def details(self, *args): if self.params.key: item = Album.get(self.params.key) if item: return {'Album': Album} else: self.status = 'Album does not exists' self.redirect(AlbumController.get_url()) else: self.status = 'Key not provided' return {'Album':Album}
def edit(self, *args): if self.params.key: item = Album.get(self.params.key) if item: return {'op':'update', 'AlbumForm': AlbumForm(instance=item)} else: self.status = 'Album does not exists' self.redirect(AlbumController.get_url()) else: self.status = 'Key not provided' return {'op':'insert' ,'AlbumForm':AlbumForm()}
def index(self, galery): results =None index = 0; count=20 try: index = int(self.params.index) count = int(self.params.count) except: pass nextIndex = index+count; previousIndex = index<=0 and -1 or (index-count>0 and 0 or index-count) result = {'AlbumList': Album.all().fetch(limit=count, offset=index)} result.update(locals()) return result
def save(self, *args): instance = None if self.params.key: instance = Album.get(self.params.key) form=AlbumForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'Album is saved' self.redirect(AlbumController.get_url()) else: self.SetTemplate(templateName = 'Album_edit.html') self.status = 'Form is not Valid' return {'op':'update', 'AlbumForm': form}
def view(self, album, *args): album = Album.get_by_key_name(album) gd_client = gdata.photos.service.PhotosService() handle = album.Galery.PicasaUsername album_name=album picset = [] feed = gd_client.GetFeed('/data/feed/api/user/%s/album/%s? kind=photo' % (handle, album_name)) for entry in feed.entry: if entry.geo.Point: pos = entry.geo.Point.pos.text else: pos = '0 0' picsrc = entry.content.src description = entry.summary.text picLink = entry.link[1].href logging.warn('-'.join([str(picsrc), str(description), str(picLink)])) picset.append( PicasaImage(picsrc, picLink, picsrc, description, album, pos) ) return self.respond({'feed': picset})