def showactivity(request, gurl_number, turl_number): corporation = Corporation.objects(url_number=gurl_number).get() activity = Activity.objects(url_number=turl_number).get() 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) sccard = S_C_Card.objects(user=request.user, corporation=corporation).get() reply.creator = sccard reply.creat_time = datetime.datetime.now() reply.target = activity reply.is_active = True reply.save() activity.clicks = topic.clicks - 1 activity.save() return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/activity/' + str(turl_number) + '/') else: reply_form = NewReplyForm() activity.clicks = activity.clicks + 1 activity.save() return render_to_response('corporation/activity_corporation.html', { 'corporation': corporation, 'current_user': request.user, 'reply_form': reply_form, 'activity': activity, 'STATIC_URL': STATIC_URL }, context_instance=RequestContext(request))
def showmail(request, url_number): mail = Sitemail.objects(url_number=url_number).get() if request.user in [a.target for a in mail.creator]: mail.is_readed = True mail.save() if request.method == "POST": form = NewReplyForm(request.POST) if form.is_valid(): content = form.cleaned_data['content'] reply = Reply(content=content) sscard = S_S_Card.objects.get_or_create( user=request.user, target=mail.creator[0].user) reply.creator = sscard[0] reply.creat_time = datetime.datetime.now() reply.target = mail reply.is_active = True reply.save() return HttpResponseRedirect('') else: return render_to_response('sitemail/showmail.html', { 'mail': mail, 'STATIC_URL': STATIC_URL, 'current_user': request.user }, context_instance=RequestContext(request))
def showmail(request, url_number): mail = Sitemail.objects(url_number=url_number).get() if request.user in [a.target for a in mail.creator]: mail.is_readed = True mail.save() if request.method == "POST": form = NewReplyForm(request.POST) if form.is_valid(): content = form.cleaned_data["content"] reply = Reply(content=content) sscard = S_S_Card.objects.get_or_create(user=request.user, target=mail.creator[0].user) reply.creator = sscard[0] reply.creat_time = datetime.datetime.now() reply.target = mail reply.is_active = True reply.save() return HttpResponseRedirect("") else: return render_to_response( "sitemail/showmail.html", {"mail": mail, "STATIC_URL": STATIC_URL, "current_user": request.user}, context_instance=RequestContext(request), )
def showactivity(request, gurl_number, turl_number): corporation = Corporation.objects(url_number=gurl_number).get() activity = Activity.objects(url_number=turl_number).get() 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) sccard = S_C_Card.objects(user=request.user, corporation=corporation).get() reply.creator = sccard reply.creat_time = datetime.datetime.now() reply.target = activity reply.is_active = True reply.save() activity.clicks = topic.clicks - 1 activity.save() return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/activity/' + str(turl_number) + '/') else: reply_form = NewReplyForm() activity.clicks = activity.clicks + 1 activity.save() return render_to_response('corporation/activity_corporation.html', {'corporation':corporation, 'current_user':request.user, 'reply_form':reply_form, 'activity':activity, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
def createupdate(request): allPeople = [] for i in xrange(6): firstName = request.POST.get('firstName' + str(i)) if firstName is not None and len(firstName) > 0: lastName = request.POST.get('lastName' + str(i)) or "" nickName = request.POST.get('nickName' + str(i)) or "" preferNick = request.POST.get('preferNick' + str(i)) or False allPeople.append(Person(firstName=firstName, lastName=lastName, nickName=nickName, prefersNickName=preferNick)) r = None if len(allPeople) > 0: r = Reply() r.ip="127.0.0.1" r.save() for p in allPeople: p.save() r.invitedPeople.add(p) r.attendingPeople.add(p) emails = request.POST.get('email') for email in emails.split(','): e = InviteEmail() e.email = email.strip() e.save() r.emails.add(e) r.hasPlusOne = request.POST.get('allowPlusOne') or False r.save() return render_to_response('adminNewReply.html', { 'numPeople' : xrange(6), 'lastReply' : r, }, context_instance=RequestContext(request))
def showtopic(request, gurl_number, turl_number): corporation = Corporation.objects(url_number=gurl_number).get() topic = Topic.objects(url_number=turl_number).get() 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) 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.clicks = topic.clicks - 1 topic.save() return HttpResponseRedirect('/corporation/' + 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('/corporation/' + 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('corporation/topic_corporation.html', { 'corporation': corporation, 'current_user': request.user, 'reply_form': reply_form, 'topic': topic, 'STATIC_URL': STATIC_URL }, context_instance=RequestContext(request))
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))
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))
def get_reply_creat_inactive(self): from reply.models import Reply return Reply.objects(creator=self, is_active=False)
def get_topic_reply_inactive(self): from reply.models import Reply from topic.models import Topic return Reply.objects(creator=self, is_active=True).distinct('target').objects(_cls=Topic, is_active=False)
def get_reply_group_creat_active(self): from reply.models import Reply return Reply.objects(creator__in=self.get_sgcard_all(), is_active=True)
def get_reply_corporation_creat_inactive(self): from reply.models import Reply return Reply.objects(creator__in=self.get_sccard_all(), is_active=False)
def get_topic_reply_inactive(self): from reply.models import Reply from topic.models import Topic return Reply.objects(creator=self, is_active=True).distinct('target').objects( _cls=Topic, is_active=False)
def get_reply_corporation_reply_active(self): from reply.models import Reply return Reply.objects(creator__in=self.get_sccard_all(), is_active=True).distinct('target')
def get_reply(self):#得到回复列表 return Reply.objects(target=self)
def get_reply(self): from reply.models import Reply return Reply.objects(target=self)
def save_reply(form, request, sell): """Tool method for save reply""" content = request.POST["content"] reply = Reply(replyTIME=datetime.datetime.now(), replyUSER=request.user, berepliedABILITY=sell, replyWORDS=content) reply.save()
def get_reply_reply_inactive(self): from reply.models import Reply return Reply.objects(creator=self, is_active=True).distinct('target').objects( _cls=Reply, is_active=False)
def get_reply_reply_inactive(self): from reply.models import Reply return Reply.objects(creator=self, is_active=True).distinct('target').objects(_cls=Reply, is_active=False)
def get_topic_group_reply_active(self): #我回复的小组话题(active) from reply.models import Reply return Reply.objects(creator__in=self.get_sgcard_all(), is_active=True).distinct('target')
def get_activity_reply_active(self): from reply.models import Reply from activity.models import Activity return Reply.objects(creator=self, is_active=True).distinct('target').objects(_cls=Activity, is_active=True)
def get_topic_group_reply_active(self):#我回复的小组话题(active) from reply.models import Reply return Reply.objects(creator__in=self.get_sgcard_all(), is_active=True).distinct('target')
def get_activity_reply_active(self): from reply.models import Reply from activity.models import Activity return Reply.objects(creator=self, is_active=True).distinct('target').objects( _cls=Activity, is_active=True)
def save_reply(form, request, task): '''Tool method for save reply''' content = request.POST['content'] reply = Reply(replyTIME=datetime.datetime.now(), replyUSER=request.user, berepliedMISSION=task, replyWORDS=content) reply.save()
def get_reply(self): #得到回复列表 return Reply.objects(target=self)