Пример #1
0
 def _add_section(self, section):
     name = section["name"]
     order = section["order"]
     nodes = section.get("nodes")
     
     s = Section(name=name, order=order)
     s.save()
     
     tmpnode = None
     if nodes:
         for n in nodes:
             name = n[0]
             is_trash = n[1]
             tmpnode = Node(section=s, name=name, is_trash=is_trash, description=name, order=1)
             tmpnode.save()
     
     return tmpnode
Пример #2
0
 def _add_section(self, section):
     name = section["name"]
     order = section["order"]
     nodes = section.get("nodes")
     
     s = Section(name=name, order=order)
     s.save()
     
     tmpnode = None
     if nodes:
         for n in nodes:
             name = n[0]
             is_trash = n[1]
             tmpnode = Node(section=s, name=name, is_trash=is_trash, description=name, order=1)
             tmpnode.save()
     
     return tmpnode
Пример #3
0
def ask_questions(request):
    """sk questions API"""  
    qtitle = request.POST['TITLE']   
    tags = request.POST['TAGS']
    author = request.POST['AUTHORID']
    qbody = request.POST['BODY']
    p2 = Node(title = qtitle, tagnames = tags, author_id = author, body = qbody, node_type = "question")
    "cannot succeed in setting node_type here and I don't know why"
    p2.save()

    " change node_type to question"
    cursor = connection.cursor()
    sql = "update forum_node set node_type = 'question' where 1 order by id desc limit 1;"
    cursor.execute(sql)

    questions = Question.objects.filter(title__contains=qtitle)
    response = question_list(questions)

    return HttpResponse(simplejson.dumps(response), mimetype='application/json')
Пример #4
0
def ask_questions(request):
    """sk questions API"""
    qtitle = request.POST['TITLE']
    tags = request.POST['TAGS']
    author = request.POST['AUTHORID']
    qbody = request.POST['BODY']
    p2 = Node(title=qtitle,
              tagnames=tags,
              author_id=author,
              body=qbody,
              node_type="question")
    "cannot succeed in setting node_type here and I don't know why"
    p2.save()

    " change node_type to question"
    cursor = connection.cursor()
    sql = "update forum_node set node_type = 'question' where 1 order by id desc limit 1;"
    cursor.execute(sql)

    questions = Question.objects.filter(title__contains=qtitle)
    response = question_list(questions)

    return HttpResponse(simplejson.dumps(response),
                        mimetype='application/json')