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


Python generic.EditView类代码示例

本文整理汇总了Python中uliweb.utils.generic.EditView的典型用法代码示例。如果您正苦于以下问题:Python EditView类的具体用法?Python EditView怎么用?Python EditView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: edit_post

    def edit_post(self, forum_id, topic_id, post_id):
        """
        修改回复
        """
        from uliweb.utils.generic import EditView
        
        Forum = get_model('forum')
        forum = Forum.get(int(forum_id))
        
        Topic = get_model('forumtopic')
        topic = Topic.get(int(topic_id))
        Post = get_model('forumpost')
        obj = Post.get(int(post_id))
        cur_page = request.values.get('page', 1)
        
        def pre_save(obj, data):
            data['updated_on'] = date.now()

        def post_save(obj, data):
            self._clear_files(obj.slug, data['content'])
        
        def get_form_field(name, obj):
            from uliweb.form import TextField
            if name == 'content':
                return TextField('内容', required=True, convert_html=True, rows=20)
        
        if obj.parent == None:
            anchor = post_id
        else:
            anchor = 'post_'+post_id
        url = '/forum/%s/%s?page=%s#%s' % (forum_id, topic_id, str(cur_page), anchor)
        view = EditView('forumpost', ok_url=url,
            obj=obj, pre_save=pre_save, post_save=post_save, get_form_field=get_form_field, 
            template_data={'forum':forum, 'topic':topic, 'slug':obj.slug, 'anchor':anchor})
        return view.run()
开发者ID:chyhutu,项目名称:plugs,代码行数:35,代码来源:views.py

示例2: generic_edit

def generic_edit(model=None, id=None, obj=None, get_url=get_url, layout='layout.html',
    template=None, title=None, view=None, data=None):
    from uliweb.utils.generic import EditView
    from uliweb import response
    
    if not view:
        Model = get_model(model)
        if not model or not Model:
            return error("Can't find model [%s], please check it" % model)

        if not obj:
            obj = Model.get(Model.c.id == int(id))
        view = EditView(model, get_url('view', id=id), obj=obj)
        
    result = view.run()
    if isinstance(result, dict):
        template = template or 'generic_edit.html'
        response.template = template
        if not title:
            name = getattr(model, '__verbose_name__', '')
            title = _("View") + safe_unicode(name) + ('(#%d)' % id)
        elif callable(title):
            title = title('edit', obj)
        data = data or {}
        result['get_url'] = get_url
        result['title'] = title
        result['obj_id'] = id
        result.update(data)
        return render_template(template, layout, result)
    else:
        return result
开发者ID:chyhutu,项目名称:plugs,代码行数:31,代码来源:views.py

示例3: edit

    def edit(self, id):
        """
        编辑教程
        """
        from uliweb.utils.generic import EditView

        def pre_save(obj, data):
            if request.user.id not in data['authors']:
                data['authors'].append(request.user.id)
            data['modified_date'] = date.now()
            data['modified_user'] = request.user.id

        def post_created_form(fcls, model, obj):
            fcls.authors.html_attrs['url'] = '/users/search'
            fcls.authors.query = obj.authors.all()
        
        obj = self.model.get_or_notfound(int(id))
        
        if not self._can_edit_tutorial(obj):
            flash("你无权修改教程", 'error')
            return redirect(url_for(TutorialView.read, id=id))
        
        view = EditView(self.model, ok_url=url_for(TutorialView.read, id=id), 
            obj=obj, pre_save=pre_save, post_created_form=post_created_form)
        return view.run()
开发者ID:Yixiaohan,项目名称:uliwebzone,代码行数:25,代码来源:views.py

示例4: edit_chapter

    def edit_chapter(self, id):
        """
        编辑章节
        """
        from uliweb.utils.generic import EditView
    
        obj = self.model_chapters.get_or_notfound(int(id))
        old_title = obj.title
        
        if not self._can_edit_tutorial(obj.tutorial):
            flash("你无权添加新章节", 'error')
            return redirect(url_for(TutorialView.view_chapter, id=id))
        
        def pre_save(obj, data):
#            data['content'] = self._prepare_content(data['content'], data['render'])
            data['html'] = self._get_chapter_html(data['content'], data['format'], data['render'], data['scrollable'])
            data['chars_count'] = len(data['content'])
            data['modified_date'] = date.now()
            data['modified_user'] = request.user.id
            
        def post_save(obj, data):
            obj.tutorial.modified_date = date.now()
            obj.tutorial.modified_user = request.user.id
            obj.tutorial.save();
            
            #删除章节顺序cache
            if old_title != obj.title:
                cache = functions.get_cache()
                cache.delete(self._get_tutorial_chapters_cache_key(obj._tutorial_))
        
        view = EditView(self.model_chapters, 
            ok_url=url_for(TutorialView.view_chapter, id=id), 
            obj=obj, pre_save=pre_save, post_save=post_save)
        return view.run()
