def home(request): # from flickr photos, get one tagged 'main' # import pdb; pdb.set_trace() main = flickr.api.walk(user_id=flickr.user_id, tags="main", sort="date-posted-desc") #get all photos tagged 'favorite' favorites = flickr.api.walk(user_id=flickr.user_id, tags="favorite", sort = "date-posted-desc") images = [] # The following sizes are for testing sizes = ['495x374', '495x374'] try: main_photo = list(iter(main))[0] images.append((flickr.get_url(main_photo, 'b'), sizes[0], main_photo.get('title'))) # This occurs when the main photo is the same with the favorite for i, favorite in enumerate(favorites): if main_photo.get('id') != favorite.get('id'): images.append((flickr.get_url(favorite, 'b'), sizes[i % len(sizes)], favorite.get('title'))) except: # When main_photo is different from favorite, this occurs for i, favorite in enumerate(favorites): images.append((flickr.get_url(favorite, 'b'), sizes[i % len(sizes)], favorite.get('title'))) recent = Menya.objects.filter(is_active=True).order_by('-created_on')[:5] context = dict(images=images, recent=recent) return render(request, 'public/home.html', context)
def home(request): # from flickr photos get one tagged "main"(should have only one) main = flickr.api.walk(user_id=flickr.user_id, tags="main", sort="date-posted-desc") # from flickr get all photo elements tagged "favorite" favorites = flickr.api.walk(user_id=flickr.user_id, tags="favorite, -main", sort="date-posted-desc") images = [] sizes = ['496x374', '296x224', '296x146', '194x146', '194x224'] try: main_photo = list(iter(main))[0] images.append((flickr.get_url(main_photo, 'b'), sizes[0], main_photo.get('title'))) # create an image file from every favorite for i,favorite in enumerate(favorites): if main_photo.get('id') != favorite.get('id'): images.append((flickr.get_url(favorite, 'b'), sizes[i % len(sizes)], favorite.get('title'))) except: # create an image file from every favorite for i,favorite in enumerate(favorites): images.append((flickr.get_url(favorite, 'b'), sizes[i % len(sizes)], favorite.get('title'))) # get recent blog posts recent = Post.objects.filter(is_active=True).order_by('-created_on')[:5] # get upcoming events upcoming = Event.objects.filter(date__gte=datetime.today())[:5] context = dict(images = images, recent=recent, upcoming=upcoming ) return render(request, 'public/home.html', context)
def show_index(image_id): print('REQUEST IMAGE: {}'.format(image_id)) album = 'all' if 'album' in session: album = session['album'] picture_list = load_album(album) print('LOADED ALBUM: {} = {}'.format(album, picture_list)) if image_id not in picture_list: print('ERR: image {} not in session album {}.'.format(image_id, session['album'])) image_id = random.choice(picture_list) return redirect('photo/{}'.format(image_id)) next_image_id = picture_list[(picture_list.index(image_id)+1) % len(picture_list)] image = { 'id': image_id, 'next': next_image_id, 'url': get_url(image_id), 'exif': get_exif(image_id) } title = 'photographie' if album == 'all' else FLICKR_ALBUMS[album]['title'] return render_template('single.tpl.html', image=image, menus=MENU_ITEMS, title=title)
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags = "kumenya"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'kum')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags = "bahandi"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'ba')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags="amateka"): return flickr.get_url(photo, 'amateka')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags="ndende"): return flickr.get_url(photo, 'ndende')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags = "ubuvanganzo"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'ubuva')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags = "twibwire"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'twi')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags = "ibitekerezo"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'ibi')
def photo(self): for photo in flickr.api.walk(user_id=flickr.user_id, tags="ikoranabuhanga"): if photo.get('id') == self.image_id: return flickr.get_url(photo, 'm')