From 8f1946711528b6456521a3d44a26511d8087031b Mon Sep 17 00:00:00 2001 From: whimlex Date: Sat, 31 Jan 2015 17:18:07 +0800 Subject: [PATCH 01/26] =?UTF-8?q?=E8=8B=B1=E6=96=87=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 111 ++++++++++++++++++++++++++++++------------ config/locales/zh.yml | 77 ++++++++++++++++++----------- 2 files changed, 127 insertions(+), 61 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index cb89070ff..b21793f57 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -161,13 +161,8 @@ en: label_approve: Approve label_refusal: Refusal notice_account_updated: Account was successfully updated. - notice_account_invalid_creditentials: Invalid user or password - notice_account_password_updated: Password was successfully updated. notice_account_wrong_password: Wrong password notice_account_register_done: Account was successfully created. To activate your account, click on the link that was emailed to you. - notice_account_unknown_email: Unknown user. - notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password. - notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you. notice_account_activated: Your account has been activated. You can now log in. notice_successful_create: Successful creation. notice_successful_update: Successful update. @@ -243,7 +238,6 @@ en: field_is_required: Required field_firstname: Name field_lastname: Last name - field_mail: Email field_job_category: Job category # added by bai field_filename: File field_file_dense: File Dense @@ -279,14 +273,11 @@ en: field_homepage: Homepage field_parent: Subproject of field_is_in_roadmap: Issues displayed in roadmap - field_login: Account/Email field_mail_notification: Email notifications field_admin: Administrator field_last_login_on: Last connection field_language: Language field_effective_date: Date - field_new_password: New password - field_password_confirmation: Confirmation field_version: Version field_type: Type field_host: Host @@ -646,7 +637,6 @@ en: label_information: Information label_information_plural: Information label_please_login: Please log in - label_login_with_open_id_option: or login with OpenID label_home: Home label_my_page: My page label_my_account: My account @@ -655,9 +645,6 @@ en: label_my_page_block: My page block label_administration: Administration label_login: Login - # edit by meng - # Logout - label_logout: Logout # end label_help: Help label_reported_issues: Reported issues @@ -1018,8 +1005,6 @@ en: label_gantt_progress_line: Progress line label_files_filter: Files Filter: - button_submit: Submit - button_save: Save button_check_all: Check all button_uncheck_all: Uncheck all button_collapse_all: Collapse all @@ -1099,7 +1084,6 @@ en: text_tip_issue_end_day: issue ending this day text_tip_issue_begin_end_day: issue beginning and ending this day text_caracters_maximum: "%{count} characters maximum." - text_caracters_minimum: "Must be at least %{count} characters long." text_length_between: "Length between %{min} and %{max} characters." text_tracker_no_workflow: No workflow defined for this tracker text_unallowed_characters: Unallowed characters @@ -1438,7 +1422,6 @@ en: label_tags_user_mail: User E-mail: label_tags_user_name: User Name: label_tags_numbers: Tag numbers: - label_max_number: Open label nickname is displayed on the web site of your,Must be at most 25 characters long. label_all_revisions: All revisions: label_repository_name: Repository name label_upassword_info: The password can be shared in the group @@ -1734,7 +1717,6 @@ en: label_your_course: your course label_have_message : have a new message - label_login_prompt: Email/NickName :lable_not_receive_mail: Click here don't receive email form site! #added by linchun as competition# @@ -1756,17 +1738,83 @@ en: # edit by meng # Trustie账户> 登陆 lable_user_name: Username + label_login_prompt: Email/Trustie account field_password: Password field_identity_url: OpenID URL - label_stay_logged_in: Keep me signed in - label_password_lost: Forget password? + label_stay_logged_in: "Keep me signed in" + label_password_lost: "Forget password?" button_login: Login + # account_controller中判断用户名或密码输入有误的提示信息 + notice_account_invalid_creditentials: "Invalid user or password." + # account_controller中判断未激活的提示信息 + notice_account_invalid_creditentials_new: "Please check your email to activate your account." # Trustie账户> 注册 + # 页面中密码和确认密码不一致信息,正则判断,邮件地址合法等信息由application_helper中error_messages_for方法来判断提示信息 + # rails本身机制ActiveRecord提供 + # 在model层的 validates_方法进行辅助验校 + # 其输出的提示信息在国际化yml中的activerecord中配置 label_register: Sign up + label_login_with_open_id_option: or login with OpenID + field_login: Account/Email + label_max_number: "Trustie username is your public identity displayed on Trustie website, only for letters and numbers." + field_password: Password + text_caracters_minimum: "Must be at least %{count} characters long." + field_password_confirmation: Confirmation + field_mail: Email + label_mail_attention: "QQ-mail may not receive this e-mail, if other mailboxes not received, probably in spam." + label_mail_attention1: "Activation email sent for Gmail and Edu-mail which sometimes slower, please be patient." + button_submit: Submit + # register中js判断密码设置是否合法提示信息 + setting_password_min_length_limit: "Password length greater than at least %{count} characters." + setting_password_error: "Password length inadequate or password inconsistent." + setting_password_success: "Password set successfully." + # account_controller中register方法判断注册成功的提示信息 + notice_account_register_done: "Successful account creation, please use the link in the registration confirmation email to activate your account, if our messages are not in your inbox, it could in the spam box, please check it carefully." + + + # Trustie账户模块 > 忘记密码 + label_password_forget: Forget password + # field_mail: 邮件地址 + # (Trustie账户模块> 注册)变量 + # button_submit: 提交 + # (Trustie账户模块> 注册 )变量 + notice_account_unknown_email: Unknown user + # account_controller中lost_password方法判断的邮件发送提示信息 + notice_account_lost_email_sent: "An email with a temporary login link will be sent to that email address, which you can use to login and configure a new password." + + + # Trustie账户模块 > 重置密码 + # label_password_forget: 忘记密码 + # (Trustie账户模块> 忘记密码)变量 + field_new_password: New password + # text_caracters_minimum: "至少需要 %{count} 个字符。" + # (Trustie账户模块> 注册)变量 + # field_password_confirmation: 密码确认 + # (Trustie账户模块> 注册)变量 + notice_account_password_updated: "Password was successfully updated." + notice_can_t_change_password: "This account uses an external authentication source. Impossible to change the password." + button_save: Save + + + # Trustie账户模块 > 登出 + label_logout: Logout + + + # Trustie账户模块 > 激活 + label_regiter_account: Registering for an account + label_email_valid: E-mail activation + notice_email_register_time: "Please click on the link in the email to continue to complete the registration within 24 hours" + notice_email_arrival: "An activation email has been sent to the email address you register." + label_check_email: "Now check your email" + label_mail_resend: "Resend the activation email" + notice_account_activated: "Your Trustie account has been activated." + + + # 托管平台主页 # edit by meng # 托管平台主页> 顶部菜单 @@ -1807,18 +1855,18 @@ en: label_rights_reserved: ©2007~2014 label_contact_us: Contact # 英文版不需要显示国内许可证 ,需要页面做判断 - #label_license: 湘ICP备09019772 + # label_license: 湘ICP备09019772 # 项目托管平台 - # 项目托管平台主页 >主旨 + # 项目托管平台主页 > 主旨 label_project_trustie: label_project_trustie_theme: - # 项目托管平台主页 >热门项目栏 + # 项目托管平台主页 > 热门项目栏 lable_hot_projects: Hot Projects label_project_new: New project label_join_project: Join a project @@ -1827,7 +1875,7 @@ en: label_project_score_tips: "Considering all activities of the project, project's score reflects the activity level of project" label_project_score: Score - # 项目托管平台主页 >用户动态栏 + # 项目托管平台主页 > 用户动态栏 lable_user_active: User Movements field_user_active_published: released field_user_active_uploaded: uploaded @@ -1854,7 +1902,7 @@ en: # "缺陷 #1869 (已解决):subject" # tracker.name和status在数据库中以中文字段形式存储 - # 项目托管平台主页 >贴吧动态栏 + # 项目托管平台主页 > 贴吧动态栏 lable_bar_active: Bar Posts label_my_question: My-question label_my_feedback: My-feedback @@ -1864,7 +1912,7 @@ en: label_final_reply: Last-reply - # 项目托管平台 >新建项目 + # 项目托管平台 > 新建项目 label_project_new_description: "A project can be used to do anything that requires distributed collaboration." field_name: Name field_description: Description @@ -1876,7 +1924,7 @@ en: button_create: Create - # 项目托管平台 >加入项目 + # 项目托管平台 > 加入项目 @@ -1886,17 +1934,17 @@ en: # 课程托管平台主页 - # 课程托管平台主页 >主旨 + # 课程托管平台主页 > 主旨 label_course_trustie: label_course_trustie_theme: - # 课程托管平台主页 > + # 课程托管平台主页 > # 竞赛托管平台主页 - # 竞赛托管平台主页 >主旨 + # 竞赛托管平台主页 > 主旨 label_contest_trustie: label_contest_trustie_theme: - # 竞赛托管平台主页 > + # 竞赛托管平台主页 > # edit by meng @@ -2062,7 +2110,6 @@ en: modal_valid_passing: can be used. label_company_name: Company Name - notice_account_invalid_creditentials_new: You have not to the mailbox activation label_school_no_course: The school did not offer any courses, you can view other school curriculum label_school_less_course: The school offers courses in less, you can view other school curriculum label_file_not_found: Sorry, the file can't be downloaded now! diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 6afc95979..b7a0dad4f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -602,7 +602,6 @@ zh: label_information: 信息 label_information_plural: 信息 label_please_login: 请登录 - label_login_with_open_id_option: 或使用OpenID登录 label_home: 主页 label_web_title: 浏览器标题 label_site_title: 网站标题 @@ -690,7 +689,6 @@ zh: label_my_projects: 我的项目 label_my_page_block: 我的工作台模块 label_administration: 管理 - label_login: 登录 label_help: 帮助 label_reported_issues: 已报告的问题 label_assigned_to_me_issues: 指派给我的问题 @@ -2144,13 +2142,13 @@ zh: label_login_prompt: 邮箱/登录名 field_password: 密码 field_identity_url: OpenID URL - label_stay_logged_in: 保持登录状态 - label_password_lost: 忘记密码? + label_stay_logged_in: "保持登录状态" + label_password_lost: "忘记密码?" button_login: 登录 # account_controller中判断用户名或密码输入有误的提示信息 - notice_account_invalid_creditentials: 无效的用户名或密码 + notice_account_invalid_creditentials: "无效的用户名或密码" # account_controller中判断未激活的提示信息 - notice_account_invalid_creditentials_new: 您还未到邮箱激活 + notice_account_invalid_creditentials_new: "您还未到邮箱激活" # Trustie账户模块> 注册 @@ -2161,23 +2159,23 @@ zh: label_register: 注册 label_login_with_open_id_option: 或使用OpenID登录 field_login: 登录名 - label_max_number: 登录名是在网站中显示的您的公开标识,只能为英文和数字。 + label_max_number: "登录名是在网站中显示的您的公开标识,只能为英文和数字。" field_password: 密码 text_caracters_minimum: "至少需要 %{count} 个字符。" field_password_confirmation: 密码确认 field_mail: 邮件地址 - label_mail_attention: qq邮箱可能收不到此邮件,其他邮箱如果没有收到可能在垃圾邮件中, - label_mail_attention1: 其中gmail与教育网邮箱的激活邮件有时比较慢,请耐心等待。 + label_mail_attention: "qq邮箱可能收不到此邮件,其他邮箱如果没有收到可能在垃圾邮件中," + label_mail_attention1: "其中gmail与教育网邮箱的激活邮件有时比较慢,请耐心等待。" button_submit: 提交 # register中js判断密码设置是否合法提示信息 setting_password_min_length_limit: "密码长度至少大于 %{count} 个字符。" - setting_password_error: 密码长度不够或密码不一致 - setting_password_success: 密码设置成功 + setting_password_error: "密码长度不够或密码不一致" + setting_password_success: "密码设置成功" # account_controller中register方法判断注册成功的提示信息 - notice_account_register_done: 帐号创建成功,请使用注册确认邮件中的链接来激活您的帐号, 如果您的邮件没有在收件箱中可能在垃圾箱中,请您注意查收。 + notice_account_register_done: "帐号创建成功,请使用注册确认邮件中的链接来激活您的帐号,如果您的邮件没有在收件箱中可能在垃圾箱中,请您注意查收。" - # Trustie账户模块 >忘记密码 + # Trustie账户模块 > 忘记密码 label_password_forget: 忘记密码 # field_mail: 邮件地址 # (Trustie账户模块> 注册)变量 @@ -2188,7 +2186,7 @@ zh: notice_account_lost_email_sent: 系统已将引导您设置新密码的邮件发送给您。 - # Trustie账户模块 >重置密码 + # Trustie账户模块 > 重置密码 # label_password_forget: 忘记密码 # (Trustie账户模块> 忘记密码)变量 field_new_password: 新密码 @@ -2201,11 +2199,11 @@ zh: button_save: 保存 - # Trustie账户模块 >登出 + # Trustie账户模块 > 登出 label_logout: 退出 - # Trustie账户模块 >激活 + # Trustie账户模块 > 激活 label_regiter_account: 注册帐号 label_email_valid: 邮箱激活 notice_email_register_time: 请在24小时内点击邮件中的链接继续完成注册 @@ -2217,9 +2215,25 @@ zh: - # 托管平台主页 + # Trustie个人主页 + # edit by meng + # Trustie个人主页> + + + + + + + + + + + + + + # Trustie托管平台主页 # edit by meng - # 托管平台主页> 顶部菜单> + # 托管平台主页> 顶部菜单 field_homepage: 主页 label_project_deposit: 项目托管 label_course_practice: 课程实践 @@ -2228,9 +2242,14 @@ zh: label_contest_innovate: 创新竞赛 label_software_user: 软件创客 label_requirement_enterprise: 软件众包 - label_stores_index: 资源搜索 + label_stores_index: 资源搜索 + # 托管平台主页> 顶部菜单> 账户信息 + # (Trustie账户模块> 注册)变量 + # label_register: 注册 + label_login: 登录 + # (Trustie账户模块> 登出)变量 + # label_logout: 退出 - # 托管平台主页> 顶部菜单> @@ -2268,11 +2287,11 @@ zh: # 项目托管平台主页 - # 项目托管平台主页 >主旨 + # 项目托管平台主页 > 主旨 label_project_trustie: Trustie在线项目托管平台 label_project_trustie_theme: ", 面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" - # 项目托管平台主页 >热门项目栏 + # 项目托管平台主页 > 热门项目栏 lable_hot_projects: 热门项目 label_project_new: 新建项目 label_join_project: 加入项目 @@ -2281,7 +2300,7 @@ zh: label_project_score_tips: 项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度 label_project_score: 项目评分 - # 项目托管平台主页 >用户动态栏 + # 项目托管平台主页 > 用户动态栏 lable_user_active: 用户动态 field_user_active_published: 发表了 field_user_active_uploaded: 上传了 @@ -2306,7 +2325,7 @@ zh: # "缺陷 #1869 (已解决):subject" # 而tracker.name和status在数据库中以中文字段形式存储 - # 项目托管平台主页 >用户动态栏 + # 项目托管平台主页 > 用户动态栏 lable_bar_active: 贴吧动态 label_my_question: 我要提问 label_my_feedback: 我要反馈 @@ -2316,7 +2335,7 @@ zh: label_final_reply: 最后回复 - # 项目托管平台 >新建项目 + # 项目托管平台 > 新建项目 label_project_new_description: '项目可以是软件开发项目,也可以是协作研究项目。' field_name: 名称 field_description: 描述 @@ -2327,7 +2346,7 @@ zh: field_hidden_repo: 隐藏代码库 button_create: 提交 - # 项目托管平台 >加入项目 + # 项目托管平台 > 加入项目 @@ -2335,7 +2354,7 @@ zh: # 课程托管平台 - # 课程托管平台主页 >主旨 + # 课程托管平台主页 > 主旨 label_course_trustie: Trustie在线课程实践平台 label_course_trustie_theme: ", 面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" # 课程托管平台主页 > @@ -2345,7 +2364,7 @@ zh: # 竞赛托管平台 - # 竞赛托管平台主页 >主旨 + # 竞赛托管平台主页 > 主旨 label_contest_trustie: Trustie在线竞赛实战平台 label_contest_trustie_theme: ", 面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" # 竞赛托管平台主页 > @@ -2355,7 +2374,7 @@ zh: # 邮件系统 - # 邮件 >激活邮件 + # 邮件 > 激活邮件 # edit by meng # 邮件中文格式 mail_issue_greetings: "亲爱的Trustie用户,您好!" From 9708c50899dc5dc6f1594295a8568613f9cd7917 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 3 Feb 2015 15:10:21 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E8=AF=84=E5=88=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/homeworks.rb | 26 ++++++++++++++++++ app/services/homework_service.rb | 46 +++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb index cba295064..7a8c87987 100644 --- a/app/api/mobile/apis/homeworks.rb +++ b/app/api/mobile/apis/homeworks.rb @@ -70,6 +70,32 @@ module Mobile present :status, 0 end + desc "作品打分" + params do + requires :token, type: String + requires :is_teacher, type: String,desc: '是否为教师(匿评作品详情返回的结果中可获取此参数的值)' + requires :is_anonymous_comments, type: String, desc: '是否为匿评(匿评作品详情返回的结果中可获取此参数的值)' + optional :stars_value, type: Integer,desc: '用户给出的评分' + optional :cur_page,type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值' + optional :cur_type, type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值' + optional :user_message, type: String, desc: '用户评论' + end + + post ':homework_id/scoring' do + cs_params = { + new_form: params.reject{|k,v| [:token,:is_teacher,:is_anonymous_comments,:stars_value,:cur_page,:cur_type,:homework_id].include?(k)}, + token: params[:token], + is_teacher: params[:is_teacher], + is_anonymous_comments: params[:is_anonymous_comments], + stars_value: params[:stars_value], + cur_page: params[:cur_page], + cur_type: params[:cur_type], + homework_id: params[:homework_id] + } + Homeworks.get_service.add_score_and_jour cs_params,current_user + present :status, 0 + end + end end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index a2c063e15..abf89229c 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -141,16 +141,56 @@ class HomeworkService end #作品打分/留言 - def add_score_and_jour params + def add_score_and_jour params,current_user @is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value] @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 @homework = HomeworkAttach.find(params[:homework_id]) + comment_status = @homework.bid.comment_status + if @is_anonymous_comments && comment_status != 1 + case comment_status + when 0 + raise '尚未开启匿评!' + when 2 + raise '匿评已结束!' + end + end + if @is_anonymous_comments && ((@m_score.nil? || @m_score.blank?) || !(params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "")) + raise '您尚未打分或评论!' + end #保存评分 - @homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score + homework = @homework + is_teacher = @is_teacher ? 1 : 0 + #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) + if @m_score + rate = @homework.rates(:quality).where(:rater_id => current_user.id, :is_teacher_score => is_teacher).first + if rate + rate.stars = @m_score + rate.save! + else + @homework.rates(:quality).new(:stars => @m_score, :rater_id => current_user.id, :is_teacher_score => is_teacher).save! + end + + if homework.is_teacher_score == 0 + if is_teacher == 1 + homework.score = @m_score + homework.is_teacher_score = 1 + else + sql = "SELECT AVG(stars) as stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id}" + score= HomeworkAttach.find_by_sql(sql).first.stars + homework.score = score + end + else + if is_teacher == 1 + homework.score = @m_score + homework.is_teacher_score = 1 + end + end + homework.save! + end #保存评论 @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言 - @homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation + @homework.addjours current_user.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation end end From 8bef9420cfc543fe0adb847d458ca0094a98e81b Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 3 Feb 2015 15:22:45 +0800 Subject: [PATCH 03/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E7=89=88=E4=B8=AD=E8=87=AA=E5=B7=B1=E8=83=BD=E7=9C=8B=E5=88=B0?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E7=A7=81=E6=9C=89=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 2 +- config/locales/zh.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9001546dc..3ae5538e9 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -29,7 +29,7 @@ class WelcomeController < ApplicationController unless params[:organization].nil? @cur_projects = Project.find(params[:organization]) @organization = @cur_projects.enterprise_name - @organization_projects = current_user.admin? ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization) + @organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization) @e_count = @organization_projects.count @part_projects = [] # 取十个 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7187c70d3..15ab84133 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2520,9 +2520,9 @@ zh: # 项目企业模块 - label_all_enterprises: 所有企业 + label_all_enterprises: 所有组织 label_my_enterprise: 我的企业 - label_enterprise_tips: 暂时还没有该企业对应的项目,系统的其它项目您可能会感兴趣! - label_part_enterprise_tips: 您可能对系统的其它项目会感兴趣! - label_enterprise_nil: 该模块为最新上线模块,目前还未有项目关联到企业! + label_enterprise_tips: 该组织暂时还没创建公开项目,您可能会对系统的其它项目感兴趣! + label_part_enterprise_tips: 您可能对系统的其它项目感兴趣! + label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目! label_enterprises: 组织 From 87e658a0f1367a73afaf5f2e1abd243054a3b0ac Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 3 Feb 2015 15:46:17 +0800 Subject: [PATCH 04/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=8C=BF=E8=AF=84=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E5=90=8E=E4=BE=9D=E7=84=B6=E5=8F=AF=E4=BB=A5=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=EF=BC=88=E5=B1=9E=E4=BA=8E=E7=95=99=E8=A8=80=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/homework_service.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index abf89229c..b468e1110 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -146,13 +146,8 @@ class HomeworkService @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 @homework = HomeworkAttach.find(params[:homework_id]) comment_status = @homework.bid.comment_status - if @is_anonymous_comments && comment_status != 1 - case comment_status - when 0 - raise '尚未开启匿评!' - when 2 - raise '匿评已结束!' - end + if @is_anonymous_comments && comment_status == 0 + raise '尚未开启匿评!' end if @is_anonymous_comments && ((@m_score.nil? || @m_score.blank?) || !(params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "")) raise '您尚未打分或评论!' From 8216453a027f9486229244ab42a51a18f3642821 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 3 Feb 2015 16:03:30 +0800 Subject: [PATCH 05/26] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0comment=5Fstatus=E5=AD=97=E6=AE=B5=200:?= =?UTF-8?q?=E6=89=80=E5=B1=9E=E4=BD=9C=E4=B8=9A=E5=B0=9A=E6=9C=AA=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=8C=BF=E8=AF=84=EF=BC=8C1=EF=BC=9A=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E4=B8=AD=202=EF=BC=9A=E5=8C=BF=E8=AF=84=E7=BB=93?= =?UTF-8?q?=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/homework_attach.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/api/mobile/entities/homework_attach.rb b/app/api/mobile/entities/homework_attach.rb index 256dcdf61..690ec8e94 100644 --- a/app/api/mobile/entities/homework_attach.rb +++ b/app/api/mobile/entities/homework_attach.rb @@ -17,6 +17,8 @@ module Mobile case field when :homework_times f.bid.courses.first.homeworks.index(f.bid) + 1 unless (f.bid.nil? || f.bid.courses.nil? || f.bid.courses.first.nil?) + when :comment_status + f.bid.comment_status end end end @@ -28,6 +30,8 @@ module Mobile homework_attach_expose :homework_times homework_attach_expose :description homework_attach_expose :created_at + #comment_status 0:所属作业尚未开启匿评,1:匿评中 2:匿评结束 + homework_attach_expose :comment_status expose :attachments,using: Mobile::Entities::Attachment do |f, opt| if f.respond_to?(:attachments) f.send(:attachments) From 6d79c2cf83f6322c35df3ce0b4c502876356b70a Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Feb 2015 11:57:37 +0800 Subject: [PATCH 06/26] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=AB=AF=EF=BC=A1?= =?UTF-8?q?=EF=BC=B0=EF=BC=A9=E6=B7=BB=E5=8A=A0=E6=96=B0=E9=97=BB=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=AE=9E=E4=BD=93Comment=EF=BC=8C=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E4=B8=AD=E5=BC=95=E7=94=A8Comment,=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E6=96=B0=E9=97=BB=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E8=AF=A5=E6=8E=A5=E5=8F=A3=E4=B8=8D=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 22 ++++++++++++++++++++++ app/api/mobile/apis/courses.rb | 3 ++- app/api/mobile/entities/comment.rb | 30 ++++++++++++++++++++++++++++++ app/api/mobile/entities/news.rb | 6 +++++- app/services/comment_service.rb | 12 ++++++++++++ app/services/courses_service.rb | 7 +++++-- 6 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 app/api/mobile/apis/comments.rb create mode 100644 app/api/mobile/entities/comment.rb create mode 100644 app/services/comment_service.rb diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb new file mode 100644 index 000000000..fb6d01fb4 --- /dev/null +++ b/app/api/mobile/apis/comments.rb @@ -0,0 +1,22 @@ +#coding=utf-8 +module Mobile + module Apis + class Comments < Grape::API + resource :comments do + desc '课程通知评论' + params do + requires :token, type: String + requires :comment, type: String + end + post ':id' do + cs = CommentService.new + comments = cs.news_comments params,current_user + raise "create comments failed #{comments.errors.full_messages}" if comments.new_record? + present :data, comments, with: Mobile::Entities::Comment + present :status, 0 + end + + end + end + end +end \ No newline at end of file diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 7c1aa5e7e..2e678bad4 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -188,10 +188,11 @@ module Mobile desc "课程通知列表" params do + optional :token, type: String end get ":course_id/news" do cs = CoursesService.new - news = cs.course_news_list params + news = cs.course_news_list params,current_user.nil? ? User.find(2):current_user present :data, news, with: Mobile::Entities::News present :status, 0 end diff --git a/app/api/mobile/entities/comment.rb b/app/api/mobile/entities/comment.rb new file mode 100644 index 000000000..803d0c6d0 --- /dev/null +++ b/app/api/mobile/entities/comment.rb @@ -0,0 +1,30 @@ +module Mobile + module Entities + class Comment < Grape::Entity + include Redmine::I18n + def self.comment_expose(field) + expose field do |f,opt| + if f.is_a?(Hash) && f.key?(field) + f[field] + elsif f.is_a?(::Comment) + if f.respond_to?(field) + if field == :created_on + format_time(f.send(field)) + else + f.send(field) + end + end + end + end + end + comment_expose :id + expose :author, using: Mobile::Entities::User do |c, opt| + if c.is_a? ::Comment + c.author + end + end + comment_expose :comments + comment_expose :created_on + end + end +end \ No newline at end of file diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 7c77f8c82..406db59e4 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -34,7 +34,11 @@ module Mobile #评论数量 news_expose :comments_count #评论 - news_expose :comments + expose :comments, using: Mobile::Entities::Comment do |f, opt| + if f.is_a?(Hash) && f.key?(:comments) + f[:comments] + end + end end diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb new file mode 100644 index 000000000..b6727a941 --- /dev/null +++ b/app/services/comment_service.rb @@ -0,0 +1,12 @@ +class CommentService + #评论 + def news_comments params,current_user + raise Unauthorized unless @news.commentable? + @news = News.find(params[:id]) + @comment = Comment.new + @comment.safe_attributes = params[:comment] + @comment.author = current_user + @news.comments << @comment + @comment + end +end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 41b6f2c68..afd674610 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -106,11 +106,14 @@ class CoursesService end #课程通知列表 - def course_news_list params + def course_news_list params,current_user if params[:course_id] && @course==nil @course = Course.find(params[:course_id]) end - scope = @course ? @course.news.course_visible : News.course_visible + if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) + raise '403' + end + scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user) news = [] scope.each do |n| news << {:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count} From 3cd97f8a7013c7e7f407b60d4e1b24cf60710d46 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Feb 2015 13:47:52 +0800 Subject: [PATCH 07/26] =?UTF-8?q?API=E6=B7=BB=E5=8A=A0comment=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index bee78a20e..bad8c1a77 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -6,6 +6,7 @@ module Mobile require_relative 'apis/watches' require_relative 'apis/upgrade' require_relative 'apis/homeworks' + require_relative 'apis/comments' class API < Grape::API version 'v1', using: :path format :json @@ -37,6 +38,7 @@ module Mobile mount Apis::Watches mount Apis::Upgrade mount Apis::Homeworks + mount Apis::Comment #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? From 4fdc1b97a5022185d322c32a92fecab8d4594721 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Feb 2015 14:07:00 +0800 Subject: [PATCH 08/26] =?UTF-8?q?=E9=85=8D=E7=BD=AEAPI=20comment=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=AD=A3=E6=98=BE=E7=A4=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=80=9A=E7=9F=A5=E6=8E=A5=E5=8F=A3=E6=9C=AA=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- app/api/mobile/apis/courses.rb | 2 +- app/services/comment_service.rb | 2 +- app/services/courses_service.rb | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index bad8c1a77..8f7f0342f 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -38,7 +38,7 @@ module Mobile mount Apis::Watches mount Apis::Upgrade mount Apis::Homeworks - mount Apis::Comment + mount Apis::Comments #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 2e678bad4..8f8c08c3f 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -199,7 +199,7 @@ module Mobile desc "显示课程通知" params do - + optional :token, type: String end get "news/:id" do cs = CoursesService.new diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index b6727a941..23f4355e6 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -1,8 +1,8 @@ class CommentService #评论 def news_comments params,current_user - raise Unauthorized unless @news.commentable? @news = News.find(params[:id]) + raise Unauthorized unless @news.commentable? @comment = Comment.new @comment.safe_attributes = params[:comment] @comment.author = current_user diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index afd674610..77b5e325d 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -131,9 +131,18 @@ class CoursesService #显示课程通知(包括评论) 需验证权限 def show_course_news params,current_user @news = News.find(params[:id]) + @course = @news.course + if @course + if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) + raise '403' + end + else + raise 'news in unknown course' + end @comments = @news.comments @comments.reverse! if current_user.wants_comments_in_reverse_order? {:news => @news,:comments => @comments} + #comments = [] #@comments.each do |comment| # comments << {:author_id => comment.author_id,:author_name => comment.author.name,:commont_content => comment.comments,:time => format_time(comment.created_on)} From d6b82c3549c5aaaf4e232d3de38c4380cc8fbfb3 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Feb 2015 14:39:46 +0800 Subject: [PATCH 09/26] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E8=AF=84=E8=AE=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 7 +++++-- app/services/comment_service.rb | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index fb6d01fb4..402bce66f 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -6,11 +6,14 @@ module Mobile desc '课程通知评论' params do requires :token, type: String - requires :comment, type: String + requires :comments, type: String end post ':id' do cs = CommentService.new - comments = cs.news_comments params,current_user + cs_params = { + id: params[:id], + comment: params.reject{|k,v| [:id].include?(k)}} + comments = cs.news_comments cs_params,current_user raise "create comments failed #{comments.errors.full_messages}" if comments.new_record? present :data, comments, with: Mobile::Entities::Comment present :status, 0 diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 23f4355e6..c7e4b29a7 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -2,9 +2,16 @@ class CommentService #评论 def news_comments params,current_user @news = News.find(params[:id]) - raise Unauthorized unless @news.commentable? + @course = @news.course + if @course.nil? + raise 'news in unknown course' + end + raise Unauthorized unless @news.commentable?(current_user) + if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) + raise '403' + end @comment = Comment.new - @comment.safe_attributes = params[:comment] + @comment.send(:safe_attributes=,params[:comment],current_user) @comment.author = current_user @news.comments << @comment @comment From d6813e5996cb5a5ed2b0e5b6edf5b28edd219d90 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Feb 2015 15:54:50 +0800 Subject: [PATCH 10/26] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 19 +++++++++++++++++++ app/services/comment_service.rb | 20 ++++++++++++++++++++ app/services/courses_service.rb | 2 -- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 402bce66f..fb30f59f4 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -19,6 +19,25 @@ module Mobile present :status, 0 end + desc '作业留言(教师布置的作业)' + params do + requires :token, type: String + requires :id, type: Integer,desc: '老师布置的作业id' + requires :message,type: String, desc: '留言' + optional :reference_content, type: String ,desc: '引用的内容' + optional :reference_user_id, type: Integer,desc: '被引用的人' + end + post 'create_homework_message' do + cs_params = { + id: params[:id], + token: params[:token], + reference_content: params[:reference_content], + bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}} + cs = CommentService.new + cs.homework_message cs_params,current_user + present :status, 0 + end + end end end diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index c7e4b29a7..84a7d09cf 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -16,4 +16,24 @@ class CommentService @news.comments << @comment @comment end + + #作业留言 + def homework_message params,current_user + @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) + if params[:bid_message][:message].size>0 + if params[:reference_content] + message = params[:bid_message][:message] + "\n" + params[:reference_content] + else + message = params[:bid_message][:message] + @m = message + end + refer_user_id = params[:bid_message][:reference_user_id].to_i + @bid.add_jour(current_user, message, refer_user_id) + end + #@user = @bid.author + #@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + #@jour = paginateHelper @jours,10 + @bid.set_commit(@feedback_count) + end + end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 77b5e325d..341ecd422 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -136,8 +136,6 @@ class CoursesService if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) raise '403' end - else - raise 'news in unknown course' end @comments = @news.comments @comments.reverse! if current_user.wants_comments_in_reverse_order? From ef203ff40c0bf8250bbf3a084c733e2970a18424 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Feb 2015 16:11:35 +0800 Subject: [PATCH 11/26] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 11 ++++++----- app/models/bid.rb | 4 +++- app/services/comment_service.rb | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index fb30f59f4..c6d925868 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -22,19 +22,20 @@ module Mobile desc '作业留言(教师布置的作业)' params do requires :token, type: String - requires :id, type: Integer,desc: '老师布置的作业id' + #requires :id, type: Integer,desc: '老师布置的作业id' requires :message,type: String, desc: '留言' - optional :reference_content, type: String ,desc: '引用的内容' - optional :reference_user_id, type: Integer,desc: '被引用的人' + #optional :reference_content, type: String ,desc: '引用的内容' + #optional :reference_user_id, type: Integer,desc: '被引用的人' end - post 'create_homework_message' do + post ':id/create_homework_message' do cs_params = { id: params[:id], token: params[:token], reference_content: params[:reference_content], bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}} cs = CommentService.new - cs.homework_message cs_params,current_user + message = cs.homework_message cs_params,current_user + present :data, message, with: Mobile::Entities::Jours present :status, 0 end diff --git a/app/models/bid.rb b/app/models/bid.rb index f423266b8..eb7e5d83f 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -93,7 +93,9 @@ class Bid < ActiveRecord::Base # 'deadline' def add_jour(user, notes, reference_user_id = 0, options = {}) if options.count == 0 - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + self.journals_for_messages << jfm + jfm else jfm = self.journals_for_messages.build(options) jfm.save diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 84a7d09cf..5d40bf6bc 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -28,12 +28,13 @@ class CommentService @m = message end refer_user_id = params[:bid_message][:reference_user_id].to_i - @bid.add_jour(current_user, message, refer_user_id) + jfm = @bid.add_jour(current_user, message, refer_user_id) end #@user = @bid.author #@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') #@jour = paginateHelper @jours,10 @bid.set_commit(@feedback_count) + jfm end end \ No newline at end of file From 0dfa42837709576213e1abc7a3f3a6c9d7ee7b43 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Feb 2015 17:32:19 +0800 Subject: [PATCH 12/26] =?UTF-8?q?=E6=89=8B=E6=9C=BA=EF=BC=A1=EF=BC=B0?= =?UTF-8?q?=EF=BC=A9=E6=B7=BB=E5=8A=A0=E5=9B=9E=E5=A4=8D=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 20 +++++++++++++++++- app/api/mobile/entities/jours.rb | 3 +++ app/services/comment_service.rb | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index c6d925868..3f252070f 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -22,7 +22,6 @@ module Mobile desc '作业留言(教师布置的作业)' params do requires :token, type: String - #requires :id, type: Integer,desc: '老师布置的作业id' requires :message,type: String, desc: '留言' #optional :reference_content, type: String ,desc: '引用的内容' #optional :reference_user_id, type: Integer,desc: '被引用的人' @@ -39,6 +38,25 @@ module Mobile present :status, 0 end + desc '回复留言' + params do + requires :token, type: String + requires :reference_id, type: Integer,desc: '所属留言树的根留言id(最顶层的非回复的留言,留言对象中的m_parent_id)' + requires :reference_user_id,type: Integer ,desc: '被回复的留言的作者id' + #requires :reference_message_id,type: Integer,desc: '被回复的留言的id' + requires :user_notes,type: String,desc: '留言的内容' + requires :jour_type,type: String,desc: '等于父留言的jour_type' + requires :jour_id,type:Integer, desc: '等于父留言的jour_id' + end + post ':reference_message_id/create_reply'do + cs = CommentService.new + message = cs.create_reply params,current_user + raise "create reply failed #{message.errors.full_messages}" if message.new_record? + present :data, message, with: Mobile::Entities::Jours + present :status, 0 + end + + end end end diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 5a9f48cbc..10fd0f893 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -18,12 +18,15 @@ module Mobile end end jours_expose :id + jours_expose :jour_type + jours_expose :jour_id expose :user,using: Mobile::Entities::User do |f, opt| f.user end jours_expose :created_on jours_expose :notes jours_expose :m_reply_id + jours_expose :m_parent_id expose :reply_user,using: Mobile::Entities::User do |f, opt| f.at_user end diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 5d40bf6bc..5a5667a92 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -37,4 +37,39 @@ class CommentService jfm end + #回复留言接口 + def create_reply params,current_user + # 这里是创建回复所使用的方法,此方法只针对回复,每一个新的留言并不在此方法管理范围内。 + # 由于多个地方用到了留言,而之前的表设计也有jour_type/jour_id这类信息 + # 所以在方法 add_reply_adapter 中判断所有调用此方法的来源页面, + # 为了保证兼容以往所有的代码,保证以往的方法可以调用,在返回页面中都做了各式各样的判断。 + # 页面保证 render new_respond/journal_reply + # 修改 add_reply_adapter 中可以确保留言创建成功 + # 删除留言功能要调用destroy,也记得在destroy.js中修改 + + # deny api. api useless + parent_id = params[:reference_id] + author_id = current_user.id + reply_user_id = params[:reference_user_id] + reply_id = params[:reference_message_id] # 暂时不实现 + content = params[:user_notes] + jour_type = params[:jour_type] + jour_id = params[:jour_id] + @show_name = params[:show_name] == "true" + options = { + :jour_id => jour_id, + :jour_type => jour_type, + :user_id => author_id, + :status => true, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + @jfm = ::JournalsForMessage.new(options) + #@save_succ = true if @jfm.errors.empty? + @jfm.save + @jfm + end + end \ No newline at end of file From 95b757ba0901cda67104c94ad465cdc4de3c691d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 6 Feb 2015 09:32:32 +0800 Subject: [PATCH 13/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=88=90=E5=8A=9F=E5=92=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=88=90=E5=8A=9F=E5=90=8E=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_alert.html.erb | 27 +++++++++++++++++++++++++++ app/views/poll/publish_poll.js.erb | 10 +++++++++- app/views/poll/republish_poll.js.erb | 10 +++++++++- config/locales/zh.yml | 1 + public/stylesheets/polls.css | 6 ++++++ 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 app/views/poll/_alert.html.erb diff --git a/app/views/poll/_alert.html.erb b/app/views/poll/_alert.html.erb new file mode 100644 index 000000000..b3de53d1f --- /dev/null +++ b/app/views/poll/_alert.html.erb @@ -0,0 +1,27 @@ + + + + + + + +
+
+
+

