Commit 34cc42fe authored by alexandre's avatar alexandre

Added support for pad creation from panel

parent 2fc0700d
{% load static %}<!DOCTYPE html>
{% load static apass_tags %}<!DOCTYPE html>
<html xmlns:aa="http://activearchives.org/terms/">
<head>
<meta charset="UTF-8" />
......@@ -28,8 +28,9 @@
<a class="toggle__label" href="#filters">filters</a>
<a class="toggle__label" href="#help">help</a>
<a class="toggle__label" href="#chat">chat</a>
<a class="toggle__label" href="{% url 'pad-create' %}">create</a>
<!-- <a class="toggle__label" href="#create">create</a> -->
{% if user.is_authenticated %}
<a class="toggle__label" href="#create">create</a>
{% endif %}
</div>
<div class="panel__main">
......@@ -45,9 +46,14 @@
<iframe src="https://webchat.freenode.net/" frameborder="0"></iframe>
</div>
{% if user.is_authenticated %}
<div class="panel__section" id="create">
{% create_form %}
{% comment %}
{% include 'apass/organisms/forms/create.html' %}
{% endcomment %}
</div>
{% endif %}
</div>
</aside>
</main>
......
{% extends "base.html" %}
{% block content %}
<form action="{% url 'pad-create' %}" method="post">
{{ form.errors }}
{% csrf_token %}
{{ form }}
<input class="submit" type="submit" value="Create">
</form>
{% endblock %}
<form action="{% url 'pad-create' %}" method="post">
{% csrf_token %}
Pad name yoyo
{{ form }}
<input class="submit" type="submit" value="Create">
</form>
from django import template
from etherpadlite import forms
from etherpadlite.models import PadAuthor
from ethertoff.templatetags.wikify import wikifyPath, ensureTrailingSlash
register = template.Library()
@register.inclusion_tag('partials/create_form.html', takes_context=True)
def create_form(context):
request = context.get('request')
author = PadAuthor.objects.get(user=request.user)
group = author.group.all()[0]
form = forms.PadCreate({'group': group.groupID, 'name': ''})
con = {
'form': form,
'pk': group.pk,
'title': 'Create pad in %(grp)s' % {'grp': group}
}
# con.update(csrf(request))
return con
# return render(
# request,
# 'pad-create.html',
# con,
# )
# @login_required(login_url='/accounts/login')
# def padCreate(request, prefix=''):
# """
# Create a pad
# """
# # normally the ‘pads’ context processor should have made sure that these objects exist:
# author = PadAuthor.objects.get(user=request.user)
# group = author.group.all()[0]
# if request.method == 'POST': # Process the form
# form = forms.PadCreate(request.POST)
# if form.is_valid():
# slug = re.sub(r'\s+', '_', form.cleaned_data['name'])
# slug = slug.strip(":") # avoids leading and trailing "::"
# pad = createPad(slug=slug, server=group.server, group=group)
# return HttpResponseRedirect(reverse('pad-write', args=(pad.display_slug,) ))
# else:
# # No form to process so create a fresh one
# # prefix should contain the name of the folder
# form = forms.PadCreate({'group': group.groupID, 'name': wikifyPath(ensureTrailingSlash(prefix) if prefix else '')})
# con = {
# 'form': form,
# 'pk': group.pk,
# 'title': _('Create pad in %(grp)s') % {'grp': group}
# }
# con.update(csrf(request))
# return render(
# request,
# 'pad-create.html',
# con,
# )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment