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
    }))
def before_pad_save(sender, instance, **kwargs):
    padID = etherpad.createGroupPad(instance.group.groupprofile.etherpad_group_id,
        instance.name)
    etherpad.setPublicStatus(padID, 'false')