开发者ID:Yixiaohan,项目名称:uliwebzone,代码行数:34,代码来源:views.py

示例5: edit

    def edit(self, id):
        """
        Edit the role
        """
        
        from uliweb.utils.generic import EditView
        from uliweb.orm import get_model
        
        obj = self.model.get(int(id))
        
#        def get_form_field(name, obj):
#            from uliweb.form import SelectField
#            
#            if name == 'users':
#                choices = [(x.id, x.username) for x in obj.users.all()]
#                return SelectField('用户', name=name, choices=choices, 
#                    multiple=True, html_attrs={'url':'/config/users/search'},
#                    datatype=int)

        fields = [
            {'name':'name', 'verbose_name':_('Name')},
            {'name':'description', 'verbose_name':_('Description')},
        ]

        view = EditView(self.model, url_for(PermissionView.view, id=int(id)), 
            obj=obj, fields=fields)
        return view.run()
开发者ID:limodou,项目名称:plugs,代码行数:27,代码来源:views.py

示例6: edit_image

 def edit_image(self):
     from forms import UploadImageForm
     from uliweb.utils.generic import EditView
     from uliweb.contrib.upload import get_url, get_filename
     import os
     import Image
     
     def pre_save(obj, data):
         if 'image' in data and data['image']:
             data['image'].filename = _get_portrait_image_filename(request.user.id)
             
     image = _get_portrait_image_filename(request.user.id)
     f = get_filename(image)
     if os.path.exists(f):
         url = get_url(image)
         img = Image.open(f)
         template_data = {'image_url':url, 'size':img.size}
     else:
         url = None
         template_data = {'image_url':url, 'size':(0, 0)}
         
     view = EditView('user', condition=request.user.id, ok_url=url_for(UserView.edit_image),
         pre_save=pre_save, fields=['image'], template_data=template_data)
     
     return view.run()
开发者ID:pyhunterpig,项目名称:plugs,代码行数:25,代码来源:views_admin.py

示例7: edit

 def edit(self, id):
     from uliweb.utils.generic import EditView
     
     obj = self.model.get_or_notfound(int(id))
     view = EditView(self.model, 
         ok_url=url_for(BlogView.view, id=int(id)), 
         obj=obj)
     return view.run()
开发者ID:damonchen,项目名称:uliweb-doc,代码行数:8,代码来源:views.py

示例8: edit_topic

    def edit_topic(self, forum_id, topic_id):
        """
        修改主题
        """
        from uliweb.utils.generic import EditView

        Forum = get_model("forum")
        forum = Forum.get(int(forum_id))
        Topic = get_model("forumtopic")
        topic = Topic.get(int(topic_id))
        Post = get_model("forumpost")
        post = Post.get((Post.c.topic == int(topic_id)) & (Post.c.floor == 1))

        # compatiable not saving the first post slug bug
        if not post.slug:
            post.slug = uuid.uuid1().hex
            post.save()

        def post_save(obj, data):
            # 更新Post表
            post.content = data["content"]
            post.save()

            self._clear_files(obj.slug, data["content"])

        def pre_save(obj, data):
            flag = False
            if data["topic_type"] != obj.topic_type:
                flag = True
            if not flag and data["subject"] != obj.subject:
                flag = True
            if not flag and data["content"] != safe_str(post.content):
                flag = True
            if flag:
                data["modified_user"] = request.user.id
                data["updated_on"] = date.now()

        def get_form_field(name, obj):
            from uliweb.form import TextField

            if name == "content":
                return TextField("内容", required=True, rows=20, convert_html=True)

        data = {"content": post.content}
        view = EditView(
            "forumtopic",
            url_for(ForumView.topic_view, forum_id=forum_id, topic_id=topic_id),
            obj=topic,
            data=data,
            pre_save=pre_save,
            hidden_fields=["slug"],
            post_save=post_save,
            get_form_field=get_form_field,
            template_data={"forum": forum, "topic": topic, "slug": post.slug},
        )
        return view.run()
开发者ID:tangjn,项目名称:plugs,代码行数:56,代码来源:views.py

