Return to Snippet

Revision: 38465
at January 4, 2011 23:41 by shilesh


Updated Code
--partial--

#_messaging_options.html.haml

.ugc-middle.partner-portal-middle
  .ugc-middle-content-block.ugc-middle-content-pp-block  
    %p{:class => "cb-#{@backfilling}"}
      = @backfilling_message


--views rendering partial--

#1. cobrand/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options'

#2. dashboard/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options' 
  - else      
    .ugc-middle.partner-portal-middle
     ...
     ..

--- controllers populates state and messages ---

 # dashboard_controller and cobrand_controller has the same code.

    @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
    
    # Change in message @ view can be achieved by editing here.
    @backfilling_message = if(@backfilling == 'busy')
      <<-eos
      The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>     
      if you have an urgent data request. Thank you for your patience.
      eos
    elsif(@backfilling == 'stale')
      <<-eos 
      FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>
      if you have an urgent data request. Thank you for your patience.
      eos


---
#The same code at both controller can be moved to a helper and call it from a helper. This #approach would reduce our chances of customizing these messages specific to cobrand and #dashboard.

#--- specs --

#I have created a shared example group which can be reused by both DashBoard(Broker) and #CoBrand.

# This group should support both DashBoard and CoBrand

shared_examples_for "Supporting back filling messages" do
  it "should have message as 'unavailable' when state is 'busy'" do
    @controller.stub!(:init_props)# No more pre-populating values
    AppConfig.merge({"fansnap.broker.backfill" => "busy"})# Setting the value to be busy
    AppConfig.merge({"fansnap.cobrand.backfill" => "busy"})
    # Expecting that 'over riding properties through hierarchy' works fine.
    get :index, :channel_name => "fs"        
    #Check if the view has proper message
    assigns[:backfilling_message].should =~ /The Partner Portal is not currently available/
  end      
  
  it "should have no message when state is 'ok'" do
    @controller.stub!(:init_props)# No more pre-populating values
    AppConfig.merge({"fansnap.broker.backfill" => "ok"})# Setting the value to be 'ok'
    AppConfig.merge({"fansnap.cobrand.backfill" => "ok"})
    get :index, :channel_name => "fs"        
    #Check if the view has no error message
    assigns[:backfilling_message].should be_nil
  end  
end

and then dashboard and cobrand controllers uses it as;
  it_should_behave_like "Supporting back filling messages"

#Both specs are green now.

Revision: 38464
at January 4, 2011 23:40 by shilesh


Updated Code
--partial--

#_messaging_options.html.haml

.ugc-middle.partner-portal-middle
  .ugc-middle-content-block.ugc-middle-content-pp-block  
    %p{:class => "cb-#{@backfilling}"}
      = @backfilling_message


--views rendering partial--

1. cobrand/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options'

2. dashboard/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options' 
  - else      
    .ugc-middle.partner-portal-middle
     ...
     ..

--- controllers populates state and messages ---

 # dashboard_controller and cobrand_controller has the same code.

    @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
    
    # Change in message @ view can be achieved by editing here.
    @backfilling_message = if(@backfilling == 'busy')
      <<-eos
      The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>     
      if you have an urgent data request. Thank you for your patience.
      eos
    elsif(@backfilling == 'stale')
      <<-eos 
      FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>
      if you have an urgent data request. Thank you for your patience.
      eos


---
The same code at both controller can be moved to a helper and call it from a helper. This approach would reduce our chances of customizing these messages specific to cobrand and dashboard.

--- specs --

I have created a shared example group which can be reused by both DashBoard(Broker) and CoBrand.

# This group should support both DashBoard and CoBrand

shared_examples_for "Supporting back filling messages" do
  it "should have message as 'unavailable' when state is 'busy'" do
    @controller.stub!(:init_props)# No more pre-populating values
    AppConfig.merge({"fansnap.broker.backfill" => "busy"})# Setting the value to be busy
    AppConfig.merge({"fansnap.cobrand.backfill" => "busy"})
    # Expecting that 'over riding properties through hierarchy' works fine.
    get :index, :channel_name => "fs"        
    #Check if the view has proper message
    assigns[:backfilling_message].should =~ /The Partner Portal is not currently available/
  end      
  
  it "should have no message when state is 'ok'" do
    @controller.stub!(:init_props)# No more pre-populating values
    AppConfig.merge({"fansnap.broker.backfill" => "ok"})# Setting the value to be 'ok'
    AppConfig.merge({"fansnap.cobrand.backfill" => "ok"})
    get :index, :channel_name => "fs"        
    #Check if the view has no error message
    assigns[:backfilling_message].should be_nil
  end  
