def post_queue_add_page(request, addpagerequest_id, html, url): """Called by the server-side renderer to finish adding a page.""" addPageRequest = models.AddPageRequest.objects.get(id=addpagerequest_id) # If this page was already completed, don't add it again -- there's a possibility that multiple # threads are working on the same page at once. if addPageRequest.status_code == models.StatusCode.DONE: log.error("Multiple threads processed APR %s" % addPageRequest.id) return flowgram = addPageRequest.flowgram user = flowgram.owner title = helpers.get_title(request) # Modify the HTML to add base tag etc. (html, url) = fix.process_page(html, url) # Create and save the page: page = addPageRequest.page page.title = title page.save() html = helpers.cache_css_files(page, html) page = controller.create_page_to_flowgram(flowgram, page, html, do_make_thumbnail=False, set_position=False) # Updating the status code and page addPageRequest.status_code = models.StatusCode.DONE controller.set_page_hl_contents(page, html) addPageRequest.save() log.action('post_queue_add_page %s to %s for %s' % (page.id, flowgram.id, user.username))
def add_page(request, url, html): if not url.startswith('http://') and not url.startswith('https://'): return helpers.redirect(url, 'This type of page cannot be added to a flowgram.') user = request.user title = helpers.get_title(request) (flowgram, page) = pages.add_page(user, url, html, title) log.action('add_page created page with ID %s for Flowgram with ID %s by user %s' % \ (page.id, flowgram.id, user.username)) return helpers.redirect(url, 'Page added to your Flowgram "%s"' % flowgram.title)