parent
811c3a065e
commit
9fbf713709
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the sub_domains controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,28 @@
|
||||
class SubDomainsController < ApplicationController
|
||||
layout 'base_org'
|
||||
|
||||
def create
|
||||
if SubDomain.where("org_subfield_id=#{params[:org_subfield_id]} and name=?",params[:name]).count == 0
|
||||
@res = true
|
||||
# @organization = Organization.find(params[:organization_id])
|
||||
@subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
# @subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1)
|
||||
@subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id],:priority => @subfield.sub_domains.blank? ? 1.1 : @subfield.sub_domains.order("priority").last.priority + 0.1)
|
||||
# if !params[:sub_dir].blank?
|
||||
# sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
|
||||
# "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
|
||||
# if SubfieldSubdomainDir.find_by_sql(sql).count == 0
|
||||
# SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase)
|
||||
# end
|
||||
# end
|
||||
@subdomain.update_column(:field_type, params[:field_type])
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@subdomain = SubDomain.find(params[:id])
|
||||
render layout: 'base'
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module SubDomainsHelper
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
class SubDomain < ActiveRecord::Base
|
||||
attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status
|
||||
belongs_to :org_subfield, :foreign_key => :org_subfield_id
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
class CreateSubDomains < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :sub_domains do |t|
|
||||
t.integer :org_subfield_id
|
||||
t.integer :priority, :default => false
|
||||
t.string :name
|
||||
t.string :field_type
|
||||
t.integer :hide, :default => false
|
||||
t.integer :status, :default => false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SubDomainsController, :type => :controller do
|
||||
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
FactoryGirl.define do
|
||||
factory :sub_domain do
|
||||
org_subfield_id 1
|
||||
priority 1
|
||||
name "MyString"
|
||||
field_type "MyString"
|
||||
hide 1
|
||||
status 1
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SubDomain, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in new issue