本文整理匯總了Python中relations.models.S_G_Card.objects方法的典型用法代碼示例。如果您正苦於以下問題:Python S_G_Card.objects方法的具體用法?Python S_G_Card.objects怎麽用?Python S_G_Card.objects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類relations.models.S_G_Card
的用法示例。
在下文中一共展示了S_G_Card.objects方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: group
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def group(request, gurl_number):
group = Group.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
sgcard = S_G_Card.objects(user=request.user, group=group).get()
topic.creator = sgcard
topic.save()
return HttpResponseRedirect('/group/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
else:
form = NewTopicForm()
return render_to_response('group/group.html', {'form':form, 'group':group, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
示例2: entergroup
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def entergroup(self, user):
from relations.models import S_G_Card
if self.get_user_active():
if S_G_Card.objects(user=user, group=self):
S_G_Card.objects(user=user, group=self).update(set__is_active=True, set__is_admin=False, set__creat_time=datetime.datetime.now())
else:
S_G_Card(user=user, group=self, is_active=True, is_admin=False,creat_time=datetime.datetime.now()).save()
else:
if S_G_Card.objects(user=user, group=self):
S_G_Card.objects(user=user, group=self).update(set__is_active=True, set__is_admin=True,set__creat_time=datetime.datetime.now())
else:
S_G_Card(user=user, group=self, is_active=True,is_admin=True, creat_time=datetime.datetime.now()).save()
示例3: showtopic
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card 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))
示例4: kick_out
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def kick_out(self,user_url_number):
from accounts.models import Student
from relations.models import S_G_Card
user = Student.objects(url_number=user_url_number).get()
S_G_Card.objects(group=self,user=user).update(set__is_active=False)
示例5: promote
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def promote(self,user_url_number):
from accounts.models import Student
from relations.models import S_G_Card
user = Student.objects(url_number=user_url_number).get()
S_G_Card.objects(group=self,user=user).update(set__is_admin=True)
示例6: get_sgcard_not_admin
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def get_sgcard_not_admin(self):
from relations.models import S_G_Card
return S_G_Card.objects(group=self, is_active=True, is_admin=False)
示例7: get_sgcard_inactive
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def get_sgcard_inactive(self):
from relations.models import S_G_Card
return S_G_Card.objects(group=self, is_active=False)
示例8: get_sgcard_all
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def get_sgcard_all(self):
from relations.models import S_G_Card
return S_G_Card.objects(group=self)
示例9: quitgroup
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def quitgroup(self, user):
from relations.models import S_G_Card
S_G_Card.objects(user=user, group=self, is_active=True).update(set__is_active=False)
示例10: ask_for_admin
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def ask_for_admin(self,user):
from relations.models import S_G_Card
if not self.get_user_admin():
S_G_Card.objects(user=user, group=self, is_active=True).update(set__is_admin=True)
示例11: get_sgcard_admin
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def get_sgcard_admin(self):
from relations.models import S_G_Card
return S_G_Card.objects(user=self, is_active=True, is_admin=True)
示例12: find_group
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def find_group(self):
from relations.models import S_G_Card
return S_G_Card.objects(group__nin=self.get_group_all())
示例13: get_topic_group_active
# 需要導入模塊: from relations.models import S_G_Card [as 別名]
# 或者: from relations.models.S_G_Card import objects [as 別名]
def get_topic_group_active(self):#我關注的小組的話題
from topic.models import Topic
from relations.models import S_G_Card
return Topic.objects(creator__in=S_G_Card.objects(group__in=self.get_group_active()), is_active=True)