Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the possibility to create pads from the UI

  • Loading branch information...
commit ea018dd54cf04b53313f81fce34e72cd36b73035 1 parent 9cd7b7c
@sfyn authored
View
5 forms.py
@@ -0,0 +1,5 @@
+from django import forms
+
+class PadCreate(forms.Form):
+ name = forms.CharField()
+ group = forms.CharField(widget=forms.HiddenInput)
View
11 templates/etherpad-lite/padCreate.html
@@ -0,0 +1,11 @@
+{% extends "etherpad-lite/base.html" %}
+{% load url from future %}
+
+{% block content %}
+
+<form action="/etherpad/create/{{ pk }}/" method="post">{% csrf_token %}
+{{ form.as_p }}
+<input type="submit" value="Submit" />
+</form>
+
+{% endblock %}
View
7 templates/etherpad-lite/profile.html
@@ -9,12 +9,13 @@
<a href="/logout">Logout</a>
-{% for group, pads in groups.items %}
+{% for group, data in groups.items %}
<h2>Pads in group {{group}}:</h2>
<ul>
- {%for pad in pads%}
- <li><a href="/etherpad/{{pad.id}}">{{pad.name}}</a></li>
+ {%for pad in data.pads%}
+ <li><a href="/etherpad/{{pad.id}}">{{pad.name}}</a></li>
{%endfor%}
+ <li><a class="action" href="/etherpad/create/{{data.group.id}}">Create</a></li>
</ul>
{% endfor %}
View
1  urls.py
@@ -9,4 +9,5 @@
url(r'^logout$', 'django.contrib.auth.views.logout', {'template_name': 'etherpad-lite/logout.html'}),
url(r'^accounts/profile/$', 'django_etherpad_lite.views.profile'),
url(r'^etherpad/(?P<pk>\d+)/$', 'django_etherpad_lite.views.pad'),
+ url(r'^etherpad/create/(?P<pk>\d+)/$', 'django_etherpad_lite.views.padCreate')
)
View
21 views.py
@@ -2,11 +2,13 @@
from django.shortcuts import render_to_response, get_object_or_404
from django_etherpad_lite.models import *
+from django_etherpad_lite import forms
from django.db.models import Count
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.admin.views.decorators import staff_member_required
from django.template import RequestContext
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from django.core.context_processors import csrf
import datetime
import time
from django_etherpad_lite import simplecurl
@@ -14,6 +16,21 @@
DJANGO_ETHERPAD_LITE_SESSION_LENGTH = 45 * 24 * 60 * 60
+def padCreate(request, pk):
+ group = get_object_or_404(PadGroup, pk=pk)
+ if request.method == 'POST':
+ form = forms.PadCreate(request.POST)
+ if form.is_valid():
+ pad = Pad(name=form.cleaned_data['name'], server=group.server, group=group)
+ pad.save()
+ pad.Create()
+ return HttpResponseRedirect('/accounts/profile/')
+ else:
+ form = forms.PadCreate({'group':group.groupID})
+ con = {'form': form, 'pk': pk}
+ con.update(csrf(request))
+ return render_to_response('etherpad-lite/padCreate.html', con)
+
def profile(request):
name = request.user.__unicode__()
@@ -28,7 +45,7 @@ def profile(request):
groups = {}
for g in author.group.all():
- groups[g.__unicode__()] = Pad.objects.filter(group=g)
+ groups[g.__unicode__()] = {'group': g, 'pads': Pad.objects.filter(group=g)}
return render_to_response('etherpad-lite/profile.html', {'name': name, 'author': author, 'groups':groups});
def pad(request, pk):
Please sign in to comment.
Something went wrong with that request. Please try again.