示例9: admin_categories_edit

 def admin_categories_edit(self, id):
     """
     修改板块
     """
     from uliweb.utils.generic import EditView
     
     category = get_model('forumcategory')
     obj = category.get(int(id))
     view = EditView(category, obj=obj, success_data=True)
     return view.run(json_result=True)
开发者ID:qq40660,项目名称:forum2,代码行数:10,代码来源:views.py

示例10: edit

    def edit(self, id):
        from uliweb.utils.generic import EditView
        from forms import EditUserForm

        if request.user.is_superuser:
            view = EditView('user', condition=int(id), ok_url=get_url('view', id=id),
                form_cls=EditUserForm, meta='AdminEditForm')
            return view.run()
        else:
            flash(_('You have no previlege to edit user.'), 'error')
            return redirect(request.referrer)
开发者ID:lypinggan,项目名称:plugs,代码行数:11,代码来源:views_admin.py

示例11: forumtopictype_edit

 def forumtopictype_edit(self, id):
     """
     修改论坛
     """
     from uliweb.utils.generic import EditView
     
     forumtopictype = get_model('forumtopictype')
 
     obj = forumtopictype.get(int(id))
     
     view = EditView('forumtopictype', obj=obj, success_data=True)
     return view.run(json_result=True)
开发者ID:qq40660,项目名称:forum2,代码行数:12,代码来源:views.py

示例12: forumtopictype_edit

 def forumtopictype_edit(self, id):
     """
     修改论坛
     """
     from uliweb.utils.generic import EditView
     
     forumtopictype = get_model('forumtopictype')
 
     obj = forumtopictype.get(int(id))
     
     view = EditView('forumtopictype', url_for(ForumView.admin_forumtopictype), obj=obj)
     return view.run()
开发者ID:pyhunterpig,项目名称:plugs,代码行数:12,代码来源:views.py

示例13: category_edit

    def category_edit(self, id):
        """
        修改板块
        """
        from uliweb.utils.generic import EditView
        
        category = get_model('forumcategory')

        obj = category.get(int(id))
        
        view = EditView('forumcategory', url_for(ForumView.admin_category), obj=obj)
        return view.run()
开发者ID:pyhunterpig,项目名称:plugs,代码行数:12,代码来源:views.py

示例14: edit

    def edit(self, id):
        from uliweb.utils.generic import EditView
        from forms import ApproveEditForm
        from uliweb.form.layout import BootstrapTableLayout

        obj = self.model.get(int(id))
        helper = ApproveHelper()
        helper.bind(obj, get_workflow=True)
        tasks = helper.get_active_tasks()
        if len(tasks) == 1:
            task_id = tasks[0].get_unique_id()
            fields = [{"name": "trans_message", "verbose_name": "流转意见"}]

            if helper.has_deliver_permission(tasks[0], request.user):

                task_name = tasks[0].get_name()

                form_cls = ApproveEditForm().get_form(task_name)
                fields = form_cls.fields
                layout = form_cls.layout
                auto_fill_fields = form_cls.auto_fill_fields
                if hasattr(form_cls, "static_fields"):
                    static_fields = form_cls.static_fields
                else:
                    static_fields = fields[0:-1]

                def pre_save(obj, data):
                    if auto_fill_fields:
                        data[auto_fill_fields[0]] = request.user.id
                        data[auto_fill_fields[1]] = datetime.datetime.now()

                def post_created_form(fcls, model, obj):
                    fcls.layout_class_args = {"table_class": "table width100"}
                    fcls.layout_class = BootstrapTableLayout

                view = EditView(
                    self.model,
                    url_for(self.__class__.view, id=id),
                    fields=fields,
                    static_fields=static_fields,
                    post_created_form=post_created_form,
                    obj=obj,
                    pre_save=pre_save,
                    layout=layout,
                )
                return view.run()
            else:
                flash(u"您没有权限访问编辑填写功能。")
                return redirect(url_for(ApproveView.view, id=id))
        else:
            flash(u"您没有权限访问编辑填写功能。")
            return redirect(url_for(ApproveView.view, id=id))
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:52,代码来源:views.py

示例15: forum_edit

    def forum_edit(self, id):
        """
        修改论坛
        """
        from uliweb.utils.generic import EditView

        forum = get_model("forum")

        obj = forum.get(int(id))

        def post_created_form(fcls, model, obj):
            fcls.managers.html_attrs["url"] = "/config/users/search"
            fcls.managers.query = obj.managers.all()

        view = EditView("forum", url_for(ForumView.admin_forum), obj=obj, post_created_form=post_created_form)
        return view.run()
开发者ID:datakungfu,项目名称:plugs,代码行数:16,代码来源:views.py


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