Exemple #1
0
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))
Exemple #2
0
def add_page(user, url, html, title):
    # Modifying the HTML to add a base tag, etc.
    (html, url) = fix.process_page(html, url)
    
    # Creating and saving the page.
    page = models.Page.objects.create(title=title, source_url=url)
    html = helpers.cache_css_files(page, html)

    (flowgram, is_new) = controller.get_working_flowgram(user)
    if is_new:
        log.action('Created new working Flowgram with ID %s as a result of calling get_working_flowgram in add_page.' % \
                       flowgram.id)
    page = controller.create_page_to_flowgram(flowgram, page, html)
        
    # Removing the user's 'just_published' attribute.
    profile = user.get_profile()
    profile.just_published = False
    profile.save()

    return (flowgram, page)