diff --git a/Gemfile b/Gemfile index c770fbf38..c78f31283 100644 --- a/Gemfile +++ b/Gemfile @@ -51,5 +51,6 @@ gem "russian" gem "grit" gem 'unicorn' gem 'delayed_job' +gem 'paperclip', "~> 2.3" -gem 'jammit' \ No newline at end of file +gem 'jammit' diff --git a/Gemfile.lock b/Gemfile.lock index e0082a62f..9711fb45a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,9 @@ GEM net-ssh (2.1.3) net-ssh-gateway (1.0.1) net-ssh (>= 1.99.1) + paperclip (2.3.8) + activerecord + activesupport pg (0.10.1) polyglot (0.3.1) rack (1.2.1) @@ -155,6 +158,7 @@ DEPENDENCIES hoptoad_notifier (~> 2.3) hpricot jammit + paperclip (~> 2.3) pg rails (= 3.0.5) rspec-rails (>= 2.0.1) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 4e82da3fe..fb56b9566 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -27,17 +27,25 @@ class ProductsController < ApplicationController @product.build = DEFAULT_BUILD end + def edit + @product = @platform.products.find params[:id] + end + def create @product = @platform.products.new params[:product] if @product.save - flash[:notice] = '' + flash[:notice] = t('flash.product.saved') redirect_to @platform else - flash[:error] = '' + flash[:error] = t('flash.product.save_error') render :action => :new end end + def show + @product = Product.find params[:id] + end + protected def find_product_by_name diff --git a/app/models/product.rb b/app/models/product.rb index cefacc47b..e59bde390 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -9,5 +9,17 @@ class Product < ActiveRecord::Base 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") + + protected + + def merge_tar_errors + errors[:tar] += errors[:tar_content_type] + errors[:tar_content_type] = [] + end end diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index a99777e3d..be5142c48 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -77,7 +77,7 @@ - @platform.products.recent.each do |product| %tr{:class => cycle("odd", "even")} %td - = link_to product.name, platform_product_path(@platform, product) + = link_to product.name, edit_platform_product_path(@platform, product) %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")} .actions-bar.wat-cf diff --git a/app/views/products/_form.html.haml b/app/views/products/_form.html.haml index a96fa0e3e..2df5f1467 100644 --- a/app/views/products/_form.html.haml +++ b/app/views/products/_form.html.haml @@ -13,6 +13,9 @@ .group = f.label :menu, t("activerecord.attributes.product.menu"), :class => :label = 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 %button.button{:type => "submit"} diff --git a/app/views/products/edit.html.haml b/app/views/products/edit.html.haml new file mode 100644 index 000000000..0f5e6bc01 --- /dev/null +++ b/app/views/products/edit.html.haml @@ -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') diff --git a/app/views/products/new.html.haml b/app/views/products/new.html.haml index 3b503559d..6e226404e 100644 --- a/app/views/products/new.html.haml +++ b/app/views/products/new.html.haml @@ -6,7 +6,7 @@ .content %h2.title= t("layout.products.new_header") .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} -#- content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/products/show.html.haml b/app/views/products/show.html.haml new file mode 100644 index 000000000..d428badc2 --- /dev/null +++ b/app/views/products/show.html.haml @@ -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") + diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 4f9e4d1d8..1d4934d0b 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -59,7 +59,9 @@ ru: new: Новый продукт list_header: Продукты new_header: Новый продукт + edit_header: Редактирование продукта confirm_delete: Вы уверены, что хотите удалить этот продукт? + invalid_content_type: имеет неверный тип projects: list: Список list_header: Проекты @@ -138,6 +140,9 @@ ru: saved: Репозиторий успешно добавлен save_error: Не удалось добавить репозиторий destroyed: Репозиторий успешно удален + product: + saved: Продукт успешно сохранен + save_error: Не удалось сохранить изменения platform: saved: Платформа успешно добавлена saved_error: Не удалось создать платформу @@ -196,6 +201,7 @@ ru: counter: Содержимое .counter build: Содержимое build menu: Содержимое .menu.xml + tar: Tar.gz файл arch: name: Название diff --git a/db/migrate/20110412074038_add_attachment_tar_to_product.rb b/db/migrate/20110412074038_add_attachment_tar_to_product.rb new file mode 100644 index 000000000..b97643f1c --- /dev/null +++ b/db/migrate/20110412074038_add_attachment_tar_to_product.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 4d4c3e045..3394b5d30 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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| t.string "name", :null => false @@ -83,9 +83,9 @@ ActiveRecord::Schema.define(:version => 20110411160955) do end create_table "products", :force => true do |t| - t.string "name", :null => false - t.integer "platform_id", :null => false - t.integer "build_status", :default => 2, :null => false + t.string "name", :null => false + t.integer "platform_id", :null => false + t.integer "build_status", :default => 2, :null => false t.string "build_path" t.datetime "created_at" t.datetime "updated_at" @@ -93,6 +93,10 @@ ActiveRecord::Schema.define(:version => 20110411160955) do t.text "counter" t.text "ks" t.text "menu" + t.string "tar_file_name" + t.string "tar_content_type" + t.integer "tar_file_size" + t.datetime "tar_updated_at" end create_table "projects", :force => true do |t| diff --git a/lib/build_server.rb b/lib/build_server.rb index ce4fccc62..45b549cc2 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -15,12 +15,16 @@ class BuildServer SRPM_NOT_FOUND = 12800 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 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) + Rails.logger.info "add_platform ok" end diff --git a/public/stylesheets/web-app-theme/override.css b/public/stylesheets/web-app-theme/override.css index ec8382733..093906632 100644 --- a/public/stylesheets/web-app-theme/override.css +++ b/public/stylesheets/web-app-theme/override.css @@ -1 +1 @@ -/* Override here any style defined by web-app-theme */ \ No newline at end of file +/* 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; } \ No newline at end of file diff --git a/public/system/tars/1/original/aterm-2.5.tar.gz b/public/system/tars/1/original/aterm-2.5.tar.gz new file mode 100644 index 000000000..44436ba69 Binary files /dev/null and b/public/system/tars/1/original/aterm-2.5.tar.gz differ