Exemple #1
0
    def edit(self, id):
        """
        编辑分类
        """
        obj = self.model.get_or_notfound(int(id))

        if not functions.has_role(request.user, 'superuser'):
            flash("你无权修改教程", 'error')
            return redirect(url_for(TutorialcateView.read, id=id))

        view = functions.EditView(self.model,
                                  ok_url=url_for(TutorialcateView.read, id=id),
                                  obj=obj)
        return view.run()
Exemple #2
0
 def edit(self, id):
     def success_data(obj, data):
         from uliweb.utils.generic import get_field_display
         
         d = obj.to_dict()
         d['content'] = get_field_display(self.model, 'content', obj)
         return d
        
     obj = self.model.get_or_notfound(int(id))
     view = functions.EditView(self.model, obj=obj, 
         template_data={'title':'修改课程动态'},
         success_data=success_data,
         )
     response.template = 'GenericView/ajax_edit.html'
     return view.run(json_result=True)
Exemple #3
0
    def edit(self, id):
        def success_data(obj, data):
            d = obj.to_dict()
            d['teacher'] = unicode(obj.teacher)
            return d
           
        def post_created_form(fcls, model, obj):
            User = get_model('user')
            fcls.teacher.query = User.filter(User.c.id==obj._teacher_)
        
        obj = self.model.get_or_notfound(int(id))
        view = functions.EditView(self.model, 
            obj=obj, 
#            template_data={'class_id':self.class_id},
            post_created_form=post_created_form,
            success_data=success_data,
            )
        response.template = 'GenericView/ajax_edit.html'
        return view.run(json_result=True)
Exemple #4
0
    def edit(self, id):
        def success_data(obj, data):
            d = obj.to_dict()
            return d
           
        def post_created_form(fcls, model, obj):
            pass
        
        template_data = {}
        
        obj = self.model.get_or_notfound(int(id))
        view = functions.EditView(self.model, 
            ok_url=url_for(self.__class__.list),
            obj=obj, 
            template_data=template_data,
            post_created_form=post_created_form,
            success_data=True,
            )
#        response.template = 'GenericView/edit.html'
        return view.run(json_result=True)
Exemple #5
0
 def edit(self, id):
     def success_data(obj, data):
         from uliweb.utils.generic import get_field_display
         
         d = obj.to_dict()
         d['teachers'] = get_field_display(self.model, 'teachers', obj)
         d['position'] = self._position(d['position'], obj)
         d['type'] = get_field_display(self.model, 'type', obj)
         return d
        
     def post_created_form(fcls, model, obj):
         fcls.teachers.query = obj.teachers
         fcls.map.validators.append(validators.IS_URL)
     
     obj = self.model.get_or_notfound(int(id))
     view = functions.EditView(self.model, obj=obj, 
         template_data={'class_id':self.class_id},
         post_created_form=post_created_form,
         success_data=success_data,
         )
     return view.run(json_result=True)
Exemple #6
0
    def _edit(self, model, obj, json_result=False, **kwargs):
        self._process_fields_convert_map(kwargs)

        view = functions.EditView(model, obj=obj, **kwargs)
        return view.run(json_result=json_result)
Exemple #7
0
def edit(id):
    File = get_model('file')
    obj = File.get(int(id))
    view = functions.EditView(File, obj=obj, ok_url='/list', upload_to='aaa', upload_to_sub='bbb', fileserving_config='UPLOAD_TEST')
    return view.run()