Merge pull request #26 from warpc/platform_admin_fixes
Fix autocomplete. Rsync stubs for development env. Blocked problematic validation for development env
This commit is contained in:
commit
1d55e8758e
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}
|
||||
|
|
|
@ -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"}
|
||||
|
|
|
@ -25,3 +25,7 @@ Rosa::Application.configure do
|
|||
end
|
||||
|
||||
require 'stub_xml_rpc'
|
||||
|
||||
Rails.application.config.to_prepare {
|
||||
Platform.send :include, Modules::Models::RsyncStub
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ ru:
|
|||
confirm_delete: Вы уверены, что хотите удалить эту категорию?
|
||||
|
||||
platforms:
|
||||
admin_uname: Владелец
|
||||
admin_id: Владелец
|
||||
build_all: Собрать все
|
||||
list: Список
|
||||
new: Создать
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue