[refs #12] Add platform update options
This commit is contained in:
parent
222033de5e
commit
4a723369a2
|
@ -50,6 +50,8 @@ class PlatformsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@admin_id = @platform.owner.id
|
||||||
|
@admin_uname = @platform.owner.uname
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -68,6 +70,26 @@ class PlatformsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@admin_id = params[:admin_id]
|
||||||
|
@admin_uname = params[:admin_uname]
|
||||||
|
#@platform.owner = @admin_id.blank? ? get_owner : User.find(@admin_id)
|
||||||
|
#if @platform.save!
|
||||||
|
|
||||||
|
if @platform.update_attributes(
|
||||||
|
:owner => @admin_id.blank? ? get_owner : User.find(@admin_id),
|
||||||
|
:description => params[:platform][:description],
|
||||||
|
:released => params[:platform][:released]
|
||||||
|
)
|
||||||
|
#@platform.make_admin_relation(@admin_id)
|
||||||
|
flash[:notice] = I18n.t("flash.platform.saved")
|
||||||
|
redirect_to @platform
|
||||||
|
else
|
||||||
|
flash[:error] = I18n.t("flash.platform.saved_error")
|
||||||
|
render :action => :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def freeze
|
def freeze
|
||||||
@platform.released = true
|
@platform.released = true
|
||||||
if @platform.save
|
if @platform.save
|
||||||
|
|
|
@ -24,6 +24,7 @@ class Platform < ActiveRecord::Base
|
||||||
# before_update :check_freezing
|
# before_update :check_freezing
|
||||||
after_create lambda { mount_directory_for_rsync unless hidden? }
|
after_create lambda { mount_directory_for_rsync unless hidden? }
|
||||||
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
||||||
|
after_update :update_owner_relation
|
||||||
|
|
||||||
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
||||||
scope :open, where(:visibility => 'open')
|
scope :open, where(:visibility => 'open')
|
||||||
|
@ -130,9 +131,16 @@ class Platform < ActiveRecord::Base
|
||||||
#FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }"
|
#FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }"
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_admin_relation(user_id)
|
#def make_admin_relation(user_id)
|
||||||
r = self.relations.build :object_id => user_id, :object_type => 'User', :role => 'admin'
|
# r = self.relations.build :object_id => user_id, :object_type => 'User', :role => 'admin'
|
||||||
r.save
|
# r.save
|
||||||
|
#end
|
||||||
|
|
||||||
|
def update_owner_relation
|
||||||
|
if owner_id_was != owner_id
|
||||||
|
r = relations.where(:object_id => owner_id_was, :object_type => owner_type_was)[0]
|
||||||
|
r.update_attributes(:object_id => owner_id, :object_type => owner_type)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
= javascript_include_tag "autocomplete-rails.js"
|
= javascript_include_tag "autocomplete-rails.js"
|
||||||
|
|
||||||
|
- unless ['edit', 'update'].include? controller.action_name
|
||||||
.group
|
.group
|
||||||
= f.label :name, :class => :label
|
= f.label :name, :class => :label
|
||||||
= f.text_field :name, :class => 'text_field'
|
= f.text_field :name, :class => 'text_field'
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
= f.label :description, :class => :label
|
= f.label :description, :class => :label
|
||||||
= f.text_field :description, :class => 'text_field'
|
= f.text_field :description, :class => 'text_field'
|
||||||
|
|
||||||
|
- unless ['edit', 'update'].include? controller.action_name
|
||||||
.group
|
.group
|
||||||
= f.label :distrib_type, :class => :label
|
= f.label :distrib_type, :class => :label
|
||||||
= f.select :distrib_type, options_for_select(APP_CONFIG['distr_types'])
|
= f.select :distrib_type, options_for_select(APP_CONFIG['distr_types'])
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
= link_to t("layout.platforms.freeze"), freeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_freeze"), :method => :post, :class => "button" if can? :freeze, @platform
|
= link_to t("layout.platforms.freeze"), freeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_freeze"), :method => :post, :class => "button" if can? :freeze, @platform
|
||||||
= link_to "Клонировать", clone_platform_path(@platform), :class => "button" if can? :clone, @platform
|
= link_to "Клонировать", clone_platform_path(@platform), :class => "button" if can? :clone, @platform
|
||||||
= link_to t("layout.platforms.build_all"), build_all_platform_path(@platform), :confirm => I18n.t("layout.confirm"), :method => :post, :class => "button" if can? :build_all, @platform
|
= link_to t("layout.platforms.build_all"), build_all_platform_path(@platform), :confirm => I18n.t("layout.confirm"), :method => :post, :class => "button" if can? :build_all, @platform
|
||||||
|
= link_to t("layout.platforms.edit"), edit_platform_path(@platform), :class => "button" if can? :edit, @platform
|
||||||
|
|
||||||
%a{ :name => "repositories" }
|
%a{ :name => "repositories" }
|
||||||
.block
|
.block
|
||||||
|
|
|
@ -98,6 +98,7 @@ ru:
|
||||||
build_all: Собрать все
|
build_all: Собрать все
|
||||||
list: Список
|
list: Список
|
||||||
new: Создать
|
new: Создать
|
||||||
|
edit: Редактировать
|
||||||
new_header: Новая платформа
|
new_header: Новая платформа
|
||||||
edit_header: Редактировать
|
edit_header: Редактировать
|
||||||
list_header: Платформы
|
list_header: Платформы
|
||||||
|
|
Loading…
Reference in New Issue