Beispiel #1
0
def edit_pad(request, slug, name):
    user = request.user
    assert (user.userprofile.slug == slug)
    group =  Group.objects.filter(name=user.email)[0]
    # if it exists, render it
    pads = Pad.objects.filter(name=name)
    if pads:
        pad = pads[0]
    else:
        # if it doesn't exist, create it
        padID = etherpad.createGroupPad(group.groupprofile.etherpad_group_id,
            name)
        pad = Pad(author=user,group=group,name=name,slug=slug, padID=padID)
        etherpad.setPublicStatus(padID, 'false')
        pad.save()

    url = settings.ETHERPAD_HOST + '/p/' + group.groupprofile.etherpad_group_id + '$' + pad.name
    url = "http://localhost:8081/e" + '/p/' + group.groupprofile.etherpad_group_id + '$' + pad.name
    rendered_url = "http://localhost:8081/read/" + slug + '/' + name
    validUntil = time.time() + 10000;
    sessionID = etherpad.createSession(pad.group.groupprofile.etherpad_group_id, 
        pad.author.userprofile.etherpad_author_id, validUntil)

    request.session['sessionID'] = sessionID
    return render_to_response('coauthor/edit.html', ctx(request, {
        'host': request.META['HTTP_HOST'],
        'sessionID': sessionID,
        'etherpad_url': url,
        'render_pad_url': rendered_url,
        'name': name
    }))
Beispiel #2
0
def edit_pad(request, name):
    # XXX check it doesn't exist already
    user = request.user
    group =  Group.objects.filter(name=user.email)[0]
    pad = Pad(author=user,group=group,name=name)
    pad.save()
    url = settings.ETHERPAD_HOST + '/p/' + group.groupprofile.etherpad_group_id + '$' + pad.name
    url = "http://localhost:8081/e" + '/p/' + group.groupprofile.etherpad_group_id + '$' + pad.name

    validUntil = time.time() + 10000;
    sessionID = etherpad.createSession(pad.group.groupprofile.etherpad_group_id, 
        pad.author.userprofile.etherpad_author_id, validUntil)
    print "sessionID:", sessionID

    request.session['sessionID'] = sessionID
    print "ETHERPAD_URL =", url
    return render_to_response('coauthor/edit.html', ctx(request, {
        'render_pad_url': reverse('render-pad', kwargs={'name': name}),
        'host': request.META['HTTP_HOST'],
        'sessionID': sessionID,
        'etherpad_url': url,
        'name': name
    }))