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 += 1 topic.save() if request.method == "POST": form = NewPostForm(request.POST) if form.is_valid(): content = form.cleaned_data["content"] post = Post(content=content) post.author = request.user post.creat_time = datetime.datetime.now() post.floor = Post.objects(topic=topic).count() + 1 post.topic = topic post.is_active = True post.save() topic.update_author = request.user topic.update_time = datetime.datetime.now() topic.save() return HttpResponseRedirect("/group/" + str(gurl_number) + "/topic/" + str(turl_number) + "/") else: form = NewPostForm() return render_to_response( "group/group_topic.html", {"group": group, "current_user": request.user, "form": form, "topic": topic, "STATIC_URL": STATIC_URL}, context_instance=RequestContext(request), )
def get_inactive_topic_list(self): from accounts.models import S_G_Card creator = S_G_Card.objects(group=self).all() from forum.models import Topic return Topic.objects(creator__in=creator, is_active=False)
def grouptopics(self):#我关注的小组的话题 from forum.models import Topic return Topic.objects(creator__in=S_G_Card.objects(group__in=self.get_sgcard().scalar('group')))
def grouptopics_creat(self):#我创建的话题 from forum.models import Topic return Topic.objects(creator__in=S_G_Card.objects(user=self))
def get_inactive_topic_list(self):#得到删除主题列表 from accounts.models import S_C_Card creator = S_C_Card.objects(corporation=self).all() from forum.models import Topic return Topic.objects(creator__in=creator,is_active=False)