通过脚手架新建了一套应用的东西,包括数据库的相应表,新建了发布应用的页面,上传图片功能未实现,界面格式还需调整

This commit is contained in:
wanglinchun 2014-04-04 17:54:20 +08:00
parent c86af5f483
commit a9e9171441
19 changed files with 433 additions and 2 deletions

View File

@ -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.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -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

View File

@ -0,0 +1,2 @@
module SoftapplicationsHelper
end

View File

@ -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

View File

@ -0,0 +1,16 @@
<!-- fq -->
<%= render_flash_messages %>
<table width="100%" border="0" style="padding-left: 15px">
<td width="15%" class="font_lighter" style="font-size: 15px;"><%= l(:label_bidding_project) %></td> <!--标注参赛应用及数量-->
<% if User.current.logged? %>
<td width="85%">
<div class='icon icon-add'> <!--标注我要参加及添加图标-->
<%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %>
</div>
</td>
<% end %>
</table>
<%#= render :partial=> "list_projects" %>

View File

@ -0,0 +1,63 @@
<style>
input[type="submit"].contest_btn {
vertical-align: middle;
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
/*margin-right: -4px;*/
}
input[type="button"].contest_btn {
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<script type="text/javascript" language="javascript">
function clearInfo(id,content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
function showInfo(id,content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
function cancel() {
$("#put-bid-form").hide();
}
</script>
<div id='bidding_project_list'>
<%= render :partial => 'softapplication_list' %>
</div>

View File

@ -0,0 +1,64 @@
<%= form_for(@softapplication) do |f| %>
<% if @softapplication.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@softapplication.errors.count, "error") %> prohibited this softapplication from being saved:</h2>
<ul>
<% @softapplication.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<tr style="width:700px; margin-left: -10px">
<td><%= l(:label_softapplication_name) %></td>
<td style="require, color: #bb0000"> * </td>:
<td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
<td><%= l(:label_softapplication_name_condition)%></td>
</tr></ br><br /><br />
<tr style="width:800px;">
<td><%= l(:label_softapplication_version_available) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br><br /><br />
<tr style="width:800px;">
<td><%= l(:label_softapplication_type) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br><br /><br />
<tr style="width:800px;">
<td><%= l(:label_softapplication_description) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br><br /><br />
<fieldset style="width: 600px">
<div>
<%=l(:label_upload_softapplication_packets)%>&nbsp;:<br />
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
</div>
</fieldset></tr></ br></ br></ br></ br></ br>
<fieldset style="width: 600px">
<div>
<span><%=l(:label_upload_softapplication_photo)%>&nbsp;:</span>(<span style="font-size: 3px"><%=l(:label_upload_softapplication_photo_condition)%></span>)<br />
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,6 @@
<h1>Editing softapplication</h1>
<%= render 'form' %>
<%= link_to 'Show', @softapplication %> |
<%= link_to 'Back', softapplications_path %>

View File

@ -0,0 +1,33 @@
<h1>Listing softapplications</h1>
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>App type</th>
<th>App type name</th>
<th>Android min version available</th>
<th>User</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @softapplications.each do |softapplication| %>
<tr>
<td><%= softapplication.name %></td>
<td><%= softapplication.description %></td>
<td><%= softapplication.app_type_id %></td>
<td><%= softapplication.app_type_name %></td>
<td><%= softapplication.android_min_version_available %></td>
<td><%= softapplication.user_id %></td>
<td><%= link_to 'Show', softapplication %></td>
<td><%= link_to 'Edit', edit_softapplication_path(softapplication) %></td>
<td><%= link_to 'Destroy', softapplication, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Softapplication', new_softapplication_path %>

View File

@ -0,0 +1,12 @@
<h3><%=l(:label_release_softapplication)%></h3>
<!-- <%= render 'form' %>
<%= link_to 'Back', softapplications_path %> -->
<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %>
<div class="box tabular">
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>
</div>

View File

@ -0,0 +1,35 @@
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @softapplication.name %>
</p>
<p>
<b>Description:</b>
<%= @softapplication.description %>
</p>
<p>
<b>App type:</b>
<%= @softapplication.app_type_id %>
</p>
<p>
<b>App type name:</b>
<%= @softapplication.app_type_name %>
</p>
<p>
<b>Android min version available:</b>
<%= @softapplication.android_min_version_available %>
</p>
<p>
<b>User:</b>
<%= @softapplication.user_id %>
</p>
<%= link_to 'Edit', edit_softapplication_path(@softapplication) %> |
<%= link_to 'Back', softapplications_path %>

View File

@ -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个字符

View File

@ -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

View File

@ -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
}

17
test/fixtures/softapplications.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
require 'test_helper'
class SoftapplicationsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class SoftapplicationTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end