diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/collaborators_controller.rb index ba9ecf53f..a4fd46ca8 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/collaborators_controller.rb @@ -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] diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index dc9fe0bbb..0275d5054 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -45,6 +45,8 @@ class PlatformsController < ApplicationController def new @platform = Platform.new + @admin_uname = current_user.uname + @admin_id = current_user.id end def edit @@ -52,11 +54,12 @@ 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] + @admin_uname = params[:admin_uname] + @platform.owner = @admin_id.blank? ? get_owner : User.find(@admin_id) - if @platform.save! -# @platform.make_admin_relation(@platform.owner.id) + if @platform.save + #@platform.make_admin_relation(params[:admin_id]) flash[:notice] = I18n.t("flash.platform.saved") redirect_to @platform else diff --git a/app/models/platform.rb b/app/models/platform.rb index 375789fc2..913f23d67 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -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]} diff --git a/app/views/platforms/_form.html.haml b/app/views/platforms/_form.html.haml index 00b9e65a1..8c2832d5c 100644 --- a/app/views/platforms/_form.html.haml +++ b/app/views/platforms/_form.html.haml @@ -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_uname, autocomplete_user_uname_platforms_path, :id_element => '#admin_id_field' + = hidden_field_tag 'admin_id', @admin_id, :id => 'admin_id_field' .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/config/environments/development.rb b/config/environments/development.rb index c3cc4ae1e..6a687d647 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,3 +25,7 @@ Rosa::Application.configure do end require 'stub_xml_rpc' + +Rails.application.config.to_prepare { + Platform.send :include, Modules::Models::RsyncStub +} diff --git a/config/locales/ru.yml b/config/locales/ru.yml index a22921e1f..8af689a60 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -94,7 +94,7 @@ ru: confirm_delete: Вы уверены, что хотите удалить эту категорию? platforms: - admin_uname: Владелец + admin_id: Владелец build_all: Собрать все list: Список new: Создать diff --git a/lib/modules/models/rsync_stub.rb b/lib/modules/models/rsync_stub.rb new file mode 100644 index 000000000..94c4153de --- /dev/null +++ b/lib/modules/models/rsync_stub.rb @@ -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