+ <%= message%> +

+ +
+
+
+
+ + + diff --git a/app/views/poll/publish_poll.js.erb b/app/views/poll/publish_poll.js.erb index ad052f8f2..6074df6c6 100644 --- a/app/views/poll/publish_poll.js.erb +++ b/app/views/poll/publish_poll.js.erb @@ -1,2 +1,10 @@ $("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); -alert("发布成功"); \ No newline at end of file +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); +showModal('ajax-modal', '180px'); +$('#ajax-modal').css('height','111px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/poll/republish_poll.js.erb b/app/views/poll/republish_poll.js.erb index a2d8e28fa..94369678d 100644 --- a/app/views/poll/republish_poll.js.erb +++ b/app/views/poll/republish_poll.js.erb @@ -1,2 +1,10 @@ $("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); -alert("取消成功"); \ No newline at end of file +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); +showModal('ajax-modal', '180px'); +$('#ajax-modal').css('height','80px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d5c56fe13..31ec29e18 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2486,6 +2486,7 @@ zh: label_poll_result: 问卷调查_问卷统计 label_answer: 答案: label_poll_answer_valid_result: 以上为有效问答题答案! + label_poll_republish_success: 取消成功 label_answer_total: 总计: label_join_project: 加入项目 label_technical_support: 技术支持: diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index f0d670a1d..a0d64645a 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -145,3 +145,9 @@ a:hover.btn_pu{ background:#3cb761;} .polls_title_w { width:330px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_de_grey{ color:#b1b1b1;padding-left: 5px;} .ml5{ margin-left:5px;} + +/******确定弹框***********/ +.poll_alert_form{width:140px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} +.polls_alert_btn_box{width: 100%;margin: 0 auto;padding-left: 45px;} +.polls_alert_upload_box{ width:120px; margin:15px auto;} +.polls_alert_box_p{ font-size:14px; padding-left: 45px;padding-top: 10px;} From b1903dba116716a2470fcef3fab6d99dd4e9c98e Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Feb 2015 10:35:38 +0800 Subject: [PATCH 14/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 16 ++++++++++++++++ app/services/comment_service.rb | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 3f252070f..a7eea735d 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -38,6 +38,22 @@ module Mobile present :status, 0 end + desc '课程留言' + params do + requires :token, type: String + requires :course_message,type: String, desc: '留言' + end + post ':id/leave_course_message' do + cs_params = { + id: params[:id], + token: params[:token], + new_form: params.reject{|k,v| [:id,:token].include?(k)}} + cs = CommentService.new + message = cs.leave_course_message cs_params,current_user + present :data, message, with: Mobile::Entities::Jours + present :status, 0 + end + desc '回复留言' params do requires :token, type: String diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 5a5667a92..42dc8c415 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -36,6 +36,12 @@ class CommentService @bid.set_commit(@feedback_count) jfm end + #课程留言接口 + def leave_course_message params,current_user + message = params[:new_form][:course_message] + feedback = Course.add_new_jour(current_user, message, params[:id]) + feedback + end #回复留言接口 def create_reply params,current_user From 0b41afa5716eca611d5038218e9b29a00435a0cf Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 6 Feb 2015 10:51:29 +0800 Subject: [PATCH 15/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=8C=BF=E8=AF=84=E7=95=8C=E9=9D=A2=EF=BC=8C=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=90=8D=E6=98=BE=E7=A4=BA=E6=B7=B7=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_links.html.erb | 10 ++++++++-- app/views/memos/show.html.erb | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 0c2b0d7c2..989ed776d 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -1,7 +1,10 @@
+<% is_float ||= false %> <% for attachment in attachments %>

-

+ <%if is_float%> +
+ <% end%> <% if options[:length] %> <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%> @@ -9,7 +12,10 @@ <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% end %> -
+ <%if is_float%> +
+ <% end%> + <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 0330b65e4..995529fe9 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -67,7 +67,7 @@

<% if @memo.attachments.any?%> <% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %> - <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %> + <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> <% end %>

@@ -136,7 +136,7 @@

<% if reply.attachments.any?%> <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> - <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> + <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options, :is_float => true} %> <% end %>

