fixes conflicts with master

This commit is contained in:
rgarcia
2017-05-31 10:36:38 +02:00
47 changed files with 537 additions and 61 deletions

View File

@@ -97,6 +97,10 @@ body.admin {
}
}
td.break {
word-break: break-word;
}
&.fixed {
table-layout: fixed;
}

View File

@@ -1141,10 +1141,8 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar {
// 10. Officials levels
// --------------------
[class^="level-"] {
color: black;
}
.level-1, .level-2, .level-3,
.level-4, .level-5,
.is-author, .is-association {
color: black;
}

View File

@@ -206,9 +206,9 @@
.participation-not-allowed {
background: $warning-bg;
color: $color-warning;
height: 100%;
left: 0;
line-height: $line-height;
min-height: 100%;
padding: $line-height $line-height/2;
position: absolute;
text-align: center;

View File

@@ -0,0 +1,37 @@
class Admin::AdministratorsController < Admin::BaseController
load_and_authorize_resource
def index
@administrators = @administrators.page(params[:page])
end
def search
@user = User.find_by(email: params[:email])
respond_to do |format|
if @user
@administrator = Administrator.find_or_initialize_by(user: @user)
format.js
else
format.js { render "user_not_found" }
end
end
end
def create
@administrator.user_id = params[:user_id]
@administrator.save
redirect_to admin_administrators_path
end
def destroy
if current_user.id == @administrator.user_id
flash[:error] = I18n.t("admin.administrators.administrator.restricted_removal")
else
@administrator.destroy
end
redirect_to admin_administrators_path
end
end

View File

@@ -0,0 +1,12 @@
class Admin::NewslettersController < Admin::BaseController
def index
end
def users
zip = NewsletterZip.new('emails')
zip.create
send_file(File.join(zip.path), type: 'application/zip')
end
end

View File

@@ -29,7 +29,7 @@ module AdminHelper
end
def menu_profiles?
["organizations", "officials", "moderators", "valuators", "managers"].include? controller_name
["administrators", "organizations", "officials", "moderators", "valuators", "managers"].include? controller_name
end
def menu_banners?

View File

@@ -34,6 +34,7 @@ module Abilities
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment, Legislation::Question, Legislation::Annotation]
can [:search, :create, :index, :destroy], ::Administrator
can [:search, :create, :index, :destroy], ::Moderator
can [:search, :create, :index, :summary], ::Valuator
can [:search, :create, :index, :destroy], ::Manager

View File

@@ -145,7 +145,7 @@ class Budget
return :not_selected unless selected?
return :no_ballots_allowed unless budget.balloting?
return :different_heading_assigned unless ballot.valid_heading?(heading)
return :not_enough_money if ballot.present? && !enough_money?(ballot)
return :not_enough_money_html if ballot.present? && !enough_money?(ballot)
end
def permission_problem(user)

View File

@@ -50,10 +50,10 @@ class Poll
if dob.blank?
nil
else
now = Time.now.utc.to_date
now = Time.current.to_date
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
end
end
end
end
end

View File

@@ -53,6 +53,7 @@ class User < ActiveRecord::Base
scope :moderators, -> { joins(:moderator) }
scope :organizations, -> { joins(:organization) }
scope :officials, -> { where("official_level > 0") }
scope :newsletter, -> { where(newsletter: true) }
scope :for_render, -> { includes(:organization) }
scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) }
scope :email_digest, -> { where(email_digest: true) }

View File

@@ -95,6 +95,10 @@
<strong><%= t("admin.menu.title_profiles") %></strong>
</a>
<ul <%= "class=is-active" if menu_profiles? %>>
<li <%= "class=active" if controller_name == "administrators" %>>
<%= link_to t("admin.menu.administrators"), admin_administrators_path %>
</li>
<li <%= "class=active" if controller_name == "organizations" %>>
<%= link_to t("admin.menu.organizations"), admin_organizations_path %>
</li>
@@ -171,5 +175,12 @@
<% end %>
</li>
<% end %>
<li <%= "class=active" if controller_name == "newsletter" %>>
<%= link_to admin_newsletters_path do %>
<span class="icon-zip"></span>
<%= t("admin.menu.newsletter") %>
<% end %>
</li>
</ul>
</div>

View File

