merges master and fixes conflicts

This commit is contained in:
kikito
2015-08-17 17:38:34 +02:00
51 changed files with 579 additions and 60 deletions

View File

@@ -1,8 +1,11 @@
App.Comments =
add_response: (parent_id, response_html) ->
add_comment: (parent_id, response_html) ->
$(response_html).insertAfter($("#js-comment-form-#{parent_id}"))
add_reply: (parent_id, response_html) ->
$("##{parent_id} .comment-children:first").prepend($(response_html))
display_error: (field_with_errors, error_html) ->
$(error_html).insertAfter($("#{field_with_errors}"))

View File

@@ -0,0 +1,7 @@
App.ModeratorComments =
add_class_faded: (id) ->
$("##{id} .comment-body:first").addClass("faded")
hide_moderator_actions: (id) ->
$("##{id} #moderator-comment-actions:first").hide()

View File

@@ -0,0 +1,8 @@
App.ModeratorDebates =
add_class_faded: (id) ->
$("##{id}").addClass("faded")
$("#comments").addClass("faded")
hide_moderator_actions: (id) ->
$("##{id} #moderator-debate-actions:first").hide()

View File

@@ -571,4 +571,9 @@
}
}
}
}
.faded {
opacity: 0.4;
}

View File

@@ -134,7 +134,7 @@ header {
min-height: rem-calc(480);
&.results {
min-height: rem-calc(192);
min-height: rem-calc(216);
}
h1 {
@@ -276,6 +276,35 @@ header {
}
}
.subnavigation {
background: white;
border-bottom: 1px solid white;
clear: both;
a {
color: $link;
font-size: rem-calc(14);
font-weight: bold;
&.active {
color: $text;
&:after {
bottom: -17px;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
border-top-color: #fff;
border-width: 8px;
margin-left: -8px;
}
}
}
}
// 05. Footer
// - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,6 +1,5 @@
class Admin::BaseController < ApplicationController
layout 'admin'
before_action :authenticate_user!
skip_authorization_check

View File

@@ -0,0 +1,13 @@
class Admin::CommentsController < Admin::BaseController
def index
@comments = Comment.only_hidden
end
def restore
@comment = Comment.with_hidden.find(params[:id])
@comment.restore
redirect_to admin_comments_path, notice: t('admin.comments.restore.success')
end
end

View File

@@ -1,5 +1,4 @@
class Admin::DashboardController < Admin::BaseController
layout 'admin'
def index
end

View File

@@ -0,0 +1,16 @@
class Admin::DebatesController < Admin::BaseController
def index
@debates = Debate.only_hidden
end
def show
@debate = Debate.with_hidden.find(params[:id])
end
def restore
@debate = Debate.with_hidden.find(params[:id])
@debate.restore
redirect_to admin_debates_path, notice: t('admin.debates.restore.success')
end
end

View File

@@ -2,6 +2,7 @@ class CommentsController < ApplicationController
before_action :authenticate_user!
before_action :build_comment, only: :create
before_action :parent, only: :create
load_and_authorize_resource
respond_to :html, :js
@@ -50,4 +51,5 @@ class CommentsController < ApplicationController
def email_on_comment_reply?
reply? && parent.author.email_on_comment_reply?
end
end

View File

@@ -1,6 +1,8 @@
class DebatesController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
load_and_authorize_resource
respond_to :html, :js
def index
@debates = Debate.search(params)
@@ -9,6 +11,7 @@ class DebatesController < ApplicationController
def show
set_debate_votes(@debate)
@comments = @debate.root_comments.with_hidden.recent
end
def new
@@ -46,7 +49,6 @@ class DebatesController < ApplicationController
set_debate_votes(@debate)
end
private
def debate_params

View File

@@ -0,0 +1,8 @@
class Moderation::CommentsController < Moderation::BaseController
def hide
@comment = Comment.find(params[:id])
@comment.hide
end
end

View File

@@ -1,5 +1,4 @@
class Moderation::DashboardController < Moderation::BaseController
layout 'admin'
def index
end

View File

@@ -0,0 +1,7 @@
class Moderation::DebatesController < Moderation::BaseController
def hide
@debate = Debate.find(params[:id])
@debate.hide
end
end

View File

@@ -0,0 +1,7 @@
module AbilitiesHelper
def moderator?
current_user.try(:moderator?)
end
end

View File

@@ -27,8 +27,12 @@ class Ability
can(:verify, Organization){ |o| !o.verified? }
can(:reject, Organization){ |o| !o.rejected? }
elsif user.administrator?
can :hide, Comment
can :hide, Debate
elsif user.administrator?
can :restore, Comment
can :restore, Debate
end
end
end

View File

@@ -1,5 +1,8 @@
class Comment < ActiveRecord::Base
include ActsAsParanoidAliases
acts_as_nested_set scope: [:commentable_id, :commentable_type], counter_cache: :children_count
acts_as_paranoid column: :hidden_at
acts_as_votable
validates :body, presence: true

View File

@@ -1,5 +1,6 @@
require 'numeric'
class Debate < ActiveRecord::Base
include ActsAsParanoidAliases
default_scope { order('created_at DESC') }
apply_simple_captcha
@@ -8,6 +9,7 @@ class Debate < ActiveRecord::Base
acts_as_votable
acts_as_commentable
acts_as_taggable
acts_as_paranoid column: :hidden_at
belongs_to :author, class_name: 'User', foreign_key: 'author_id'

View File

@@ -1,6 +1,6 @@
<div id="admin_menu">
<ul>
<li><%= link_to t('admin.menu.tags'), admin_tags_path %></li>
<li><%= link_to t('admin.menu.organizations'), admin_organizations_path %></li>
</ul>
</div>
<ul id="admin_menu">
<li><%= link_to t('admin.menu.debate_topics'), admin_tags_path %></li>
<li><%= link_to t('admin.menu.hidden_debates'), admin_debates_path %></li>
<li><%= link_to t('admin.menu.hidden_comments'), admin_comments_path %></li>
<li><%= link_to t('admin.menu.organizations'), admin_organizations_path %></li>
</ul>

View File

@@ -0,0 +1,14 @@
<div class="left">
<h1><%= t("admin.comments.index.title") %></h1>
<ul>
<% @comments.each do |comment| %>
<li id="<%= dom_id(comment) %>">
<%= comment.body %>
<%= link_to t("admin.actions.restore"), restore_admin_comment_path(comment),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
</li>
<% end %>
</ul>
</div>

View File

@@ -0,0 +1,13 @@
<div class="left">
<h1><%= t("admin.debates.index.title") %></h1>
<ul>
<% @debates.each do |debate| %>
<%= link_to admin_debate_path(debate) do %>
<li id="<%= dom_id(debate) %>">
<%= link_to debate.title, admin_debate_path(debate) %>
</li>
<% end %>
<% end %>
</ul>
</div>

View File

@@ -0,0 +1,13 @@
<div class="left">
<h1><%= t("admin.debates.index.title") %></h1>
<div>
<div><%= @debate.title %></div>
<div><%= @debate.description %></div>
<div>
<%= link_to t('admin.actions.restore'), restore_admin_debate_path(@debate),
method: :put, data: { confirm: t('admin.actions.confirm') } %>
</div>
</div>
</div>

View File

@@ -0,0 +1,5 @@
<span id="moderator-comment-actions">
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment),
method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %>
</span>

View File

@@ -1,30 +1,44 @@
<div class="row">
<div id="comment-<%= comment.id %>" class="comment small-12 column">
<div id="<%= dom_id(comment) %>" class="comment small-12 column">
<%= avatar_image(comment.user, size: 32, class: 'left') %>
<% if comment.hidden? %>
<%= t("debates.comment.deleted") %>
<% else %>
<div class="comment-body">
<span class="comment-info">
<span><%= comment.user.name %></span>&nbsp;&bullet;&nbsp;<%= time_ago_in_words(comment.created_at) %>
</span>
<p><%= comment.body %></p>
<%= avatar_image(comment.user, size: 32, class: 'left') %>
<span id="<%= dom_id(comment) %>_votes" class="comment-votes right">
<%= render 'comments/votes', comment: comment %>
</span>
<div class="comment-body">
<span class="comment-info">
<span><%= comment.user.name %></span>&nbsp;&bullet;&nbsp;<%= time_ago_in_words(comment.created_at) %>
</span>
<p><%= comment.body %></p>
<p class="reply">
<%= t("debates.comment.responses", count: comment.children_count) %>
<% if user_signed_in? %>
&nbsp;|&nbsp;
<%= render 'comments/form', {parent: comment, toggeable: true} %>
<% end %>
</p>
</div>
<span id="<%= dom_id(comment) %>_votes" class="comment-votes right">
<%= render 'comments/votes', comment: comment %>
</span>
<div class="comment-children">
<%= render comment.children.reorder('id DESC, lft') %>
</div>
<p class="reply">
<%= t("debates.comment.responses", count: comment.children_count) %>
<% if user_signed_in? %>
&nbsp;|&nbsp;
<%= link_to(comment_link_text(comment), "",
class: "js-add-comment-link", data: {'id': dom_id(comment)}) %>
<% if moderator? %>
<%= render 'comments/actions', comment: comment %>
<% end %>
<%= render 'comments/form', {parent: comment, toggeable: true} %>
<% end %>
</p>
</div>
<% end %>
<div class="comment-children">
<%= render comment.children.with_deleted.reorder('id DESC, lft') %>
</div>
</div>
</div>
</div>

