Skip to content

Commit

Permalink
Merge branch 'master' of git@dev.clearplanet.co.za:bind-dlz-on-rails
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethkalmer committed Jul 18, 2008
2 parents e95b10c + fb65278 commit d9e94dc
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/controllers/record_templates_controller.rb
Expand Up @@ -29,7 +29,7 @@ def destroy
zt = @record_template.zone_template
@record_template.destroy
flash[:info] = "Record template removed"
redirect_to template_path( zt )
redirect_to zone_template_path( zt )
end

end
10 changes: 10 additions & 0 deletions app/controllers/records_controller.rb
Expand Up @@ -36,6 +36,16 @@ def destroy
redirect_to zone_path( @zone )
end

# Non-CRUD methods
def update_soa
@zone.soa_record.update_attributes( params[:record] )
if @zone.soa_record.valid?
flash[:info] = "SOA record updated!"
else
flash[:error] = "SOA record not updated!"
end
end

protected

def get_zone
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/templates_controller.rb
Expand Up @@ -48,8 +48,8 @@ def update
end

def destroy
@zone_template.delete!
redirect_to template_path
@zone_template.destroy
redirect_to zone_templates_path
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -96,7 +96,7 @@ def has_role?(role_in_question)
end

# Returns true if the user has the admin role
def admin?
def admin
@admin ||= has_role?( 'admin' )
end
alias :admin :admin?
Expand Down
10 changes: 10 additions & 0 deletions app/views/records/update_soa.js.rjs
@@ -0,0 +1,10 @@
if @zone.soa_record.errors.empty?
page.hide 'soa-edit-form'
page.show 'soa-form'
page.replace_html 'soa-form', :partial => '/zones/soa_record', :object => @zone.soa_record
page.call 'showflash', 'info', flash[:info]
else
page.call 'showflash', 'error', flash[:error]
page.hide 'soa-form'
page.show 'soa-edit-form'
end
4 changes: 2 additions & 2 deletions app/views/users/_user.html.haml
Expand Up @@ -26,7 +26,7 @@
%td
= link_to prototip_info_icon('user_edit.png', "edit-user-#{user.id}"), edit_user_path( user )
- unless user.suspended?
= link_to prototip_info_icon('user_suspend.png', "suspend-user-#{user.id}"), suspend_user_path( user ), :method => :put
= link_to prototip_info_icon('user_suspend.png', "suspend-user-#{user.id}"), suspend_user_path( user ), :method => :put unless user.eql?(current_user)
- else
= link_to prototip_info_icon('user_go.png', "reactivate-user-#{user.id}"), unsuspend_user_path( user ), :method => :put
= link_to prototip_info_icon('user_delete.png', "delete-user-#{user.id}"), purge_user_path( user ), :method => :delete unless user.admin?
= link_to prototip_info_icon('user_delete.png', "delete-user-#{user.id}"), purge_user_path( user ), :method => :delete unless user.eql?(current_user)
19 changes: 19 additions & 0 deletions app/views/zones/_soa_record.html.haml
@@ -0,0 +1,19 @@
%table#soa-form.grid
%tr
%td Primary name server
%td= soa_record.primary_ns
%tr
%td Contact
%td= soa_record.contact
%tr
%td Refresh
%td= soa_record.refresh
%tr
%td Retry
%td= soa_record.retry
%tr
%td Expire
%td= soa_record.expire
%tr
%td Minimum
%td= soa_record.minimum
1 change: 0 additions & 1 deletion app/views/zones/_zone.html.haml
Expand Up @@ -3,5 +3,4 @@
= link_to zone.name, zone_path( zone )
%td  
%td
= link_to prototip_info_icon('database_edit.png', 'edit-zone'), edit_zone_path( zone )
= link_to prototip_info_icon('database_delete.png', 'delete-zone'), zone_path( zone ), :method => :delete, :confirm => 'Are you sure?'
82 changes: 49 additions & 33 deletions app/views/zones/show.html.haml
Expand Up @@ -16,53 +16,61 @@

%h1.underline
= @zone.name
 