@@ -0,0 +1,26 @@
<div class="small-12 column">
<table>
<tbody>
<tr>
<td>
<%= administrator.name %>
</td>
<td>
<%= administrator.email %>
</td>
<td class="text-right">
<% if administrator.persisted? %>
<%= link_to t('admin.administrators.administrator.delete'),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t('admin.administrators.administrator.add'),{ controller: "admin/administrators", action: :create, user_id: administrator.user_id },
method: :post,
class: "button success" %>
<% end %>
</td>
</tr>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,46 @@
<h2 class="inline-block"><%= t("admin.administrators.index.title") %></h2>
<div class="row">
<%= form_tag search_admin_administrators_path, method: :get, remote: true do %>
<div class="small-12 medium-6 column">
<%= text_field_tag :email, '', placeholder: t('admin.administrators.search.email_placeholder') %>
</div>
<div class="small-12 medium-6 column">
<%= submit_tag t('admin.administrators.search.search'), class: 'button' %>
</div>
<% end %>
</div>
<div id="search-result" class="row"></div>
<h3><%= page_entries_info @administrators %></h3>
<table id="administrators">
<% @administrators.each do |administrator| %>
<tr>
<td>
<%= administrator.name %>
</td>
<td>
<%= administrator.email %>
</td>
<td class="text-right">
<% if administrator.persisted? %>
<%= link_to t('admin.administrators.administrator.delete'),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert"
%>
<% else %>
<%= link_to t('admin.administrators.administrator.add'),
{ controller: "admin/administrators", action: :create,
user_id: administrator.user_id },
method: :post,
class: "button success" %>
<% end %>
</td>
</tr>
<% end %>
</table>
<%= paginate @administrators %>

View File

@@ -0,0 +1 @@
$("#search-result").html("<%= j render 'administrator', administrator: @administrator %>");

View File

@@ -0,0 +1 @@
$("#search-result").html("<div class=\"small-12 column\"><div class=\"callout alert\"><%= j t('admin.administrators.search.user_not_found') %></div></div>");

View File

@@ -20,7 +20,7 @@
<td><%= geozone.name %></td>
<td><%= geozone.external_code %></td>
<td><%= geozone.census_code %></td>
<td><%= geozone.html_map_coordinates %></td>
<td class="break"><%= geozone.html_map_coordinates %></td>
<td>
<%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %>
</td>

View File

@@ -0,0 +1,3 @@
<h2><%= t("admin.newsletters.index.title") %></h2>
<%= link_to t("admin.newsletters.index.button"), users_admin_newsletters_path, class: "button" %>

View File

