コード例 #1
0
ファイル: views.py プロジェクト: sbillaudelle/holidaylines
def admin_page_edit(request, page, lang):

    p = Page.objects.filter(id=page).get()

    #if request.POST.has_key('editor'):
    #    if lang:
    #        t = p.translations.filter(language=Language.objects.filter(code=lang).get()).get()
    #        t.content = request.POST['editor']
    #        t.save()
    #    else:
    #        p.content = request.POST['editor']
    #         p.save()

    try:
        active_lang = Language.objects.filter(code=lang).get()
        translation = p.translations.filter(language=active_lang).get()
    except:
        translation = PageTranslation()
        translation.page = p
        translation.language = Language.objects.filter(code=lang).get()
        translation.save()
    title = translation.title
    content = translation.content

    langs = Language.objects.all()

    apmt = AdminPageModeThingy()
    apmt.edit = True

    return render_to_response('administration/page_edit.html', RequestContext(request, {
        'page': p,
        'translation': translation,
        'title': title,
        'content': content,
        'lang': active_lang,
        'languages': langs,
        'apmt': apmt
        }))
コード例 #2
0
ファイル: views.py プロジェクト: sbillaudelle/holidaylines
     return HttpResponse('true')
 elif request.POST['method'] == 'save_page':
     translation = PageTranslation.objects.filter(id=request.POST['id']).get()
     translation.title = request.POST['title']
     translation.content = request.POST['content']
     translation.save()
     return HttpResponse('true')
 elif request.POST['method'] == 'delete_page':
     page = Page.objects.filter(id=request.POST['id']).get()
     page.delete()
     return HttpResponse('true')
 elif request.POST['method'] == 'add_page':
     try:
         page = Page()
         page.save()
         trans = PageTranslation()
         trans.title = "New Page"
         trans.language = Language.objects.filter(code='en').get()
         trans.content = "There isn't any content yet."
         trans.page = page
         trans.save()
     except Exception, e:
         print e
     return HttpResponse(json.dumps({
         'id': page.id,
         }))
 elif request.POST['method'] == 'add_link':
     link = Link()
     link.title = request.POST['code']
     #link.name = request.POST['name']
     link.save()