当前位置: 首页>>代码示例>>Python>>正文


Python Topic.objects方法代码示例

本文整理汇总了Python中topic.models.Topic.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Topic.objects方法的具体用法?Python Topic.objects怎么用?Python Topic.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在topic.models.Topic的用法示例。


在下文中一共展示了Topic.objects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: showtopic

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
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,代码行数:40,代码来源:views.py

示例2: showtopic

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
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,代码行数:26,代码来源:views.py

示例3: get_topic_not_locked

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例4: get_topic_top

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例5: get_topic_inactive

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例6: find_topic

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 def find_topic(self):
     from topic.models import Topic
     return Topic.objects(creator__in=self.find_group())
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:5,代码来源:models.py

示例7: get_topic_corporation_creat_active

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例8: get_topic_corporation_active

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:6,代码来源:models.py

示例9: get_topic_group_creat_active

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例10: get_topic_creat_not_locked

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例11: get_topic_creat_top

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 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,代码行数:5,代码来源:models.py

示例12: get_topic_creat_inactive

# 需要导入模块: from topic.models import Topic [as 别名]
# 或者: from topic.models.Topic import objects [as 别名]
 def get_topic_creat_inactive(self):
     from topic.models import Topic
     return Topic.objects(creator=self, is_active=False)
开发者ID:longshenzhu,项目名称:COC,代码行数:5,代码来源:models.py


注:本文中的topic.models.Topic.objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。