From 4cdb3c83ddb69c6334f68e5053d7b5bad642cdca Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 6 Feb 2015 11:22:29 +0800 Subject: [PATCH 16/26] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=A8=E6=8C=87=E5=AE=9A=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=86=85=E4=BD=9C=E4=B8=9A=E6=95=B0=E9=87=8F=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/api_helper.rb | 24 ++++++++++++++++++++++++ app/helpers/homework_attach_helper.rb | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 8ff6f725c..b227a96ab 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -37,4 +37,28 @@ module ApiHelper end result end + + ######################################################### + #sw + #获取课程未匿评数量 + #param: user => "用户", course_id => "查询的课程ID" + #return: 作业的数量 + ######################################################### + def get_course_anonymous_evaluation user,course_id + course = Course.find course_id + count = 0 + if course + is_teacher = is_course_teacher user,course + if is_teacher #如果是老师,显示学生提交的作业数 + course.homeworks.each do |bid| + count += bid.homeworks.count + end + else #如果是学生,显示未匿评的数量 + course.homeworks.each do |bid| + count += get_student_not_batch_homework_list bid,user + end + end + end + count + end end \ No newline at end of file diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index c41ba54ee..0b98283ff 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -130,4 +130,22 @@ module HomeworkAttachHelper WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id} ORDER BY m_score DESC") student_batch_homework_list end + + ######################################################### + #sw + #获取学生未进行匿评的数量 + #param: bid => 作业 user => 用户 + #return 指定用户未进行匿评的作业的数量 + #user必须是学生用户 + ####################################################### + def get_student_not_batch_homework_list bid,user + HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{user.id} AND is_teacher_score = 0) AS m_score + FROM homework_attaches + INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id + WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id}) AS table1 + WHERE table1.m_score IS NULL").count + end end \ No newline at end of file From 859889b750f659daf2ee248e03e4cec25e71c56e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 6 Feb 2015 11:27:37 +0800 Subject: [PATCH 17/26] =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8C=BF=E8=AF=84=E6=95=B0=E9=87=8F=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/homework_attach_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 0b98283ff..72d381b28 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -140,8 +140,6 @@ module HomeworkAttachHelper ####################################################### def get_student_not_batch_homework_list bid,user HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{user.id} AND is_teacher_score = 0) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id From cc83b30fc6c230a54182cf4a3c0979f69210db4d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Feb 2015 14:29:42 +0800 Subject: [PATCH 18/26] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 10 ++++++++++ app/api/mobile/apis/users.rb | 18 ++++++++++-------- app/services/courses_service.rb | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 8f8c08c3f..7b3fc7cd5 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -209,6 +209,16 @@ module Mobile present :status, 0 end + desc '课程动态' + params do + requires :token, type: String + end + get "course_dynamic/:id" do + cs = CoursesService.new + count = cs.course_dynamic(params,current_user) + present :data, count + present :status, 0 + end end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 69260716e..d780b9db4 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -22,13 +22,15 @@ module Mobile desc "显示用户" params do - + requires :id, type: Integer end - get ':id' do - us = UsersService.new - ue = us.show_user params - present :data, ue,with: Mobile::Entities::User - present :status, 0 + route_param :id do + get do + us = UsersService.new + ue = us.show_user params + present :data, ue,with: Mobile::Entities::User + present :status, 0 + end end desc "修改用户" @@ -77,11 +79,11 @@ module Mobile present :status, 0 end - desc "用户搜索" + desc "用户搜索" params do requires :name, type: String, desc: '用户名关键字' end - get 'search' do + get 'search/search_user' do us = UsersService.new user = us.search_user params present :data, user, with: Mobile::Entities::User diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 341ecd422..d987514c2 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -2,6 +2,7 @@ class CoursesService include ApplicationHelper include CoursesHelper include HomeworkAttachHelper + include ApiHelper #TODO:尚未整合权限系统 #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 @@ -326,6 +327,11 @@ class CoursesService end end + def course_dynamic params,current_user + count = get_course_anonymous_evaluation current_user,params[:id] + count + end + private def show_homework_info course,bid,current_user,is_course_teacher author = bid.author.lastname + bid.author.firstname @@ -361,4 +367,6 @@ class CoursesService :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} end + + end \ No newline at end of file From d913f89a82b640bfd9b11a9d3c92cc31919b351b Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Feb 2015 15:52:34 +0800 Subject: [PATCH 19/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 2 +- app/api/mobile/entities/course_dynamic.rb | 17 +++++++++++++++++ app/helpers/api_helper.rb | 5 ++--- app/services/courses_service.rb | 17 ++++++++++++++--- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 app/api/mobile/entities/course_dynamic.rb diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 7b3fc7cd5..7dbfaffb0 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -216,7 +216,7 @@ module Mobile get "course_dynamic/:id" do cs = CoursesService.new count = cs.course_dynamic(params,current_user) - present :data, count + present :data, count, with: Mobile::Entities::CourseDynamic present :status, 0 end diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb new file mode 100644 index 000000000..11f8c2682 --- /dev/null +++ b/app/api/mobile/entities/course_dynamic.rb @@ -0,0 +1,17 @@ +module Mobile + module Entities + class CourseDynamic < Grape::Entity + def self.course_dynamic_expose(field) + expose field do |c,opt| + c[field] if (c.is_a?(Hash) && c.key?(field)) + end + end + + course_dynamic_expose :course_name + course_dynamic_expose :need_anonymous_comments_count + course_dynamic_expose :student_commit_number + course_dynamic_expose :news_count + course_dynamic_expose :message_count + end + end +end \ No newline at end of file diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index b227a96ab..c865a500b 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -44,8 +44,7 @@ module ApiHelper #param: user => "用户", course_id => "查询的课程ID" #return: 作业的数量 ######################################################### - def get_course_anonymous_evaluation user,course_id - course = Course.find course_id + def get_course_anonymous_evaluation user,course count = 0 if course is_teacher = is_course_teacher user,course @@ -59,6 +58,6 @@ module ApiHelper end end end - count + [count,is_teacher] end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index d987514c2..f4201774a 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -327,9 +327,20 @@ class CoursesService end end - def course_dynamic params,current_user - count = get_course_anonymous_evaluation current_user,params[:id] - count + def course_dynamic(params,current_user) + course = Course.find(params[:id]) + if current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course))) + raise '403' + end + count,is_teacher = get_course_anonymous_evaluation current_user,course + if is_teacher + student_commit_number = count + else + need_anonymous_comments_count = count + end + news_count = course.news.count + message_count = course.journals_for_messages.count + {:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count} end private From f380d781e72bfbcdddb0d523d250d89366a48dfd Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 9 Feb 2015 10:28:33 +0800 Subject: [PATCH 20/26] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=B7=B2=E6=9C=89=E8=AF=BE=E7=A8=8B=E5=A4=8D=E5=88=B6=E6=88=90?= =?UTF-8?q?=E6=96=B0=E8=AF=BE=E7=A8=8B=E7=9A=84=E8=B7=AF=E7=94=B1=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=96=B9=E6=B3=95=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 28 +++++++++++++++++++++++++-- config/routes.rb | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 61944ca2c..19f9c0fa2 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -955,10 +955,34 @@ class CoursesController < ApplicationController else render_403 end - end - + #根据已有课程复制课程 + #param id:已有课程ID + def copy_course + if @course + @new_course = Course.new @course.attributes + @new_course.tea_id = User.current.id + @new_course.created_at = DateTime.now + @new_course.updated_at = DateTime.now + @new_course.endup_time = nil + if @new_course.save + r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first + m = Member.new(:user => User.current, :roles => [r]) + m.project_id = -1 + course = CourseInfos.new(:user_id => User.current.id, :course_id => @new_course.id) + #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) + if @new_course.is_public == 1 + course_status = CourseStatus.create(:course_id => @new_course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => 1) + end + @new_course.members << m + @new_course.course_infos << course + redirect_to settings_course_url @new_course + end + else + render_404 + end + end private diff --git a/config/routes.rb b/config/routes.rb index a06679fba..bf0b73e8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -682,6 +682,7 @@ RedmineApp::Application.routes.draw do match 'valid_ajax', :to => 'courses#valid_ajax', :via => :get post 'join_in/join_group', :to => 'courses#join_group', :as => 'join_group' delete 'join_in/join_group', :to => 'courses#unjoin_group' + get 'copy_course' end collection do match 'join_private_courses', :via => [:get, :post] From 103a411b40b0cae04485da9cd1f672bb01008972 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Feb 2015 16:24:45 +0800 Subject: [PATCH 21/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/users.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index d780b9db4..9a5307be6 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -82,6 +82,7 @@ module Mobile desc "用户搜索" params do requires :name, type: String, desc: '用户名关键字' + requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱' end get 'search/search_user' do us = UsersService.new From 59a2c8283a4e660cc5514f12a60d58ae1fdcbe9a Mon Sep 17 00:00:00 2001 From: whimlex Date: Mon, 9 Feb 2015 22:07:21 +0800 Subject: [PATCH 22/26] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/welcome_helper.rb | 10 +- app/views/layouts/base_users.html.erb | 4 +- app/views/my/account.html.erb | 10 +- app/views/projects/_join_project.html.erb | 10 +- app/views/tags/_show_attachments.html.erb | 10 +- app/views/tags/_show_contests.html.erb | 2 +- app/views/tags/_show_courses.html.erb | 2 +- app/views/tags/_tag_add.html.erb | 2 +- app/views/tags/index.html.erb | 2 +- app/views/tags/show_all.html.erb | 2 +- app/views/users/_my_joinedcourse.html.erb | 4 +- app/views/users/show.html.erb | 2 +- app/views/welcome/_search_course.html.erb | 8 +- app/views/welcome/_search_project.html.erb | 10 +- app/views/welcome/contest.html.erb | 2 +- config/locales/account/en.yml | 90 +++ config/locales/account/zh.yml | 92 +++ config/locales/admins/en.yml | 13 + config/locales/admins/zh.yml | 16 + config/locales/commons/en.yml | 264 ++++++++ config/locales/commons/zh.yml | 267 ++++++++ config/locales/contacts/en.yml | 3 + config/locales/contacts/zh.yml | 22 + config/locales/contests/en.yml | 4 + config/locales/contests/zh.yml | 6 + config/locales/courses/en.yml | 4 + config/locales/courses/zh.yml | 17 + config/locales/en.yml | 465 +++---------- config/locales/mailers/en.yml | 4 + config/locales/mailers/zh.yml | 23 + config/locales/my/en.yml | 91 +++ config/locales/my/zh.yml | 101 +++ config/locales/navigatiors/en.yml | 8 + config/locales/navigatiors/zh.yml | 81 +++ config/locales/projects/en.yml | 6 + config/locales/projects/zh.yml | 60 ++ config/locales/users/en.yml | 19 + config/locales/users/zh.yml | 139 ++++ config/locales/zh.yml | 739 +++++---------------- lib/redmine/plugin.rb | 2 +- 40 files changed, 1633 insertions(+), 983 deletions(-) create mode 100644 config/locales/account/en.yml create mode 100644 config/locales/account/zh.yml create mode 100644 config/locales/admins/en.yml create mode 100644 config/locales/admins/zh.yml create mode 100644 config/locales/commons/en.yml create mode 100644 config/locales/commons/zh.yml create mode 100644 config/locales/contacts/en.yml create mode 100644 config/locales/contacts/zh.yml create mode 100644 config/locales/contests/en.yml create mode 100644 config/locales/contests/zh.yml create mode 100644 config/locales/courses/en.yml create mode 100644 config/locales/courses/zh.yml create mode 100644 config/locales/mailers/en.yml create mode 100644 config/locales/mailers/zh.yml create mode 100644 config/locales/my/en.yml create mode 100644 config/locales/my/zh.yml create mode 100644 config/locales/navigatiors/en.yml create mode 100644 config/locales/navigatiors/zh.yml create mode 100644 config/locales/projects/en.yml create mode 100644 config/locales/projects/zh.yml create mode 100644 config/locales/users/en.yml create mode 100644 config/locales/users/zh.yml diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index d101fd36c..eba3c0b3c 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -314,28 +314,28 @@ module WelcomeHelper str = ' '.html_safe case event.event_type when 'news' - str << content_tag("span", l(:field_user_active_published)) << + str << content_tag("span", l('user.active.published')) << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url, {:title => event.event_description}) when 'issue', 'message' , 'bid' , 'wiki-page' , 'document' - str << content_tag("span", l(:field_user_active_published)) << + str << content_tag("span", l('user.active.published')) << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(event.event_title, event.event_url, {:title => event.event_title}) when 'reply' ,'Reply', 'Memo' - str << content_tag("span", l(:field_user_active_published)) << + str << content_tag("span", l('user.active.published')) << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url, {:title => event.event_description}) when 'attachment' - str << content_tag('span', l(:field_user_active_uploaded)) << + str << content_tag('span', l('user.active.uploaded')) << content_tag('span', find_all_event_type(event)) << ': '.html_safe << link_to(event.event_title, event.event_url, {:title => event.event_title}) << link_to((' ['.html_safe+l(:label_downloads_list).to_s << ']'), project_files_path(event.container.project), :class => "attachments_list_color") else - str << content_tag("span", l(:field_user_active_updated)) << + str << content_tag("span", l('user.active.updated')) << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(event.event_title, event.event_url, {:title => event.event_title}) end diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 3b2bd8dfe..a7ed0aa25 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -68,7 +68,7 @@ - <%=link_to "主页", home_path %> > + <%=link_to l(:field_homepage), home_path %> > <%=link_to @user.name, user_path %> @@ -343,7 +343,7 @@ <% if @user.user_extensions.identity == 2 %> <%= render_menu :user_enterprise_menu %> <% else %> - <%= render_menu :user_menu,@user %> + <%= render_menu :user_menu, @user %> <% end %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 47cfb4221..554f50633 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -151,9 +151,9 @@ <% if !User.current.user_extensions.nil? && !User.current.user_extensions.student_id.nil? %> - <%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %> + <%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => l(:label_account_identity_studentID) %> <% else %> - <%= text_field_tag :no, nil, :placeholder => "请输入学号" %> + <%= text_field_tag :no, nil, :placeholder => l(:label_account_identity_studentID) %> <% end %> @@ -217,18 +217,18 @@   <% if User.current.user_extensions.nil? %> - + readonly> <% else %> <% if User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %> - + readonly> <% elsif User.current.user_extensions.school.nil? %> - + readonly> <% else %> diff --git a/app/views/projects/_join_project.html.erb b/app/views/projects/_join_project.html.erb index fdc60904d..98ab5dcd2 100644 --- a/app/views/projects/_join_project.html.erb +++ b/app/views/projects/_join_project.html.erb @@ -1,7 +1,7 @@ - 快速进入项目通道 + <%= l('project.join.title')%>