def get(self): """ Renders a page for managing images. Displays all of the images stored for the site and a form to create new images from a file. """ #create a new page and set the title html_page = util.html_page() html_page.set_title('Manage images') #If the user is logged in #display a "Sing out" link #Fetch all of the image objects #and display each in the 'content' div #And display a form to select a file with an "Add Image" button #in the 'footer' div #user = users.get_current_user() #if user: # html_page.append_top( # html_page.href( # "Sign out ??",users.create_logout_url("/"))) #make a list of images #based on the page number if it exists #and is sane # images_query = SiteImage.all() #images_query.order("data") # images = images_query.fetch(1000) # s_page = self.request.get("page") manage_list = list() for image in images: manage_list.append( html_page.div( html_page.img( '/image/get?img_id=%s' % str(image.key())), "img_box")) html_page.append_content( html_page.more_pages(manage_list,s_page,"/image/manage")) form_inputs = list() form_inputs.append(html_page.form_input('img',"file",'Add Image')) html_page.append_footer( html_page.form("Add image",'/image/add',form_inputs)) #Otherwise just just display a page to allow the user to log in #else : # html_page.append_header( # html_page.p( # 'To manage images please ' + # self.href('sign in',users.create_login_url(self.request.uri) + # " as a gmail user<br>\r" # ))) #Render the lot html_page.page(self)
def get(self): """ Called for HTTP get on /(when ever page / is requested). Presents a list of subscriptions for this week. The data presented is essentially read only of not logged in or read/write if logged in. All HTML rendering is handled by the viernes_util module. Two strings are formatted: the body and the title, these are passed to viernes_util.page which produced the complete page html. """ #create a new page and set the title html_page = util.html_page() html_page.set_title("Photo montage") form_inputs = list() form_inputs.append(html_page.form_input('img',"file",'Add Image')) html_page.append_top( html_page.form("Add Image",'/image/add',form_inputs)) html_page.append_top( html_page.form_get("Create Mosaic",'/mosaic/create')) html_page.append_content(html_page.img('/images/selected_img', 'main image', 'selected image')) html_page.append_content(html_page.img('/images/mosaic_img', 'mosaic image', 'mosaic image')) siteimgs_query = ImageModel.all() imgs_html_string = "" for siteimg in siteimgs_query : imgs_html_string += siteimg.to_html(html_page, "image/set_as_default") html_page.append_footer(html_page.div(imgs_html_string, 'site_images')) #Render it html_page.page(self)