Product management. Step 2
This commit is contained in:
parent
73f7d4c0dd
commit
856b93d3d8
1
Gemfile
1
Gemfile
|
@ -51,5 +51,6 @@ gem "russian"
|
||||||
gem "grit"
|
gem "grit"
|
||||||
gem 'unicorn'
|
gem 'unicorn'
|
||||||
gem 'delayed_job'
|
gem 'delayed_job'
|
||||||
|
gem 'paperclip', "~> 2.3"
|
||||||
|
|
||||||
gem 'jammit'
|
gem 'jammit'
|
|
@ -88,6 +88,9 @@ GEM
|
||||||
net-ssh (2.1.3)
|
net-ssh (2.1.3)
|
||||||
net-ssh-gateway (1.0.1)
|
net-ssh-gateway (1.0.1)
|
||||||
net-ssh (>= 1.99.1)
|
net-ssh (>= 1.99.1)
|
||||||
|
paperclip (2.3.8)
|
||||||
|
activerecord
|
||||||
|
activesupport
|
||||||
pg (0.10.1)
|
pg (0.10.1)
|
||||||
polyglot (0.3.1)
|
polyglot (0.3.1)
|
||||||
rack (1.2.1)
|
rack (1.2.1)
|
||||||
|
@ -155,6 +158,7 @@ DEPENDENCIES
|
||||||
hoptoad_notifier (~> 2.3)
|
hoptoad_notifier (~> 2.3)
|
||||||
hpricot
|
hpricot
|
||||||
jammit
|
jammit
|
||||||
|
paperclip (~> 2.3)
|
||||||
pg
|
pg
|
||||||
rails (= 3.0.5)
|
rails (= 3.0.5)
|
||||||
rspec-rails (>= 2.0.1)
|
rspec-rails (>= 2.0.1)
|
||||||
|
|
|
@ -27,17 +27,25 @@ class ProductsController < ApplicationController
|
||||||
@product.build = DEFAULT_BUILD
|
@product.build = DEFAULT_BUILD
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@product = @platform.products.find params[:id]
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@product = @platform.products.new params[:product]
|
@product = @platform.products.new params[:product]
|
||||||
if @product.save
|
if @product.save
|
||||||
flash[:notice] = ''
|
flash[:notice] = t('flash.product.saved')
|
||||||
redirect_to @platform
|
redirect_to @platform
|
||||||
else
|
else
|
||||||
flash[:error] = ''
|
flash[:error] = t('flash.product.save_error')
|
||||||
render :action => :new
|
render :action => :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@product = Product.find params[:id]
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_product_by_name
|
def find_product_by_name
|
||||||
|
|
|
@ -9,5 +9,17 @@ class Product < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :platform
|
belongs_to :platform
|
||||||
|
|
||||||
|
has_attached_file :tar
|
||||||
|
validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip"], :message => I18n.t('layout.products.invalid_content_type')
|
||||||
|
|
||||||
|
after_validation :merge_tar_errors
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def merge_tar_errors
|
||||||
|
errors[:tar] += errors[:tar_content_type]
|
||||||
|
errors[:tar_content_type] = []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
- @platform.products.recent.each do |product|
|
- @platform.products.recent.each do |product|
|
||||||
%tr{:class => cycle("odd", "even")}
|
%tr{:class => cycle("odd", "even")}
|
||||||
%td
|
%td
|
||||||
= link_to product.name, platform_product_path(@platform, product)
|
= link_to product.name, edit_platform_product_path(@platform, product)
|
||||||
%td.last
|
%td.last
|
||||||
#{link_to t("layout.show"), platform_product_path(@platform, product)} | #{link_to t("layout.delete"), platform_product_path(@platform, product), :method => :delete, :confirm => t("layout.products.confirm_delete")}
|
#{link_to t("layout.show"), platform_product_path(@platform, product)} | #{link_to t("layout.delete"), platform_product_path(@platform, product), :method => :delete, :confirm => t("layout.products.confirm_delete")}
|
||||||
.actions-bar.wat-cf
|
.actions-bar.wat-cf
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
.group
|
.group
|
||||||
= f.label :menu, t("activerecord.attributes.product.menu"), :class => :label
|
= f.label :menu, t("activerecord.attributes.product.menu"), :class => :label
|
||||||
= f.text_area :menu, :class => 'text_field', :cols => 80
|
= f.text_area :menu, :class => 'text_field', :cols => 80
|
||||||
|
.group
|
||||||
|
= f.label :tar, t("activerecord.attributes.product.tar"), :class => :label
|
||||||
|
= f.file_field :tar, :class => 'file_field'
|
||||||
|
|
||||||
.group.navform.wat-cf
|
.group.navform.wat-cf
|
||||||
%button.button{:type => "submit"}
|
%button.button{:type => "submit"}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
.block
|
||||||
|
.secondary-navigation
|
||||||
|
%ul.wat-cf
|
||||||
|
%li.first= link_to @platform.name, platform_path(@platform) + "#products"
|
||||||
|
%li.active= link_to @product.name, edit_platform_product_path(@platform, @product)
|
||||||
|
.content
|
||||||
|
%h2.title= t("layout.products.edit_header")
|
||||||
|
.inner
|
||||||
|
= form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f|
|
||||||
|
= render :partial => "form", :locals => {:f => f}
|
||||||
|
|
||||||
|
-#- content_for :sidebar, render(:partial => 'sidebar')
|
|
@ -6,7 +6,7 @@
|
||||||
.content
|
.content
|
||||||
%h2.title= t("layout.products.new_header")
|
%h2.title= t("layout.products.new_header")
|
||||||
.inner
|
.inner
|
||||||
= form_for [@platform, @product], :html => { :class => :form } do |f|
|
= form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f|
|
||||||
= render :partial => "form", :locals => {:f => f}
|
= render :partial => "form", :locals => {:f => f}
|
||||||
|
|
||||||
-#- content_for :sidebar, render(:partial => 'sidebar')
|
-#- content_for :sidebar, render(:partial => 'sidebar')
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
.block
|
||||||
|
.secondary-navigation
|
||||||
|
%ul.wat-cf
|
||||||
|
%li.first= link_to @platform.name, platform_path(@platform) + "#products"
|
||||||
|
%li.active= link_to @product.name, platform_product_path(@platform, @product)
|
||||||
|
|
||||||
|
.content
|
||||||
|
.inner
|
||||||
|
%p
|
||||||
|
%b
|
||||||
|
= t("activerecord.attributes.product.name")
|
||||||
|
\:
|
||||||
|
= @product.name
|
||||||
|
.wat-cf
|
||||||
|
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_product_path(@platform, @product), :method => "delete", :class => "button", :confirm => t("layout.products.confirm_delete")
|
||||||
|
|
|
@ -59,7 +59,9 @@ ru:
|
||||||
new: Новый продукт
|
new: Новый продукт
|
||||||
list_header: Продукты
|
list_header: Продукты
|
||||||
new_header: Новый продукт
|
new_header: Новый продукт
|
||||||
|
edit_header: Редактирование продукта
|
||||||
confirm_delete: Вы уверены, что хотите удалить этот продукт?
|
confirm_delete: Вы уверены, что хотите удалить этот продукт?
|
||||||
|
invalid_content_type: имеет неверный тип
|
||||||
projects:
|
projects:
|
||||||
list: Список
|
list: Список
|
||||||
list_header: Проекты
|
list_header: Проекты
|
||||||
|
@ -138,6 +140,9 @@ ru:
|
||||||
saved: Репозиторий успешно добавлен
|
saved: Репозиторий успешно добавлен
|
||||||
save_error: Не удалось добавить репозиторий
|
save_error: Не удалось добавить репозиторий
|
||||||
destroyed: Репозиторий успешно удален
|
destroyed: Репозиторий успешно удален
|
||||||
|
product:
|
||||||
|
saved: Продукт успешно сохранен
|
||||||
|
save_error: Не удалось сохранить изменения
|
||||||
platform:
|
platform:
|
||||||
saved: Платформа успешно добавлена
|
saved: Платформа успешно добавлена
|
||||||
saved_error: Не удалось создать платформу
|
saved_error: Не удалось создать платформу
|
||||||
|
@ -196,6 +201,7 @@ ru:
|
||||||
counter: Содержимое .counter
|
counter: Содержимое .counter
|
||||||
build: Содержимое build
|
build: Содержимое build
|
||||||
menu: Содержимое .menu.xml
|
menu: Содержимое .menu.xml
|
||||||
|
tar: Tar.gz файл
|
||||||
|
|
||||||
arch:
|
arch:
|
||||||
name: Название
|
name: Название
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
class AddAttachmentTarToProduct < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :products, :tar_file_name, :string
|
||||||
|
add_column :products, :tar_content_type, :string
|
||||||
|
add_column :products, :tar_file_size, :integer
|
||||||
|
add_column :products, :tar_updated_at, :datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :products, :tar_file_name
|
||||||
|
remove_column :products, :tar_content_type
|
||||||
|
remove_column :products, :tar_file_size
|
||||||
|
remove_column :products, :tar_updated_at
|
||||||
|
end
|
||||||
|
end
|
12
db/schema.rb
12
db/schema.rb
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110411160955) do
|
ActiveRecord::Schema.define(:version => 20110412074038) do
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
@ -83,9 +83,9 @@ ActiveRecord::Schema.define(:version => 20110411160955) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "products", :force => true do |t|
|
create_table "products", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.integer "platform_id", :null => false
|
t.integer "platform_id", :null => false
|
||||||
t.integer "build_status", :default => 2, :null => false
|
t.integer "build_status", :default => 2, :null => false
|
||||||
t.string "build_path"
|
t.string "build_path"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
@ -93,6 +93,10 @@ ActiveRecord::Schema.define(:version => 20110411160955) do
|
||||||
t.text "counter"
|
t.text "counter"
|
||||||
t.text "ks"
|
t.text "ks"
|
||||||
t.text "menu"
|
t.text "menu"
|
||||||
|
t.string "tar_file_name"
|
||||||
|
t.string "tar_content_type"
|
||||||
|
t.integer "tar_file_size"
|
||||||
|
t.datetime "tar_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "projects", :force => true do |t|
|
create_table "projects", :force => true do |t|
|
||||||
|
|
|
@ -15,12 +15,16 @@ class BuildServer
|
||||||
SRPM_NOT_FOUND = 12800
|
SRPM_NOT_FOUND = 12800
|
||||||
|
|
||||||
def self.client
|
def self.client
|
||||||
@@client ||= XMLRPC::Client.new3(:host => APP_CONFIG['build_server_ip'], :port => APP_CONFIG['build_server_port'], :path => APP_CONFIG['build_server_path'])
|
Rails.logger.info "Client called"
|
||||||
|
@@client ||= XMLRPC::Client.new3('host' => APP_CONFIG['build_server_ip'], 'port' => APP_CONFIG['build_server_port'], 'path' => APP_CONFIG['build_server_path'])
|
||||||
|
Rails.logger.info "Client finished"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.add_platform name, root_folder, repos = [], git_path = nil
|
def self.add_platform name, root_folder, repos = [], git_path = nil
|
||||||
|
Rails.logger.info "add_platform start"
|
||||||
self.client.call('add_platform', name, git_path, root_folder, repos)
|
self.client.call('add_platform', name, git_path, root_folder, repos)
|
||||||
|
Rails.logger.info "add_platform ok"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* Override here any style defined by web-app-theme */
|
/* Override here any style defined by web-app-theme */
.form input.file_field:hover {
-webkit-box-shadow: rgba(0,0,0,0.0) 0 0 0px;
-moz-box-shadow: rgba(0,0,0,0.0) 0 0 0px;
box-shadow: 0 0 0px rgba(0, 0, 0, 0.0);
border: 0px solid #a2a294;
}
|
Binary file not shown.
Loading…
Reference in New Issue