Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 68 lines (52 sloc) 1.892 kb
2aae1e2 @dbunskoek first commit
dbunskoek authored
1 from django.contrib.auth import authenticate, login
2 from django.http import HttpResponse, HttpResponseRedirect
3 from django.contrib.admin.views.decorators import staff_member_required
4 from django.utils import simplejson
5 from django.utils.translation import ugettext as _
6 from django.views.decorators.csrf import csrf_exempt
7
8 from textile import textile
9
10 from models import Page
11
12
13 def fiber_login(request):
14 username = request.POST['username']
15 password = request.POST['password']
16 user = authenticate(username=username, password=password)
17
18 result = {}
19 if user is not None:
20 if user.is_active:
21 login(request, user)
22 result = {
23 'status': 'success',
24 }
25 else:
26 result = {
27 'status': 'inactive',
28 'message': _('This account is inactive.'),
29 }
30 else:
31 result = {
32 'status': 'failed',
33 'message': _('Please enter a correct username and password. Note that both fields are case-sensitive.'),
34 }
35 json = simplejson.dumps(result)
36 return HttpResponse(json, mimetype='application/json')
37
38
39 @staff_member_required
40 def page_move_up(request, id):
41 page = Page.objects.get(pk=id)
42
43 if (page):
44 previous_sibling_page = page.get_previous_sibling()
45 if (previous_sibling_page):
46 page.move_to(previous_sibling_page, position='left')
47
48 return HttpResponseRedirect('../../')
49
50
51 @staff_member_required
52 def page_move_down(request, id):
53 page = Page.objects.get(pk=id)
54
55 if (page):
56 next_sibling_page = page.get_next_sibling()
57 if (next_sibling_page):
58 page.move_to(next_sibling_page, position='right')
59
60 return HttpResponseRedirect('../../')
61
62
63 @csrf_exempt
64 def render_textile(request):
65 return HttpResponse(
66 textile(request.POST['data'])
67 )
Something went wrong with that request. Please try again.