end

and then dashboard and cobrand controllers uses it as;
  it_should_behave_like "Supporting back filling messages"

Both specs are green now.

Revision: 38463
at January 3, 2011 20:10 by shilesh


Updated Code
--partial--

#_messaging_options.html.haml

.ugc-middle.partner-portal-middle
  .ugc-middle-content-block.ugc-middle-content-pp-block  
    %p{:class => "cb-#{@backfilling}"}
      = @backfilling_message


--views rendering partial--

1. cobrand/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options'

2. dashboard/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options' 
  - else      
    .ugc-middle.partner-portal-middle
     ...
     ..

--- controllers populates state and messages ---

 # dashboard_controller and cobrand_controller has the same code.

    @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
    
    # Change in message @ view can be achieved by editing here.
    @backfilling_message = if(@backfilling == 'busy')
      <<-eos
      The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>     
      if you have an urgent data request. Thank you for your patience.
      eos
    elsif(@backfilling == 'stale')
      <<-eos 
      FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at 
      <a href="mailto:[email protected]"> [email protected] </a>
      if you have an urgent data request. Thank you for your patience.
      eos


---
The same code at both controller can be moved to a helper and call it from a helper. This approach would reduce our chances of customizing these messages specific to cobrand and dashboard.

Revision: 38462
at January 3, 2011 18:29 by shilesh


Updated Code
--partial--

#_messaging_options.html.haml

.ugc-middle.partner-portal-middle
  .ugc-middle-content-block.ugc-middle-content-pp-block  
    %p{:class => "cb-#{@backfilling}"}
      = @backfilling_message


--views rendering partial--

1. cobrand/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options'

2. dashboard/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options' 
  - else      
    .ugc-middle.partner-portal-middle
     ...
     ..

--- controllers populates state and messages ---

 # dashboard_controller and cobrand_controller has the same code.

    @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
    
    # Change in message @ view can be achieved by editing here.
    @backfilling_message = if(@backfilling == 'busy')
    <<-eos
    The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at 
    <a href="mailto:[email protected]"> [email protected] </a>     
    if you have an urgent data request. Thank you for your patience.
    eos
    elsif(@backfilling == 'stale')
    <<-eos 
    FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at 
    <a href="mailto:[email protected]"> [email protected] </a>
    if you have an urgent data request. Thank you for your patience.
    eos


---
The same code at both controller can be moved to a helper and call it from a helper. This approach would reduce our chances of customizing these messages specific to cobrand and daahboard.

Revision: 38461
at January 3, 2011 18:27 by shilesh


Initial Code
--partial--

_messaging_options.html.haml

.ugc-middle.partner-portal-middle
  .ugc-middle-content-block.ugc-middle-content-pp-block  
    %p{:class => "cb-#{@backfilling}"}
      = @backfilling_message


--views rendering partial--

1. cobrand/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options'

2. dashboard/index.html.haml
  - if (@backfilling == "stale" || @backfilling == "busy")
    = render :partial => 'partners/messaging_options' 
  - else      
    .ugc-middle.partner-portal-middle
     ...
     ..

--- controllers populates state and messages ---

  dashboard_controller and cobrand_controller has the same code.

    @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
    
    # Change in message @ view can be achieved by editing here.
    @backfilling_message = if(@backfilling == 'busy')
    <<-eos
    The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at 
    <a href="mailto:[email protected]"> [email protected] </a>     
    if you have an urgent data request. Thank you for your patience.
    eos
    elsif(@backfilling == 'stale')
    <<-eos 
    FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at 
    <a href="mailto:[email protected]"> [email protected] </a>
    if you have an urgent data request. Thank you for your patience.
    eos


---
The same code at both controller can be moved to a helper and call it from a helper. This approach would reduce our chances of customizing these messages specific to cobrand and daahboard.

Initial URL


Initial Description
Added partial, shared by both cobrand and dashboard views.busy/stale messages are dynamic ad can be customized for each of them independently.

Initial Title
messages-partner_portal

Initial Tags


Initial Language
Ruby