Esempio n. 1
0
def save(request):
    response = {}
    response['success'] = True
    response['errors'] = {}
    u = request.user
    args = json.loads(request.raw_post_data)
    # 'url' for flatpages needs to be unique :( just want it to be the ID
    pages = ExtendedFlatPage.objects.all().order_by('id')
    url = "0" if len(pages) < 1 else str(pages[len(pages)-1].id+1)
    f = ExtendedFlatPage(page_url=args['url'], content=args['html'], original_html=args['original_html'], title=args['name'], url=url, created_by=u.id, updated_by=u.id)
    f.save()
    f.sites.add(Site.objects.get(id=1))
    f.save()
    response["id"] = f.id
    return HttpResponse(json.dumps(response), mimetype='application/json')
Esempio n. 2
0
 def handle(self, *args, **options):
     e = ExtendedFlatPage(url="/1/", title="one", updated_by=1, created_by=1, content="<html><head><title>one</title></head><body>this is page one</body></html>", original_html="<html><head><title>one</title></head><body>this is page one</body></html>", page_url="http://www.wisc.edu/")
     e.save()
     e.site = [1]
     e.save()
     f = ExtendedFlatPage(url="/2/", title="two", updated_by=1, created_by=1, content="<html><head><title>two</title></head><body>this is page two</body></html>", original_html="<html><head><title>two</title></head><body>this is page two</body></html>", page_url="http://www.economist.com/")
     f.save()
     f.site = [1]
     f.save()