@@ -20,29 +20,29 @@
<div class="row stats-numbers">
<div class="small-12 medium-3 column">
<p class="featured">
<%= t "admin.stats.show.summary.visits" %><br>
<%= t "admin.stats.show.summary.visits" %> <br>
<span class="number"><%= number_with_delimiter(@visits) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.debates" %><br>
<%= t "admin.stats.show.summary.debates" %> <br>
<span class="number"><%= number_with_delimiter(@debates) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.proposals" %><br>
<%= t "admin.stats.show.summary.proposals" %> <br>
<span class="number"><%= number_with_delimiter(@proposals) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.comments" %><br>
<%= t "admin.stats.show.summary.comments" %> <br>
<span class="number"><%= number_with_delimiter(@comments) %></span>
</p>
<% if feature?(:budgets) %>
<p>
<%= t "admin.stats.show.summary.budgets" %><br>
<%= t "admin.stats.show.summary.budgets" %> <br>
<span class="number"><%= number_with_delimiter(@budgets) %></span>
</p>
<p class="featured">
<%= t "admin.stats.show.summary.budget_investments" %><br>
<%= t "admin.stats.show.summary.budget_investments" %> <br>
<span class="number"><%= number_with_delimiter(@investments) %></span>
</p>
<% end %>
@@ -50,56 +50,56 @@
<div class="small-12 medium-3 column">
<p class="featured">
<%= t "admin.stats.show.summary.proposal_votes" %><br>
<span class="number"><%= number_with_delimiter(@proposal_votes) %><br></span>
<%= t "admin.stats.show.summary.proposal_votes" %> <br>
<span class="number"><%= number_with_delimiter(@proposal_votes) %> <br></span>
</p>
<p>
<%= t "admin.stats.show.summary.debate_votes" %><br>
<%= t "admin.stats.show.summary.debate_votes" %> <br>
<span class="number"><%= number_with_delimiter(@debate_votes) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.comment_votes" %><br>
<%= t "admin.stats.show.summary.comment_votes" %> <br>
<span class="number"><%= number_with_delimiter(@comment_votes) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.votes" %><br>
<%= t "admin.stats.show.summary.votes" %> <br>
<span class="number"><%= number_with_delimiter(@votes) %></span>
</p>
</div>
<div class="small-12 medium-3 column">
<p class="featured">
<%= t "admin.stats.show.summary.verified_users" %><br>
<%= t "admin.stats.show.summary.verified_users" %> <br>
<span class="number"><%= number_with_delimiter(@verified_users) %></span>
</p>
<p class="featured">
<%= t "admin.stats.show.summary.unverified_users" %><br>
<%= t "admin.stats.show.summary.unverified_users" %> <br>
<span class="number"><%= number_with_delimiter(@unverified_users) %></span>
</p>
</div>
<div class="small-12 medium-3 column">
<p class="featured">
<%= t "admin.stats.show.summary.users" %><br>
<%= t "admin.stats.show.summary.users" %> <br>
<span class="number"><%= number_with_delimiter(@users) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.user_level_two" %><br>
<%= t "admin.stats.show.summary.user_level_two" %> <br>
<span class="number"><%= number_with_delimiter(@user_level_two) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.user_level_three" %><br>
<%= t "admin.stats.show.summary.user_level_three" %> <br>
<span class="number"><%= number_with_delimiter(@user_level_three) %></span>
</p>
<p>
<%= t "admin.stats.show.summary.verified_users_who_didnt_vote_proposals" %><br>
<%= t "admin.stats.show.summary.verified_users_who_didnt_vote_proposals" %> <br>
<span class="number">
<%=number_with_delimiter(@user_ids_who_didnt_vote_proposals)%>
</span>
@@ -109,7 +109,7 @@
<% if feature?(:spending_proposals) %>
<div class="small-12 medium-3 column">
<p class="featured">
<%= t "admin.stats.show.summary.spending_proposals" %><br>
<%= t "admin.stats.show.summary.spending_proposals" %> <br>
<span class="number"><%= number_with_delimiter(@spending_proposals) %></span>
</p>
</div>

View File

@@ -50,8 +50,9 @@
signup: link_to(t("votes.signup"), new_user_registration_path),
my_heading: link_to(investment.heading.name,
budget_investments_path(budget_id: investment.budget_id,
heading_id: investment.heading_id))
).html_safe %>
heading_id: investment.heading_id)),
change_ballot: link_to(t("budgets.ballots.reasons_for_not_balloting.change_ballot"),
budget_ballot_path(@budget))).html_safe %>
</p>
</div>

View File

@@ -42,6 +42,12 @@
@assigned_heading.name,
budget_investments_path(@budget, heading_id: @assigned_heading.try(:id)))
) %>
<br>
<small>
<%= t("budgets.investments.header.change_ballot",
check_ballot: link_to(t("budgets.investments.header.check_ballot_link"),
budget_ballot_path(@budget))).html_safe %>
</small>
</div>
</div>
<% end %>

View File

@@ -2,7 +2,7 @@
<div class="row">
<div class="small-12 medium-9 column">
<%= back_link_to budget_investments_path(investment.budget) %>
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
<h1><%= investment.title %></h1>

View File

@@ -41,11 +41,19 @@
</em>
</p>
<% elsif @assigned_heading.present? %>
<p><%= t("budgets.investments.index.sidebar.different_heading_assigned_html",
<p>
<%= t("budgets.investments.index.sidebar.different_heading_assigned_html",
heading_link: link_to(
@assigned_heading.name,
budget_investments_path(@budget, heading_id: @assigned_heading.try(:id)))
) %></p>
) %>
<br>
<small>
<%= t("budgets.investments.index.sidebar.change_ballot",
check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"),
budget_ballot_path(@budget))).html_safe %>
</small>
</p>
<% else %>
<p><strong><%= t("budgets.investments.index.sidebar.zero") %></strong></p>
<% end %>

View File

@@ -31,7 +31,7 @@
<%= render 'layouts/admin_header' %>
<div class="no-margin-top row no-max-width collapse" data-equalizer>
<div class="small-12 medium-3 column">
<div class="small-12 medium-3 column" data-equalizer-watch>
<div class="show-for-small-only">
<button type="button" class="button hollow expanded" data-toggle="offCanvas"><%= t("admin.menu.admin") %></button>