= link_to prototip_info_icon('database_edit.png', 'zone-edit'), edit_zone_path( @zone )

#domain-name.padded
%table.grid
%tr
%td Domain
%td= @zone.name
%tr#note-row
%td Notes
%tr
%td{ :valign => 'top' } Notes
%td
= @zone.notes unless @zone.notes.blank?
 
= link_to_function prototip_info_icon('note_edit.png', 'note-edit'), "showNote()"
#note-row
= @zone.notes
%br
= link_to_function prototip_info_icon('note_edit.png', 'note-edit'), "showNote()"

#note{ :style => "display: none;" }
- remote_form_for( :zone, @zone, :url => formatted_update_note_zone_path( @zone, :js ), :html => { :method => :put } ) do |f|
= f.text_area :notes, :rows => 5
%br/
= link_to_function "Cancel", "hideNote()"
= submit_tag "Update note"
#note{ :style => "display: none;" }
- remote_form_for( :zone, @zone, :url => formatted_update_note_zone_path( @zone, :js ), :html => { :method => :put } ) do |f|
= f.text_area :notes, :rows => 5, :cols => 17
%br/
= link_to_function "Cancel", "hideNote()"
= submit_tag "Update note"


#domain-soa.padded
%h2.underline
SOA Record
 
= prototip_info_icon('database_edit.png', 'soa-record-edit')
%table.grid
%tr
%td Primary name server
%td= @zone.soa_record.primary_ns
%tr
%td Contact
%td= @zone.soa_record.contact
%tr
%td Refresh
%td= @zone.soa_record.refresh
%tr
%td Retry
%td= @zone.soa_record.retry
%tr
%td Expire
%td= @zone.soa_record.expire
%tr
%td Minimum
%td= @zone.soa_record.minimum
= link_to_function prototip_info_icon('database_edit.png', 'soa-record-edit'), "showSOAEdit()"
= render :partial => '/zones/soa_record', :object => @zone.soa_record

#soa-edit-form{ :style => "display: none;" }
- remote_form_for( :record, :url => formatted_update_soa_record_path( @zone.soa_record, :js, :zone_id => @zone.id ), :html => { :method => :put } ) do |f|
%table.grid
%tr
%td Primary name server
%td= f.text_field :primary_ns
%tr
%td Contact
%td= f.text_field :contact
%tr
%td Refresh
%td= f.text_field :refresh
%tr
%td Retry
%td= f.text_field :retry
%tr
%td Expire
%td= f.text_field :expire
%tr
%td Minimum
%td= f.text_field :minimum
%tr
%td
%td
= link_to_function "Cancel", "showSOAForm()"
= submit_tag "Update"

#domain-records.padded
%h2.underline Zone records
Expand Down Expand Up @@ -156,3 +164,11 @@
$('note').hide();
$('note-row').show();
}
function showSOAEdit() {
$('soa-form').hide();
$('soa-edit-form').show();
}
function showSOAForm() {
$('soa-edit-form').hide();
$('soa-form').show();
}
2 changes: 2 additions & 0 deletions app/views/zones/update_note.js.rjs
@@ -1,4 +1,6 @@
if @zone.errors.empty?
page.hide 'note'
page.show 'note-row'
page.replace_html('note-row', @zone.notes)
page.replace_html('zone_notes', @zone.notes)
end
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -33,6 +33,7 @@

# RESTful zones and records
map.resources :zones, :has_many => :records, :member => { :update_note => :put }
map.resources :records, :member => { :update_soa => :put }
map.resources :soa, :controller => 'records'

# RESTful templates
Expand Down
4 changes: 2 additions & 2 deletions spec/models/user_spec.rb
Expand Up @@ -187,7 +187,7 @@ def create_user(options = {})
fixtures :all

it "should have a admin boolean flag" do
users( :admin ).admin?.should be_true
users( :quentin ).admin?.should be_false
users( :admin ).admin.should be_true
users( :quentin ).admin.should be_false
end
end

0 comments on commit d9e94dc

Please sign in to comment.