Skip to content

Commit

Permalink
Afficher Ville, Code postal et Région avant confirmation d'un match (h…
Browse files Browse the repository at this point in the history
…ostolab#662)

* Add city & zipcode columns

* Add city & zipcode display
  • Loading branch information
mininao authored Apr 29, 2021
1 parent 40ced95 commit df841ee
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
7 changes: 7 additions & 0 deletions app/models/vaccination_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def build_campaign_smart_defaults
end
end

def human_friendly_geo_area
if zipcode && city && geo_context
region = geo_context.split(",")[-1]
"#{city}, #{region} (#{zipcode})"
end
end

private

def approximated_lat_lon
Expand Down
6 changes: 4 additions & 2 deletions app/views/matches/_match_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
<% else %>
<strong> Distance du centre de vaccination </strong>
<p>
<% distance = distance_delta({ lat: user.lat, lon: user.lon}, { lat: vaccination_center.lat, lon: vaccination_center.lon }) %>
<%= distance[:delta_in_words] %>
À
<% distance = distance_delta({lat: user.lat, lon: user.lon}, {lat: vaccination_center.lat, lon: vaccination_center.lon}) %>
<%= distance[:delta_in_words] %> de
vous<%= ", à #{vaccination_center.human_friendly_geo_area}" if vaccination_center.human_friendly_geo_area %>
</p>
<% end %>
</div>
Expand Down
30 changes: 16 additions & 14 deletions app/views/matches/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<div class="row">
<div class="col-sm-12 col-md-8 col-lg-8">
<div class="text-left mt-4">
<% if @match.confirmed? %>
<%= render 'confirmed', match: @match %>
<% elsif @match.refused? %>
<%= render 'refused', match: @match %>
<% elsif @match.expired? %>
<%= render 'expired', match: @match %>
<% elsif !@match.confirmable? %>
<%= render 'overbooked', match: @match %>
<% elsif !@match.expired? %>
<%= render 'pending', match: @match %>
<% end %>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-8 col-lg-8">
<div class="text-left mt-4">
<% if @match.confirmed? %>
<%= render 'confirmed', match: @match %>
<% elsif @match.refused? %>
<%= render 'refused', match: @match %>
<% elsif @match.expired? %>
<%= render 'expired', match: @match %>
<% elsif !@match.confirmable? %>
<%= render 'overbooked', match: @match %>
<% elsif !@match.expired? %>
<%= render 'pending', match: @match %>
<% end %>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class AddCityZipcodeToVaccinationCenters < ActiveRecord::Migration[6.1]
def change
add_column :vaccination_centers, :zipcode, :string
add_column :vaccination_centers, :city, :string
add_column :vaccination_centers, :geo_citycode, :string
add_column :vaccination_centers, :geo_context, :string

add_index :vaccination_centers, :zipcode
add_index :vaccination_centers, :city
add_index :vaccination_centers, :geo_citycode
add_index :vaccination_centers, :geo_context
end
end
10 changes: 9 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit df841ee

Please sign in to comment.