Skip to content

Commit

Permalink
Can not change the name of the primary domain. Set the primary domain
Browse files Browse the repository at this point in the history
from the actions table only.
  • Loading branch information
Doug Youch committed Jul 29, 2010
1 parent fb83654 commit 55b3f0f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
18 changes: 6 additions & 12 deletions app/controllers/domains_controller.rb
Expand Up @@ -20,14 +20,19 @@ def index
def display_domains_table(display=true)

active_table_action(:domain) do |act,dids|
@domains = Domain.find(dids,:conditions => { :database => Configuration.domain_info.database })
@domains = Domain.find(dids,:conditions => { :database => Configuration.domain_info.database }, :order => 'id')
case act
when 'activate':
@domains.each { |dmn| dmn.update_attribute(:active,true) }
when 'deactivate':
@domains.each { |dmn| dmn.update_attribute(:active,false) }
when 'delete':
@domains.each { |dmn| dmn.destroy_domain }
when 'primary':
new_primary_domain = @domains[0]
Domain.update_all "`primary` = 0", "`database` = \"#{Configuration.domain_info.database}\""
new_primary_domain.reload
new_primary_domain.update_attribute :primary, true
end
end

Expand Down Expand Up @@ -77,15 +82,4 @@ def edit
end
end
end

def primary
@dmn = Domain.find_site_domain(params[:path][0],Configuration.domain_info.database)

if @dmn
@dmn.set_primary
end

redirect_to :action => 'index'
end

end
1 change: 1 addition & 0 deletions app/controllers/manage/domains_controller.rb
Expand Up @@ -147,6 +147,7 @@ def setup
if @domain.domain_type == 'domain'
if params[:domain][:database] == 'create'
if self.client.can_add_database?
@domain.primary = true
@domain.attributes = params[:domain].slice(:www_prefix,:active)
@domain.max_file_storage = params[:domain][:max_file_storage].blank? ? DomainDatabase::DEFAULT_MAX_FILE_STORAGE : params[:domain][:max_file_storage].to_i

Expand Down
2 changes: 1 addition & 1 deletion app/models/domain.rb
Expand Up @@ -35,7 +35,7 @@ class Domain < SystemModel
validates_inclusion_of :domain_type, :in => %w(domain redirect)

def before_create #:nodoc:
self.inactive_message = 'Site Currently Down for Maintenance' if self.blank?
self.inactive_message = 'Site Currently Down for Maintenance' if self.inactive_message.blank?
end

def validate
Expand Down
9 changes: 3 additions & 6 deletions app/views/domains/_domains_table.rhtml
@@ -1,9 +1,10 @@
<% active_table_for :domains_table, @tbl,
:actions =>[
['Make Active','activate','Activate the selected domains?'],
['Make inactive','deactivate','Deactivate the selected domains?']
['Make Primary','primary', 'Make this domain the primary domain?']
],
:more_actions => [
['Make inactive','deactivate','Deactivate the selected domains?'],
['Delete','delete','Delete the selected domains? (Last domain will not be deleted)' ]
] do |t| -%>
<tr <%= highlight_row :domain,t.id %>>
Expand All @@ -19,11 +20,7 @@
</td>
<td align='center'><%= t.www_prefix? ? 'Yes' : 'No' %></td>
<td align='center'>
<% if t.primary? %>
<%= "Yes".t %>
<% else -%>
<%= link_to 'No', :action => 'primary',:method => 'post', :path => t.id, :confirm => 'Make this domain the primary domain?' %>
<% end -%>
<%= t.primary? ? "Yes".t : 'No'.t %>
</td>
<td><%= h(t.version_name) %></td>
</tr>
Expand Down
8 changes: 3 additions & 5 deletions app/views/domains/edit.rhtml
Expand Up @@ -4,11 +4,9 @@
<%= f.radio_buttons :active, [['Site is active',true ],['Site is inactive',false]] , :label => '',:single => true, :description => 'If the site is inactive only the /website admin interface will be accessible' %>
<%= f.text_field :name, :label => 'Domain Name', :description => 'WARNING: changing the domain name could disable access to this site' %>
<%= f.check_boxes :primary, [['Primary site domain',true ]] , :label => 'Primary domain',:single => true, :description => 'The primary domain will be the one from which emails will be sent' %>
<% unless @dmn.primary -%>
<%= f.text_field :name, :label => 'Domain Name', :description => 'WARNING: changing the domain name could disable access to this site' %>
<% end -%>
<%= f.radio_buttons :www_prefix, [['Use www. prefix',true ],['No www. prefix',false]] , :label => 'WWW Prefix',:single => true %>
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/initialize_system.rake
Expand Up @@ -24,7 +24,7 @@ namespace "cms" do
:system_admin => true)

# Make the initial domain
domain = client.domains.create(:name => ENV['DOMAIN'])
domain = client.domains.create(:name => ENV['DOMAIN'], :primary => true)

print "Successfully Created Client, Domain and System User\n"
end
Expand Down

0 comments on commit 55b3f0f

Please sign in to comment.