Ejemplo n.º 1
0
def modify_honor():
    honor_form = form.HonorForm()
    file_form = form.FileUploadForm()
    honor_form.users.choices = user_server.get_user_choice()
    if honor_form.validate_on_submit():
        try:
            honor = honor_server.get_by_id(honor_form.id.data)
            from dao.dbResource import ResourceLevel, ResourceUsage
            resource_list = []
            for name, file in request.files.items(multi=True):
                if file.filename == '':
                    continue
                file_form.level.data = ResourceLevel.PUBLIC
                file_form.name.data = unicode(file.filename).split('.')[0]
                file_form.usage.data = ResourceUsage.HONOR_RES
                ret = resource_server.save_file(file_form, file, current_user, 'honor')
                if ret == 'OK':
                    resource = resource_server.get_by_name(file_form.name.data)
                    resource_list.append(resource)
            msg = honor_server.modify_honor(honor, honor_form, resource_list)
            return msg
        except:
            current_app.logger.error(traceback.format_exc())
            return 'failed'
    return u'数据填写有误'
Ejemplo n.º 2
0
def modify_honor():
    honor_form = form.HonorForm()
    honor_form.users.choices = user_server.get_user_choice()
    if honor_form.validate_on_submit():
        try:
            msg = honor_server.modify_honor(honor_form)
            return msg
        except:
            return 'failed'
    return u'数据填写有误'