summaryrefslogtreecommitdiff
path: root/wiki
diff options
context:
space:
mode:
authorJoaquín Aguirrezabalaga <kinote@kinote.org>2014-01-03 01:06:22 +0100
committerJoaquín Aguirrezabalaga <kinote@kinote.org>2014-01-03 01:06:40 +0100
commitf05c5e2d8a705df1c94b63a978267b291c893bbb (patch)
treea8bd95e9cc2c0bd48be57893ccc4ddec63152d29 /wiki
parent802a74102b9073e961ef1d7a487f99b962d76512 (diff)
downloadelgarito-master.tar.gz
elgarito-master.zip
django 1.6HEADmaster
Diffstat (limited to 'wiki')
-rw-r--r--wiki/admin.py2
-rw-r--r--wiki/urls.py20
-rw-r--r--wiki/views.py23
3 files changed, 26 insertions, 19 deletions
diff --git a/wiki/admin.py b/wiki/admin.py
index adb63d4..95835e8 100644
--- a/wiki/admin.py
+++ b/wiki/admin.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 ts=4 shiftwidth=4 softtabstop=4 expandtab:
from django.contrib import admin
-from elgarito.wiki.models import Pagina
+from wiki.models import Pagina
class PaginaAdmin(admin.ModelAdmin):
diff --git a/wiki/urls.py b/wiki/urls.py
index ddcddf3..07dd356 100644
--- a/wiki/urls.py
+++ b/wiki/urls.py
@@ -1,12 +1,14 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, url
-urlpatterns = patterns('elgarito.wiki.views',
- (r'^$', 'index'),
+urlpatterns = patterns(
+ 'wiki.views',
+
+ url(r'^$', 'index'),
- #(r'^((?:[A-Z]+[a-z]+){2,})/$', 'pagina'),
- (r'^nueva/$', 'nueva'),
- (r'^lista/$', 'lista'),
- (r'^(?P<titulo>\w+)/$', 'pagina'),
- (r'^(?P<titulo>\w+)/editar/$', 'editar'),
- #(r'^(?P<titulo>\w+)/eliminar/$', 'eliminar'),
+ #url(r'^((?:[A-Z]+[a-z]+){2,})/$', 'pagina'),
+ url(r'^nueva/$', 'nueva'),
+ url(r'^lista/$', 'lista'),
+ url(r'^(?P<titulo>\w+)/$', 'pagina'),
+ url(r'^(?P<titulo>\w+)/editar/$', 'editar'),
+ #url(r'^(?P<titulo>\w+)/eliminar/$', 'eliminar'),
)
diff --git a/wiki/views.py b/wiki/views.py
index 9d5ac78..a214690 100644
--- a/wiki/views.py
+++ b/wiki/views.py
@@ -1,13 +1,15 @@
# vim: set fileencoding=utf-8 ts=4 shiftwidth=4 softtabstop=4 expandtab:
-from elgarito.wiki.models import Pagina, PaginaForm
-from django.shortcuts import render_to_response, get_object_or_404
+from wiki.models import Pagina, PaginaForm
+from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import user_passes_test
+
def index(request):
return HttpResponseRedirect('/wiki/Portada/')
+
def lista(request):
lista_paginas = Pagina.objects.all()
return render_to_response('wiki/lista.html',
@@ -15,6 +17,7 @@ def lista(request):
'lista_paginas': lista_paginas
}))
+
def pagina(request, titulo, static=None):
try:
pagina = Pagina.objects.get(titulo__exact=titulo)
@@ -24,9 +27,10 @@ def pagina(request, titulo, static=None):
'static': static,
}))
except Pagina.DoesNotExist:
- pagina = Pagina(titulo = titulo)
+ pagina = Pagina(titulo=titulo)
return HttpResponseRedirect('/wiki/' + pagina.titulo + '/editar/')
+
@user_passes_test(lambda u: u.has_perm('wiki.can_editar_pagina'),
login_url='/usuarios/login/')
def editar(request, titulo, static=None):
@@ -39,7 +43,7 @@ def editar(request, titulo, static=None):
pagina.texto = request.POST['texto']
pagina.autor_id = request.user.id
pagina.save()
- return HttpResponseRedirect('/wiki/' + pagina.titulo +'/')
+ return HttpResponseRedirect('/wiki/' + pagina.titulo + '/')
else:
try:
pagina = Pagina.objects.get(titulo__exact=titulo)
@@ -48,20 +52,21 @@ def editar(request, titulo, static=None):
form = PaginaForm(instance=pagina)
return render_to_response('wiki/editar.html',
RequestContext(request, {
- 'form' : form,
+ 'form': form,
'pagina': pagina,
'static': static,
}))
+
@user_passes_test(lambda u: u.has_perm('wiki.can_add_pagina'),
login_url='/usuarios/login/')
def nueva(request):
if request.POST:
pagina = Pagina(id=None,
- titulo = request.POST['titulo'],
- texto = request.POST['texto'],
- autor = request.user,
- )
+ titulo=request.POST['titulo'],
+ texto=request.POST['texto'],
+ autor=request.user,
+ )
pagina.save()
return HttpResponseRedirect('/wiki/%s/' % pagina.titulo)
else: