Merge stable
This commit is contained in:
commit
9688b7ee48
|
@ -3,12 +3,13 @@ $(document).on "click", "a[data-action=ab-destroy]", (ev) ->
|
|||
btn = $(this)
|
||||
aid = btn[0].dataset.aId
|
||||
swal
|
||||
title: "Really delete?"
|
||||
text: "The question will be moved back to your inbox."
|
||||
title: "Are you sure?"
|
||||
text: "The question will be moved back to your inbox, but it won't delete any posts to social media."
|
||||
type: "warning"
|
||||
showCancelButton: true
|
||||
confirmButtonColor: "#DD6B55"
|
||||
confirmButtonText: "Delete"
|
||||
confirmButtonText: "Yes"
|
||||
cancelButtonText: "No"
|
||||
closeOnConfirm: true
|
||||
, ->
|
||||
$.ajax
|
||||
|
@ -23,4 +24,4 @@ $(document).on "click", "a[data-action=ab-destroy]", (ev) ->
|
|||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
||||
complete: (jqxhr, status) ->
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
$(document).on "click", "a[data-action=ab-question-destroy]", (ev) ->
|
||||
ev.preventDefault()
|
||||
btn = $(this)
|
||||
qid = btn[0].dataset.qId
|
||||
swal
|
||||
title: "Are you sure?"
|
||||
text: "The question will be removed."
|
||||
type: "warning"
|
||||
showCancelButton: true
|
||||
confirmButtonColor: "#DD6B55"
|
||||
confirmButtonText: "Yes"
|
||||
cancelButtonText: "No"
|
||||
closeOnConfirm: true
|
||||
, ->
|
||||
$.ajax
|
||||
url: '/ajax/destroy_question' # TODO: find a way to use rake routes instead of hardcoding them here
|
||||
type: 'POST'
|
||||
data:
|
||||
question: qid
|
||||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
if btn[0].dataset.redirect != undefined
|
||||
window.location.pathname = btn[0].dataset.redirect
|
||||
else
|
||||
$("div.answerbox[data-q-id=#{qid}], div.questionbox[data-id=#{qid}]").slideUp()
|
||||
showNotification data.message, data.success
|
||||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
|
@ -0,0 +1,5 @@
|
|||
$(document).on "click", "a[data-action=ab-question-report]", (ev) ->
|
||||
ev.preventDefault()
|
||||
btn = $(this)
|
||||
qId = btn[0].dataset.qId
|
||||
reportDialog "question", qId, -> btn.button "reset"
|
|
@ -19,6 +19,16 @@ body {
|
|||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.question-page {
|
||||
padding-top: 100px;
|
||||
}
|
||||
|
||||
@media(max-width: $screen-xs-max) {
|
||||
.question-page {
|
||||
padding-top: 130px;
|
||||
}
|
||||
}
|
||||
|
||||
.centre {
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -135,4 +145,4 @@ body {
|
|||
|
||||
.panel-default {
|
||||
border-color: transparent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
|
||||
.answerbox--question-text {
|
||||
line-height: 1.3em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.answerbox--answer-date {
|
||||
font-size: 12px;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,22 @@
|
|||
|
||||
.panel-primary .answerbox--question-text {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
#questions .panel-body .media {
|
||||
&, .media-body {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-question {
|
||||
position: fixed;
|
||||
border-top: 1px solid #fff;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.answerbox--question-media, .question-media, .question-body {
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
$main-color: #5e35b1;
|
||||
$black: #000;
|
|
@ -1,6 +1,31 @@
|
|||
class Ajax::QuestionController < ApplicationController
|
||||
include MarkdownHelper
|
||||
|
||||
def destroy
|
||||
params.require :question
|
||||
|
||||
question = Question.find params[:question]
|
||||
if question.nil?
|
||||
@status = :not_found
|
||||
@message = "Question does not exist"
|
||||
@success = false
|
||||
return
|
||||
end
|
||||
|
||||
if not (current_user.mod? or question.user == current_user)
|
||||
@status = :not_authorized
|
||||
@message = "You are not allowed to delete this question"
|
||||
@success = false
|
||||
return
|
||||
end
|
||||
|
||||
question.destroy!
|
||||
|
||||
@status = :okay
|
||||
@message = "Successfully deleted question."
|
||||
@success = true
|
||||
end
|
||||
|
||||
def create
|
||||
params.require :question
|
||||
params.require :anonymousQuestion
|
||||
|
|
|
@ -8,9 +8,9 @@ class Answer < ActiveRecord::Base
|
|||
after_create do
|
||||
Inbox.where(user: self.user, question: self.question).destroy_all
|
||||
|
||||
Notification.notify self.question.user, self unless self.question.author_is_anonymous
|
||||
Notification.notify self.question.user, self unless self.question.user == self.user or self.question.user.nil?
|
||||
Subscription.subscribe self.user, self
|
||||
Subscription.subscribe self.question.user, self unless self.question.user.nil?
|
||||
Subscription.subscribe self.question.user, self unless self.question.author_is_anonymous
|
||||
self.user.increment! :answered_count
|
||||
self.question.increment! :answer_count
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'ajax/shared/status'
|
|
@ -1,9 +1,8 @@
|
|||
.col-md-3.col-sm-3.col-xs-12
|
||||
.panel.panel-default.hidden-xs
|
||||
.panel-body
|
||||
%ul.nav.nav-pills.nav-stacked
|
||||
= nav_entry "All reports", moderation_path
|
||||
= nav_entry "Answers", moderation_path('answer')
|
||||
= nav_entry "Comments", moderation_path('comment')
|
||||
= nav_entry "Users", moderation_path('user')
|
||||
= nav_entry "Questions", moderation_path('question')
|
||||
%ul.nav.nav-pills.nav-stacked
|
||||
= list_group_item "All reports", moderation_path
|
||||
= list_group_item "Answers", moderation_path('answer')
|
||||
= list_group_item "Comments", moderation_path('comment')
|
||||
= list_group_item "Users", moderation_path('user')
|
||||
= list_group_item "Questions", moderation_path('question')
|
||||
|
|
|
@ -1,46 +1,47 @@
|
|||
.panel.panel-default.moderationbox{data: { id: report.id }}
|
||||
.panel-heading
|
||||
%img.img-rounded.answerbox--img{src: gravatar_url(report.user)}
|
||||
= user_screen_name report.user
|
||||
reported a
|
||||
= report.type.sub('Reports::', '')
|
||||
%span{title: report.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
||||
= time_ago_in_words(report.created_at)
|
||||
ago
|
||||
.panel-body
|
||||
%p
|
||||
- if report.type == 'Reports::User'
|
||||
= user_screen_name report.target
|
||||
- else
|
||||
= report.target.content
|
||||
%p
|
||||
%b
|
||||
Reason:
|
||||
%br
|
||||
- (report.reason || "No reason provided.").lines.each do |reason|
|
||||
- next unless reason.strip.length > 0
|
||||
= reason.strip
|
||||
= unless report.target.nil?
|
||||
.panel.panel-default.moderationbox{data: { id: report.id }}
|
||||
.panel-heading
|
||||
%img.img-rounded.answerbox--img{src: gravatar_url(report.user)}
|
||||
= user_screen_name report.user
|
||||
reported a
|
||||
= report.type.sub('Reports::', '')
|
||||
%span{title: report.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
||||
= time_ago_in_words(report.created_at)
|
||||
ago
|
||||
.panel-body
|
||||
%p
|
||||
- if report.type == 'Reports::User'
|
||||
= user_screen_name report.target
|
||||
- else
|
||||
= report.target.content
|
||||
%p
|
||||
%b
|
||||
Reason:
|
||||
%br
|
||||
.row
|
||||
.col-md-6.col-sm-4.col-xs-6.text-left
|
||||
%a.btn.btn-primary{href: content_url(report)}
|
||||
View reported
|
||||
= report.type.sub('Reports::', '')
|
||||
- if report.target.respond_to? :user and not report.target.user.nil?
|
||||
%a.btn.btn-primary{href: show_user_profile_path(report.target.user.screen_name)}
|
||||
View reported User
|
||||
.col-md-6.col-sm-8.col-xs-6.text-right
|
||||
%span.mod-count{id: "mod-count-#{report.id}"}
|
||||
= report.votes
|
||||
.btn-group
|
||||
%button.btn.btn-success.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, true) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' }}
|
||||
%i.fa.fa-thumbs-up
|
||||
%button.btn.btn-danger.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, false) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' }}
|
||||
%i.fa.fa-thumbs-down
|
||||
%button.btn.btn-primary.btn-sm{type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden }}
|
||||
%i.fa.fa-comments
|
||||
%span{id: "mod-comment-count-#{report.id}"}= report.moderation_comments.all.count
|
||||
%button.btn.btn-default.btn-sm{type: :button, name: "mod-delete-report", data: { id: report.id }}
|
||||
%i.fa.fa-trash-o
|
||||
.panel-footer{id: "mod-comments-section-#{report.id}", style: 'display: none'}
|
||||
%div{id: "mod-comments-#{report.id}"}= render 'moderation/discussion', report: report
|
||||
- (report.reason || "No reason provided.").lines.each do |reason|
|
||||
- next unless reason.strip.length > 0
|
||||
= reason.strip
|
||||
%br
|
||||
.row
|
||||
.col-md-6.col-sm-4.col-xs-6.text-left
|
||||
%a.btn.btn-primary{href: content_url(report)}
|
||||
View reported
|
||||
= report.type.sub('Reports::', '')
|
||||
- if report.target.respond_to? :user and not report.target.user.nil?
|
||||
%a.btn.btn-primary{href: show_user_profile_path(report.target.user.screen_name)}
|
||||
View reported User
|
||||
.col-md-6.col-sm-8.col-xs-6.text-right
|
||||
%span.mod-count{id: "mod-count-#{report.id}"}
|
||||
= report.votes
|
||||
.btn-group
|
||||
%button.btn.btn-success.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, true) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' }}
|
||||
%i.fa.fa-thumbs-up
|
||||
%button.btn.btn-danger.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, false) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' }}
|
||||
%i.fa.fa-thumbs-down
|
||||
%button.btn.btn-primary.btn-sm{type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden }}
|
||||
%i.fa.fa-comments
|
||||
%span{id: "mod-comment-count-#{report.id}"}= report.moderation_comments.all.count
|
||||
%button.btn.btn-default.btn-sm{type: :button, name: "mod-delete-report", data: { id: report.id }}
|
||||
%i.fa.fa-trash-o
|
||||
.panel-footer{id: "mod-comments-section-#{report.id}", style: 'display: none'}
|
||||
%div{id: "mod-comments-#{report.id}"}= render 'moderation/discussion', report: report
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
.container.j2-page
|
||||
/ TODO: make this pretty (it's currently C-c'd straight from shared/_answerbox)
|
||||
.panel.panel-default
|
||||
.panel.panel-question
|
||||
.container
|
||||
.panel-body
|
||||
.media
|
||||
.media.question-media
|
||||
- unless @question.author_is_anonymous
|
||||
%a.pull-left{href: show_user_profile_path(@question.user.screen_name)}
|
||||
%img.img-rounded.answerbox--img{src: gravatar_url(@question.user)}
|
||||
.media-body
|
||||
.media-body.question-body
|
||||
- if user_signed_in?
|
||||
.pull-right
|
||||
.btn-group
|
||||
%button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }}
|
||||
%span.caret
|
||||
%ul.dropdown-menu.dropdown-menu-right{role: :menu}
|
||||
- if current_user.mod? or @question.user == current_user
|
||||
%li.text-danger
|
||||
%a{href: '#', data: { action: 'ab-question-destroy', q_id: @question.id, redirect: if @question.author_is_anonymous? then "/" else show_user_questions_path(@question.user.screen_name) end }}
|
||||
%i.fa.fa-trash-o
|
||||
Delete Question
|
||||
- unless @question.user == current_user
|
||||
%li
|
||||
%a{href: '#', data: { action: 'ab-question-report', q_id: @question.id }}
|
||||
%i.fa.fa-exclamation-triangle
|
||||
Report
|
||||
%h6.text-muted.media-heading.answerbox--question-user
|
||||
= user_screen_name @question.user, @question.author_is_anonymous
|
||||
asked
|
||||
|
@ -14,6 +29,8 @@
|
|||
= time_ago_in_words(@question.created_at)
|
||||
ago
|
||||
%p.answerbox--question-text= @question.content
|
||||
.container.question-page
|
||||
/ TODO: make this pretty (it's currently C-c'd straight from shared/_answerbox)
|
||||
|
||||
#answers
|
||||
- @answers.each do |a|
|
||||
|
@ -38,4 +55,4 @@
|
|||
%label
|
||||
%input{type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider }}
|
||||
Post to
|
||||
= service.provider.capitalize
|
||||
= service.provider.capitalize
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
.panel.panel-default.answerbox{data: { id: a.id }}
|
||||
.panel.panel-default.answerbox{data: { id: a.id, q_id: a.question.id }}
|
||||
- if @question.nil?
|
||||
.panel-heading
|
||||
.media
|
||||
.media.question-media
|
||||
- unless a.question.author_is_anonymous
|
||||
%a.pull-left{href: show_user_profile_path(a.question.user.screen_name)}
|
||||
%img.img-rounded.answerbox--img{src: gravatar_url(a.question.user)}
|
||||
.media-body
|
||||
.media-body.question-body
|
||||
- if user_signed_in?
|
||||
.pull-right
|
||||
.btn-group
|
||||
%button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }}
|
||||
%span.caret
|
||||
%ul.dropdown-menu.dropdown-menu-right{role: :menu}
|
||||
- if current_user.mod? or a.question.user == current_user
|
||||
%li.text-danger
|
||||
%a{href: '#', data: { action: 'ab-question-destroy', q_id: a.question.id }}
|
||||
%i.fa.fa-trash-o
|
||||
Delete Question
|
||||
- unless a.question.user == current_user
|
||||
%li
|
||||
%a{href: '#', data: { action: 'ab-question-report', q_id: a.question.id }}
|
||||
%i.fa.fa-exclamation-triangle
|
||||
Report
|
||||
%h6.text-muted.media-heading.answerbox--question-user
|
||||
= user_screen_name a.question.user, a.question.author_is_anonymous
|
||||
asked
|
||||
|
@ -67,4 +83,4 @@
|
|||
= render 'shared/answerbox_buttons', a: a
|
||||
.panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil }
|
||||
%div{id: "ab-smiles-#{a.id}"}= render 'shared/smiles', a: a
|
||||
%div{id: "ab-comments-#{a.id}"}= render 'shared/comments', a: a
|
||||
%div{id: "ab-comments-#{a.id}"}= render 'shared/comments', a: a
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
%li.text-danger
|
||||
%a{href: '#', data: { a_id: a.id, action: 'ab-destroy' }}
|
||||
%i.fa.fa-trash-o
|
||||
Delete
|
||||
Return to Inbox
|
||||
- unless a.user == current_user
|
||||
%li
|
||||
%a{href: '#', data: { a_id: a.id, action: 'ab-report' }}
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
.panel.panel-default
|
||||
.panel.panel-default.questionbox{data: { id: q.id }}
|
||||
.panel-body
|
||||
.media
|
||||
.media-body
|
||||
- if user_signed_in?
|
||||
.pull-right
|
||||
.btn-group
|
||||
%button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }}
|
||||
%span.caret
|
||||
%ul.dropdown-menu.dropdown-menu-right{role: :menu}
|
||||
- if current_user.mod? or q.user == current_user
|
||||
%li.text-danger
|
||||
%a{href: '#', data: { action: 'ab-question-destroy', q_id: q.id }}
|
||||
%i.fa.fa-trash-o
|
||||
Delete Question
|
||||
- unless q.user == current_user
|
||||
%li
|
||||
%a{href: '#', data: { action: 'ab-question-report', q_id: q.id }}
|
||||
%i.fa.fa-exclamation-triangle
|
||||
Report
|
||||
%h6.media-heading.text-muted.answerbox--question-user
|
||||
= user_screen_name q.user
|
||||
asked
|
||||
|
@ -14,4 +30,4 @@
|
|||
%a{href: show_user_question_path(q.user.screen_name, q.id)}
|
||||
#{q.answer_count} answers
|
||||
%p.answerbox--question-text
|
||||
= q.content
|
||||
= q.content
|
||||
|
|
|
@ -67,6 +67,7 @@ Rails.application.routes.draw do
|
|||
|
||||
namespace :ajax do
|
||||
match '/ask', to: 'question#create', via: :post, as: :ask
|
||||
match '/destroy_question', to: 'question#destroy', via: :post, as: :destroy_question
|
||||
match '/generate_question', to: 'inbox#create', via: :post, as: :generate_question
|
||||
match '/delete_inbox', to: 'inbox#remove', via: :post, as: :delete_inbox
|
||||
match '/delete_all_inbox', to: 'inbox#remove_all', via: :post, as: :delete_all_inbox
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150421120557) do
|
||||
ActiveRecord::Schema.define(version: 20150422024104) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -132,6 +132,7 @@ ActiveRecord::Schema.define(version: 20150421120557) do
|
|||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "deleted", default: false
|
||||
t.string "reason"
|
||||
end
|
||||
|
||||
create_table "services", force: :cascade do |t|
|
||||
|
|
Loading…
Reference in New Issue