当前位置: 首页>>代码示例>>Python>>正文


Python Corporation.objects方法代码示例

本文整理汇总了Python中models.Corporation.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Corporation.objects方法的具体用法?Python Corporation.objects怎么用?Python Corporation.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Corporation的用法示例。


在下文中一共展示了Corporation.objects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: corporation_manage_department

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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))
开发者ID:longshenzhu,项目名称:COC,代码行数:36,代码来源:views.py

示例2: visit_corporation_topics

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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))
开发者ID:longshenzhu,项目名称:COC,代码行数:29,代码来源:views.py

示例3: showactivity

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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))
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:27,代码来源:views.py

示例4: ask_quitcorporation

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def ask_quitcorporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = S_S_Card.objects.get_or_create(user=request.user, target__in=corporation.get_user_admin)
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='退社申请', content=content, creator=creator, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number).save()
            return HttpResponse('success')
        
    else:
        return HttpResponse('success')
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:15,代码来源:views.py

示例5: visit_corporation_structure

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def visit_corporation_structure(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = [a[0] for a in [S_S_Card.objects.get_or_create(user=request.user, target=admin) for admin in corporation.get_user_admin()]]
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='入社申请', content=content, creator=creator, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number).save()
            S_C_Card(user=request.user,corporation=corporation,is_active=False,is_admin=False).save()
            return HttpResponse('success')
            
            
    else:
        form = NewAskForm()
        return render_to_response('corporation/corporation_structure.html', {'form':form,'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:18,代码来源:views.py

示例6: corporation_manage_edit

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def corporation_manage_edit(request,url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = ModifyCorporationForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            introduction = form.cleaned_data['introduction']
            corporation.update(set__name=name, set__introduction=introduction)
            if request.FILES:
                path = 'img/corporation/' + str(url_number)
                if not os.path.exists(MEDIA_ROOT + path):
                    os.makedirs(MEDIA_ROOT + path)
                
                img = Image.open(request.FILES['logo'])
                if img.mode == 'RGB':
                    filename = 'logo.jpg'
                    filename_thumbnail = 'thumbnail.jpg'
                elif img.mode == 'P':
                    filename = 'logo.png'
                    filename_thumbnail = 'thumbnail.png'
                filepath = '%s/%s' % (path, filename)
                filepath_thumbnail = '%s/%s' % (path, filename_thumbnail)
                # 获得图像的宽度和高度
                width, height = img.size
                # 计算宽高
                ratio = 1.0 * height / width
                # 计算新的高度
                new_height = int(288 * ratio)
                new_size = (288, new_height)
                # 缩放图像
                if new_height >= 288:
                    thumbnail_size = (0,0,288,288)
                else:
                    thumbnail_size = (0,0,new_height,new_height)
                    
                out = img.resize(new_size, Image.ANTIALIAS)
                thumbnail = out.crop(thumbnail_size)
                thumbnail.save(MEDIA_ROOT + filepath_thumbnail)
                corporation.thumbnail = MEDIA_URL + filepath_thumbnail
                out.save(MEDIA_ROOT + filepath)
                corporation.logo = MEDIA_URL + filepath
                
            corporation.save()
            return HttpResponseRedirect('/corporation/' + str(url_number) + '/')
    else:
        form = ModifyCorporationForm()
        return render_to_response('corporation/corporation_manage_edit.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
开发者ID:longshenzhu,项目名称:COC,代码行数:49,代码来源:views.py

示例7: visit_corporation_activity

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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))
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:22,代码来源:views.py

示例8: showtopic

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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))
开发者ID:longshenzhu,项目名称:COC,代码行数:26,代码来源:views.py

示例9: quitcorporation

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def quitcorporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    corporation.quitcorporation(request.user)
    return HttpResponse('success')
开发者ID:longshenzhu,项目名称:COC,代码行数:6,代码来源:views.py

示例10: corporation_manage_advance

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def corporation_manage_advance(request,url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_manage_advance.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
开发者ID:longshenzhu,项目名称:COC,代码行数:5,代码来源:views.py

示例11: visit_corporation_activity

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def visit_corporation_activity(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_activity.html', {'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
开发者ID:longshenzhu,项目名称:COC,代码行数:5,代码来源:views.py

示例12: cancle_watch_corporation

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def cancle_watch_corporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    corporation.diswatch_corporation(request.user)
    return HttpResponse('success')
开发者ID:longshenzhu,项目名称:COC,代码行数:6,代码来源:views.py

示例13: delete

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation 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')
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:8,代码来源:views.py

示例14: kick_out

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def kick_out(request,corporation_url_number,user_url_number):
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    corporation.kick_out(user_url_number)
    return HttpResponse('success')
开发者ID:longshenzhu,项目名称:COC,代码行数:6,代码来源:views.py

示例15: promote

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import objects [as 别名]
def promote(request,corporation_url_number,user_url_number):
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    corporation.promote(user_url_number)
    return HttpResponse('success')
开发者ID:longshenzhu,项目名称:COC,代码行数:6,代码来源:views.py


注:本文中的models.Corporation.objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。