本文整理汇总了Python中relations.models.S_C_Card.objects方法的典型用法代码示例。如果您正苦于以下问题:Python S_C_Card.objects方法的具体用法?Python S_C_Card.objects怎么用?Python S_C_Card.objects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类relations.models.S_C_Card
的用法示例。
在下文中一共展示了S_C_Card.objects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: corporation_manage_department
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def corporation_manage_department(request,url_number):
from accounts.models import Student
corporation = Corporation.objects(url_number=url_number).get()
if request.method == "POST":
if "user_url_number" in request.POST:
form_move = MoveMemberForm(request.POST)
if form_move.is_valid():
department_name = form_move.cleaned_data['department_name']
user_url_number = form_move.cleaned_data['user_url_number']
user = Student.objects(url_number=user_url_number).get()
sccard = S_C_Card.objects(user=user,corporation=corporation).get()
corporation.delete_member_from_department(sccard.department,user_url_number)
corporation.add_member_to_department(department_name,user_url_number)
return HttpResponseRedirect('')
elif "creat_department" in request.POST:
form_creat = CreatDepartmentForm(request.POST)
if form_creat.is_valid():
department_name = form_creat.cleaned_data['department_name']
corporation.creat_department(department_name)
return HttpResponseRedirect('')
elif "delete_department" in request.POST:
form_delete = DeleteDepartmentForm(request.POST)
if form_delete.is_valid():
department_name = form_delete.cleaned_data['department_name']
corporation.delete_department(department_name)
return HttpResponseRedirect('')
else:
form_move = MoveMemberForm()
form_creat = CreatDepartmentForm()
form_delete = DeleteDepartmentForm()
return render_to_response('corporation/corporation_manage_department.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
示例2: visit_corporation_topics
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
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))
示例3: showactivity
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
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))
示例4: entercorporation
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def entercorporation(self, user):
from relations.models import S_C_Card
if self.get_user_admin():
if S_C_Card.objects(user=user, corporation=self):
S_C_Card.objects(user=user, corporation=self).update(set__is_active=True, set__is_admin=False, set__creat_time=datetime.datetime.now())
else:
S_C_Card(user=user, corporation=self, is_active=True, is_admin=False, creat_time=datetime.datetime.now()).save()
else:
if S_C_Card.objects(user=user, corporation=self):
S_C_Card.objects(user=user, corporation=self).update(set__is_active=True, set__is_admin=True, set__creat_time=datetime.datetime.now())
else:
S_C_Card(user=user, corporation=self, is_active=True, is_admin=True, creat_time=datetime.datetime.now()).save()
示例5: visit_corporation_activity
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def visit_corporation_activity(request, url_number):
corporation = Corporation.objects(url_number=url_number).get()
sccard = S_C_Card.objects(corporation=corporation,user=request.user).get()
if request.method == "POST":
form = CreatActivityForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
start_time = form.cleaned_data['start_time']
finish_time = form.cleaned_data['finish_time']
place = form.cleaned_data['place']
max_student = form.cleaned_data['max_student']
pay = form.cleaned_data['pay']
detail = form.cleaned_data['detail']
aurl_number = len(Activity.objects) + 1
activity = Activity(creator=sccard,url_number=aurl_number,name=name,start_time=start_time,finish_time=finish_time,place=place,max_student=max_student,pay=pay,detail=detail,clicks = 0).save()
return HttpResponseRedirect('/corporation/' + str(url_number) + '/activity/' + str(aurl_number) + '/')
else:
form = CreatActivityForm()
return render_to_response('corporation/corporation_activity.html', {'form':form, 'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
示例6: showtopic
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
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))
示例7: kick_out
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def kick_out(self,user_url_number):
from relations.models import S_C_Card
user = Student.objects(url_number=user_url_number).get()
S_C_Card.objects(corporation=self, user=user).update(set__is_active=False)
示例8: promote
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def promote(self,user_url_number):
from relations.models import S_C_Card
user = Student.objects(url_number=user_url_number).get()
S_C_Card.objects(corporation=self, user=user).update(set__is_admin=True)
示例9: delete_member_from_department
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def delete_member_from_department(self, department_name, user_url_number):
user = Student.objects(url_number=user_url_number).get()
from relations.models import S_C_Card
return S_C_Card.objects(user=user, corporation=self).update(set__department="")
示例10: get_sccard_not_admin
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def get_sccard_not_admin(self):
from relations.models import S_C_Card
return S_C_Card.objects(corporation=self, is_active=True, is_admin=False)
示例11: get_sccard_inactive
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def get_sccard_inactive(self):
from relations.models import S_C_Card
return S_C_Card.objects(corporation=self, is_active=False)
示例12: find_corporation
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def find_corporation(self):
from relations.models import S_C_Card
return S_C_Card.objects(corporation__nin=self.get_corporation_all())
示例13: quitcorporation
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def quitcorporation(self, user):
from relations.models import S_C_Card
S_C_Card.objects(user=user, corporation=self, is_active=True).update(set__is_active=False)
示例14: get_sccard_admin
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def get_sccard_admin(self):
from relations.models import S_C_Card
return S_C_Card.objects(user=self, is_active=True, is_admin=True)
示例15: delete
# 需要导入模块: from relations.models import S_C_Card [as 别名]
# 或者: from relations.models.S_C_Card import objects [as 别名]
def delete(request,corporation_url_number,user_url_number):
from accounts.models import Student
corporation = Corporation.objects(url_number=corporation_url_number).get()
user = Student.objects(url_number=user_url_number).get()
S_C_Card.objects(user=user, corporation=corporation).delete()
return HttpResponse('success')