예제 #1
0
파일: views.py 프로젝트: pgwt/COC
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),
        )
예제 #2
0
파일: models.py 프로젝트: pgwt/COC
 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)
예제 #3
0
파일: models.py 프로젝트: pgwt/COC
 def grouptopics(self):#我关注的小组的话题
     from forum.models import Topic
     return Topic.objects(creator__in=S_G_Card.objects(group__in=self.get_sgcard().scalar('group')))
예제 #4
0
파일: models.py 프로젝트: pgwt/COC
 def grouptopics_creat(self):#我创建的话题
     from forum.models import Topic
     return Topic.objects(creator__in=S_G_Card.objects(user=self))
예제 #5
0
파일: models.py 프로젝트: pgwt/COC
 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)
예제 #6
0
파일: models.py 프로젝트: pgwt/COC
 def get_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)