[refs #12] Fix platform admin relations. Locales correction. Add validationa and rsync stubs.

This commit is contained in:
konstantin.grabar 2011-12-12 18:10:39 +04:00
parent a7a1639df7
commit 6a364b73a6
7 changed files with 37 additions and 9 deletions

View File

@ -30,7 +30,6 @@ class CollaboratorsController < ApplicationController
def update
all_user_ids = []
all_groups_ids = []
puts params.inspect
Relation::ROLES.each { |r|
all_user_ids = all_user_ids | params['user'][r.to_sym].keys if params['user'] && params['user'][r.to_sym]
all_groups_ids = all_groups_ids | params['group'][r.to_sym].keys if params['group'] && params['group'][r.to_sym]

View File

@ -52,11 +52,11 @@ class PlatformsController < ApplicationController
def create
@platform = Platform.new params[:platform]
@platform.owner = (params[:admin_uname]) ? User.find_by_uname(params[:admin_uname]) : nil
@platform.owner ||= get_owner
@admin_id = params[:admin_id]
if @platform.save!
# @platform.make_admin_relation(@platform.owner.id)
if @platform.save
@platform.make_admin_relation(@admin_id)
flash[:notice] = I18n.t("flash.platform.saved")
redirect_to @platform
else

View File

@ -14,7 +14,9 @@ class Platform < ActiveRecord::Base
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :description, :presence => true, :uniqueness => true
validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }
if !Rails.env.development?
validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }
end
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}

View File

@ -21,9 +21,9 @@
= f.check_box :released, :class => 'check_box'
.group
= label_tag "admin_uname", t("layout.platforms.admin_uname"), :class => :label
= autocomplete_field_tag 'admin_uname', params[:admin_uname], autocomplete_user_uname_platforms_path
=# text_field_tag 'admin_id', '', :id => 'admin_id_field'
= label_tag "", t("layout.platforms.admin_id"), :class => :label
= autocomplete_field_tag 'admin_id', @admin_id, autocomplete_user_uname_platforms_path, :id_element => '#admin_id_field'
= hidden_field_tag 'admin_id', '', :id => 'admin_id_field'
.group.navform.wat-cf
%button.button{:type => "submit"}

View File

@ -25,3 +25,7 @@ Rosa::Application.configure do
end
require 'stub_xml_rpc'
Rails.application.config.to_prepare {
Platform.send :include, Modules::Models::RsyncStub
}

View File

@ -94,7 +94,7 @@ ru:
confirm_delete: Вы уверены, что хотите удалить эту категорию?
platforms:
admin_uname: Владелец
admin_id: Владелец
build_all: Собрать все
list: Список
new: Создать

View File

@ -0,0 +1,23 @@
module Modules
module Models
module RsyncStub
extend ActiveSupport::Concern
included do
def mount_directory_for_rsync
true
end
def umount_directory_for_rsync
true
end
end
module InstanceMethods
end
module ClassMethods
end
end
end
end