From 9f039a49aa9b113e9e090bda5d874f02f2951a65 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 2 Aug 2019 16:45:17 +0800 Subject: [PATCH 1/2] add delete course tiding --- app/controllers/courses_controller.rb | 2 ++ app/decorators/tiding_decorator.rb | 6 +++++- config/locales/tidings/zh-CN.yml | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index abc3e4856..9f62a03bb 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -234,6 +234,8 @@ class CoursesController < ApplicationController def destroy if @course.is_delete == 0 @course.delete! + Tiding.create!(user_id: @course.tea_id, trigger_user_id: 1, container_id: @course.id, + container_type: 'Course', tiding_type: 'Delete', extra: @course.name) normal_status(0, "成功") else normal_status(-1, "课堂已删除,无需重复操作") diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index 677812217..c7d914089 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -126,7 +126,11 @@ module TidingDecorator end def course_content - I18n.t(locale_format) % container.name + if tiding_type == 'Delete' + I18n.t(locale_format(tiding_type)) % extra + else + I18n.t(locale_format) % container.name + end end def shixun_content diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index 21d2d0879..e00407b28 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -55,6 +55,8 @@ "2_end": "你提交的试用授权申请,审核未通过
原因:%{reason}" Apply_end: "提交了试用授权申请" Course_end: "成功创建了课堂:%s" + Course: + Delete_end: "你删除了课堂:%s" Shixun_end: "成功创建了实训:%s" Subject_end: "成功创建了实训课程:%s" ArchiveCourse_end: "你的课堂已经归档:%s" From b5e9c29b772c41ea8686349205d746ee939fddc6 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 2 Aug 2019 16:47:25 +0800 Subject: [PATCH 2/2] modify user update account api check --- app/forms/users/update_account_form.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/forms/users/update_account_form.rb b/app/forms/users/update_account_form.rb index d82459fcf..16c3c8013 100644 --- a/app/forms/users/update_account_form.rb +++ b/app/forms/users/update_account_form.rb @@ -5,8 +5,8 @@ class Users::UpdateAccountForm attr_accessor :nickname, :name, :show_realname, :gender, :location, :location_city, :identity, :student_id, :technical_title, :school_id, :department_id - validates :nickname, presence: true - validates :name, presence: true + validates :nickname, presence: true, length: { maximum: 20 } + validates :name, presence: true, length: { maximum: 10 } validates :gender, presence: true, numericality: { only_integer: true }, inclusion: { in: [0, 1] } validates :location, presence: true validates :location_city, presence: true