From b4c299bff86983f85b3df396214b0790f2a8d019 Mon Sep 17 00:00:00 2001 From: ganyiang Date: Fri, 30 May 2014 09:35:06 +0800 Subject: [PATCH 001/139] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dosp=E4=B8=AD=E2=80=9C?= =?UTF-8?q?=E7=83=AD=E5=B8=96=E2=80=9D=E4=B8=8B=E6=98=BE=E7=A4=BA=E2=80=9C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=B8=AE=E5=8A=A9=E2=80=9D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/open_source_projects/_show_memo.html.erb | 1 - app/views/open_source_projects/_show_topics.html.erb | 1 - public/stylesheets/buglist-div-use.css | 2 +- public/stylesheets/buglist.css | 1 + 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb index c5448a595..6633ccd75 100644 --- a/app/views/open_source_projects/_show_memo.html.erb +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -61,7 +61,6 @@ 帖子来源:<%=link_to 'OSChina', topic.url %> - <%= no_use_link(topic, User.current) %> diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index f207cc552..38f689244 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -458,7 +458,6 @@ 帖子来源:<%=link_to 'OSChina', topic.url %> - <%= no_use_link(topic, User.current) %> diff --git a/public/stylesheets/buglist-div-use.css b/public/stylesheets/buglist-div-use.css index de0c7c4ad..8ee6af1e8 100644 --- a/public/stylesheets/buglist-div-use.css +++ b/public/stylesheets/buglist-div-use.css @@ -31,7 +31,7 @@ overflow: hidden; float: left; width: 440px; - left: 3%; + left: 2%; } diff --git a/public/stylesheets/buglist.css b/public/stylesheets/buglist.css index 4bc9267f7..49e816581 100644 --- a/public/stylesheets/buglist.css +++ b/public/stylesheets/buglist.css @@ -9,6 +9,7 @@ padding:0 0 0 0px; .li_time { padding:0 7px 0 0; +list-style-type: square; } From 9f16123bed895232ac607d3a85e16949ed12cbe8 Mon Sep 17 00:00:00 2001 From: ganyiang Date: Fri, 30 May 2014 11:29:05 +0800 Subject: [PATCH 002/139] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dosp=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E9=A1=B5=E9=9D=A2=EF=BC=8Cfooter=E6=BC=82?= =?UTF-8?q?=E7=A7=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/open_source_projects/showmemo.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/open_source_projects/showmemo.html.erb b/app/views/open_source_projects/showmemo.html.erb index 387237113..7c3bd5c31 100644 --- a/app/views/open_source_projects/showmemo.html.erb +++ b/app/views/open_source_projects/showmemo.html.erb @@ -51,5 +51,6 @@ :title => l(:button_delete) ) if @forum.destroyable_by?(User.current) %> +
<%= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos, :open_source_project => @open_source_project} %>
\ No newline at end of file From bf71a38608794dabd6a43672f7d3a47ef761124e Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 30 May 2014 20:32:37 +0800 Subject: [PATCH 003/139] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/contestnotifications.js | 2 + .../stylesheets/contestnotifications.css | 4 + app/controllers/application_controller.rb | 30 ++++ app/controllers/comments_controller.rb | 9 + .../contestnotifications_controller.rb | 161 ++++++++++++++++++ app/controllers/documents_controller.rb | 1 + .../issue_categories_controller.rb | 7 + app/controllers/members_controller.rb | 1 + app/controllers/versions_controller.rb | 8 + app/helpers/contestnotifications_helper.rb | 2 + app/models/contest.rb | 12 ++ app/models/contestnotification.rb | 61 +++++++ app/models/user.rb | 1 + app/views/contestnotifications/_form.html.erb | 41 +++++ app/views/contestnotifications/edit.html.erb | 6 + app/views/contestnotifications/index.html.erb | 133 +++++++++++++++ app/views/contestnotifications/new.html.erb | 16 ++ app/views/contestnotifications/show.html.erb | 35 ++++ config/locales/zh.yml | 2 + config/routes.rb | 3 + ...40530010015_create_contestnotifications.rb | 14 ++ db/schema.rb | 13 +- lib/redmine.rb | 8 + test/fixtures/contestnotifications.yml | 17 ++ .../contestnotifications_controller_test.rb | 49 ++++++ test/unit/contestnotification_test.rb | 7 + .../contestnotifications_helper_test.rb | 4 + 27 files changed, 646 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/contestnotifications.js create mode 100644 app/assets/stylesheets/contestnotifications.css create mode 100644 app/controllers/contestnotifications_controller.rb create mode 100644 app/helpers/contestnotifications_helper.rb create mode 100644 app/models/contestnotification.rb create mode 100644 app/views/contestnotifications/_form.html.erb create mode 100644 app/views/contestnotifications/edit.html.erb create mode 100644 app/views/contestnotifications/index.html.erb create mode 100644 app/views/contestnotifications/new.html.erb create mode 100644 app/views/contestnotifications/show.html.erb create mode 100644 db/migrate/20140530010015_create_contestnotifications.rb create mode 100644 test/fixtures/contestnotifications.yml create mode 100644 test/functional/contestnotifications_controller_test.rb create mode 100644 test/unit/contestnotification_test.rb create mode 100644 test/unit/helpers/contestnotifications_helper_test.rb diff --git a/app/assets/javascripts/contestnotifications.js b/app/assets/javascripts/contestnotifications.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/contestnotifications.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/contestnotifications.css b/app/assets/stylesheets/contestnotifications.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/contestnotifications.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a25b346ca..06e2285c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -264,6 +264,12 @@ class ApplicationController < ActionController::Base render_404 end + def find_contest_by_contest_id + @contest = Contest.find(params[:contest_id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + # Find a project based on params[:project_id] # TODO: some subclasses override this, see about merging their logic def find_optional_project @@ -274,12 +280,26 @@ class ApplicationController < ActionController::Base render_404 end + def find_optional_contest + @contest = Contest.find(params[:contest_id]) unless params[:contest_id].blank? + allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @contest, :global => true) + allowed ? true : deny_access + rescue ActiveRecord::RecordNotFound + render_404 + end + # Finds and sets @project based on @object.project def find_project_from_association render_404 unless @object.present? @project = @object.project end + + def find_contest_from_association + render_404 unless @object.present? + + @contest = @object.contest + end def find_model_object model = self.class.model_object @@ -291,6 +311,16 @@ class ApplicationController < ActionController::Base render_404 end + def find_model_object_contest + model = self.class.model_object + if model + @object = model.find(params[:id]) + self.instance_variable_set('@' + controller_name.singularize, @object) if @object + end + rescue ActiveRecord::RecordNotFound + render_404 + end + def self.model_object(model) self.model_object = model end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b2689d0c2..5b5578c09 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,6 +19,7 @@ class CommentsController < ApplicationController default_search_scope :news model_object News before_filter :find_model_object + before_filter :find_model_object_contest before_filter :find_project_from_association before_filter :authorize @@ -50,4 +51,12 @@ class CommentsController < ApplicationController @comment = nil @news end + + def find_model_object_contest + super + @contestnotification = @object + @comment = nil + @contestnotification + end + end diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb new file mode 100644 index 000000000..4ca19e6ed --- /dev/null +++ b/app/controllers/contestnotifications_controller.rb @@ -0,0 +1,161 @@ +class ContestnotificationsController < ApplicationController + # GET /contestnotifications + # GET /contestnotifications.json + layout 'base_contest' + default_search_scope :contestnotification + model_object Contestnotification + before_filter :find_model_object_contest, :except => [:new, :create, :index] + before_filter :find_contest_from_association, :except => [:new, :create, :index] + before_filter :find_contest_by_contest_id, :only => [:new, :create] + before_filter :authorize, :except => [:index] + before_filter :find_optional_contest, :only => :index + accept_rss_auth :index + accept_api_auth :index + + def index + # @contestnotifications = Contestnotification.all +# + # respond_to do |format| + # format.html # index.html.erb + # format.json { render json: @contestnotifications } + # end + + ### begin ### + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit + else + @limit = 10 + end + + scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible + + @contestnotification_count = scope.count + @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] + @offset ||= @contestnotification_pages.offset + @contestnotifications = scope.all(:include => [:author, :contest], + :order => "#{Contestnotification.table_name}.created_on DESC", + :offset => @offset, + :limit => @limit) + + respond_to do |format| + format.html { + @contestnotification = Contestnotification.new # for adding news inline + render :layout => 'base_contest' + } + format.api + format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } + end + ### end ### + end + + # GET /contestnotifications/1 + # GET /contestnotifications/1.json + def show + # @contestnotification = Contestnotification.find(params[:id]) +# + # respond_to do |format| + # format.html # show.html.erb + # format.json { render json: @contestnotification } + # end + @comments = @contestnotification.comments + @comments.reverse! if User.current.wants_comments_in_reverse_order? + render :layout => 'base_contest' + + end + + # GET /contestnotifications/new + # GET /contestnotifications/new.json + def new + # @contestnotification = Contestnotification.new +# + # respond_to do |format| + # format.html # new.html.erb + # format.json { render json: @contestnotification } + # end + @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + render :layout => 'base_contest' + end + + # GET /contestnotifications/1/edit + def edit + # @contestnotification = Contestnotification.find(params[:id]) + end + + # POST /contestnotifications + # POST /contestnotifications.json + def create + # @contestnotification = Contestnotification.new(params[:contestnotification]) +# + # respond_to do |format| + # if @contestnotification.save + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' } + # format.json { render json: @contestnotification, status: :created, location: @contestnotification } + # else + # format.html { render action: "new" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } + # end + # end + @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + @contestnotification.safe_attributes = params[:contestnotification] + @news.save_attachments(params[:attachments]) + if @contestnotification.save + render_attachment_warning_if_needed(@contestnotification) + flash[:notice] = l(:notice_successful_create) + redirect_to project_news_index_path(@contest) + else + layout_file = 'base_contest' + render :action => 'new', :layout => layout_file + end + end + + # PUT /contestnotifications/1 + # PUT /contestnotifications/1.json + def update + # @contestnotification = Contestnotification.find(params[:id]) +# + # respond_to do |format| + # if @contestnotification.update_attributes(params[:contestnotification]) + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' } + # format.json { head :no_content } + # else + # format.html { render action: "edit" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } + # end + # end + @contestnotification.safe_attributes = params[:contestnotification] + @contestnotification.save_attachments(params[:attachments]) + if @contestnotification.save + render_attachment_warning_if_needed(@contestnotification) + flash[:notice] = l(:notice_successful_update) + redirect_to contestnotification_path(@contestnotification) + else + render :action => 'edit' + end + end + + # DELETE /contestnotifications/1 + # DELETE /contestnotifications/1.json + def destroy + # @contestnotification = Contestnotification.find(params[:id]) + # @contestnotification.destroy +# + # respond_to do |format| + # format.html { redirect_to contestnotifications_url } + # format.json { head :no_content } + # end + @contestnotification.destroy + redirect_to contest_contestnotification_index_path(@contest) + end + + private + + def find_optional_contest + return true unless params[:contest_id] + @contest = Contest.find(params[:contest_id]) + authorize + rescue ActiveRecord::RecordNotFound + render_404 + end + +end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 51486f252..7e21242cc 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -21,6 +21,7 @@ class DocumentsController < ApplicationController model_object Document before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :find_model_object, :except => [:index, :new, :create] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] before_filter :authorize , :except => [:index]#Added by young diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index a716653a5..f5ba71def 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -19,6 +19,7 @@ class IssueCategoriesController < ApplicationController menu_item :settings model_object IssueCategory before_filter :find_model_object, :except => [:index, :new, :create] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :authorize @@ -119,4 +120,10 @@ class IssueCategoriesController < ApplicationController super @category = @object end + + def find_model_object_contest + super + @category = @object + end + end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index d8e583bf7..29c37c09b 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,6 +17,7 @@ class MembersController < ApplicationController model_object Member before_filter :find_model_object, :except => [:index, :create, :autocomplete] + before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete] before_filter :find_project_from_association, :except => [:index, :create, :autocomplete] before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete] before_filter :authorize diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 49e32ba17..72cb5301f 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -20,6 +20,7 @@ class VersionsController < ApplicationController menu_item :roadmap model_object Version before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed] before_filter :authorize @@ -154,6 +155,13 @@ class VersionsController < ApplicationController redirect_to settings_project_path(@project, :tab => 'versions') end + def close_completed_contest + if request.put? + @contest.close_completed_versions + end + redirect_to settings_contest_path(@contest, :tab => 'versions') + end + def destroy if @version.fixed_issues.empty? @version.destroy diff --git a/app/helpers/contestnotifications_helper.rb b/app/helpers/contestnotifications_helper.rb new file mode 100644 index 000000000..ab17149d7 --- /dev/null +++ b/app/helpers/contestnotifications_helper.rb @@ -0,0 +1,2 @@ +module ContestnotificationsHelper +end diff --git a/app/models/contest.rb b/app/models/contest.rb index 9a3268654..4234f7519 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -13,6 +13,7 @@ class Contest < ActiveRecord::Base has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_many :contestnotification, :dependent => :destroy, :include => :author @@ -93,6 +94,17 @@ class Contest < ActiveRecord::Base end end + # Closes open and locked project versions that are completed + def close_completed_versions_contest + Version.transaction do + versions.where(:status => %w(open locked)).all.each do |version| + if version.completed? + version.update_attribute(:status, 'closed') + end + end + end + end + def set_commit(commit) self.update_attribute(:commit, commit) end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb new file mode 100644 index 000000000..b0021c98a --- /dev/null +++ b/app/models/contestnotification.rb @@ -0,0 +1,61 @@ +class Contestnotification < ActiveRecord::Base + attr_accessible :author_id, :comments_count, :contest_id, :description, :summary, :title + + include Redmine::SafeAttributes + belongs_to :contest + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_at" + # fq + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + + validates_presence_of :title, :description + validates_length_of :title, :maximum => 60 + validates_length_of :summary, :maximum => 255 + + acts_as_attachable :delete_permission => :manage_contestnotification + acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest + acts_as_event :url => Proc.new {|o| {:controller => 'contestnotification', :action => 'show', :id => o.id}} + acts_as_activity_provider :find_options => {:include => [:contest, :author]}, + :author_key => :author_id + acts_as_watchable + + after_create :add_author_as_watcher, :reset_counters! + + after_create :act_as_activity + + + # scope :visible, lambda {|*args| + # includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_news, *args)) + # } + + safe_attributes 'title', 'summary', 'description' + + def visible?(user=User.current) + !user.nil? && user.allowed_to?(:view_contestnotification, contest) + end + + # Returns true if the news can be commented by user + def commentable?(user=User.current) + user.allowed_to?(:comment_contestnotification, contest) + end + + def recipients + contest.users.select {|user| user.notify_about?(self)}.map(&:mail) + end + + # returns latest news for contests visible by user + def self.latest(user = User.current, count = 5) + visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all + end + + private + + def add_author_as_watcher + Watcher.create(:watchable => self, :user => author) + end + ## fq + def act_as_activity + self.acts << Activity.new(:user_id => self.author_id) + end + +end diff --git a/app/models/user.rb b/app/models/user.rb index cf8e3c0cf..c8b02f1a7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -109,6 +109,7 @@ class User < Principal # added by bai has_many :join_in_contests, :dependent => :destroy has_many :news, :foreign_key => 'author_id' + has_many :contestnotification, :foreign_key => 'author_id' has_many :comments, :foreign_key => 'author_id' has_many :wiki_contents, :foreign_key => 'author_id' has_many :journals diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb new file mode 100644 index 000000000..7fb5b719f --- /dev/null +++ b/app/views/contestnotifications/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for(@contestnotification) do |f| %> + <% if @contestnotification.errors.any? %> +
+

<%= pluralize(@contestnotification.errors.count, "error") %> prohibited this contestnotification from being saved:

+ +
    + <% @contestnotification.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :contest_id %>
+ <%= f.number_field :contest_id %> +
+
+ <%= f.label :title %>
+ <%= f.text_field :title %> +
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %> +
+
+ <%= f.label :description %>
+ <%= f.text_field :description %> +
+
+ <%= f.label :author_id %>
+ <%= f.number_field :author_id %> +
+
+ <%= f.label :comments_count %>
+ <%= f.number_field :comments_count %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb new file mode 100644 index 000000000..1db3cd205 --- /dev/null +++ b/app/views/contestnotifications/edit.html.erb @@ -0,0 +1,6 @@ +

Editing contestnotification

+ +<%= render 'form' %> + +<%= link_to 'Show', @contestnotification %> | +<%= link_to 'Back', contestnotifications_path %> diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb new file mode 100644 index 000000000..2dbfdf899 --- /dev/null +++ b/app/views/contestnotifications/index.html.erb @@ -0,0 +1,133 @@ + + + +<% + btn_tips = l(:label_news_new) + label_tips = l(:label_news) +%> + + + <%= label_tips %> + + +<%= link_to(btn_tips, + new_contest_contestnotification_path(@contest), + :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + +<% if @contest && User.current.allowed_to?(:manage_news, @contest) %> + +<% end %> +
+ <% if @contestnotifications.empty? %> +

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

+ <% else %> + <% @contestnotifications.each do |contestnotification| %> + + + + + + +
<%= link_to image_tag(url_to_avatar(contestnotification.author), :class => "avatar"), user_path(contestnotification.author) %> + + + + + + + + + + + + +
+ <%= link_to_user(contestnotification.author) if contestnotification.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> + <%= delete_link contestnotification_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> +
+ <%= textilizable(contestnotification, :description) %>
<%= l :label_update_time %> + : <%= format_time(contestnotification.created_at) %><%= link_to l(:label_project_newother), contestnotification_path(contestnotification) %><%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count >= 0 %>
+
+ <% end %> + <% end %> +
+ +
+ + + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> + <% end %> + + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + <% html_title(l(:label_news_plural)) -%> +
+ + + + diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb new file mode 100644 index 000000000..f29bf784e --- /dev/null +++ b/app/views/contestnotifications/new.html.erb @@ -0,0 +1,16 @@ + + + + + +<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest), + :html => { :id => 'news-form', :multipart => true } do |f| %> + <%= render :partial => 'news/form', :locals => { :f => f } %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> +<% end %> +
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb new file mode 100644 index 000000000..310f8b579 --- /dev/null +++ b/app/views/contestnotifications/show.html.erb @@ -0,0 +1,35 @@ +

<%= notice %>

+ +

+ Contest: + <%= @contestnotification.contest_id %> +

+ +

+ Title: + <%= @contestnotification.title %> +

+ +

+ Summary: + <%= @contestnotification.summary %> +

+ +

+ Description: + <%= @contestnotification.description %> +

+ +

+ Author: + <%= @contestnotification.author_id %> +

+ +

+ Comments count: + <%= @contestnotification.comments_count %> +

+ + +<%= link_to 'Edit', edit_contestnotification_path(@contestnotification) %> | +<%= link_to 'Back', contestnotifications_path %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f86a757c6..51337ddca 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1961,6 +1961,8 @@ zh: label_attendingcontestwork_deposit_project: 托管项目 label_attendingcontestwork_sorting_intimation: 您可以重新打分,打分结果以最后一次打分为主! + label_contest_notification: 竞赛通知 + #end # ajax异步验证 diff --git a/config/routes.rb b/config/routes.rb index b2fdd370d..ef63888f8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + resources :contestnotifications + + resources :homework_users diff --git a/db/migrate/20140530010015_create_contestnotifications.rb b/db/migrate/20140530010015_create_contestnotifications.rb new file mode 100644 index 000000000..087c2cf8c --- /dev/null +++ b/db/migrate/20140530010015_create_contestnotifications.rb @@ -0,0 +1,14 @@ +class CreateContestnotifications < ActiveRecord::Migration + def change + create_table :contestnotifications do |t| + t.integer :contest_id + t.string :title + t.string :summary + t.string :description + t.integer :author_id + t.integer :comments_count + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 68b9ad655..1123adad2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140526104509) do +ActiveRecord::Schema.define(:version => 20140530010015) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -210,6 +210,17 @@ ActiveRecord::Schema.define(:version => 20140526104509) do t.string "reward" end + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.string "description" + t.integer "author_id" + t.integer "comments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contests", :force => true do |t| t.string "name" t.string "budget", :default => "" diff --git a/lib/redmine.rb b/lib/redmine.rb index 3a3cad611..7b28ac22e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -146,6 +146,12 @@ Redmine::AccessControl.map do |map| map.permission :comment_news, {:comments => :create} end + map.project_module :contestnotification do |map| + map.permission :manage_contestnotification, {:contestnotification => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member + map.permission :view_contestnotification, {:contestnotification => [:index, :show]}, :public => true, :read => true + map.permission :comment_contestnotification, {:comments => :create} + end + map.project_module :documents do |map| map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin @@ -390,6 +396,7 @@ Redmine::Activity.map do |activity| activity.register :issues, :class_name => %w(Issue Journal) activity.register :changesets activity.register :news + activity.register :contestnotification activity.register :documents, :class_name => %w(Document Attachment) activity.register :files, :class_name => 'Attachment' activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false @@ -405,6 +412,7 @@ end Redmine::Search.map do |search| search.register :issues search.register :news + search.register :contestnotification search.register :documents search.register :changesets search.register :wiki_pages diff --git a/test/fixtures/contestnotifications.yml b/test/fixtures/contestnotifications.yml new file mode 100644 index 000000000..6409a5f71 --- /dev/null +++ b/test/fixtures/contestnotifications.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + contest_id: 1 + title: MyString + summary: MyString + description: MyString + author_id: 1 + comments_count: 1 + +two: + contest_id: 1 + title: MyString + summary: MyString + description: MyString + author_id: 1 + comments_count: 1 diff --git a/test/functional/contestnotifications_controller_test.rb b/test/functional/contestnotifications_controller_test.rb new file mode 100644 index 000000000..948955a87 --- /dev/null +++ b/test/functional/contestnotifications_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ContestnotificationsControllerTest < ActionController::TestCase + setup do + @contestnotification = contestnotifications(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:contestnotifications) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create contestnotification" do + assert_difference('Contestnotification.count') do + post :create, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title } + end + + assert_redirected_to contestnotification_path(assigns(:contestnotification)) + end + + test "should show contestnotification" do + get :show, id: @contestnotification + assert_response :success + end + + test "should get edit" do + get :edit, id: @contestnotification + assert_response :success + end + + test "should update contestnotification" do + put :update, id: @contestnotification, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title } + assert_redirected_to contestnotification_path(assigns(:contestnotification)) + end + + test "should destroy contestnotification" do + assert_difference('Contestnotification.count', -1) do + delete :destroy, id: @contestnotification + end + + assert_redirected_to contestnotifications_path + end +end diff --git a/test/unit/contestnotification_test.rb b/test/unit/contestnotification_test.rb new file mode 100644 index 000000000..22b8113c7 --- /dev/null +++ b/test/unit/contestnotification_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContestnotificationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/contestnotifications_helper_test.rb b/test/unit/helpers/contestnotifications_helper_test.rb new file mode 100644 index 000000000..d79755d82 --- /dev/null +++ b/test/unit/helpers/contestnotifications_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ContestnotificationsHelperTest < ActionView::TestCase +end From 09ea833dcbd122c668c5ae81d638894f873be903 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 30 May 2014 20:52:55 +0800 Subject: [PATCH 004/139] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_contestnotifications.html.erb | 28 ++++++ app/views/contestnotifications/_form.html.erb | 18 +++- app/views/contestnotifications/edit.html.erb | 17 +++- app/views/contestnotifications/new.html.erb | 2 +- app/views/contestnotifications/show.html.erb | 93 ++++++++++++++++++- 5 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 app/views/contestnotifications/_contestnotifications.html.erb diff --git a/app/views/contestnotifications/_contestnotifications.html.erb b/app/views/contestnotifications/_contestnotifications.html.erb new file mode 100644 index 000000000..0866ea198 --- /dev/null +++ b/app/views/contestnotifications/_contestnotifications.html.erb @@ -0,0 +1,28 @@ + + + + + + + +
+ + + + + + + + + + +
<%=link_to contestnotification.author,contestnotification_path(contestnotification)%> + <%= l(:label_project_newshare) %> <%= link_to h(contestnotification.title), news_path(contestnotification) %> +

<%=h contestnotification.description%>

<%= contestnotification.created_on %><%= link_to l(:label_project_newother),contestnotification_path(contestnotification)%> + <%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count > 0 %> +
diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb index 7fb5b719f..ee49a15e6 100644 --- a/app/views/contestnotifications/_form.html.erb +++ b/app/views/contestnotifications/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_for(@contestnotification) do |f| %> + + + +<%= error_messages_for @contestnotification %> +
+ <% str =l(:label_news_new) %> +
+
+

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

+ +

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

+

<%= render :partial => 'attachments/form', :locals => {:container => @contestnotification} %>

+
+ +<%= wikitoolbar_for 'news_description' %> diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb index 1db3cd205..6d680f2e6 100644 --- a/app/views/contestnotifications/edit.html.erb +++ b/app/views/contestnotifications/edit.html.erb @@ -1,6 +1,19 @@ -

Editing contestnotification

+ + +

<%=l(:label_news)%>

+ +<%= labelled_form_for @contestnotification, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<%= preview_link preview_news_path(:project_id => @contest, :id => @contestnotification), 'news-form' %> +<% end %> +
+ +<% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> +<% end %> diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index f29bf784e..cd5920273 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -11,6 +11,6 @@ :html => { :id => 'news-form', :multipart => true } do |f| %> <%= render :partial => 'news/form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> + <%= preview_link preview_news_path(:contest_id => @contest), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> <% end %>
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index 310f8b579..3b3a53fd8 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -1,4 +1,4 @@ -

<%= notice %>

+ + + +
+ <%= watcher_link(@contestnotification, User.current) %> + <%= link_to(l(:button_edit), + edit_news_path(@news), + :class => 'icon icon-edit', + :accesskey => accesskey(:edit), + :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %> + <%= delete_link news_path(@contestnotification) if User.current.allowed_to?(:manage_contestnotification, @contest) %> +
+ +

<%=h @contestnotification.title %>

+ +<% if authorize_for('contestnotification', 'edit') %> + +<% end %> + +
+ +
+ <%= textilizable(@contestnotification, :description) %> +
+ <%= link_to_attachments @contestnotification %> +
+ + <% if @contestnotification.commentable? %> +

+ <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> +

+ <%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotification}, :id => "add_comment_form", :style => "display:none;") do %> +
+ <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'comment_comments' %> +
+

+ <%= submit_tag l(:button_add) %> +

+ <% end %> + <% end %> + + <% html_title @contestnotification.title -%> + + <% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + +
+
+

<%= l(:label_comment_plural) %>

+ <% comments = @comments.reverse %> + <% comments.each do |comment| %> + <% next if comment.new_record? %> + + + + + +
<%= image_tag(url_to_avatar(comment.author), :class => "avatar")%> + + + + + + + + + + + +
<%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>
+

+ <%= textilizable(comment.comments) %> +

<%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotification, :comment_id => comment}, + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
+ <% end if @comments.any? %> +
+ + From 528af32f914e72c9d240cd9398cb1c376c4c44ac Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 3 Jun 2014 09:27:07 +0800 Subject: [PATCH 005/139] =?UTF-8?q?=E4=BF=AE=E6=94=B9forge=EF=BC=8Clocalho?= =?UTF-8?q?st=E9=A6=96=E9=A1=B5=E4=B8=8D=E8=83=BD=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 4 +-- app/controllers/comments_controller.rb | 4 +-- .../contestnotifications_controller.rb | 32 +++++++++---------- app/helpers/welcome_helper.rb | 5 +-- app/models/contestnotification.rb | 2 +- .../_contestnotifications.html.erb | 12 +++---- app/views/contestnotifications/_form.html.erb | 4 +-- app/views/contestnotifications/edit.html.erb | 4 +-- app/views/contestnotifications/index.html.erb | 20 ++++++------ app/views/contestnotifications/new.html.erb | 2 +- app/views/contestnotifications/show.html.erb | 24 +++++++------- lib/redmine.rb | 4 +-- 12 files changed, 59 insertions(+), 58 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06e2285c2..27829fa08 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -296,9 +296,9 @@ class ApplicationController < ActionController::Base end def find_contest_from_association - render_404 unless @object.present? + render_404 unless @contest.present? - @contest = @object.contest + @contest = @contest.contest end def find_model_object diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 5b5578c09..d54e9ae7e 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -54,9 +54,9 @@ class CommentsController < ApplicationController def find_model_object_contest super - @contestnotification = @object + @contestnotifications = @object @comment = nil - @contestnotification + @contestnotifications end end diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 4ca19e6ed..15455c806 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -28,23 +28,23 @@ class ContestnotificationsController < ApplicationController @limit = 10 end - scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible + scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible @contestnotification_count = scope.count @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] @offset ||= @contestnotification_pages.offset - @contestnotifications = scope.all(:include => [:author, :contest], + @contestnotificationss = scope.all(:include => [:author, :contest], :order => "#{Contestnotification.table_name}.created_on DESC", :offset => @offset, :limit => @limit) respond_to do |format| format.html { - @contestnotification = Contestnotification.new # for adding news inline + @contestnotifications = Contestnotifications.new # for adding news inline render :layout => 'base_contest' } format.api - format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } + format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } end ### end ### end @@ -58,7 +58,7 @@ class ContestnotificationsController < ApplicationController # format.html # show.html.erb # format.json { render json: @contestnotification } # end - @comments = @contestnotification.comments + @comments = @contestnotifications.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? render :layout => 'base_contest' @@ -73,7 +73,7 @@ class ContestnotificationsController < ApplicationController # format.html # new.html.erb # format.json { render json: @contestnotification } # end - @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) render :layout => 'base_contest' end @@ -96,11 +96,11 @@ class ContestnotificationsController < ApplicationController # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # end # end - @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) - @contestnotification.safe_attributes = params[:contestnotification] + @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) + @contestnotifications.safe_attributes = params[:contestnotifications] @news.save_attachments(params[:attachments]) - if @contestnotification.save - render_attachment_warning_if_needed(@contestnotification) + if @contestnotifications.save + render_attachment_warning_if_needed(@contestnotifications) flash[:notice] = l(:notice_successful_create) redirect_to project_news_index_path(@contest) else @@ -123,12 +123,12 @@ class ContestnotificationsController < ApplicationController # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # end # end - @contestnotification.safe_attributes = params[:contestnotification] - @contestnotification.save_attachments(params[:attachments]) - if @contestnotification.save - render_attachment_warning_if_needed(@contestnotification) + @contestnotifications.safe_attributes = params[:contestnotifications] + @contestnotifications.save_attachments(params[:attachments]) + if @contestnotifications.save + render_attachment_warning_if_needed(@contestnotifications) flash[:notice] = l(:notice_successful_update) - redirect_to contestnotification_path(@contestnotification) + redirect_to contestnotification_path(@contestnotifications) else render :action => 'edit' end @@ -144,7 +144,7 @@ class ContestnotificationsController < ApplicationController # format.html { redirect_to contestnotifications_url } # format.json { head :no_content } # end - @contestnotification.destroy + @contestnotifications.destroy redirect_to contest_contestnotification_index_path(@contest) end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 330010212..dc651d38a 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -319,9 +319,10 @@ module WelcomeHelper "show_documents" => true, "show_messages" => true, "show_news" => true, - "show_bids" => true + "show_bids" => true, + "show_contest" => true } - activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } + activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'}) end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index b0021c98a..f7087c49d 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -45,7 +45,7 @@ class Contestnotification < ActiveRecord::Base # returns latest news for contests visible by user def self.latest(user = User.current, count = 5) - visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all + visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_on DESC").limit(count).all end private diff --git a/app/views/contestnotifications/_contestnotifications.html.erb b/app/views/contestnotifications/_contestnotifications.html.erb index 0866ea198..4a062f3b5 100644 --- a/app/views/contestnotifications/_contestnotifications.html.erb +++ b/app/views/contestnotifications/_contestnotifications.html.erb @@ -10,17 +10,17 @@ - - + - - +
<%=link_to contestnotification.author,contestnotification_path(contestnotification)%> - <%= l(:label_project_newshare) %> <%= link_to h(contestnotification.title), news_path(contestnotification) %> + <%=link_to contestnotifications.author,contestnotifications_path(contestnotifications)%> + <%= l(:label_project_newshare) %> <%= link_to h(contestnotifications.title), news_path(contestnotifications) %>

<%=h contestnotification.description%>

<%=h contestnotifications.description%>

<%= contestnotification.created_on %><%= link_to l(:label_project_newother),contestnotification_path(contestnotification)%> - <%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count > 0 %> + <%= contestnotifications.created_on %><%= link_to l(:label_project_newother),contestnotifications_path(contestnotifications)%> + <%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count > 0 %>
diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb index ee49a15e6..6904714d6 100644 --- a/app/views/contestnotifications/_form.html.erb +++ b/app/views/contestnotifications/_form.html.erb @@ -41,7 +41,7 @@ <% end %> --> -<%= error_messages_for @contestnotification %> +<%= error_messages_for @contestnotifications %>
<% str =l(:label_news_new) %>
@@ -49,7 +49,7 @@

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

-

<%= render :partial => 'attachments/form', :locals => {:container => @contestnotification} %>

+

<%= render :partial => 'attachments/form', :locals => {:container => @contestnotifications} %>

<%= wikitoolbar_for 'news_description' %> diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb index 6d680f2e6..121b15d9a 100644 --- a/app/views/contestnotifications/edit.html.erb +++ b/app/views/contestnotifications/edit.html.erb @@ -7,10 +7,10 @@

<%=l(:label_news)%>

-<%= labelled_form_for @contestnotification, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> +<%= labelled_form_for @contestnotifications, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> <%= submit_tag l(:button_save) %> -<%= preview_link preview_news_path(:project_id => @contest, :id => @contestnotification), 'news-form' %> +<%= preview_link preview_news_path(:project_id => @contest, :id => @contestnotifications), 'news-form' %> <% end %>
diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 2dbfdf899..514b89060 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -49,11 +49,11 @@ <% if @contest && User.current.allowed_to?(:manage_news, @contest) %> <% end %>
- <% if @contestnotifications.empty? %> + <% if @contestnotificationss.empty? %>

<%= l(:label_no_data) %>

<% else %> - <% @contestnotifications.each do |contestnotification| %> + <% @contestnotificationss.each do |contestnotifications| %> - + diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index cd5920273..6e474b4ea 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -7,7 +7,7 @@ -<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest), +<%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_index_path(@contest), :html => { :id => 'news-form', :multipart => true } do |f| %> <%= render :partial => 'news/form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index 3b3a53fd8..a8069c73c 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -36,24 +36,24 @@
- <%= watcher_link(@contestnotification, User.current) %> + <%= watcher_link(@contestnotifications, User.current) %> <%= link_to(l(:button_edit), edit_news_path(@news), :class => 'icon icon-edit', :accesskey => accesskey(:edit), :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %> - <%= delete_link news_path(@contestnotification) if User.current.allowed_to?(:manage_contestnotification, @contest) %> + <%= delete_link news_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %>
-

<%=h @contestnotification.title %>

+

<%=h @contestnotifications.title %>

-<% if authorize_for('contestnotification', 'edit') %> +<% if authorize_for('contestnotifications', 'edit') %> -
<%= link_to image_tag(url_to_avatar(contestnotification.author), :class => "avatar"), user_path(contestnotification.author) %><%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %> + <%= textilizable(contestnotifications, :description) %> - + : <%= format_time(contestnotifications.created_at) %> +
- <%= link_to_user(contestnotification.author) if contestnotification.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> - <%= delete_link contestnotification_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> + <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> + <%= delete_link contestnotifications_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %>
- <%= textilizable(contestnotification, :description) %>
<%= l :label_update_time %> - : <%= format_time(contestnotification.created_at) %><%= link_to l(:label_project_newother), contestnotification_path(contestnotification) %><%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count >= 0 %><%= link_to l(:label_project_newother), contestnotifications_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %>
<%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotification, :comment_id => comment}, + <%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotifications, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
diff --git a/lib/redmine.rb b/lib/redmine.rb index 7b28ac22e..a72e74ce4 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -147,8 +147,8 @@ Redmine::AccessControl.map do |map| end map.project_module :contestnotification do |map| - map.permission :manage_contestnotification, {:contestnotification => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member - map.permission :view_contestnotification, {:contestnotification => [:index, :show]}, :public => true, :read => true + map.permission :manage_contestnotification, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member + map.permission :view_contestnotification, {:contestnotifications => [:index, :show]}, :public => true, :read => true map.permission :comment_contestnotification, {:comments => :create} end From 81a45fe977a9432d08374391823cb48bc79be6ef Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 3 Jun 2014 15:27:04 +0800 Subject: [PATCH 006/139] dfs --- .../contestnotifications_controller.rb | 20 +-- app/controllers/contests_controller.rb | 6 +- app/controllers/roles_controller.rb | 108 -------------- app/models/contestnotification.rb | 6 +- app/views/contestnotifications/index.html.erb | 133 ------------------ config/routes.rb | 8 +- lib/redmine.rb | 12 +- lib/redmine/access_control.rb | 18 ++- 8 files changed, 44 insertions(+), 267 deletions(-) delete mode 100644 app/controllers/roles_controller.rb diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 15455c806..110f26466 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -1,9 +1,9 @@ class ContestnotificationsController < ApplicationController # GET /contestnotifications # GET /contestnotifications.json - layout 'base_contest' - default_search_scope :contestnotification - model_object Contestnotification + layout 'base_newcontest' + default_search_scope :contestnotifications + model_object Contestnotifications before_filter :find_model_object_contest, :except => [:new, :create, :index] before_filter :find_contest_from_association, :except => [:new, :create, :index] before_filter :find_contest_by_contest_id, :only => [:new, :create] @@ -30,18 +30,18 @@ class ContestnotificationsController < ApplicationController scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible - @contestnotification_count = scope.count - @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] - @offset ||= @contestnotification_pages.offset + @contestnotifications_count = scope.count + @contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page'] + @offset ||= @contestnotifications_pages.offset @contestnotificationss = scope.all(:include => [:author, :contest], - :order => "#{Contestnotification.table_name}.created_on DESC", + :order => "#{Contestnotifications.table_name}.created_on DESC", :offset => @offset, :limit => @limit) respond_to do |format| format.html { - @contestnotifications = Contestnotifications.new # for adding news inline - render :layout => 'base_contest' + @contestnotification = Contestnotification.new # for adding news inline + render :layout => 'base_newcontest' } format.api format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } @@ -60,7 +60,7 @@ class ContestnotificationsController < ApplicationController # end @comments = @contestnotifications.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? - render :layout => 'base_contest' + render :layout => 'base_newcontest' end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index b51a11436..bd4206808 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -4,9 +4,9 @@ class ContestsController < ApplicationController menu_item :respond menu_item :project, :only => :show_project menu_item :application, :only => :show_softapplication - menu_item :attendingcontest, :only => :show_attendingcontest - menu_item :contestnotification, :only => :show_notification - before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :show_notification, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, + menu_item :attendingcontests, :only => :show_attendingcontest + menu_item :contestnotifications, :only => :index + before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, :show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] # added by fq diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb deleted file mode 100644 index f4bae1e81..000000000 --- a/app/controllers/roles_controller.rb +++ /dev/null @@ -1,108 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class RolesController < ApplicationController - layout 'admin' - - before_filter :require_admin, :except => [:index, :show] - before_filter :require_admin_or_api_request, :only => [:index, :show] - before_filter :find_role, :only => [:show, :edit, :update, :destroy] - accept_api_auth :index, :show - - def index - respond_to do |format| - format.html { - @role_pages, @roles = paginate Role.sorted, :per_page => 25 - render :action => "index", :layout => false if request.xhr? - } - format.api { - @roles = Role.givable.all - } - end - end - - def show - respond_to do |format| - format.api - end - end - - def new - # Prefills the form with 'Non member' role permissions by default - @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) - if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy]) - @role.copy_from(@copy_from) - end - @roles = Role.sorted.all - end - - def create - @role = Role.new(params[:role]) - if request.post? && @role.save - # workflow copy - if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from])) - @role.workflow_rules.copy(copy_from) - end - flash[:notice] = l(:notice_successful_create) - redirect_to roles_path - else - @roles = Role.sorted.all - render :action => 'new' - end - end - - def edit - end - - def update - if request.put? and @role.update_attributes(params[:role]) - flash[:notice] = l(:notice_successful_update) - redirect_to roles_path - else - render :action => 'edit' - end - end - - def destroy - @role.destroy - redirect_to roles_path - rescue - flash[:error] = l(:error_can_not_remove_role) - redirect_to roles_path - end - - def permissions - @roles = Role.sorted.all - @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } - if request.post? - @roles.each do |role| - role.permissions = params[:permissions][role.id.to_s] - role.save - end - flash[:notice] = l(:notice_successful_update) - redirect_to roles_path - end - end - - private - - def find_role - @role = Role.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end -end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index f7087c49d..75b0f5814 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -31,12 +31,12 @@ class Contestnotification < ActiveRecord::Base safe_attributes 'title', 'summary', 'description' def visible?(user=User.current) - !user.nil? && user.allowed_to?(:view_contestnotification, contest) + !user.nil? && user.allowed_to?(:view_contestnotifications, contest) end # Returns true if the news can be commented by user def commentable?(user=User.current) - user.allowed_to?(:comment_contestnotification, contest) + user.allowed_to?(:comment_contestnotifications, contest) end def recipients @@ -57,5 +57,5 @@ class Contestnotification < ActiveRecord::Base def act_as_activity self.acts << Activity.new(:user_id => self.author_id) end - + end diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 514b89060..e69de29bb 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -1,133 +0,0 @@ - - - -<% - btn_tips = l(:label_news_new) - label_tips = l(:label_news) -%> - - - <%= label_tips %> - - -<%= link_to(btn_tips, - new_contest_contestnotification_path(@contest), - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> - -<% if @contest && User.current.allowed_to?(:manage_news, @contest) %> - -<% end %> -
- <% if @contestnotificationss.empty? %> -

- <%= l(:label_no_data) %> -

- <% else %> - <% @contestnotificationss.each do |contestnotifications| %> - - - - - - -
<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %> - - - - - - - - - - - - -
- <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> - <%= delete_link contestnotifications_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> -
- <%= textilizable(contestnotifications, :description) %>
<%= l :label_update_time %> - : <%= format_time(contestnotifications.created_at) %><%= link_to l(:label_project_newother), contestnotifications_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %>
-
- <% end %> - <% end %> -
- -
- - - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> - <% end %> - - <% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> - <%= stylesheet_link_tag 'scm' %> - <% end %> - - <% html_title(l(:label_news_plural)) -%> -
- - - - diff --git a/config/routes.rb b/config/routes.rb index ef63888f8..c6a727ca6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,8 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - resources :contestnotifications - + resources :contestnotifications + + match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' resources :homework_users @@ -85,7 +86,7 @@ RedmineApp::Application.routes.draw do match 'show_project' , via: :get match 'show_softapplication' , via: :get match 'show_attendingcontest' , via: :get - match 'show_notification' , via: :get + #match 'show_notification' , via: :get match 'show_participator' , via: :get match 'set_reward_project' , via: [:get, :post] match 'set_reward_softapplication' , via: [:get, :post] @@ -93,6 +94,7 @@ RedmineApp::Application.routes.draw do match 'add_softapplication' , via: [:get, :post] match 'create' , via: :post match 'settings' , via: [:get, :post] + end end diff --git a/lib/redmine.rb b/lib/redmine.rb index a72e74ce4..861e14f7e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -93,6 +93,7 @@ Redmine::AccessControl.map do |map| map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true map.permission :select_project_modules, {:projects => :modules}, :require => :member + map.permission :select_contest_modules, {:contests => :modules}, :require => :member map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member @@ -146,10 +147,10 @@ Redmine::AccessControl.map do |map| map.permission :comment_news, {:comments => :create} end - map.project_module :contestnotification do |map| - map.permission :manage_contestnotification, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member - map.permission :view_contestnotification, {:contestnotifications => [:index, :show]}, :public => true, :read => true - map.permission :comment_contestnotification, {:comments => :create} + map.contest_module :contestnotifications do |map| + map.permission :manage_contestnotifications, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member + map.permission :view_contestnotifications, {:contestnotifications => [:index, :show]}, :public => true, :read => true + map.permission :comment_contestnotifications, {:comments => :create} end map.project_module :documents do |map| @@ -293,7 +294,8 @@ Redmine::MenuManager.map :contest_menu do |menu| #menu.push :project, :show_project_contest_path, :caption => :label_contest_project #menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application menu.push :attendingcontest, {:controller => 'contests', :action => 'show_attendingcontest'}, :caption => :label_attending_contest - menu.push :contestnotification, {:controller => 'contests', :action => 'show_notification'}, :caption => :label_contest_notification + menu.push :contestnotifications, { :controller => 'contestnotifications', :action => 'index' }, :param => :contest_id, :caption => :label_contest_notification + #menu.push :contestnotification, {:controller => 'contests', :action => 'show_notification'}, :caption => :label_contest_notification # menu.push :attendingcontest, :show_attendingcontest_contest_path, :caption => :label_attendin,g_contest # menu.push :result, { :controller => 'bids', :action => 'show_results' }, # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index 7c4a5a5ec..dfde5debc 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -67,20 +67,26 @@ module Redmine def available_project_modules @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact end - + def available_contest_modules + @available_contest_modules ||= @permissions.collect(&:contest_module).uniq.compact + end + def modules_permissions(modules) @permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)} + @permissions.select {|p| p.contest_module.nil? || modules.include?(p.contest_module.to_s)} end end class Mapper def initialize @project_module = nil + @contest_module = nil end def permission(name, hash, options={}) @permissions ||= [] options.merge!(:project_module => @project_module) + options.merge!(:contest_module => @contest_module) @permissions << Permission.new(name, hash, options) end @@ -90,13 +96,19 @@ module Redmine @project_module = nil end + def contest_module(name, options={}) + @contest_module = name + yield self + @contest_module = nil + end + def mapped_permissions @permissions end end class Permission - attr_reader :name, :actions, :project_module + attr_reader :name, :actions, :project_module, :contest_module def initialize(name, hash, options) @name = name @@ -105,6 +117,8 @@ module Redmine @require = options[:require] @read = options[:read] || false @project_module = options[:project_module] + @contest_module = options[:contest_module] + hash.each do |controller, actions| if actions.is_a? Array @actions << actions.collect {|action| "#{controller}/#{action}"} From a3fb48a4bb43f74cf8a48156a76c6f6eaf9ee991 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 3 Jun 2014 18:24:55 +0800 Subject: [PATCH 007/139] 0603 --- .../contestnotifications_controller.rb | 33 +++--- app/models/contest.rb | 2 +- app/models/contestnotification.rb | 11 +- app/views/contestnotifications/index.html.erb | 101 ++++++++++++++++ app/views/contestnotifications/new.html.erb | 6 +- app/views/roles/roles_controller.rb | 108 ++++++++++++++++++ config/routes.rb | 9 +- 7 files changed, 242 insertions(+), 28 deletions(-) create mode 100644 app/views/roles/roles_controller.rb diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 110f26466..675efd7f0 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -3,16 +3,19 @@ class ContestnotificationsController < ApplicationController # GET /contestnotifications.json layout 'base_newcontest' default_search_scope :contestnotifications - model_object Contestnotifications + # model_object Contestnotifications before_filter :find_model_object_contest, :except => [:new, :create, :index] before_filter :find_contest_from_association, :except => [:new, :create, :index] before_filter :find_contest_by_contest_id, :only => [:new, :create] before_filter :authorize, :except => [:index] - before_filter :find_optional_contest, :only => :index + before_filter :find_optional_contest, :only => [:index] accept_rss_auth :index accept_api_auth :index + + def index + @user = @contest.author # @contestnotifications = Contestnotification.all # # respond_to do |format| @@ -28,13 +31,13 @@ class ContestnotificationsController < ApplicationController @limit = 10 end - scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible + scope = @contest ? @contest.contestnotifications.visible : Contestnotification.visible @contestnotifications_count = scope.count @contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page'] @offset ||= @contestnotifications_pages.offset @contestnotificationss = scope.all(:include => [:author, :contest], - :order => "#{Contestnotifications.table_name}.created_on DESC", + :order => "#{Contestnotification.table_name}.created_at DESC", :offset => @offset, :limit => @limit) @@ -67,14 +70,14 @@ class ContestnotificationsController < ApplicationController # GET /contestnotifications/new # GET /contestnotifications/new.json def new - # @contestnotification = Contestnotification.new -# - # respond_to do |format| - # format.html # new.html.erb - # format.json { render json: @contestnotification } - # end - @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) - render :layout => 'base_contest' + @contestnotification = Contestnotification.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @contestnotification } + end + # @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) + # render :layout => 'base_contest' end # GET /contestnotifications/1/edit @@ -151,9 +154,9 @@ class ContestnotificationsController < ApplicationController private def find_optional_contest - return true unless params[:contest_id] - @contest = Contest.find(params[:contest_id]) - authorize + return true unless params[:id] + @contest = Contest.find(params[:id]) + # authorize rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/models/contest.rb b/app/models/contest.rb index 4234f7519..d41506b87 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -13,7 +13,7 @@ class Contest < ActiveRecord::Base has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy - has_many :contestnotification, :dependent => :destroy, :include => :author + has_many :contestnotifications, :dependent => :destroy, :include => :author diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index 75b0f5814..f6b0fd168 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -12,9 +12,9 @@ class Contestnotification < ActiveRecord::Base validates_length_of :title, :maximum => 60 validates_length_of :summary, :maximum => 255 - acts_as_attachable :delete_permission => :manage_contestnotification + acts_as_attachable :delete_permission => :manage_contestnotifications acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest - acts_as_event :url => Proc.new {|o| {:controller => 'contestnotification', :action => 'show', :id => o.id}} + acts_as_event :url => Proc.new {|o| {:controller => 'contestnotifications', :action => 'show', :id => o.id}} acts_as_activity_provider :find_options => {:include => [:contest, :author]}, :author_key => :author_id acts_as_watchable @@ -24,9 +24,10 @@ class Contestnotification < ActiveRecord::Base after_create :act_as_activity - # scope :visible, lambda {|*args| - # includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_news, *args)) - # } + scope :visible, lambda {|*args| + nil + #includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contestnotifications, *args)) + } safe_attributes 'title', 'summary', 'description' diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index e69de29bb..73adc758c 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -0,0 +1,101 @@ + + + +<% + btn_tips = l(:label_news_new) + label_tips = l(:label_news) +%> + + + <%= label_tips %> + + +<%= link_to(btn_tips, + new_contest_contestnotification_path(@contest), + :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + +<% if @contest && User.current.allowed_to?(:manage_contestnotifications, @contest) %> + +<% end %> +
+ <% if @contestnotificationss.empty? %> +

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

+ <% else %> + <% @contestnotificationss.each do |contestnotifications| %> + + + + + + +
<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %> + + + + + + + + + + + + +
+ <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(contestnotifications.title), contestnotification_path(contestnotifications) %> + <%= delete_link contestnotification_path(contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %> +
+ <%= textilizable(contestnotifications, :description) %>
<%= l :label_update_time %> +  <%= format_time(contestnotifications.created_at) %><%= link_to l(:label_project_newother), contestnotification_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %>
+
+ <% end %> + <% end %> +
+ +
+ + + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:contest_id => @contest, :key => User.current.rss_key} %> + <% end %> + + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + <% html_title(l(:label_news_plural)) -%> +
+ + + + \ No newline at end of file diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index 6e474b4ea..8b84b9685 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -7,10 +7,10 @@ -<%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_index_path(@contest), +<%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_path(@contest), :html => { :id => 'news-form', :multipart => true } do |f| %> - <%= render :partial => 'news/form', :locals => { :f => f } %> + <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%= preview_link preview_news_path(:contest_id => @contest), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> + <%#= preview_link preview_contestnotifications_path(:contest_id => @contest), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> <% end %>
diff --git a/app/views/roles/roles_controller.rb b/app/views/roles/roles_controller.rb new file mode 100644 index 000000000..f4bae1e81 --- /dev/null +++ b/app/views/roles/roles_controller.rb @@ -0,0 +1,108 @@ +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class RolesController < ApplicationController + layout 'admin' + + before_filter :require_admin, :except => [:index, :show] + before_filter :require_admin_or_api_request, :only => [:index, :show] + before_filter :find_role, :only => [:show, :edit, :update, :destroy] + accept_api_auth :index, :show + + def index + respond_to do |format| + format.html { + @role_pages, @roles = paginate Role.sorted, :per_page => 25 + render :action => "index", :layout => false if request.xhr? + } + format.api { + @roles = Role.givable.all + } + end + end + + def show + respond_to do |format| + format.api + end + end + + def new + # Prefills the form with 'Non member' role permissions by default + @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) + if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy]) + @role.copy_from(@copy_from) + end + @roles = Role.sorted.all + end + + def create + @role = Role.new(params[:role]) + if request.post? && @role.save + # workflow copy + if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from])) + @role.workflow_rules.copy(copy_from) + end + flash[:notice] = l(:notice_successful_create) + redirect_to roles_path + else + @roles = Role.sorted.all + render :action => 'new' + end + end + + def edit + end + + def update + if request.put? and @role.update_attributes(params[:role]) + flash[:notice] = l(:notice_successful_update) + redirect_to roles_path + else + render :action => 'edit' + end + end + + def destroy + @role.destroy + redirect_to roles_path + rescue + flash[:error] = l(:error_can_not_remove_role) + redirect_to roles_path + end + + def permissions + @roles = Role.sorted.all + @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } + if request.post? + @roles.each do |role| + role.permissions = params[:permissions][role.id.to_s] + role.save + end + flash[:notice] = l(:notice_successful_update) + redirect_to roles_path + end + end + + private + + def find_role + @role = Role.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end +end diff --git a/config/routes.rb b/config/routes.rb index c6a727ca6..6876f1af9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,17 +16,16 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - resources :contestnotifications + match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' resources :homework_users - resources :no_uses delete 'no_uses', :to => 'no_uses#delete' - resources :apply_project_masters + resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' resources :homework_attach do @@ -79,6 +78,7 @@ RedmineApp::Application.routes.draw do match 'new_join' , via: :post match 'new' , via: :post end + resources :contestnotifications member do match 'add_softapplication' match 'update_contest' , via: [:put] @@ -95,7 +95,8 @@ RedmineApp::Application.routes.draw do match 'create' , via: :post match 'settings' , via: [:get, :post] - end + end + end resources :stores do From 9d783a7caa0a84681190c5163908da9228b946e7 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 3 Jun 2014 21:52:16 +0800 Subject: [PATCH 008/139] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=AD=89tab-menu=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contestnotifications_controller.rb | 102 ++++--- app/views/contestnotifications/_form.html.erb | 55 ---- app/views/contestnotifications/index.html.erb | 4 - app/views/contestnotifications/new.html.erb | 18 +- app/views/layouts/base_newcontest.html.erb | 41 +-- config/routes.rb | 9 +- db/schema.rb | 271 +++++++++++++----- public/stylesheets/application.css | 4 + 8 files changed, 282 insertions(+), 222 deletions(-) diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 675efd7f0..f2c0fb80f 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -4,31 +4,41 @@ class ContestnotificationsController < ApplicationController layout 'base_newcontest' default_search_scope :contestnotifications # model_object Contestnotifications - before_filter :find_model_object_contest, :except => [:new, :create, :index] - before_filter :find_contest_from_association, :except => [:new, :create, :index] - before_filter :find_contest_by_contest_id, :only => [:new, :create] - before_filter :authorize, :except => [:index] + # before_filter :find_model_object_contest, :except => [:new, :create, :index] + # before_filter :find_contest_from_association, :except => [:new, :create, :index] + # before_filter :find_contest_by_contest_id, :only => [:new, :create] + before_filter :find_contest + before_filter :find_author + # before_filter :authorize, :except => [:index] before_filter :find_optional_contest, :only => [:index] accept_rss_auth :index - accept_api_auth :index - + accept_api_auth :index - - def index + def find_author @user = @contest.author + render_404 if @user.nil? + end + def find_contest + @contest = Contest.find(params[:contest_id]) + render_404 if @contest.nil? + end + + + def index + # @contestnotifications = Contestnotification.all -# + # # respond_to do |format| - # format.html # index.html.erb - # format.json { render json: @contestnotifications } + # format.html # index.html.erb + # format.json { render json: @contestnotifications } # end - + ### begin ### case params[:format] - when 'xml', 'json' - @offset, @limit = api_offset_and_limit - else - @limit = 10 + when 'xml', 'json' + @offset, @limit = api_offset_and_limit + else + @limit = 10 end scope = @contest ? @contest.contestnotifications.visible : Contestnotification.visible @@ -39,8 +49,8 @@ class ContestnotificationsController < ApplicationController @contestnotificationss = scope.all(:include => [:author, :contest], :order => "#{Contestnotification.table_name}.created_at DESC", :offset => @offset, - :limit => @limit) - + :limit => @limit) + respond_to do |format| format.html { @contestnotification = Contestnotification.new # for adding news inline @@ -49,20 +59,20 @@ class ContestnotificationsController < ApplicationController format.api format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } end - ### end ### + ### end ### end # GET /contestnotifications/1 # GET /contestnotifications/1.json def show # @contestnotification = Contestnotification.find(params[:id]) -# + # # respond_to do |format| - # format.html # show.html.erb - # format.json { render json: @contestnotification } + # format.html # show.html.erb + # format.json { render json: @contestnotification } # end @comments = @contestnotifications.comments - @comments.reverse! if User.current.wants_comments_in_reverse_order? + @comments.reverse! if User.current.wants_comments_in_reverse_order? render :layout => 'base_newcontest' end @@ -89,17 +99,17 @@ class ContestnotificationsController < ApplicationController # POST /contestnotifications.json def create # @contestnotification = Contestnotification.new(params[:contestnotification]) -# + # # respond_to do |format| - # if @contestnotification.save - # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' } - # format.json { render json: @contestnotification, status: :created, location: @contestnotification } - # else - # format.html { render action: "new" } - # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } - # end + # if @contestnotification.save + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' } + # format.json { render json: @contestnotification, status: :created, location: @contestnotification } + # else + # format.html { render action: "new" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # end - @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) + # end + @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) @contestnotifications.safe_attributes = params[:contestnotifications] @news.save_attachments(params[:attachments]) if @contestnotifications.save @@ -107,7 +117,7 @@ class ContestnotificationsController < ApplicationController flash[:notice] = l(:notice_successful_create) redirect_to project_news_index_path(@contest) else - layout_file = 'base_contest' + layout_file = 'base_contest' render :action => 'new', :layout => layout_file end end @@ -116,15 +126,15 @@ class ContestnotificationsController < ApplicationController # PUT /contestnotifications/1.json def update # @contestnotification = Contestnotification.find(params[:id]) -# + # # respond_to do |format| - # if @contestnotification.update_attributes(params[:contestnotification]) - # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' } - # format.json { head :no_content } - # else - # format.html { render action: "edit" } - # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } - # end + # if @contestnotification.update_attributes(params[:contestnotification]) + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' } + # format.json { head :no_content } + # else + # format.html { render action: "edit" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } + # end # end @contestnotifications.safe_attributes = params[:contestnotifications] @contestnotifications.save_attachments(params[:attachments]) @@ -142,10 +152,10 @@ class ContestnotificationsController < ApplicationController def destroy # @contestnotification = Contestnotification.find(params[:id]) # @contestnotification.destroy -# + # # respond_to do |format| - # format.html { redirect_to contestnotifications_url } - # format.json { head :no_content } + # format.html { redirect_to contestnotifications_url } + # format.json { head :no_content } # end @contestnotifications.destroy redirect_to contest_contestnotification_index_path(@contest) @@ -156,9 +166,9 @@ class ContestnotificationsController < ApplicationController def find_optional_contest return true unless params[:id] @contest = Contest.find(params[:id]) - # authorize + # authorize rescue ActiveRecord::RecordNotFound render_404 end - + end diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb index 6904714d6..e69de29bb 100644 --- a/app/views/contestnotifications/_form.html.erb +++ b/app/views/contestnotifications/_form.html.erb @@ -1,55 +0,0 @@ - - - -<%= error_messages_for @contestnotifications %> -
- <% str =l(:label_news_new) %> -
-
-

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

- -

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

-

<%= render :partial => 'attachments/form', :locals => {:container => @contestnotifications} %>

-
- -<%= wikitoolbar_for 'news_description' %> diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 73adc758c..090b72a36 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -72,10 +72,6 @@
- <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:contest_id => @contest, :key => User.current.rss_key} %> - <% end %> - <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> <%= stylesheet_link_tag 'scm' %> diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index 8b84b9685..2ad240014 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -1,16 +1,6 @@ - - - - - -<%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_path(@contest), - :html => { :id => 'news-form', :multipart => true } do |f| %> - <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %> - <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%#= preview_link preview_contestnotifications_path(:contest_id => @contest), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> -<% end %> +<%#= labelled_form_for @contestnotifications, :url => contest_contestnotifications_path(@contest), :html => { :id => 'news-form', :multipart => true } do |f| %> + <%#= render :partial => 'contestnotifications/form', :locals => { :f => f } %> + <%#= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> +<%# end %>
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index e621f2f8b..0ac197348 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -43,7 +43,7 @@ <%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> > - <%= link_to @contest.name, show_contest_contest_path %> + <%= link_to @contest.name, show_contest_contest_path(@contest) %> @@ -95,21 +95,17 @@
- - + @@ -127,7 +123,7 @@
- - <%=link_to "#{@contest.watcher_users.count}", :controller => 'contests', :action => 'show_project' %> + <%=link_to "#{@contest.watcher_users.count}",show_project_contest_path(@contest) %> <% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> <%=link_to "#{@contest.projects.where('is_public=1').count}" %> <% else %> - <%=link_to "#{@contest.contesting_softapplications.count}", :controller => 'contests', :action => 'show_attendingcontest' %> + <%=link_to "#{@contest.contesting_softapplications.count}",show_attendingcontest_contest_path(@contest) %> <% end %>
- + @@ -210,25 +206,7 @@
- - +
@@ -236,7 +214,12 @@
<% if display_main_menu?(@contest) %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index dcf5609b7..1c707bdb0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,8 +18,8 @@ RedmineApp::Application.routes.draw do - match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' - + #match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' + resources :homework_users resources :no_uses @@ -72,6 +72,7 @@ RedmineApp::Application.routes.draw do ## new added by linchun #新竞赛相关 resources :contests, only: [:index] do + resources :contestnotifications#, except: [:index] collection do match 'new_contest' , via: :get match 'join_in_contest' , via: :post @@ -80,11 +81,11 @@ RedmineApp::Application.routes.draw do match 'new_join' , via: :post match 'new' , via: :post end - resources :contestnotifications member do + delete 'destroy_contest' match 'add_softapplication' match 'update_contest' , via: [:put] - match 'show_contest' , via: :get + match 'show_contest' , via: [:get, :post] match 'show_project' , via: :get match 'show_softapplication' , via: :get match 'show_attendingcontest' , via: :get diff --git a/db/schema.rb b/db/schema.rb index 1123adad2..0e8337b94 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -23,16 +23,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - create_table "andoidcontests", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - create_table "apply_project_masters", :force => true do |t| t.integer "user_id" t.string "apply_type" @@ -55,18 +45,12 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.datetime "created_on" t.string "description" t.string "disk_directory" - t.integer "attachtype", :default => 1 end add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - create_table "auth_sources", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false @@ -87,6 +71,20 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + create_table "bak_mentioned", :primary_key => "Id", :force => true do |t| + t.string "this_real_name", :limit => 1000 + t.integer "is_mentioned_in" + t.string "context", :limit => 2000 + end + + add_index "bak_mentioned", ["this_real_name", "is_mentioned_in"], :name => "name_mention", :length => {"this_real_name"=>900, "is_mentioned_in"=>nil} + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name" + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_2" + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_3", :length => {"this_real_name"=>900} + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_4" + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_5" + add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_6" + create_table "biding_projects", :force => true do |t| t.integer "project_id" t.integer "bid_id" @@ -126,12 +124,9 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" add_index "boards", ["project_id"], :name => "boards_project_id" - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "categories", :primary_key => "Id", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "proj_categories" end create_table "changes", :force => true do |t| @@ -309,6 +304,14 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" + create_table "eco_projects", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.integer "eco_proj_id" + t.datetime "date_collected" + end + + add_index "eco_projects", ["proj_id"], :name => "proj_id" + create_table "enabled_modules", :force => true do |t| t.integer "project_id" t.string "name", :null => false @@ -330,6 +333,137 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + create_table "events", :primary_key => "event_id", :force => true do |t| + t.string "job_name" + t.datetime "event_time" + t.string "event_type", :limit => 20 + end + + create_table "fm_article", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "article_title", :limit => 16777215 + t.text "article_link", :limit => 16777215 + t.text "article_time", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_article", ["proj_id"], :name => "proj_id" + + create_table "fm_bugtracker_link", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_bugtracker_link", ["proj_id"], :name => "proj_id" + + create_table "fm_datametric_link", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_datametric_link", ["proj_id"], :name => "proj_id" + + create_table "fm_dependency_link", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_dependency_link", ["proj_id"], :name => "proj_id" + + create_table "fm_download_link", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "download_link", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_download_link", ["proj_id"], :name => "proj_id" + + create_table "fm_heartbeat", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.float "popularity_score", :limit => 12 + t.float "vitality_score", :limit => 12 + t.integer "subscription" + t.integer "voting_score" + t.integer "voting_count" + t.datetime "date_collected" + end + + add_index "fm_heartbeat", ["proj_id"], :name => "proj_id" + + create_table "fm_license", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_license", ["proj_id"], :name => "proj_id" + + create_table "fm_mailinglist_link", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_mailinglist_link", ["proj_id"], :name => "proj_id" + + create_table "fm_operating_system", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_operating_system", ["proj_id"], :name => "proj_id" + + create_table "fm_programming_language", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_programming_language", ["proj_id"], :name => "proj_id" + + create_table "fm_project_spotlight", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.text "project_name", :limit => 16777215 + t.text "project_spotlight_link", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_project_spotlight", ["proj_id"], :name => "proj_id" + + create_table "fm_release", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.text "release_version", :limit => 16777215 + t.text "release_time", :limit => 16777215 + t.text "release_tag", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_release", ["proj_id"], :name => "proj_id" + + create_table "fm_submit", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "submitter", :limit => 16777215 + t.text "submitter_link", :limit => 16777215 + t.text "submit_time", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_submit", ["proj_id"], :name => "proj_id" + + create_table "fm_summary", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.text "description", :limit => 16777215 + t.datetime "date_collected" + end + + add_index "fm_summary", ["proj_id"], :name => "proj_id" + create_table "forums", :force => true do |t| t.string "name", :null => false t.string "description", :default => "" @@ -351,12 +485,9 @@ ActiveRecord::Schema.define(:version => 20140530010015) do create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "reward" - t.string "name" - t.string "description" - t.integer "state" end create_table "homework_for_courses", :force => true do |t| @@ -364,13 +495,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.integer "bid_id" end - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "issue_categories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -580,6 +704,14 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.datetime "updated_at", :null => false end + create_table "ohloh_tagged", :force => true do |t| + t.integer "proj_id", :default => 0, :null => false + t.string "description", :limit => 100, :null => false + t.datetime "date_collected" + end + + add_index "ohloh_tagged", ["proj_id"], :name => "proj_id" + create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" @@ -603,7 +735,7 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.integer "users_count", :default => 0 t.date "last_commit_time" t.string "url" - t.date "date_collected" + t.datetime "date_collected" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -644,14 +776,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "projects", :force => true do |t| t.string "name", :default => "", :null => false t.text "description" @@ -667,8 +791,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.boolean "inherit_members", :default => false, :null => false t.integer "project_type" t.boolean "hidden_repo", :default => false, :null => false - t.integer "user_id" - t.integer "attachmenttype", :default => 1 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -697,13 +819,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "queries", ["project_id"], :name => "index_queries_on_project_id" add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "relative_memos", :force => true do |t| t.integer "osp_id", :null => false t.integer "parent_id" @@ -720,10 +835,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.integer "viewed_count_crawl", :default => 0 t.integer "viewed_count_local", :default => 0 t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" end create_table "repositories", :force => true do |t| @@ -756,7 +867,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.string "province" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "logo_link" end create_table "seems_rateable_cached_ratings", :force => true do |t| @@ -812,9 +922,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.integer "softapplication_id" t.integer "is_public" t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" end create_table "students_for_courses", :force => true do |t| @@ -824,6 +931,14 @@ ActiveRecord::Schema.define(:version => 20140530010015) do t.datetime "updated_at", :null => false end + create_table "t_project_to_os_projects", :force => true do |t| + t.integer "crawl_proj_id" + t.string "crawl_proj_web" + t.integer "trustie_osp_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -882,6 +997,22 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" add_index "tokens", ["value"], :name => "tokens_value", :unique => true + create_table "tprojects", :force => true do |t| + t.string "name", :limit => 1000, :default => "0" + t.text "description", :limit => 16777215 + t.string "commit_count", :limit => 100, :default => "0" + t.string "code_line", :limit => 100 + t.string "last_commit_time", :limit => 100 + t.string "url", :limit => 1000 + t.datetime "date_collected" + t.string "created_at", :limit => 100 + t.string "updated_at", :limit => 100 + t.integer "proj_id", :null => false + t.string "user_count", :limit => 100 + end + + add_index "tprojects", ["proj_id"], :name => "proj_id" + create_table "trackers", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.boolean "is_in_chlog", :default => false, :null => false @@ -922,11 +1053,6 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - create_table "user_preferences", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.text "others" @@ -937,11 +1063,16 @@ ActiveRecord::Schema.define(:version => 20140530010015) do add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" create_table "user_scores", :force => true do |t| - t.integer "user_id" - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "activity" + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "level" + t.integer "file" + t.integer "issue" end create_table "user_statuses", :force => true do |t| diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 977aef8fe..ba077555a 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2072,6 +2072,7 @@ button.tab-left, button.tab-right { padding:4px; width: 20px; bottom: -1px; + } button.tab-left { @@ -2115,6 +2116,9 @@ button.tab-right { font-weight:bold; border-top-left-radius:4px; border-top-right-radius:4px; + /*new added*/ + margin-top: 16px; + /*end*/ } #content .tabs_new ul li a:hover { From b5be2d58ceae241d51d1bb64deff981f66e087ec Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 09:35:39 +0800 Subject: [PATCH 009/139] =?UTF-8?q?=E8=8B=B1=E6=96=87=E5=AD=90=E7=AB=99?= =?UTF-8?q?=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 30 +++++++++++++++--------------- config/locales/en.yml | 18 +++++++++++++++++- config/locales/zh.yml | 12 ++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index e6c3ab1f5..6e0d6e919 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -118,13 +118,13 @@
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %> + <%= l(:label_welcome_trustie) %> <%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> - <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> + <%= text_field_tag 'name', params[:name], placeholder:<%=l(:label_searching_intimation)%>, name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%>   <%= hidden_field_tag 'project_type', params[:project_type] %> <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> @@ -139,8 +139,8 @@
-

最新热门竞赛

- <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> +

<%=l(:label_current_hot_contest)%>

+ <%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> @@ -166,7 +166,7 @@
- 发布时间:<%=format_time contest.created_on %> + <%=l(:label_release_time)%>: <%=format_time contest.created_on %>
@@ -179,11 +179,11 @@

- 问题和反馈动态 - <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> - <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%=l(:label_issue_feedback_activities)%> + <%= link_to l(:label_my_question), newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%= link_to l(:label_my_feedback), suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>

- <%= link_to "更多>>", forums_path %> + <%= link_to l(:label_more_information), forums_path %>
    <% find_new_forum_topics(11).each do |topic|%> @@ -197,13 +197,13 @@ <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> - 楼主: <%= link_to_user(topic.author) %> + <%=l(:label_question_sponsor)%>: <%= link_to_user(topic.author) %> - 最后回复:<%=link_to_user topic.last_reply.try(:author) %> + <%=l(:label_final_reply)%>: <%=link_to_user topic.last_reply.try(:author) %> - 回复(<%= link_to topic.try(:replies_count), topic.event_url %>) + <%=l(:label_reply)%>(<%= link_to topic.try(:replies_count), topic.event_url %>)
@@ -214,8 +214,8 @@
-

最新参赛作品

- <%= link_to "更多>>", {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> +

<%=l(:label_current_attendingcontest_work)%>

+ <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
<% if Softapplication.count > 0%>
@@ -235,7 +235,7 @@

- 发布时间:<%=format_time softapplication.created_at %> + <%=l(:label_release_time)%>: <%=format_time softapplication.created_at %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index fd4368be8..072dd9ecb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1402,7 +1402,7 @@ en: #end label_bids_published: published label_bids_published_ago: ago - label_welcome_trustie: Trustie forge + label_welcome_trustie: Trustie label_welcome_trustie_project: Online projects hosting platform label_welcome_trustie_course: Online Courses practice platform label_welcome_trustie_project_description: Software for Chinese college students and practitioners to provide social-oriented project management, code hosting, resource sharing, cooperation and exchange. @@ -1617,6 +1617,22 @@ en: label_class_hour: period label_activity_time: publish date +#added by linchun as competition# + label_welcome_trustie_contest: Contest Platform + label_welcome_trustie_contest_description: For the University student and programming enthusiasts,providing social competition、application、coding management and so on. + + label_current_hot_contest: Latest Hot Competition + label_current_attendingcontest_work: Latest Competition Work + label_issue_feedback_activities: Question&Feedback + label_more_information: More... + label_my_question: My-question + label_my_feedback: My-feedback + label_release_time: Release-time + label_question_sponsor: Sponsor + label_final_reply: Final-reply + label_reply: Reply + +#end # ajax异步验证 modal_valid_passing: can be used. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 51337ddca..b958362c4 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1963,6 +1963,18 @@ zh: label_contest_notification: 竞赛通知 + label_current_hot_contest: 最新热门竞赛 + label_current_attendingcontest_work: 最新参赛作品 + label_issue_feedback_activities: 问题和反馈动态 + label_more_information: 更多... + label_my_question: 我要提问 + label_my_feedback: 我要反馈 + label_release_time: 发布时间 + label_question_sponsor: 楼主 + label_final_reply: 最后回复 + label_reply: 回复 + label_weixin: 微信扫码 + label_searching_intimation: 请输入要搜索的关键字 #end # ajax异步验证 From ebcdd2cc9e761b88aedf1f075ce9bc0034d0de12 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:08:57 +0800 Subject: [PATCH 010/139] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 2 +- config/locales/en.yml | 3 ++- config/locales/zh.yml | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 6e0d6e919..b0432156c 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -124,7 +124,7 @@
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> - <%= text_field_tag 'name', params[:name], placeholder:<%=l(:label_searching_intimation)%>, name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> + <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%>   <%= hidden_field_tag 'project_type', params[:project_type] %> <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 072dd9ecb..3d9349f57 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1631,7 +1631,8 @@ en: label_question_sponsor: Sponsor label_final_reply: Final-reply label_reply: Reply - + label_weixin: WeiXin + label_searching_intimation: please input the keywords #end # ajax异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index b958362c4..9b77a5f57 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1962,7 +1962,8 @@ zh: label_attendingcontestwork_sorting_intimation: 您可以重新打分,打分结果以最后一次打分为主! label_contest_notification: 竞赛通知 - + + #english site translation label_current_hot_contest: 最新热门竞赛 label_current_attendingcontest_work: 最新参赛作品 label_issue_feedback_activities: 问题和反馈动态 @@ -1973,8 +1974,10 @@ zh: label_question_sponsor: 楼主 label_final_reply: 最后回复 label_reply: 回复 - label_weixin: 微信扫码 - label_searching_intimation: 请输入要搜索的关键字 + label_weixin: 微信扫码 + label_search_intimation: 请输入要搜索的关键字 + #end + #end # ajax异步验证 From e5a76251a51f8b08ec48ff97263d43b9a3a34292 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:24:47 +0800 Subject: [PATCH 011/139] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 3d9349f57..d257711f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1405,8 +1405,10 @@ en: label_welcome_trustie: Trustie label_welcome_trustie_project: Online projects hosting platform label_welcome_trustie_course: Online Courses practice platform + label_welcome_trustie_contest: Online Contests practice platform label_welcome_trustie_project_description: Software for Chinese college students and practitioners to provide social-oriented project management, code hosting, resource sharing, cooperation and exchange. label_welcome_trustie_course_description: Teachers and Students for Chinese universities to provide social-oriented curriculum management, resource sharing, cooperation achieved, collaborative research. + label_welcome_trustie_contest_description: Software for Chinese college students and practitioners to provide social-oriented contest management, code hosting, resource sharing, cooperation and exchange. label_welcome_trustie_description: a socialized collaboration platform for project management, collaborative research, software development and software crowdsourcing for creative university students and entrepreneurs. label_user_project: Projects label_bid_respond_quote: Respond @@ -1618,8 +1620,6 @@ en: label_activity_time: publish date #added by linchun as competition# - label_welcome_trustie_contest: Contest Platform - label_welcome_trustie_contest_description: For the University student and programming enthusiasts,providing social competition、application、coding management and so on. label_current_hot_contest: Latest Hot Competition label_current_attendingcontest_work: Latest Competition Work @@ -1630,9 +1630,9 @@ en: label_release_time: Release-time label_question_sponsor: Sponsor label_final_reply: Final-reply - label_reply: Reply - label_weixin: WeiXin - label_searching_intimation: please input the keywords + label_reply: Reply + label_weixin: 微信扫码 + label_search_intimation: 请输入要搜索的关键字 #end # ajax异步验证 From 4b54f2949d44611f04d4c1029ee615f2347c7385 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:28:20 +0800 Subject: [PATCH 012/139] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 2 +- config/locales/en.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index b0432156c..452f10f4b 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -109,7 +109,7 @@
diff --git a/config/locales/en.yml b/config/locales/en.yml index d257711f4..60bb8bbd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1631,7 +1631,7 @@ en: label_question_sponsor: Sponsor label_final_reply: Final-reply label_reply: Reply - label_weixin: 微信扫码 + label_weixin: WeiXin label_search_intimation: 请输入要搜索的关键字 #end From 7abeabeadf3c48134df24a82bae79cff54f94b43 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:31:02 +0800 Subject: [PATCH 013/139] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 2 +- config/locales/en.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 452f10f4b..4bc96cdc1 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -124,7 +124,7 @@
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> - <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> + <%= text_field_tag 'name', params[:name], :placeholder => l(:label_search_intimation), name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%>   <%= hidden_field_tag 'project_type', params[:project_type] %> <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 60bb8bbd0..54057a702 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1632,7 +1632,7 @@ en: label_final_reply: Final-reply label_reply: Reply label_weixin: WeiXin - label_search_intimation: 请输入要搜索的关键字 + label_search_intimation: please input the keywords #end # ajax异步验证 From a38ffb9e9d136bd2b65945396cfcb93bb805434f Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:43:32 +0800 Subject: [PATCH 014/139] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 4 ++-- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 4bc96cdc1..e65e25304 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -154,9 +154,9 @@ <%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> <% if contest.id == 2 or contest.id == 3 or contest.id == 6 %> - (<%= link_to("含#{contest.projects.where('is_public=1').count}个作品", show_attendingcontest_contest_path(contest), :target => "_blank") %>) + (<%= link_to("#{contest.projects.where('is_public=1').count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %>) <% else %> - (<%= link_to("含#{contest.contesting_softapplications.count}个作品", show_attendingcontest_contest_path(contest), :target => "_blank") %>) + (<%= link_to("#{contest.contesting_softapplications.count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %>) <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 54057a702..ffe8b5e31 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1633,6 +1633,7 @@ en: label_reply: Reply label_weixin: WeiXin label_search_intimation: please input the keywords + label_work_quantity: work #end # ajax异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9b77a5f57..b924a24b2 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1976,6 +1976,7 @@ zh: label_reply: 回复 label_weixin: 微信扫码 label_search_intimation: 请输入要搜索的关键字 + label_work_quantity: 个作品 #end #end From da26c70f6c6d61ab08adc9c56f0eed29ad696410 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 4 Jun 2014 10:53:04 +0800 Subject: [PATCH 015/139] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=AD=90=E7=AB=99=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_link_to_another.html.erb | 6 +++--- config/locales/en.yml | 3 +++ config/locales/zh.yml | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/welcome/_link_to_another.html.erb b/app/views/welcome/_link_to_another.html.erb index f5f360d3e..bda48e753 100644 --- a/app/views/welcome/_link_to_another.html.erb +++ b/app/views/welcome/_link_to_another.html.erb @@ -1,6 +1,6 @@
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index ffe8b5e31..7236992fd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1634,6 +1634,9 @@ en: label_weixin: WeiXin label_search_intimation: please input the keywords label_work_quantity: work + label_projects_management_platform: Projects-platform + label_courses_management_platform: Courses-platform + label_contests_management_platform: Competitions-platform #end # ajax异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index b924a24b2..6812d6a63 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1977,6 +1977,9 @@ zh: label_weixin: 微信扫码 label_search_intimation: 请输入要搜索的关键字 label_work_quantity: 个作品 + label_projects_management_platform: 项目托管平台 + label_courses_management_platform: 课程实践平台 + label_contests_management_platform: 竞赛托管平台 #end #end From 8fb82bbdc41966e6d04fae8d7ed6d78d3bca4e61 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 4 Jun 2014 14:20:26 +0800 Subject: [PATCH 016/139] register Mod --- app/models/user.rb | 1 + app/views/account/register.html.erb | 756 +++++++++++++++------------- 2 files changed, 398 insertions(+), 359 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index aef29f18e..d79cf11e1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -137,6 +137,7 @@ class User < Principal has_one :user_extensions,:dependent => :destroy ## end + #default_scope -> { includes(:user_extensions, :user_score) } scope :teacher, -> { joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER) } diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index cc7a26ad8..fac05e6de 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -1,409 +1,447 @@ -

<%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>

+

<%= l(:label_register) %> <%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>

<%= labelled_form_for @user, :url => register_path do |f| %> -<%= error_messages_for 'user' %> + <%= error_messages_for 'user' %> -
-

<%= l(:lable_contest_user) %><%= link_to(@user.show_name, user_path(@user))%><%= l(:lable_contest_user) %><%= link_to(@user.name, user_path(@user))%>
<%= l(:label_bids_reward_method) %><%= @contest.budget%>
- - + +
<%= l(:label_identity) %> * - -
+

+ <% if @user.auth_source_id.nil? %> +

<%= f.text_field :login, :size => 25, :required => true %> + <%= l(:label_max_number) %>

-<% if @user.auth_source_id.nil? %> -

<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %>

-

<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

+

<%= f.password_field :password, :size => 25, :required => true %> + <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

-

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

-<% end %> -
+

+ + + + + + +
+ <%= l(:label_location) %> * + + + + +
+

+ + -

<%= submit_tag l(:button_submit) %>

+

+ + + + +
<%= submit_tag l(:button_submit) %>
+

<% end %> <% if Setting.openid? %> -

<%= f.text_field :identity_url %>

+

<%= f.text_field :identity_url %>

<% end %> -<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %> -

<%= custom_field_tag_with_label :user, value %>

+<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> +

<%= custom_field_tag_with_label :user, value %>

<% end %> \ No newline at end of file From 78ac974a75bc662b56c83bcfad2ac7771e462141 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 4 Jun 2014 16:01:33 +0800 Subject: [PATCH 017/139] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=BD=9C=E4=B8=9A=202.=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E5=9C=A8=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E4=BD=9C=E4=B8=9A=E4=B8=8B=E6=8F=90=E4=BA=A4=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=96=B9=E6=B3=95=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?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/helpers/courses_helper.rb | 2 +- app/views/bids/_bid_homework_show.html.erb | 8 +++++++- config/locales/zh.yml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b0c7e1861..054b3b5a3 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -159,7 +159,7 @@ module CoursesHelper end #获取当前用户在指定作业下提交的作业的集合 def cur_user_homework_for_bid bid - cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,params[:id]) + cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) cur_user_homework end end diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 3ef55c567..c4eb875a1 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -15,7 +15,13 @@ <% if(User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> <%# 提交作业按钮 %> - <%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@project) %> + + <% cur_user_homework = cur_user_homework_for_bid(bid) %> + <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> + <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> + <% else %> + <%= l(:lable_has_commit_homework)%> + <% end %> <% end %> <% if (User.current.admin?||User.current.id==bid.author_id) %> <%= link_to( diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9f6fb26c9..de390a8f8 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1277,6 +1277,7 @@ zh: label_current_contributors: 位当前贡献者 label_commit_limit: 作业提交时间已过! label_commit_ar: 作业提交截止时间快到了! + lable_has_commit_homework: 您已提交过作业 #modify by men label_x_current_contributors: zero: 位当前贡献者 From af68d154515f9d7aa05c8b8c54c36c0bb97d70f4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 4 Jun 2014 16:23:43 +0800 Subject: [PATCH 018/139] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=A2=9E?= =?UTF-8?q?=E3=80=81=E5=88=A0=E3=80=81=E6=94=B9=E3=80=81=E6=9F=A5=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E4=BD=9C=E4=B8=9A=E8=B5=84=E6=96=99=E7=9A=84=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 108 +++++++++++------- app/controllers/zipdown_controller.rb | 19 +-- 2 files changed, 77 insertions(+), 50 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 24e1a86e4..64b34dfc1 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -18,7 +18,8 @@ class HomeworkAttachController < ApplicationController end def create - #if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) + bid = Bid.find params[:bid_id] + if User.current.admin? || User.current.member_of?(bid.courses.first) user_id = params[:user_id] bid_id = params[:bid_id] sta = 0 @@ -32,7 +33,7 @@ class HomeworkAttachController < ApplicationController :bid_id => bid_id } - #@bid = Bid.find bid_id + #@homework_list = @bid.homeworks @homework = HomeworkAttach.new(options) @@ -45,77 +46,98 @@ class HomeworkAttachController < ApplicationController format.json { head :no_content } end else - + render_403 :message => :notice_not_authorized end - #end + else + + end end def new - @homework = HomeworkAttach.new @bid = Bid.find(params[:id]) - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @homework } + if User.current.admin? || User.current.member_of?(@bid.courses.first) + @homework = HomeworkAttach.new + respond_to do |format| + format.html # new.html.erb + format.json { render json: @homework } + end + else + render_403 :message => :notice_not_authorized end end def edit @homework = HomeworkAttach.find(params[:id]) + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + else + render_403 :message => :notice_not_authorized + end end def update @homework = HomeworkAttach.find(params[:id]) - name = params[:homework_name] - description = params[:homework_description] - @homework.name = name - @homework.description = description - if params[:attachments] - @homework.save_attachments(params[:attachments]) - end - if @homework.save - respond_to do |format| - format.html { redirect_to project_for_bid_path @homework.bid } - format.json { head :no_content } + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + name = params[:homework_name] + description = params[:homework_description] + @homework.name = name + @homework.description = description + if params[:attachments] + @homework.save_attachments(params[:attachments]) + end + if @homework.save + respond_to do |format| + format.html { redirect_to project_for_bid_path @homework.bid } + format.json { head :no_content } + end + else end else + render_403 :message => :notice_not_authorized end end def destroy @homework = HomeworkAttach.find(params[:id]) - if @homework.destroy - respond_to do |format| - format.html { redirect_to project_for_bid_path @homework.bid } - format.json { head :no_content } + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if @homework.destroy + respond_to do |format| + format.html { redirect_to project_for_bid_path @homework.bid } + format.json { head :no_content } + end + else end else + render_403 :message => :notice_not_authorized end end #显示作业信息 def show @homework = HomeworkAttach.find(params[:id]) - # 打分统计 - stars_reates = @homework. - rates(:quality) - stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count - stars_status = stars_reates.select("stars, count(*) as scount"). - group("stars") - @stars_status_map = Hash.new(0.0) - stars_status.each do |star_status| - percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f - percent_m = format("%.2f", percent) - @stars_status_map["star#{star_status.stars.to_i}".to_sym] = - percent_m.to_s + "%" + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + # 打分统计 + stars_reates = @homework. + rates(:quality) + stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count + stars_status = stars_reates.select("stars, count(*) as scount"). + group("stars") + @stars_status_map = Hash.new(0.0) + stars_status.each do |star_status| + percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f + percent_m = format("%.2f", percent) + @stars_status_map["star#{star_status.stars.to_i}".to_sym] = + percent_m.to_s + "%" + end + @limit = 10 + @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") + else + render_403 :message => :notice_not_authorized end - @limit = 10 - @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") - @feedback_count = @jours.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - @jour = @jours[@offset, @limit] - @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") end #删除留言 diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 5f5a22279..5caa97a22 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -26,14 +26,19 @@ class ZipdownController < ApplicationController obj_id = params[:obj_id] user_id = params[:user_id] obj = obj_class.constantize.find(obj_id) - zipfile = nil - case obj.class.to_s.to_sym - when :Bid - zipfile = zip_user_bid obj,user_id - else - logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" + + if User.current.admin? || User.current.member_of?(obj.courses.first) + zipfile = nil + case obj.class.to_s.to_sym + when :Bid + zipfile = zip_user_bid obj,user_id + else + logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" + end + send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile + else + render_403 :message => :notice_not_authorized end - send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile end private From 39ce95a950e62553af283021546a97fbc8de5840 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 4 Jun 2014 17:22:42 +0800 Subject: [PATCH 019/139] =?UTF-8?q?=E7=BE=8E=E5=8C=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_homework.html.erb | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 5a358628e..81a8b0861 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -47,27 +47,31 @@
- +
- diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index 2ad240014..c4e322ec8 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -1,6 +1,7 @@ -<%#= labelled_form_for @contestnotifications, :url => contest_contestnotifications_path(@contest), :html => { :id => 'news-form', :multipart => true } do |f| %> - <%#= render :partial => 'contestnotifications/form', :locals => { :f => f } %> - <%#= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> -<%# end %> +<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %> + <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form' ,target='preview',{:class => 'whiteButton m3p10'}%> +<% end %>
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index a8069c73c..517f60bca 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -50,10 +50,10 @@ <% if authorize_for('contestnotifications', 'edit') %> @@ -48,7 +48,7 @@ - +
+ <% if get_avatar?(project) %> - <%= image_tag(url_to_avatar(project),:style => "width:60px;height:60px" ) %> + <%= image_tag(url_to_avatar(project),:style => "width:80px;height:80px" ) %> <% else %> - <%= image_tag('../images/avatars/Project/course.jpg', :style => "width:60px;height:60px") %> + <%= image_tag('../images/avatars/Project/course.jpg', :style => "width:80px;height:80px") %> <% end %> - - - + - - -<% - btn_tips = l(:label_news_new) - label_tips = l(:label_news) -%> - - <%= label_tips %> + <%= l(:label_news) %> -<%= link_to(btn_tips, +<%= link_to(l(:label_news_new), new_contest_contestnotification_path(@contest), :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + :onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %> <% if @contest && User.current.allowed_to?(:manage_contestnotifications, @contest) %> - @@ -55,7 +48,7 @@ - +
课程名: - <%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %> +
+ + + <%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %> + +
作业名: - <%= h @bid.name %> + + + <%= h @bid.name %> +
- <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(contestnotifications.title), contestnotification_path(contestnotifications) %> - <%= delete_link contestnotification_path(contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %> + <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %> + <%= delete_link contest_contestnotification_path(contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %>
<%= l :label_update_time %>  <%= format_time(contestnotifications.created_at) %><%= link_to l(:label_project_newother), contestnotification_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %><%= link_to l(:label_project_newother), contest_contestnotification_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %>
- <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %> + <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %><%= l(:label_project_notice) %><%#= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %> <%= delete_link contest_contestnotification_path(contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %>
<%= l :label_update_time %>  <%= format_time(contestnotifications.created_at) %><%= link_to l(:label_project_newother), contest_contestnotification_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %><%#= link_to l(:label_project_newother), contest_contestnotification_path(contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if(contestnotifications.comments_count >= 0)%>
diff --git a/config/routes.rb b/config/routes.rb index aba8b4e32..df0501209 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,7 +76,7 @@ RedmineApp::Application.routes.draw do match '/contestnotifications/preview', :controller => 'previews', :action => 'contestnotifications', :as => 'preview_contestnotifications', :via => [:get, :post, :put] ## new added by linchun #新竞赛相关 resources :contests, only: [:index] do - resources :contestnotifications#, except: [:index] + resources :contestnotifications collection do match 'new_contest' , via: :get match 'join_in_contest' , via: :post From 2e11d76652d8ce007fb46f07801c35d30731483d Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 4 Jun 2014 21:26:57 +0800 Subject: [PATCH 023/139] lin --- app/models/contestnotification.rb | 2 +- app/views/contestnotifications/index.html.erb | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index b983778e4..a055d3000 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -46,7 +46,7 @@ class Contestnotification < ActiveRecord::Base # returns latest news for contests visible by user def self.latest(user = User.current, count = 5) - visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_on DESC").limit(count).all + visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_at DESC").limit(count).all end private diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 658d7d894..c9ce1622d 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -1,12 +1,11 @@ - <%= l(:label_news) %> <%= link_to(l(:label_news_new), - new_contest_contestnotification_path(@contest), - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %> + new_contest_contestnotification_path(@contest), + :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %> <% if @contest && User.current.allowed_to?(:manage_contestnotifications, @contest) %> <% end %> -
+
<%= textilizable(@contestnotifications, :description) %> @@ -68,13 +68,13 @@ <%= link_to_attachments @contestnotifications %>
- <% if @contestnotifications.commentable? %> + <% if @contestnotifications.notificationcommentable? %>

- <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> + <%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "comment_comments" %>

- <%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotifications}, :id => "add_comment_form", :style => "display:none;") do %> + <%= form_tag({:controller => 'notificationcomments', :action => 'create', :id => @contestnotifications}, :id => "add_notificationcomment_form", :style => "display:none;") do %>
- <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= text_area 'notificationcomment', 'notificationcomments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= wikitoolbar_for 'comment_comments' %>

@@ -92,33 +92,33 @@

-

<%= l(:label_comment_plural) %>

- <% comments = @comments.reverse %> - <% comments.each do |comment| %> - <% next if comment.new_record? %> +

<%= l(:label_comment_plural) %>

+ <% notificationcomments = @notificationcomments.reverse %> + <% notificationcomments.each do |notificationcomment| %> + <% next if notificationcomment.new_record? %> - +
<%= image_tag(url_to_avatar(comment.author), :class => "avatar")%><%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%> - + - - +
<%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %><%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>

- <%= textilizable(comment.comments) %> + <%= textilizable(notificationcomment.notificationcomments) %>

<%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotifications, :comment_id => comment}, + <%= format_time(notificationcomment.created_at) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
- <% end if @comments.any? %> + <% end if @notificationcomments.any? %>
diff --git a/db/schema.rb b/db/schema.rb index 3573c188f..50d8e823f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -211,9 +211,9 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.string "summary" t.string "description" t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "comments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "contests", :force => true do |t| @@ -671,8 +671,8 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.boolean "inherit_members", :default => false, :null => false t.integer "project_type" t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 t.integer "user_id" + t.integer "attachmenttype", :default => 1 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -709,7 +709,7 @@ ActiveRecord::Schema.define(:version => 20140605003915) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id" + t.integer "osp_id", :null => false t.integer "parent_id" t.string "subject", :null => false t.text "content", :null => false @@ -796,10 +796,11 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.string "url" t.string "title" t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_id" t.integer "user_id" + t.string "description" end create_table "softapplications", :force => true do |t| @@ -904,8 +905,8 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "identity" t.string "technical_title" + t.integer "identity" t.string "student_id" t.string "teacher_realname" t.string "student_realname" diff --git a/lib/redmine.rb b/lib/redmine.rb index c612fd89e..71fbfed5b 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -148,9 +148,9 @@ Redmine::AccessControl.map do |map| end map.contest_module :contestnotifications do |map| - map.permission :manage_contestnotifications, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member + map.permission :manage_contestnotifications, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :notificationcomments => [:destroy]}, :require => :member map.permission :view_contestnotifications, {:contestnotifications => [:index, :show]}, :public => true, :read => true - map.permission :comment_contestnotifications, {:comments => :create} + map.permission :notificationcomment_contestnotifications, {:notificationcomments => :create} end map.project_module :documents do |map| From 982bf17ebc0cb25df6e00793f748825ee067a44d Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 11:19:59 +0800 Subject: [PATCH 027/139] dfd --- app/models/contestnotification.rb | 4 ++-- app/models/notificationcomments.rb | 2 +- app/views/contestnotifications/show.html.erb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index cba9dfa0c..04ceb93c2 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -1,10 +1,10 @@ class Contestnotification < ActiveRecord::Base - attr_accessible :author_id, :comments_count, :contest_id, :description, :summary, :title + attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title include Redmine::SafeAttributes belongs_to :contest belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_at" + has_many :notificationcomments, :as => :notificationcommented, :dependent => :delete_all, :order => "created_at" # fq has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/models/notificationcomments.rb b/app/models/notificationcomments.rb index 142cef1db..1aad7c7e3 100644 --- a/app/models/notificationcomments.rb +++ b/app/models/notificationcomments.rb @@ -5,7 +5,7 @@ class Notificationcomments < ActiveRecord::Base belongs_to :notificationcommented, :polymorphic => true, :counter_cache => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - validates_presence_of :notificationcommented, :author, :comments + validates_presence_of :notificationcommented, :author, :notificationcomments safe_attributes 'notificationcomments' end diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index a9ba5f513..bd4c8a4f8 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -70,12 +70,12 @@ <% if @contestnotifications.notificationcommentable? %>

- <%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "comment_comments" %> + <%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "notificationcomment_notificationcomments" %>

<%= form_tag({:controller => 'notificationcomments', :action => 'create', :id => @contestnotifications}, :id => "add_notificationcomment_form", :style => "display:none;") do %>
<%= text_area 'notificationcomment', 'notificationcomments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> - <%= wikitoolbar_for 'comment_comments' %> + <%= wikitoolbar_for 'notificationcomment_notificationcomments' %>

<%= submit_tag l(:button_add) %> From f17c01010f32b7d62b4de711d1abd30715812859 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 11:58:59 +0800 Subject: [PATCH 028/139] werew --- app/models/contestnotification.rb | 2 +- app/views/contestnotifications/index.html.erb | 2 +- app/views/news/index.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index 04ceb93c2..2f09e7f9c 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -1,5 +1,5 @@ class Contestnotification < ActiveRecord::Base - attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title + #attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title include Redmine::SafeAttributes belongs_to :contest diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 93d4aaf1f..f4354a099 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -48,7 +48,7 @@ <%= l :label_update_time %>  <%= format_time(contestnotifications.created_at) %> - <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments.count)})" if(contestnotifications.notificationcomments.count >= 0)%> + <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if(contestnotifications.notificationcomments_count >= 0)%> diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 4dfa21d52..58b3aa43f 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -64,7 +64,7 @@ <%= l :label_update_time %> : <%= format_time(news.created_on) %> - <%= link_to l(:label_project_newother), news_path(news) %><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %> + From 81a97f6a5e98c39053f074a97aa020b2b47bd7c7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Jun 2014 14:00:18 +0800 Subject: [PATCH 029/139] =?UTF-8?q?=201.=E8=80=81=E5=B8=88=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9A=E6=98=AF=E5=90=A6=E5=90=AF=E7=94=A8=E4=BA=92=E8=AF=84?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=AF=A5=E5=8A=9F=E8=83=BD=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82=E5=AF=B9=E4=B8=8D=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E4=BA=92=E8=AF=84=E7=9A=84=E4=BD=9C=E4=B8=9A=EF=BC=8C=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E4=B8=8D=E5=8F=AF=E4=B8=8B=E8=BD=BD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=8F=AF=E4=BA=92=E7=9B=B8=E6=89=93=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E5=8F=AF=E4=BB=A5=E7=95=99=E8=A8=80=EF=BC=9B?= =?UTF-8?q?=E8=80=81=E5=B8=88=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E8=AF=84?= =?UTF-8?q?=E5=88=86=E3=80=81=E4=B8=8B=E8=BD=BD=E4=BD=9C=E4=B8=9A=E7=AD=89?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E3=80=82=E5=90=AF=E7=94=A8=E4=BA=92=E8=AF=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=9F=E8=83=BD=E5=92=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E4=B8=80=E6=A0=B7=20=202.=E5=AF=B9=E5=90=AF=E7=94=A8=E4=BA=92?= =?UTF-8?q?=E8=AF=84=E7=9A=84=E4=BD=9C=E4=B8=9A=EF=BC=8C=E6=AF=8F=E4=B8=AA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AA=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=89=93=E5=88=86=EF=BC=8C=E6=89=93=E5=88=86?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E5=8F=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 +++- app/controllers/homework_attach_controller.rb | 4 +++ app/helpers/courses_helper.rb | 6 +++++ app/helpers/projects_helper.rb | 13 ++++++++++ app/views/bids/_fork_form.html.erb | 1 + app/views/bids/_homework_form.html.erb | 1 + app/views/bids/_homework_list.html.erb | 16 ++++++++++-- .../_comprehensive_evaluation.html.erb | 11 +------- .../homework_attach/_evaluation.html.erb | 4 +++ app/views/homework_attach/show.html.erb | 26 ++++++++++++++----- app/views/projects/_homework_form.html.erb | 4 +-- config/locales/zh.yml | 6 +++++ .../20140605025247_add_evaluation_to_bid.rb | 5 ++++ db/schema.rb | 3 ++- 14 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 app/views/homework_attach/_evaluation.html.erb create mode 100644 db/migrate/20140605025247_add_evaluation_to_bid.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 5fb5d1853..97ebb4d49 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -176,7 +176,8 @@ class BidsController < ApplicationController @homework.budget = 0 @homework.author_id = User.current.id @homework.commit = 0 - @homework.homework_type = params[:bid][:homework_type] + @homework.homework_type = 1 + @homework.is_evaluation = params[:bid][:is_evaluation] @homework.parent_id = @bid.id @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) # @bid. @@ -408,6 +409,7 @@ class BidsController < ApplicationController if @bid.homework_type == 1 @homework = HomeworkAttach.new #@homework_list = @bid.homeworks + #增加作业按评分排序, @homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC") @@ -692,6 +694,7 @@ class BidsController < ApplicationController @bid = Bid.new @bid.name = params[:bid][:name] @bid.description = params[:bid][:description] + @bid.is_evaluation = params[:bid][:is_evaluation] @bid.reward_type = 3 # @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 64b34dfc1..1c3e8cabe 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -128,6 +128,10 @@ class HomeworkAttachController < ApplicationController @stars_status_map["star#{star_status.stars.to_i}".to_sym] = percent_m.to_s + "%" end + #是否已经进行过评价 + @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0 + #是否开启互评功能 + @is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil @limit = 10 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") @feedback_count = @jours.count diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 054b3b5a3..fb0a269e6 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -162,4 +162,10 @@ module CoursesHelper cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) cur_user_homework end + + #判断当前用户对指定作业是否已经评价过 + def has_evaluation? homework + seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count + seem_count > 0 + end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index a42a626dc..085035a2c 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -227,6 +227,19 @@ module ProjectsHelper type << option2 end + #是否启动互评下拉框 + def is_evaluation_option + type = [] + option1 = [] + option2 = [] + option1 << l(:lable_start_mutual_evaluation) + option1 << 1 + option2 << l(:lable_close_mutual_evaluation) + option2 << 2 + type << option1 + type << option2 + end + # 用来判断用户是否是项目的管理员 # added by william def is_manager?(user_id,project_id) diff --git a/app/views/bids/_fork_form.html.erb b/app/views/bids/_fork_form.html.erb index 1bfb4550b..3fcf0f02e 100644 --- a/app/views/bids/_fork_form.html.erb +++ b/app/views/bids/_fork_form.html.erb @@ -19,6 +19,7 @@

<%= f.select :homework_type, homework_type_option %>

--> +

<%= f.select :is_evaluation, is_evaluation_option %>

<%= l(:label_attachment_plural) %>

<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>

\ No newline at end of file diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index f726c038f..92b162035 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -36,6 +36,7 @@

<%= f.select :homework_type, homework_type_option %>

--> +

<%= f.select :is_evaluation, is_evaluation_option %>

<%= hidden_field_tag 'course_id', @project_id %>

<%= l(:label_attachment_plural) %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index fd4b0a93e..5e041065d 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,6 +1,8 @@ <% is_student = is_cur_course_student? @bid.courses.first %> <% is_teacher = is_course_teacher User.current,@bid.courses.first %> + +<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> <%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
@@ -53,11 +55,21 @@ <% else %> <% homework_filename = homework.name %> <% end %> - <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%> + + <% if is_evaluation || is_teacher%> + <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%> + <% else %> + <%= homework_filename %> + <% end %> + <% if is_student %> - <%= link_to "互评>>" , homework_attach_path(homework)%> + <% if is_evaluation %> + <%= link_to "互评>>" , homework_attach_path(homework)%> + <% else %> + <%= link_to "查看详细" , homework_attach_path(homework)%> + <% end %> <% else %> <% if is_teacher %> <%= link_to "综评>>" , homework_attach_path(homework)%> diff --git a/app/views/homework_attach/_comprehensive_evaluation.html.erb b/app/views/homework_attach/_comprehensive_evaluation.html.erb index e6ebacffe..08db30542 100644 --- a/app/views/homework_attach/_comprehensive_evaluation.html.erb +++ b/app/views/homework_attach/_comprehensive_evaluation.html.erb @@ -22,12 +22,6 @@
<%= comprehensive_evaluation.first.notes%>
- <% if is_teacher %> -
评分: - <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
- <% end %>
<% else %> <% if is_teacher %> @@ -35,10 +29,7 @@
作业综评:
-
评分: - <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
+ <%= render :partial => 'evaluation', :locals => {:homework => homework} %>
<%= render :partial => 'addjour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %>
diff --git a/app/views/homework_attach/_evaluation.html.erb b/app/views/homework_attach/_evaluation.html.erb new file mode 100644 index 000000000..bd8677fb1 --- /dev/null +++ b/app/views/homework_attach/_evaluation.html.erb @@ -0,0 +1,4 @@ +
评分: + <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> + (每个用户对每份作业只能进行一次评价!) +
\ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 2b2ec5cce..cdbbe9fda 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -8,7 +8,6 @@ <% is_student = is_cur_course_student? @homework.bid.courses.first %> <% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %> -

<%= notice %>

@@ -29,8 +28,12 @@ 作业下载: - <% options = {:author => true } %> - <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% if @is_evaluation || is_teacher%> + <% options = {:author => true } %> + <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% else %> + <%= l(:label_cant_download) %> + <% end %> 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> @@ -133,10 +136,19 @@
作业评论:
<% if is_student %> -
评分: - <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
+ <% if @is_evaluation %> + <% if @has_evaluation %> +
+ <%= l(:lable_has_evaluation)%> +
+ <% else %> + <%= render :partial => 'evaluation', :locals => {:homework => @homework} %> + <% end %> + <% else %> +
+ <%= l(:lable_close_evaluation)%> +
+ <% end %> <% end %>
diff --git a/app/views/projects/_homework_form.html.erb b/app/views/projects/_homework_form.html.erb index 13255120f..596d83071 100644 --- a/app/views/projects/_homework_form.html.erb +++ b/app/views/projects/_homework_form.html.erb @@ -32,10 +32,8 @@

-->

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>

-

<%= hidden_field_tag 'course_id', @project.id %>

<%= l(:label_attachment_plural) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index de390a8f8..aecf2f19a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1546,6 +1546,7 @@ zh: label_bids_credit_number: 分 field_budget: 奖励 field_deadline: 截止日期 + field_is_evaluation: 是否启动互评 label_tags_selected: 已选标签 label_tags_related: 相关标签 button_project_tags_add: 增加 @@ -1600,6 +1601,9 @@ zh: label_have_feedback: 有了 label_of_feedback: 的 label_welcome_participate: 参与了 + label_cant_download: 未开启互评功能作业不允许下载 + lable_close_evaluation: 该作业未开启互评功能 + lable_has_evaluation: 您已进行过评价 #modify by men label_x_welcome_participate: zero: 参与了 @@ -1789,6 +1793,8 @@ zh: label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 label_task_submit_form_project: 作业最终以项目形式提交 + lable_start_mutual_evaluation: 启动互评 + lable_close_mutual_evaluation: 关闭互评 label_has_been: 已经被 label_course_userd_by: 个课程引用 diff --git a/db/migrate/20140605025247_add_evaluation_to_bid.rb b/db/migrate/20140605025247_add_evaluation_to_bid.rb new file mode 100644 index 000000000..f940974b4 --- /dev/null +++ b/db/migrate/20140605025247_add_evaluation_to_bid.rb @@ -0,0 +1,5 @@ +class AddEvaluationToBid < ActiveRecord::Migration + def change + add_column :bids, :is_evaluation, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 721945ed4..185f5e134 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140527060344) do +ActiveRecord::Schema.define(:version => 20140605025247) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -105,6 +105,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do t.integer "homework_type" t.integer "parent_id" t.string "password" + t.integer "is_evaluation" end create_table "boards", :force => true do |t| From 6abdce1e5918869133ef2c29d4bfbf5dc739a653 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 14:13:27 +0800 Subject: [PATCH 030/139] sdf --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 50d8e823f..7dbc54f02 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -211,9 +211,9 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.string "summary" t.string "description" t.integer "author_id" - t.integer "comments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "contests", :force => true do |t| From f1555bf134a06a202db4e37468515e6f4251f390 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 14:58:24 +0800 Subject: [PATCH 031/139] dfg --- app/controllers/application_controller.rb | 4 ++-- app/views/contestnotifications/index.html.erb | 2 +- app/views/news/index.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 27829fa08..9eadda027 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -296,9 +296,9 @@ class ApplicationController < ActionController::Base end def find_contest_from_association - render_404 unless @contest.present? + render_404 unless @object.present? - @contest = @contest.contest + @contest =@object.contest end def find_model_object diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index f4354a099..195257237 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -48,7 +48,7 @@ <%= l :label_update_time %>  <%= format_time(contestnotifications.created_at) %> - <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if(contestnotifications.notificationcomments_count >= 0)%> + <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count >= 0 %> diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 58b3aa43f..4dfa21d52 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -64,7 +64,7 @@ <%= l :label_update_time %> : <%= format_time(news.created_on) %> - + <%= link_to l(:label_project_newother), news_path(news) %><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %> From cb03669085596ba2e4c10c08b220754f32b4dbbe Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 15:00:38 +0800 Subject: [PATCH 032/139] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index bb7a2424f..ed6cdd25a 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -70,7 +70,12 @@ class Mailer < ActionMailer::Base end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " - else + elsif journals_for_message.jour.class.to_s.to_sym == :Bid + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 999b856d84e907bc188d7c6534ad54494cc21148 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Jun 2014 15:14:51 +0800 Subject: [PATCH 033/139] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=BC=80?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2=E6=95=88?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- app/views/bids/_homework_list.html.erb | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 97ebb4d49..c0df0699c 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -878,7 +878,7 @@ class BidsController < ApplicationController def find_bid if params[:id] - @bid = Bid.find(params[:id]) + @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) @user = @bid.author end rescue diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 5e041065d..48f1c150d 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -99,7 +99,7 @@   - <% if is_cur_course_user? @bid %> + <% if User.current.member_of?(@bid.courses.first) %> <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> <% end %> @@ -112,20 +112,6 @@ <% end %> - - From 0255a61d2f4d1dba0a1904c50cab613c07e6129d Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 15:23:58 +0800 Subject: [PATCH 034/139] dfg --- app/helpers/application_helper.rb | 7 +++++++ app/views/contestnotifications/index.api.rsb | 14 ++++++++++++++ app/views/contestnotifications/show.html.erb | 14 +++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 app/views/contestnotifications/index.api.rsb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd1f6f162..f558f1e7a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,6 +46,10 @@ module ApplicationHelper def authorize_for(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @project) end + + def authorize_for_contest(controller, action) + User.current.allowed_to?({:controller => controller, :action => action}, @contest) + end # Display a link if user is authorized # @@ -57,6 +61,9 @@ module ApplicationHelper link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) end + def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) + link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) + end # Displays a link to user's account page if active def link_to_user(user, options={}) if user.is_a?(User) diff --git a/app/views/contestnotifications/index.api.rsb b/app/views/contestnotifications/index.api.rsb new file mode 100644 index 000000000..6509d2915 --- /dev/null +++ b/app/views/contestnotifications/index.api.rsb @@ -0,0 +1,14 @@ +api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do + @contestnotificationss.each do |contestnotifications| + api.contestnotifications do + api.id contestnotifications.id + api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil? + api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil? + + api.title contestnotifications.title + api.summary contestnotifications.summary + api.description contestnotifications.description + api.created_at contestnotifications.created_at + end + end +end diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index bd4c8a4f8..ead40aef7 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -38,23 +38,23 @@
<%= watcher_link(@contestnotifications, User.current) %> <%= link_to(l(:button_edit), - edit_news_path(@news), + edit_contest_contestnotification_path(@contestnotifications), :class => 'icon icon-edit', :accesskey => accesskey(:edit), - :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %> - <%= delete_link news_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %> + :onclick => '$("#edit-contestnotifications").show(); return false;') if User.current.allowed_to?(:manage_contestnotifications, @contest) %> + <%= delete_link contest_contestnotification_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %>

<%=h @contestnotifications.title %>

-<% if authorize_for('contestnotifications', 'edit') %> -