diff --git a/.gitignore b/.gitignore index e22ca28..a95c4ac 100755 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ public/image/* config/settings.local.yml config/settings/*.local.yml config/environments/*.local.yml -config/settings.yml \ No newline at end of file +config/settings.yml +.vscode \ No newline at end of file diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 498c2f3..b15b684 100755 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -100,7 +100,7 @@ def get_mp return get_divisions(@mp.id, @mp.faction) end else - #redirect_to people_path, :notice => "Не занйдено #{params[:mp]}" + redirect_to people_path, :notice => "Не занйдено #{mp_find.join(" ")}" end end diff --git a/app/controllers/policies_controller.rb b/app/controllers/policies_controller.rb index e9c74aa..b8663e0 100644 --- a/app/controllers/policies_controller.rb +++ b/app/controllers/policies_controller.rb @@ -21,6 +21,7 @@ def show if params[:history] == '1' history() end + end def detal @@ -88,8 +89,18 @@ def provisional? end # Use callbacks to share common setup or constraints between actions. def set_policy + @policy = Policy.includes(:policy_divisions).find(params[:id]) - @polisy_mp = @policy.policy_person_distances.includes(:mp).filter_polices(params[:policy]) + @policy_level_up = [] + (1..8).each do |l| + if @policy.policy_person_distances.filter_polices(l.to_s).count > 0 + @policy_level_up << l + end + end + if params[:policy].nil? + params[:policy] = @policy_level_up.first.to_s + end + @polisy_mp = @policy.policy_person_distances.includes(:mp).filter_polices(params[:policy]).where(mps: {end_date: "9999-12-31"}) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/models/policy.rb b/app/models/policy.rb index 533a4c2..922e5b9 100644 --- a/app/models/policy.rb +++ b/app/models/policy.rb @@ -15,7 +15,7 @@ class Policy < ApplicationRecord scope :never_voted, -> { where("same = 0 and same_strong = 0 and diff = 0 and diff_strong = 0") } def self.filter_polices(param) - if param.nil? + if param =="1" very_strongly_for elsif param =="2" strongly_for diff --git a/app/models/policy_person_distance.rb b/app/models/policy_person_distance.rb index c052189..27ecc20 100644 --- a/app/models/policy_person_distance.rb +++ b/app/models/policy_person_distance.rb @@ -20,7 +20,7 @@ def voted end end def self.filter_polices(param) - if param.nil? + if param=="1" very_strongly_for elsif param =="2" strongly_for diff --git a/app/views/policies/_show.erb b/app/views/policies/_show.erb index c00a9c7..59ea2a7 100644 --- a/app/views/policies/_show.erb +++ b/app/views/policies/_show.erb @@ -1,7 +1,7 @@
@@ -15,16 +15,37 @@
    -
  • ><%= link_to "Максимально голосує за", policy_path(@policy.id), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 95% та 100%" %>
  • + + <% if @policy_level_up.include?(1) %> +
  • ><%= link_to "Максимально голосує за", policy_path(@policy.id, policy: 1), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 95% та 100%" %>
  • + <% end %> + <% if @policy_level_up.include?(2) %>
  • ><%= link_to "Послідовно голосує за", policy_path(@policy.id, policy: 2), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 85% та 95%" %>
  • + <% end %> + <% if @policy_level_up.include?(3) %>
  • ><%= link_to "Переважно голосує за", policy_path(@policy.id, policy: 3 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 60% та 85%" %>
  • + <% end %> + <% if @policy_level_up.include?(4) %>
  • ><%= link_to "Суміш за та проти", policy_path(@policy.id, policy:4 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 40% та 60%%" %>
  • + <% end %> +
    +
    + <% if @policy_level_up.include?(5) %>
  • ><%= link_to "Переважно голосує проти", policy_path(@policy.id, policy:5 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 15% та 40%" %>
  • + <% end %> + <% if @policy_level_up.include?(6) %>
  • ><%= link_to "Послідовно голосує проти", policy_path(@policy.id, policy:6 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 5,0% та 15%" %>
  • + <% end %> + <% if @policy_level_up.include?(7) %>
  • ><%= link_to "Максимально голосує проти", policy_path(@policy.id, policy:7 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "між 0,0% та 5,0%" %>
  • + <% end %> + <% if @policy_level_up.include?(8) %>
  • ><%= link_to "Ніколи не голосує", policy_path(@policy.id, policy:8 ), remote: true, "data-toggle": "tooltip", "data-placement": "top", title: "У разі відсутності депутата та/або його неголосування" %>
  • + + <% end %> +