예제 #1
0
 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())
예제 #2
0
 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}
예제 #3
0
 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()}
예제 #4
0
 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
예제 #5
0
 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}
예제 #6
0
 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})