本文整理汇总了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))
示例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))
示例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)
示例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)
示例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)
示例6: find_topic
def find_topic(self):
from topic.models import Topic
return Topic.objects(creator__in=self.find_group())
示例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)
示例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)
示例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)
示例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)
示例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)
示例12: get_topic_creat_inactive
def get_topic_creat_inactive(self):
from topic.models import Topic
return Topic.objects(creator=self, is_active=False)
示例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))