Beispiel #1
0
 def delete(self, id):
     from uliweb.utils.generic import DeleteView
     
     obj = self.model.get_or_notfound(int(id))
     view = DeleteView(self.model, obj=obj, 
         ok_url=url_for(BlogView.view, id=int(id)),
         use_delete_field='deleted')
     return view.fun()
Beispiel #2
0
    def delete(self, id):
        from uliweb.utils.generic import DeleteView

        obj = self.model.get_or_notfound(int(id))
        view = DeleteView(self.model,
                          obj=obj,
                          ok_url=url_for(BlogView.view, id=int(id)),
                          use_delete_fieldname='deleted')
        return view.run()
Beispiel #3
0
 def delete(self, id):
     from uliweb.utils.generic import DeleteView
     
     if request.user.is_superuser:
         view = DeleteView('user', condition=int(id), ok_url=get_url('list'))
         return view.run()
     else:
         flash(_('You have no previlege to delete user.'), 'error')
         return redirect(url_for(users_view, id=id))
Beispiel #4
0
 def delete(self, id):
     from uliweb.utils.generic import DeleteView
     
     if request.user.is_superuser:
         view = DeleteView('user', condition=int(id), ok_url=get_url('list'))
         return view.run()
     else:
         flash(_('You have no previlege to delete user.'), 'error')
         return redirect(url_for(users_view, id=id))
Beispiel #5
0
 def delete(self, id):
     """
     Delete a role
     """
     
     from uliweb.utils.generic import DeleteView
     
     obj = self.model.get(int(id))
     view = DeleteView(self.model, url_for(RoleView.list), obj=obj)
     return view.run()
Beispiel #6
0
    def delete(self, id):
        from uliweb.utils.generic import DeleteView

        def validator(obj):
            if obj.author != request.user.id:
                return _("You can't delete this article, because you are not the author")

        obj = self.model.get(int(id))
        view = DeleteView(self.model, url_for(BlogView.list), obj=obj, validator=validator)
        return view.run()
Beispiel #7
0
    def delete(self, id):
        """
        Delete a role
        """

        from uliweb.utils.generic import DeleteView

        obj = self.model.get(int(id))
        view = DeleteView(self.model, url_for(PermissionView.list), obj=obj)
        return view.run()
Beispiel #8
0
def generic_delete(model=None, id=None, obj=None, get_url=get_url, view=None):
    from uliweb.utils.generic import DeleteView

    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 = DeleteView(Model, get_url('list'), obj=obj)

    return view.run()
Beispiel #9
0
def generic_delete(model=None, id=None, obj=None, get_url=get_url, view=None):
    from uliweb.utils.generic import DeleteView
    
    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 = DeleteView(Model, get_url('list'), obj=obj)
        
    return view.run()
Beispiel #10
0
    def delete(self, id):
        from uliweb.utils.generic import DeleteView

        def validator(obj):
            if obj.author != request.user.id:
                return _(
                    "You can't delete this article, because you are not the author"
                )

        obj = self.model.get(int(id))
        view = DeleteView(self.model,
                          url_for(BlogView.list),
                          obj=obj,
                          validator=validator)
        return view.run()
Beispiel #11
0
    def admin_categories_delete(self, id):
        """
        删除板块
        """
        from uliweb.utils.generic import DeleteView

        category = get_model('forumcategory')

        obj = category.get(int(id))

        def validator(obj):
            if obj.forums.all().count() > 0:
                return u"[%s]板块下还存在论坛,请先将论坛删除或转移至其它的板块后再删除" % obj.name

        view = DeleteView(category, obj=obj, validator=validator)
        return view.run(json_result=True)
Beispiel #12
0
 def admin_categories_delete(self, id):
     """
     删除板块
     """
     from uliweb.utils.generic import DeleteView
     
     category = get_model('forumcategory')
     
     obj = category.get(int(id))
     
     def validator(obj):
         if obj.forums.all().count() > 0:
             return u"[%s]板块下还存在论坛,请先将论坛删除或转移至其它的板块后再删除" % obj.name
     
     view = DeleteView(category, obj=obj, validator=validator)
     return view.run(json_result=True)
Beispiel #13
0
    def forumtopictype_delete(self, id):
        """
        删除论坛
        """
        from uliweb.utils.generic import DeleteView

        forumtopictype = get_model("forumtopictype")

        obj = forumtopictype.get(int(id))

        def validator(obj):
            forumtopic = get_model("forumtopic")
            if forumtopic.filter(forumtopic.c.topic_type == int(id)).count() > 0:
                return u"存在此主题类型的贴子,请先将此类型的贴子改为其它的类型后再删除"

        view = DeleteView(forumtopictype, obj=obj, validator=validator)
        return view.run(json_result=True)
Beispiel #14
0
 def forum_delete(self, id):
     """
     删除论坛
     """
     from uliweb.utils.generic import DeleteView
     
     forum = get_model('forum')
     
     obj = forum.get(int(id))
     
     def validator(obj):
         if obj.forum_topics.all().count() > 0:
             return u"[%s]论坛下还存在发贴,请先将发贴删除或转移至其它的论坛后再删除" % obj.name
     
     view = DeleteView(forum, url_for(ForumView.admin_forum), 
         url_for(ForumView.admin_forum),
         obj=obj, validator=validator)
     return view.run(json_result=True)
Beispiel #15
0
    def forumtopictype_delete(self, id):
        """
        删除论坛
        """
        from uliweb.utils.generic import DeleteView

        forumtopictype = get_model('forumtopictype')

        obj = forumtopictype.get(int(id))

        def validator(obj):
            forumtopic = get_model('forumtopic')
            if forumtopic.filter(
                    forumtopic.c.topic_type == int(id)).count() > 0:
                return u"存在此主题类型的贴子,请先将此类型的贴子改为其它的类型后再删除"

        view = DeleteView(forumtopictype, obj=obj, validator=validator)
        return view.run(json_result=True)
Beispiel #16
0
    def category_delete(self, id):
        """
        删除板块
        """
        from uliweb.utils.generic import DeleteView

        category = get_model("forumcategory")

        obj = category.get(int(id))

        def validator(obj):
            if obj.forums.all().count() > 0:
                return u"[%s]板块下还存在论坛,请先将论坛删除或转移至其它的板块后再删除" % obj.name

        view = DeleteView(
            category, url_for(ForumView.admin_category), url_for(ForumView.admin_category), obj=obj, validator=validator
        )
        return view.run()
Beispiel #17
0
 def forumtopictype_delete(self, id):
     """
     删除论坛
     """
     from uliweb.utils.generic import DeleteView
     
     forumtopictype = get_model('forumtopictype')
     
     obj = forumtopictype.get(int(id))
     
     def validator(obj):
         forumtopic = get_model('forumtopic')
         if forumtopic.filter(forumtopic.c.topic_type==int(id)).count() > 0:
             return u"存在此主题类型的贴子,请先将此类型的贴子改为其它的类型后再删除" % obj.name
     
     view = DeleteView(forumtopictype, url_for(ForumView.admin_forumtopictype), 
         url_for(ForumView.admin_forumtopictype),
         obj=obj, validator=validator)
     return view.run()
Beispiel #18
0
    def forum_delete(self, id):
        """
        删除论坛
        """
        from uliweb.utils.generic import DeleteView

        forum = get_model('forum')

        obj = forum.get(int(id))

        def validator(obj):
            if obj.forum_topics.all().count() > 0:
                return u"[%s]论坛下还存在发贴,请先将发贴删除或转移至其它的论坛后再删除" % obj.name

        view = DeleteView(forum,
                          url_for(ForumView.admin_forum),
                          url_for(ForumView.admin_forum),
                          obj=obj,
                          validator=validator)
        return view.run(json_result=True)
Beispiel #19
0
 def delete(self, id):
     from uliweb.utils.generic import DeleteView
     
     obj = self.model.get_or_notfound(int(id))
     view = DeleteView(self.model, obj=obj)
     return view.run(json_result=True)
Beispiel #20
0
    def delete(self, id):
        from uliweb.utils.generic import DeleteView

        obj = self.model.get_or_notfound(int(id))
        view = DeleteView(self.model, obj=obj)
        return view.run(json_result=True)