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


Python Group.objects方法代码示例

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


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

示例1: group

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

示例2: showtopic

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

示例3: group_manage_advance

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

示例4: group

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

示例5: group_manage_edit

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import objects [as 别名]
def group_manage_edit(request,url_number):
    group = Group.objects(url_number=url_number).get()
    if request.method == "POST":
        form = ModifyGroupForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            introduction = form.cleaned_data['introduction']
            group.update(set__name=name, set__introduction=introduction)
            if request.FILES:
                path = 'img/group/' + 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)
                group.thumbnail = MEDIA_URL + filepath_thumbnail
                out.save(MEDIA_ROOT + filepath)
                group.logo = MEDIA_URL + filepath
                
            group.save()
            return HttpResponseRedirect('/group/' + str(url_number) + '/')
    else:
        form = ModifyGroupForm()
        return render_to_response('group/group_manage_edit.html', {'group':group, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
开发者ID:longshenzhu,项目名称:COC,代码行数:49,代码来源:views.py

示例6: group_manage_edit

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import objects [as 别名]
def group_manage_edit(request, url_number):
    group = Group.objects(url_number=url_number).get()
    if request.method == "POST":
        form = ModifyGroupForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]
            introduction = form.cleaned_data["introduction"]
            group.update(set__name=name, set__introduction=introduction)
            if request.FILES:
                path = "img/group/" + 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"
                elif img.mode == "P":
                    filename = "logo.png"
                filepath = "%s/%s" % (path, filename)
                # 获得图像的宽度和高度
                width, height = img.size
                # 计算宽高
                ratio = 1.0 * height / width
                # 计算新的高度
                new_height = int(260 * ratio)
                new_size = (260, new_height)
                # 缩放图像
                out = img.resize(new_size, Image.ANTIALIAS)
                out.save(MEDIA_ROOT + filepath)
                group.logo = MEDIA_URL + filepath

            group.save()
            return HttpResponseRedirect("/group/" + str(url_number) + "/")
    else:
        form = ModifyGroupForm()
        return render_to_response(
            "group/group_manage_edit.html",
            {"group": group, "STATIC_URL": STATIC_URL, "current_user": request.user},
            context_instance=RequestContext(request),
        )
开发者ID:pgwt,项目名称:COC,代码行数:42,代码来源:views.py

示例7: showtopic

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

示例8: kick_out

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

示例9: promote

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

示例10: ask_for_admin

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

示例11: quitgroup

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

示例12: demote

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

示例13: visit_group_structure

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

示例14: entergroup

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


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