diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index a2dd8c869..f9236d0b7 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -52,16 +52,59 @@ class FilesController < ApplicationController end def create - container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) - attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type]) - render_attachment_warning_if_needed(container) + if params[:tag_name] + tag_saveEx + render :text =>"success" + else + @addTag=false + container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) + attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type]) + render_attachment_warning_if_needed(container) - if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - Mailer.attachments_added(attachments[:files]).deliver + if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + Mailer.attachments_added(attachments[:files]).deliver + end + redirect_to project_files_path(@project) end - redirect_to project_files_path(@project) end + def tag_saveEx + @tags = params[:tag_name][:name] + @obj_id = params[:object_id] + @obj_flag = params[:object_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + ## 执行成功的操作。 + else + #捕获异常 + end + end + # 返回制定资源类型的资源列表 def getattachtype sort_init 'created_on', 'desc' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9a21e26f2..7365e4048 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,7 +30,7 @@ class UsersController < ApplicationController #Ended by young - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] #edit has been deleted by huang, 2013-9-23 @@ -39,10 +39,10 @@ class UsersController < ApplicationController :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] before_filter :auth_user_extension, only: :show - accept_api_auth :index, :show, :create, :update, :destroy,:tag_save + accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx #william - before_filter :require_login, :only => :tag_save + before_filter :require_login, :only => [:tag_save,:tag_saveEx] helper :sort @@ -209,6 +209,8 @@ class UsersController < ApplicationController ## 判断课程是否过期 [需封装] @memberships_doing = [] @memberships_done = [] + @OwningCouses =[] + @JoinCouses=[] now_time = Time.now.year @memberships.map { |e| end_time = e.project.course_extra.get_time.year @@ -218,6 +220,12 @@ class UsersController < ApplicationController else @memberships_doing.push e end + + if e.project.course_extra.tea_id == User.current.id + @OwningCouses.push e + else + @JoinCouses.push e + end } # respond_to do |format| # format.html @@ -683,11 +691,51 @@ class UsersController < ApplicationController #捕获异常 end respond_to do |format| - format.html format.js - end + format.html + end + end + + def tag_saveEx + @tags = params[:tag_name][:name] + @obj_id = params[:obj_id] + @obj_flag = params[:obj_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + ## 执行成功的操作。 + else + #捕获异常 + end + respond_to do |format| + format.js + format.html + end end - ###add by huang def user_watchlist end diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 63492688a..674d73b79 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -12,5 +12,6 @@ fileSpan.find('a.remove-upload') }) .off('click'); var divattach = fileSpan.find('div.div_attachments'); -divattach.html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachment, :object_flag => "6"})%>'); +divattach.html('<%#= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); + <% end %> diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index 9d62ca37e..a01143e0b 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -2,9 +2,8 @@ <% versions = project.versions.sort %> <% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %> +<%= form_tag(project_files_path(project), :multipart => true,:name=>"upload_form", :class => "tabular") do %>
-

@@ -34,4 +33,26 @@ <%= submit_tag l(:button_add) %> <% end %> -
\ No newline at end of file +
+ + diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index a4f63e4b2..231be8beb 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -25,9 +25,10 @@ :onchange => "attachment_contenttypes_searchex(this.value)" %> <% end %> - + +
diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index b93afd41f..2fb2b5bde 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -15,9 +15,14 @@ <%=l(:label_course_doing)%>(<%=@memberships_doing.count%>) <%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' if @user == User.current %>

-
- <%= render :partial => 'course_form', :locals => {:memberships => @memberships_doing}%> -
+

+ <%= l(:label_created_course) %> +

<%= render :partial => 'course_form', :locals => {:memberships => @OwningCouses}%> +

+
+

<%= l(:label_joined_course) %> +

<%= render :partial => 'course_form', :locals => {:memberships => @JoinCouses}%> +

diff --git a/app/views/users/tag_saveEx.js.erb b/app/views/users/tag_saveEx.js.erb new file mode 100644 index 000000000..d567ee5de --- /dev/null +++ b/app/views/users/tag_saveEx.js.erb @@ -0,0 +1,20 @@ +<% if @obj_flag == '3'%> + +$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$('#put-tag-form-issue').hide(); +$('#name-issue').val(""); +<% elsif @obj_flag == '6'%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%>").hide(); +$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); +<% else %> + +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#put-tag-form #name').val(""); +//$('#put-tag-form').hide(); +<% end %> + diff --git a/config/locales/en.yml b/config/locales/en.yml index 0215d43b6..58ce0dd29 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1122,6 +1122,8 @@ en: label_activities_settings: Display settings #end + label_joined_course: Joined Courses + label_created_course: Created Courses #huang label_file_new: Download @@ -1611,4 +1613,4 @@ en: # ajax异步验证 - modal_valid_passing: can be used. + modal_valid_passing: can be used. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 666b28740..0c375a67c 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1670,7 +1670,9 @@ zh: label_no_current_participate: 该竞赛暂无参与者 #end - + + label_joined_course: 参加的课程 + label_created_course: 创建的课程 label_course: 课程 label_course_new: 新建课程 label_course_join_student: 加入课程 diff --git a/config/routes.rb b/config/routes.rb index f6717583b..14a750743 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -232,6 +232,7 @@ RedmineApp::Application.routes.draw do match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' ################# added by william match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag' + match 'users/tag_saveEx', :to => 'users#tag_saveEx', :via => :post post 'watchers/watch', :to => 'watchers#watch', :as => 'watch' delete 'watchers/watch', :to => 'watchers#unwatch'