CRUD html_map_coordinates geozone attribute

This commit is contained in:
Alberto Miedes Garcés
2016-12-08 16:50:36 +01:00
parent 6b53020185
commit 60da2a875b
5 changed files with 13 additions and 10 deletions

View File

@@ -33,15 +33,10 @@ class Admin::GeozonesController < Admin::BaseController
end end
def destroy def destroy
# Check that in none of the other associated models talbes a record exists # Check that in none of the other associated models tables a record exists
# referencing this geozone # referencing this geozone
safe_to_destroy = true safe_to_destroy = true
# safe_to_destroy &= Proposal.where(geozone: @geozone).empty?
# safe_to_destroy &= Debate.where(geozone: @geozone).empty?
# safe_to_destroy &= SpendingProposal.where(geozone: @geozone).empty?
# safe_to_destroy &= User.where(geozone: @geozone).empty?
Geozone.reflect_on_all_associations.each do |association| Geozone.reflect_on_all_associations.each do |association|
attached_model = association.klass attached_model = association.klass
safe_to_destroy &= attached_model.where(geozone: @geozone).empty? safe_to_destroy &= attached_model.where(geozone: @geozone).empty?
@@ -58,6 +53,6 @@ class Admin::GeozonesController < Admin::BaseController
private private
def geozone_params def geozone_params
params.require(:geozone).permit(:name, :external_code, :census_code) params.require(:geozone).permit(:name, :external_code, :census_code, :html_map_coordinates)
end end
end end

View File

@@ -3,15 +3,19 @@
<%= render 'errors' %> <%= render 'errors' %>
<div clas="row"> <div clas="row">
<div class="small-12 medium-6 large-6 column"> <div class="small-12 medium-6 large-4 column">
<%= f.label :name, t("admin.geozones.geozone.name") %> <%= f.label :name, t("admin.geozones.geozone.name") %>
<%= f.text_field :name, label: false %> <%= f.text_field :name, label: false %>
</div> </div>
<div class="small-12 medium-3 large-3 column"> <div class="small-12 medium-6 large-4 column">
<%= f.label :html_map_coordinates, t("admin.geozones.geozone.coordinates") %>
<%= f.text_field :html_map_coordinates, label: false %>
</div>
<div class="small-12 medium-6 large-2 column">
<%= f.label :external_code, t("admin.geozones.geozone.external_code") %> <%= f.label :external_code, t("admin.geozones.geozone.external_code") %>
<%= f.text_field :external_code, label: false %> <%= f.text_field :external_code, label: false %>
</div> </div>
<div class="small-12 medium-3 large-3 column"> <div class="small-12 medium-6 large-2 column">
<%= f.label :census_code, t("admin.geozones.geozone.census_code") %> <%= f.label :census_code, t("admin.geozones.geozone.census_code") %>
<%= f.text_field :census_code, label: false %> <%= f.text_field :census_code, label: false %>
</div> </div>

View File

@@ -9,6 +9,7 @@
<th><%= t("admin.geozones.geozone.name") %></th> <th><%= t("admin.geozones.geozone.name") %></th>
<th><%= t("admin.geozones.geozone.external_code") %></th> <th><%= t("admin.geozones.geozone.external_code") %></th>
<th><%= t("admin.geozones.geozone.census_code") %></th> <th><%= t("admin.geozones.geozone.census_code") %></th>
<th><%= t("admin.geozones.geozone.coordinates") %></th>
<th colspan="2"></th> <th colspan="2"></th>
</tr> </tr>
</thead> </thead>
@@ -19,6 +20,7 @@
<td><%= geozone.name %></td> <td><%= geozone.name %></td>
<td><%= geozone.external_code %></td> <td><%= geozone.external_code %></td>
<td><%= geozone.census_code %></td> <td><%= geozone.census_code %></td>
<td><%= geozone.html_map_coordinates %></td>
<td> <td>
<%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %> <%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %>
</td> </td>

View File

@@ -278,6 +278,7 @@ en:
name: Name name: Name
external_code: External code external_code: External code
census_code: Census code census_code: Census code
coordinates: Coordinates
errors: errors:
form: form:
error: error:

View File

@@ -276,6 +276,7 @@ es:
name: Nombre name: Nombre
external_code: Código externo external_code: Código externo
census_code: Código del censo census_code: Código del censo
coordinates: Coordenadas
errors: errors:
form: form:
error: error: