示例#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 global_variables(request):
    return {
        'hot_nodes': Node.hot(),
        'hot_topics': Topic.hot(),
        'hot_users': User.hot(),
        'latest_topics': Topic.objects.order_by('-id')[:10],
        'central_banks': CentralBank.objects.all(),
    }
示例#3
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
示例#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')
示例#5
0
文件: topics.py 项目: gfreezy/copycat
 def get_context_data(self, **kwargs):
     ctx = {
         'hot_topics': Topic.hot(),
         'hot_nodes': Node.hot(),
         'total_users': User.objects.count(),
         'total_topics': User.objects.count(),
         'total_nodes': Node.objects.count(),
         'total_replies': Reply.objects.count(),
         'planes': Plane.objects.all(),
         'tab': 'forum',
     }
     return ctx
示例#6
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')
示例#7
0
文件: root.py 项目: gfreezy/copycat
def index(request):
    hot_topics = Topic.hot()
    new_topics = Topic.objects.order_by('-id')[:10]
    recent_blogs = Blog.recent(5)
    stick_blogs = Blog.sticks()
    hot_blogs = Blog.hot(2)
    hot_nodes = Node.hot()
    return render(request, 'common/index.html', {
        'hot': hot_topics,
        'new': new_topics,
        'recent_blogs': recent_blogs,
        'hot_blogs': hot_blogs,
        'sticks': stick_blogs,
        'hot_nodes': hot_nodes,
        'recent_events': EconomicEvent.objects.order_by('-time')[:10],
        'tab': 'index',
    })