diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 9212eb4fa..c3d814b38 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -25,7 +25,7 @@ class AccountController < ApplicationController if @account.organization? params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name]) else - params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter) + params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge) end end diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb index 3f590f414..5f8b04717 100644 --- a/app/controllers/spending_proposals_controller.rb +++ b/app/controllers/spending_proposals_controller.rb @@ -1,7 +1,7 @@ class SpendingProposalsController < ApplicationController include FeatureFlags - before_action :authenticate_user!, except: [:index] + before_action :authenticate_user!, except: [:index, :show] before_action -> { flash.now[:notice] = flash[:notice].html_safe if flash[:html_safe] && flash[:notice] } load_and_authorize_resource diff --git a/app/models/user.rb b/app/models/user.rb index 7240c8929..4bb09c4a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -133,6 +133,16 @@ class User < ActiveRecord::Base update official_position: nil, official_level: 0 end + def has_official_email? + domain = Setting['email_domain_for_officials'] + !email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") ) + end + + def display_official_position_badge? + return true if official_level > 1 + official_position_badge? && official_level == 1 + end + def block debates_ids = Debate.where(author_id: id).pluck(:id) comments_ids = Comment.where(user_id: id).pluck(:id) @@ -197,11 +207,6 @@ class User < ActiveRecord::Base !erased? end - def has_official_email? - domain = Setting['email_domain_for_officials'] - !email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") ) - end - def locale self[:locale] ||= I18n.default_locale.to_s end diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index 98987626d..247aa6024 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -87,6 +87,19 @@ <% end %> + <% if @account.official_level == 1 %> +
<%= t("admin.stats.proposal_notifications.total") %>
- <%= @proposal_notifications %>
+
+ <%= @proposal_notifications.count %>
+
<%= t("admin.stats.proposal_notifications.proposals_with_notifications") %>
- <%= @proposals_with_notifications %>
+
+ <%= @proposals_with_notifications %>
+