當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Topic類代碼示例

本文整理匯總了Python中topic.models.Topic的典型用法代碼示例。如果您正苦於以下問題:Python Topic類的具體用法?Python Topic怎麽用?Python Topic使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Topic類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: showtopic

def showtopic(request, gurl_number, turl_number):
    group = Group.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    topic.clicks = topic.clicks + 1
    topic.save()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sgcard = S_G_Card.objects(user=request.user, group=group).get()
                reply.creator = sgcard
                reply.creat_time = datetime.datetime.now()
                reply.target = topic
                reply.is_active = True
                reply.save()
                topic.update_author = request.user
                topic.update_time = datetime.datetime.now()
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/group/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
            
        if "modify" in request.POST:
            modify_form = ModifyTopicForm(request.POST)
            if modify_form.is_valid():
                content = modify_form.cleaned_data['content']
                topic.content = content
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/group/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
        
    else:
        reply_form = NewReplyForm()
        modify_form = ModifyTopicForm()
        topic.clicks = topic.clicks + 1
        topic.save()
        return render_to_response('group/group_topic.html', {'group':group, 'current_user':request.user, 'reply_form':reply_form, 'topic':topic, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:38,代碼來源:views.py

示例2: showtopic

def showtopic(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    topic.clicks += 1
    topic.save()
    if request.method == 'POST':
        form = NewReplyForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            reply = Reply(content=content)
            sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
            reply.creator = sccard
            reply.creat_time = datetime.datetime.now()
            reply.target = topic
            reply.is_active = True
            reply.save()
            topic.update_author = request.user
            topic.update_time = datetime.datetime.now()
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
        
    else:
        form = NewReplyForm()
        return render_to_response('corporation/topic_corporation.html', {'corporation':corporation, 'current_user':request.user, 'form':form, 'topic':topic, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
開發者ID:longshenzhu,項目名稱:COC,代碼行數:24,代碼來源:views.py

示例3: get_topic_not_locked

 def get_topic_not_locked(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.get_sccard_all(), is_active=True, is_locked=False)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例4: get_topic_top

 def get_topic_top(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.get_sccard_all(), is_active=True, is_top=True)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例5: get_topic_inactive

 def get_topic_inactive(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.get_sccard_all(), is_active=False)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例6: find_topic

 def find_topic(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.find_group())
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例7: get_topic_corporation_creat_active

 def get_topic_corporation_creat_active(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.get_sccard_all(), is_active=True)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例8: get_topic_corporation_active

 def get_topic_corporation_active(self):#我關注的小組的話題
     from topic.models import Topic
     from relations.models import S_C_Card
     return Topic.objects(creator__in=S_C_Card.objects(corporation__in=self.get_corporation_active()), is_active=True)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:4,代碼來源:models.py

示例9: get_topic_group_creat_active

 def get_topic_group_creat_active(self):#我創建的小組話題(active)
     from topic.models import Topic
     return Topic.objects(creator__in=self.get_sgcard_all(), is_active=True)
開發者ID:NCZkevin,項目名稱:pyweb-test,代碼行數:3,代碼來源:models.py

示例10: get_topic_creat_not_locked

 def get_topic_creat_not_locked(self):
     from topic.models import Topic
     return Topic.objects(creator=self, is_active=True, is_locked=False)
開發者ID:longshenzhu,項目名稱:COC,代碼行數:3,代碼來源:models.py

示例11: get_topic_creat_top

 def get_topic_creat_top(self):
     from topic.models import Topic
     return Topic.objects(creator=self, is_active=True, is_top=True)
開發者ID:longshenzhu,項目名稱:COC,代碼行數:3,代碼來源:models.py

示例12: get_topic_creat_inactive

 def get_topic_creat_inactive(self):
     from topic.models import Topic
     return Topic.objects(creator=self, is_active=False)
開發者ID:longshenzhu,項目名稱:COC,代碼行數:3,代碼來源:models.py

示例13: visit_corporation_topics

def visit_corporation_topics(request, gurl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    if request.method == "POST":
        form = NewTopicForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            content = form.cleaned_data['content']
            topic = Topic(title=title)
            turl_number = len(Topic.objects) + 1
            topic.url_number = turl_number
            topic.content = content
            topic.creat_time = datetime.datetime.now()
            topic.is_active = True
            topic.is_locked = False
            topic.is_top = False
            topic.clicks = 0
            topic.update_time = datetime.datetime.now()
            topic.update_author = request.user
            sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
            topic.creator = sccard
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
            
            
    else:
        form = NewTopicForm()
        return render_to_response('corporation/corporation_topics.html', {'form':form, 'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
開發者ID:longshenzhu,項目名稱:COC,代碼行數:27,代碼來源:views.py


注:本文中的topic.models.Topic類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。