View File

@@ -1,5 +1,3 @@
<%= link_to(comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)}) if toggeable %>
<div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>>
<%= form_for [@debate, Comment.new], remote: true do |f| %>
<%= f.text_area :body %>

View File

@@ -1,9 +1,10 @@
var parent_id = '<%= dom_id(@parent) %>';
var parent_id = "<%= dom_id(@parent) %>";
var comment_html = "<%= j(render @comment) %>"
<% if @parent.is_a?(Debate) -%>
App.Comments.reset_form(parent_id);
App.Comments.add_comment(parent_id, comment_html);
<% else -%>
App.Comments.reset_and_hide_form(parent_id);
App.Comments.add_reply(parent_id, comment_html);
<% end -%>
App.Comments.add_response(parent_id, "<%= j(render @comment) %>");

View File

@@ -0,0 +1,2 @@
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_debate_path(debate),
method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %>

View File

@@ -1,5 +1,5 @@
<section class="debate-show">
<div id="debate-<%= @debate.id %>" class="row">
<div id="<%= dom_id(@debate) %>" class="row">
<div class="small-12 medium-9 column">
<i class="icon-angle-left left"></i>&nbsp;<%= link_to t("debates.show.back_link"), debates_path, class: 'left back' %>
@@ -21,12 +21,19 @@
<span class="bullet">&nbsp;&bullet;&nbsp;</span>
<%= l @debate.created_at.to_date %>
<span class="bullet">&nbsp;&bullet;&nbsp;</span>
<i class="icon-chat-bubble-two"></i>&nbsp;<%= link_to t("debates.show.comments", count: @debate.comment_threads.count), "#comments" %>
<i class="icon-chat-bubble-two"></i>&nbsp;
<%= link_to t("debates.show.comments", count: @debate.comment_threads.count), "#comments" %>
</div>
<%= @debate.description %>
<%= render 'shared/tags', debate: @debate %>
<% if moderator? %>
<div id='moderator-debate-actions'>
<%= render 'actions', debate: @debate %>
</div>
<% end %>
</div>
<aside class="small-12 medium-3 column">
@@ -40,7 +47,8 @@
<div class="sidebar-divider"></div>
<h3><%= t("debates.show.share") %></h3>
<%= social_share_button_tag(@debate.title) %>
<% if user_signed_in? %>
<% if user_signed_in? %>
<%= link_to t("debates.show.leave_comment"), "#comments", class: "leave-comment" %>
<% else %>
<%= link_to t("debates.show.login_to_comment"), new_user_session_path, class: "leave-comment" %>
@@ -63,7 +71,8 @@
<%= render 'comments/form', {parent: @debate, toggeable: false} %>
</div>
<% end %>
<%= render @debate.root_comments.recent %>
<%= render @comments %>
</div>
</div>
</section>

