From 98b6493b9185fd5773f72de81fee7a6a672a52db Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 09:50:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E5=BA=94=E7=94=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E4=BA=BA=E5=91=98=E5=AD=97=E6=AE=B5=E5=8F=8A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/contesting_softapplication.rb | 15 +++++ app/models/softapplication.rb | 2 +- .../contests/_list_softapplications.html.erb | 40 ++++++++++++ app/views/contests/add_softapplication.js.erb | 4 ++ .../softapplications/_message_history.erb | 32 ++++++++++ app/views/softapplications/_new_message.erb | 53 +++++++++++++++ app/views/softapplications/_pre_show.html.erb | 13 ++++ app/views/softapplications/back.js.erb | 2 + .../softapplications/create_message.js.erb | 4 ++ app/views/softapplications/more.js.erb | 2 + app/views/softapplications/new.html.erb | 9 ++- .../softapplications/new.html.erb.BASE.erb | 12 ++++ .../softapplications/new.html.erb.LOCAL.erb | 12 ++++ .../softapplications/new.html.erb.REMOTE.erb | 64 +++++++++++++++++++ app/views/softapplications/new_message.js.erb | 5 ++ app/views/softapplications/show.html.erb | 9 ++- config/locales/zh.yml | 6 +- ...5850_add_contest_id_to_softapplications.rb | 5 ++ ..._softapplication_id_to_softapplications.rb | 5 ++ ...3234_create_contesting_softapplications.rb | 12 ++++ ...d_reward_to_contesting_softapplications.rb | 5 ++ ...05214_add_is_public_to_softapplications.rb | 5 ++ ...plicationdevelopers_to_softapplications.rb | 5 ++ db/schema.rb | 13 +++- test/fixtures/contesting_softapplications.yml | 13 ++++ test/unit/contesting_softapplication_test.rb | 7 ++ 26 files changed, 346 insertions(+), 8 deletions(-) create mode 100644 app/models/contesting_softapplication.rb create mode 100644 app/views/contests/_list_softapplications.html.erb create mode 100644 app/views/contests/add_softapplication.js.erb create mode 100644 app/views/softapplications/_message_history.erb create mode 100644 app/views/softapplications/_new_message.erb create mode 100644 app/views/softapplications/_pre_show.html.erb create mode 100644 app/views/softapplications/back.js.erb create mode 100644 app/views/softapplications/create_message.js.erb create mode 100644 app/views/softapplications/more.js.erb create mode 100644 app/views/softapplications/new.html.erb.BASE.erb create mode 100644 app/views/softapplications/new.html.erb.LOCAL.erb create mode 100644 app/views/softapplications/new.html.erb.REMOTE.erb create mode 100644 app/views/softapplications/new_message.js.erb create mode 100644 db/migrate/20140410015850_add_contest_id_to_softapplications.rb create mode 100644 db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb create mode 100644 db/migrate/20140411003234_create_contesting_softapplications.rb create mode 100644 db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb create mode 100644 db/migrate/20140411005214_add_is_public_to_softapplications.rb create mode 100644 db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb create mode 100644 test/fixtures/contesting_softapplications.yml create mode 100644 test/unit/contesting_softapplication_test.rb diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb new file mode 100644 index 000000000..93aea2658 --- /dev/null +++ b/app/models/contesting_softapplication.rb @@ -0,0 +1,15 @@ + +class ContestingSoftapplication < ActiveRecord::Base + attr_accessible :contest_id, :description, :softapplication_id, :user_id + + belongs_to :contest + belongs_to :softapplication + belongs_to :user + + + def self.create_softapplication_contesting(contest_id, softapplication_id, description = nil) + self.create(:user_id => User.current.id, :contest_id => contest_id, + :softapplication_id => softapplication_id, :description => description) + end + +end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index e63eb428d..fa90881bf 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,5 +1,5 @@ class Softapplication < ActiveRecord::Base - attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id + attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers acts_as_attachable has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :contesting_softapplications, :dependent => :destroy diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb new file mode 100644 index 000000000..a0099c727 --- /dev/null +++ b/app/views/contests/_list_softapplications.html.erb @@ -0,0 +1,40 @@ + +<% contesting_softapplication.each do |c_softapplication|%> + <% if c_softapplication.softapplication %> + + + + +
+ + + + + + +
+ + + + + + + + + + + + +
+ + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %> + + <%= l(:label_joined_contest)%> +
<%= c_softapplication.softapplication.description %>
+ <%=format_time c_softapplication.created_at %> +
+
+
+ <% end %> +<% end %> + diff --git a/app/views/contests/add_softapplication.js.erb b/app/views/contests/add_softapplication.js.erb new file mode 100644 index 000000000..6071c7070 --- /dev/null +++ b/app/views/contests/add_softapplication.js.erb @@ -0,0 +1,4 @@ +$('#contesting_softapplication_list').html('<%= escape_javascript(render(:partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication})) %>'); +$("#softapplication_id").val("请选择参赛应用"); +$("#contest_message").val( "<%= l(:label_bid_reason) %>" ); +$("#put-bid-form").hide(); \ No newline at end of file diff --git a/app/views/softapplications/_message_history.erb b/app/views/softapplications/_message_history.erb new file mode 100644 index 000000000..4190e899d --- /dev/null +++ b/app/views/softapplications/_message_history.erb @@ -0,0 +1,32 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> + + +
+ <%= render :partial => 'new_message', :locals => {:softapplication => @softapplication, :sta => @state} %> +
+ + +<% if journals.size >0 %> + +<% end %> diff --git a/app/views/softapplications/_new_message.erb b/app/views/softapplications/_new_message.erb new file mode 100644 index 000000000..e46fb2997 --- /dev/null +++ b/app/views/softapplications/_new_message.erb @@ -0,0 +1,53 @@ + + + +<%= form_for('softapplication_message', + :remote => true, :method => :post, + :url => {:controller => 'softapplications', + :action => 'create_message', + :id => softapplication, + :sta => sta} + ) do |f|%> + +
+ <%= render :partial => 'pre_show', :locals => {:content => @content} %> +
+ + <% if User.current.logged? %> + + + + +
<%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%>
+ + <%= f.text_field :reference_user_id, :style=>"display:none"%> + + + + + + +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "softapplication_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('softapplication_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ + <% else %> +
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+ <% end %> +<% end %> diff --git a/app/views/softapplications/_pre_show.html.erb b/app/views/softapplications/_pre_show.html.erb new file mode 100644 index 000000000..fef1f16e4 --- /dev/null +++ b/app/views/softapplications/_pre_show.html.erb @@ -0,0 +1,13 @@ + +<% unless content.nil?%> + + + + + + + +
<%= textilizable content %>
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%>
+<% end %> + + diff --git a/app/views/softapplications/back.js.erb b/app/views/softapplications/back.js.erb new file mode 100644 index 000000000..acd52a63e --- /dev/null +++ b/app/views/softapplications/back.js.erb @@ -0,0 +1,2 @@ +$('#message_history').html('<%= escape_javascript(render(:partial => 'history_message', :locals => {:softapplication => @softapplication, :journals => @jour, :state => @state})) %>'); +$('#softapplication_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/softapplications/create_message.js.erb b/app/views/softapplications/create_message.js.erb new file mode 100644 index 000000000..bd0b13369 --- /dev/null +++ b/app/views/softapplications/create_message.js.erb @@ -0,0 +1,4 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'softapplications/message_history', :locals => {:contest => @softapplication, :journals => @jour, :state => true})) %>'); +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); +$('#softapplication_message_message').val(""); +$('#softapplication_message_reference_user_id').val(""); diff --git a/app/views/softapplications/more.js.erb b/app/views/softapplications/more.js.erb new file mode 100644 index 000000000..fc67a9fed --- /dev/null +++ b/app/views/softapplications/more.js.erb @@ -0,0 +1,2 @@ +$('#message_history').html('<%= escape_javascript(render(:partial => 'message_history', :locals => {:softapplication => @softapplication, :journals => @jour, :state => @state})) %>'); +$('#softapplication_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index cd46c7572..b47930d60 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -41,7 +41,14 @@

- + + + <%= l(:label_softapplication_developers) %> + * : <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
上传应用软件包或应用截图 <%= render_flash_messages %> diff --git a/app/views/softapplications/new.html.erb.BASE.erb b/app/views/softapplications/new.html.erb.BASE.erb new file mode 100644 index 000000000..40c6a4059 --- /dev/null +++ b/app/views/softapplications/new.html.erb.BASE.erb @@ -0,0 +1,12 @@ +

<%=l(:label_release_softapplication)%>

+ + +<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> +
+ <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/softapplications/new.html.erb.LOCAL.erb b/app/views/softapplications/new.html.erb.LOCAL.erb new file mode 100644 index 000000000..bf4e19f3f --- /dev/null +++ b/app/views/softapplications/new.html.erb.LOCAL.erb @@ -0,0 +1,12 @@ +

<%=l(:label_release_softapplication)%>

+ + +<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> +
+ <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/softapplications/new.html.erb.REMOTE.erb b/app/views/softapplications/new.html.erb.REMOTE.erb new file mode 100644 index 000000000..820165819 --- /dev/null +++ b/app/views/softapplications/new.html.erb.REMOTE.erb @@ -0,0 +1,64 @@ +

<%= l(:label_release_softapplication)%>

+ + +
+ <%= form_for Softapplication.new, :url => {:controller => 'softapplications', :action => 'create'}, :update => "bidding_project_list", :complete => '$("#put-bid-form").hide();', :html => {:multipart => true, :id => 'add_homework_form'} do |f| %> +
+ + <%= l(:label_attachment_plural) %> + + + <%= l(:label_softapplication_name) %> + * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_name_condition)%> + +
+
+ + + <%= l(:label_softapplication_version_available) %> + * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ + + <%= l(:label_softapplication_type) %> + + * : <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ + + <%= l(:label_softapplication_description) %> + * : <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ <%= render_flash_messages %> +

+ <%= render :partial => 'attachments/form' %> +

+
+ <%= submit_tag l(:button_create), :onclick => "return true" %> + +
+ + <% end %> + \ No newline at end of file diff --git a/app/views/softapplications/new_message.js.erb b/app/views/softapplications/new_message.js.erb new file mode 100644 index 000000000..ea1d02a33 --- /dev/null +++ b/app/views/softapplications/new_message.js.erb @@ -0,0 +1,5 @@ +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => @content})) %>'); +$('#softapplication_message_reference_user_id').val("<%= @id%>"); +showAndScrollTo("pre_show", "softapplication_message_reference_user_id"); + + diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index a01006cbb..c5ecac2c1 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -9,7 +9,7 @@

<%= notice %>

- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> +
@@ -24,10 +24,13 @@ 发布时间:<%=format_time @softapplication.created_at %> - 开发者:<%= @softapplication.user.name %> + 发布人员:<%= @softapplication.user.name %> 系统支持:<%= @softapplication.android_min_version_available %> - + + 应用下载: + 开发人员:<%= @softapplication.application_developers %> + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f5f120925..7db6f8908 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1837,7 +1837,9 @@ zh: label_softapplication_description: 应用简介 label_softapplication_type: 应用分类 label_softapplication_version_available: 适配版本 - label_softapplication_developer: 开发者 + label_softapplication_developer: 上传人员 + label_softapplication_developers: 开发人员 label_softapplication_name_condition: 25个汉字以内(50个字符) label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 - label_contest_description_no: 暂无描述。 \ No newline at end of file + label_contest_description_no: 暂无描述。 + \ No newline at end of file diff --git a/db/migrate/20140410015850_add_contest_id_to_softapplications.rb b/db/migrate/20140410015850_add_contest_id_to_softapplications.rb new file mode 100644 index 000000000..b7b73a4aa --- /dev/null +++ b/db/migrate/20140410015850_add_contest_id_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddContestIdToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :contest_id, :integer + end +end diff --git a/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb b/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb new file mode 100644 index 000000000..e4a51f535 --- /dev/null +++ b/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddSoftapplicationIdToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :softapplication_id, :integer + end +end diff --git a/db/migrate/20140411003234_create_contesting_softapplications.rb b/db/migrate/20140411003234_create_contesting_softapplications.rb new file mode 100644 index 000000000..118b518f5 --- /dev/null +++ b/db/migrate/20140411003234_create_contesting_softapplications.rb @@ -0,0 +1,12 @@ +class CreateContestingSoftapplications < ActiveRecord::Migration + def change + create_table :contesting_softapplications do |t| + t.integer :softapplication_id + t.integer :contest_id + t.integer :user_id + t.string :description + + t.timestamps + end + end +end diff --git a/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb b/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb new file mode 100644 index 000000000..e5e3db183 --- /dev/null +++ b/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb @@ -0,0 +1,5 @@ +class AddRewardToContestingSoftapplications < ActiveRecord::Migration + def change + add_column :contesting_softapplications, :reward, :string + end +end diff --git a/db/migrate/20140411005214_add_is_public_to_softapplications.rb b/db/migrate/20140411005214_add_is_public_to_softapplications.rb new file mode 100644 index 000000000..15d81699e --- /dev/null +++ b/db/migrate/20140411005214_add_is_public_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddIsPublicToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :is_public, :integer + end +end diff --git a/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb b/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb new file mode 100644 index 000000000..2a4ad1081 --- /dev/null +++ b/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddApplicationdevelopersToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :application_developers, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 8b443264f..54947fe75 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 => 20140411005214) do +ActiveRecord::Schema.define(:version => 20140414012423) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -696,6 +696,7 @@ ActiveRecord::Schema.define(:version => 20140411005214) do t.integer "contest_id" t.integer "softapplication_id" t.integer "is_public" + t.string "application_developers" end create_table "students_for_courses", :force => true do |t| @@ -811,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20140411005214) 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", :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 + end + create_table "user_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" diff --git a/test/fixtures/contesting_softapplications.yml b/test/fixtures/contesting_softapplications.yml new file mode 100644 index 000000000..4b64c8b03 --- /dev/null +++ b/test/fixtures/contesting_softapplications.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + softapplication_id: 1 + contest_id: 1 + user_id: 1 + description: MyString + +two: + softapplication_id: 1 + contest_id: 1 + user_id: 1 + description: MyString diff --git a/test/unit/contesting_softapplication_test.rb b/test/unit/contesting_softapplication_test.rb new file mode 100644 index 000000000..0c1364caa --- /dev/null +++ b/test/unit/contesting_softapplication_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContestingSoftapplicationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end