From a9e917144145d1a0d7c3e4b19cf0ef780552851c Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 4 Apr 2014 17:54:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E8=84=9A=E6=89=8B=E6=9E=B6?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BA=86=E4=B8=80=E5=A5=97=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=B8=9C=E8=A5=BF=EF=BC=8C=E5=8C=85=E6=8B=AC=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E7=9A=84=E7=9B=B8=E5=BA=94=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BA=86=E5=8F=91=E5=B8=83=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=8A=9F=E8=83=BD=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=A0=BC=E5=BC=8F=E8=BF=98=E9=9C=80=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/softapplications.js | 2 + app/assets/stylesheets/softapplications.css | 4 + .../softapplications_controller.rb | 83 +++++++++++++++++++ app/helpers/softapplications_helper.rb | 2 + app/models/softapplication.rb | 3 + .../contests/_softapplication_list.html.erb | 16 ++++ .../contests/show_softapplication.html.erb | 63 ++++++++++++++ app/views/softapplications/_form.html.erb | 64 ++++++++++++++ app/views/softapplications/edit.html.erb | 6 ++ app/views/softapplications/index.html.erb | 33 ++++++++ app/views/softapplications/new.html.erb | 12 +++ app/views/softapplications/show.html.erb | 35 ++++++++ config/locales/zh.yml | 11 ++- .../20140404030103_create_softapplications.rb | 14 ++++ public/stylesheets/application.css | 10 ++- test/fixtures/softapplications.yml | 17 ++++ .../softapplications_controller_test.rb | 49 +++++++++++ .../helpers/softapplications_helper_test.rb | 4 + test/unit/softapplication_test.rb | 7 ++ 19 files changed, 433 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/softapplications.js create mode 100644 app/assets/stylesheets/softapplications.css create mode 100644 app/controllers/softapplications_controller.rb create mode 100644 app/helpers/softapplications_helper.rb create mode 100644 app/models/softapplication.rb create mode 100644 app/views/contests/_softapplication_list.html.erb create mode 100644 app/views/contests/show_softapplication.html.erb create mode 100644 app/views/softapplications/_form.html.erb create mode 100644 app/views/softapplications/edit.html.erb create mode 100644 app/views/softapplications/index.html.erb create mode 100644 app/views/softapplications/new.html.erb create mode 100644 app/views/softapplications/show.html.erb create mode 100644 db/migrate/20140404030103_create_softapplications.rb create mode 100644 test/fixtures/softapplications.yml create mode 100644 test/functional/softapplications_controller_test.rb create mode 100644 test/unit/helpers/softapplications_helper_test.rb create mode 100644 test/unit/softapplication_test.rb diff --git a/app/assets/javascripts/softapplications.js b/app/assets/javascripts/softapplications.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/softapplications.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/softapplications.css b/app/assets/stylesheets/softapplications.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/app/assets/stylesheets/softapplications.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/softapplications_controller.rb b/app/controllers/softapplications_controller.rb new file mode 100644 index 00000000..3bddec62 --- /dev/null +++ b/app/controllers/softapplications_controller.rb @@ -0,0 +1,83 @@ +class SoftapplicationsController < ApplicationController + # GET /softapplications + # GET /softapplications.json + def index + @softapplications = Softapplication.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @softapplications } + end + end + + # GET /softapplications/1 + # GET /softapplications/1.json + def show + @softapplication = Softapplication.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @softapplication } + end + end + + # GET /softapplications/new + # GET /softapplications/new.json + def new + @softapplication = Softapplication.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @softapplication } + end + end + + # GET /softapplications/1/edit + def edit + @softapplication = Softapplication.find(params[:id]) + end + + # POST /softapplications + # POST /softapplications.json + def create + @softapplication = Softapplication.new(params[:softapplication]) + + respond_to do |format| + if @softapplication.save + format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } + format.json { render json: @softapplication, status: :created, location: @softapplication } + else + format.html { render action: "new" } + format.json { render json: @softapplication.errors, status: :unprocessable_entity } + end + end + end + + # PUT /softapplications/1 + # PUT /softapplications/1.json + def update + @softapplication = Softapplication.find(params[:id]) + + respond_to do |format| + if @softapplication.update_attributes(params[:softapplication]) + format.html { redirect_to @softapplication, notice: 'Softapplication was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @softapplication.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /softapplications/1 + # DELETE /softapplications/1.json + def destroy + @softapplication = Softapplication.find(params[:id]) + @softapplication.destroy + + respond_to do |format| + format.html { redirect_to softapplications_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/softapplications_helper.rb b/app/helpers/softapplications_helper.rb new file mode 100644 index 00000000..e3cb6410 --- /dev/null +++ b/app/helpers/softapplications_helper.rb @@ -0,0 +1,2 @@ +module SoftapplicationsHelper +end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb new file mode 100644 index 00000000..53440be8 --- /dev/null +++ b/app/models/softapplication.rb @@ -0,0 +1,3 @@ +class Softapplication < ActiveRecord::Base + attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id +end diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb new file mode 100644 index 00000000..9a257683 --- /dev/null +++ b/app/views/contests/_softapplication_list.html.erb @@ -0,0 +1,16 @@ + +<%= render_flash_messages %> + + + + <% if User.current.logged? %> + + <% end %> +
<%= l(:label_bidding_project) %> +
+ + <%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %> +
+
+ +<%#= render :partial=> "list_projects" %> diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb new file mode 100644 index 00000000..b3e38d5f --- /dev/null +++ b/app/views/contests/show_softapplication.html.erb @@ -0,0 +1,63 @@ + + + + + + +
+ <%= render :partial => 'softapplication_list' %> +
+ diff --git a/app/views/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb new file mode 100644 index 00000000..5a046801 --- /dev/null +++ b/app/views/softapplications/_form.html.erb @@ -0,0 +1,64 @@ +<%= form_for(@softapplication) do |f| %> + + <% if @softapplication.errors.any? %> +
+

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

+ + +
+ <% end %> + + + <%= 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;" %> + +

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

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

+
+
+ +
+
+ <%=l(:label_upload_softapplication_photo)%> :(<%=l(:label_upload_softapplication_photo_condition)%>)
+

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

+
+
+ +<% end %> + diff --git a/app/views/softapplications/edit.html.erb b/app/views/softapplications/edit.html.erb new file mode 100644 index 00000000..f93e091d --- /dev/null +++ b/app/views/softapplications/edit.html.erb @@ -0,0 +1,6 @@ +

Editing softapplication

+ +<%= render 'form' %> + +<%= link_to 'Show', @softapplication %> | +<%= link_to 'Back', softapplications_path %> diff --git a/app/views/softapplications/index.html.erb b/app/views/softapplications/index.html.erb new file mode 100644 index 00000000..be924587 --- /dev/null +++ b/app/views/softapplications/index.html.erb @@ -0,0 +1,33 @@ +

Listing softapplications

+ + + + + + + + + + + + + + +<% @softapplications.each do |softapplication| %> + + + + + + + + + + + +<% end %> +
NameDescriptionApp typeApp type nameAndroid min version availableUser
<%= softapplication.name %><%= softapplication.description %><%= softapplication.app_type_id %><%= softapplication.app_type_name %><%= softapplication.android_min_version_available %><%= softapplication.user_id %><%= link_to 'Show', softapplication %><%= link_to 'Edit', edit_softapplication_path(softapplication) %><%= link_to 'Destroy', softapplication, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Softapplication', new_softapplication_path %> diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb new file mode 100644 index 00000000..40c6a405 --- /dev/null +++ b/app/views/softapplications/new.html.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/show.html.erb b/app/views/softapplications/show.html.erb new file mode 100644 index 00000000..faf8a93e --- /dev/null +++ b/app/views/softapplications/show.html.erb @@ -0,0 +1,35 @@ +

<%= notice %>

+ +

+ Name: + <%= @softapplication.name %> +

+ +

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

+ +

+ App type: + <%= @softapplication.app_type_id %> +

+ +

+ App type name: + <%= @softapplication.app_type_name %> +

+ +

+ Android min version available: + <%= @softapplication.android_min_version_available %> +

+ +

+ User: + <%= @softapplication.user_id %> +

+ + +<%= link_to 'Edit', edit_softapplication_path(@softapplication) %> | +<%= link_to 'Back', softapplications_path %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 448690b4..ffcfd129 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1826,4 +1826,13 @@ zh: label_contest_application: 参赛应用 button_contesting_as_project: 我要参赛(新建项目) button_contesting_as_application: 我要参赛(发布应用) - + label_release_softapplication: 发布应用 + label_upload_softapplication_packets: 上传应用软件包 + label_upload_softapplication_photo: 上传产品截图 + label_upload_softapplication_photo_condition: 至少上传2张截图,至多4张;格式为gif/jpg/png, 尺寸480*800, 每张小于2M + label_softapplication_name: 应用名称 + label_softapplication_description: 应用简介 + label_softapplication_type: 应用分类 + label_softapplication_version_available: 适配版本 + label_softapplication_developer: 开发者 + label_softapplication_name_condition: 25个汉字以内(50个字符) diff --git a/db/migrate/20140404030103_create_softapplications.rb b/db/migrate/20140404030103_create_softapplications.rb new file mode 100644 index 00000000..f9094d9c --- /dev/null +++ b/db/migrate/20140404030103_create_softapplications.rb @@ -0,0 +1,14 @@ +class CreateSoftapplications < ActiveRecord::Migration + def change + create_table :softapplications do |t| + t.string :name + t.string :description + t.integer :app_type_id + t.string :app_type_name + t.string :android_min_version_available + t.integer :user_id + + t.timestamps + end + end +end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e6031684..514cb768 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2693,4 +2693,12 @@ div.repos_explain{ margin-left: -220px; } - +/* new linchun compitition */ +.contest_underline{ + margin:1; + padding:1; + width:900px; + height:0.5px; + background-color:#aaa; + overflow:hidden +} diff --git a/test/fixtures/softapplications.yml b/test/fixtures/softapplications.yml new file mode 100644 index 00000000..0ab48299 --- /dev/null +++ b/test/fixtures/softapplications.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyString + app_type_id: 1 + app_type_name: MyString + android_min_version_available: MyString + user_id: 1 + +two: + name: MyString + description: MyString + app_type_id: 1 + app_type_name: MyString + android_min_version_available: MyString + user_id: 1 diff --git a/test/functional/softapplications_controller_test.rb b/test/functional/softapplications_controller_test.rb new file mode 100644 index 00000000..8c5611cb --- /dev/null +++ b/test/functional/softapplications_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SoftapplicationsControllerTest < ActionController::TestCase + setup do + @softapplication = softapplications(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:softapplications) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create softapplication" do + assert_difference('Softapplication.count') do + post :create, softapplication: { android_min_version_available: @softapplication.android_min_version_available, app_type_id: @softapplication.app_type_id, app_type_name: @softapplication.app_type_name, description: @softapplication.description, name: @softapplication.name, user_id: @softapplication.user_id } + end + + assert_redirected_to softapplication_path(assigns(:softapplication)) + end + + test "should show softapplication" do + get :show, id: @softapplication + assert_response :success + end + + test "should get edit" do + get :edit, id: @softapplication + assert_response :success + end + + test "should update softapplication" do + put :update, id: @softapplication, softapplication: { android_min_version_available: @softapplication.android_min_version_available, app_type_id: @softapplication.app_type_id, app_type_name: @softapplication.app_type_name, description: @softapplication.description, name: @softapplication.name, user_id: @softapplication.user_id } + assert_redirected_to softapplication_path(assigns(:softapplication)) + end + + test "should destroy softapplication" do + assert_difference('Softapplication.count', -1) do + delete :destroy, id: @softapplication + end + + assert_redirected_to softapplications_path + end +end diff --git a/test/unit/helpers/softapplications_helper_test.rb b/test/unit/helpers/softapplications_helper_test.rb new file mode 100644 index 00000000..ad817360 --- /dev/null +++ b/test/unit/helpers/softapplications_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SoftapplicationsHelperTest < ActionView::TestCase +end diff --git a/test/unit/softapplication_test.rb b/test/unit/softapplication_test.rb new file mode 100644 index 00000000..b3872eec --- /dev/null +++ b/test/unit/softapplication_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SoftapplicationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end