View File

@@ -0,0 +1,50 @@
<header class="<%= header_css %>">
<section class="top-links">
<div class="row">
<div class="language">
<span id="locale-switcher">
<%= t("layouts.header.language") %>
[
<% available_locales_to_switch.each do |locale| %>
<%= link_to(locale, params.merge(locale: locale), id: "locale-link-#{locale}") %>
<% end %>
]
</div>
<div class="external-links">
<%= link_to t("layouts.header.participation"), root_path, class: "selected" %>&nbsp;|
<%= link_to t("layouts.header.external_link_transparency"), "#" %>&nbsp;|
<%= link_to t("layouts.header.external_link_opendata"), "#" %>&nbsp;|
<%= link_to t("layouts.header.external_link_blog"), "#" %>
</div>
</div>
</section>
<div class="contain-to-grid clear">
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<%= link_to root_path do %>
<%= image_tag('header_logo_madrid.png', class: 'left', size: '96x96') %>
<%= t("layouts.header.open_gov", open: "<strong>#{t('layouts.header.open')}</strong>").html_safe %> | <span><%= t("layouts.header.participation") %></span>
<% end %>
</li>
<li class="toggle-topbar menu-icon"><a href="#"><span><%= t("layouts.header.menu") %></span></a></li>
</ul>
<section class="top-bar-section">
<%= render 'devise/menu/login_items' %>
<%= render 'shared/admin_login_items' %>
</section>
</nav>
</div>
<% if home_page? %>
<div class="row home-page">
<div class="small-12 column text-center">
<h1><%= t("layouts.header.open_city") %></h1>
<h2><%= t("layouts.header.open_city_slogan") %></h2>
<%= link_to t("layouts.header.see_all_debates"), debates_path, class: 'button radius' %>
</div>
</div>
<% end %>
</header>

View File

@@ -35,6 +35,21 @@
<%= render 'devise/menu/login_items' %>
<%= render 'shared/admin_login_items' %>
</section>
<section class="subnavigation row text-center">
<div class="small-12 medium-3 column end">
<%= link_to t("layouts.header.welcome"), root_path, class: ("active" if current_page?(root_path)) %>
</div>
<div class="small-12 medium-3 column end">
<%= link_to t("layouts.header.news"), "#" %>
</div>
<div class="small-12 medium-3 column end">
<%= link_to t("layouts.header.debates"), debates_path, class: ("active" if current_page?(controller: 'debates')) %>
</div>
<div class="small-12 medium-3 column end">
<%= link_to t("layouts.header.initiatives"), "#" %>
</div>
</section>
</nav>
</div>

View File

@@ -13,7 +13,7 @@
</head>
<body>
<%= render 'layouts/header' %>
<%= render 'layouts/admin_header' %>
<% if notice %>
<p class="alert-box success"><%= notice %></p>

View File

@@ -0,0 +1,3 @@
var comment_id = '<%= dom_id(@comment) %>';
App.ModeratorComments.add_class_faded(comment_id);
App.ModeratorComments.hide_moderator_actions(comment_id);

View File

@@ -0,0 +1,3 @@
var debate_id = '<%= dom_id(@debate) %>';
App.ModeratorDebates.add_class_faded(debate_id);
App.ModeratorDebates.hide_moderator_actions(debate_id);