diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/abuse_reports_controller.rb | 23 | ||||
-rw-r--r-- | app/models/abuse_report.rb | 9 | ||||
-rw-r--r-- | app/views/abuse_reports/new.html.haml | 29 | ||||
-rw-r--r-- | app/views/users/show.html.haml | 10 |
4 files changed, 71 insertions, 0 deletions
diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb new file mode 100644 index 00000000000..757be5ef727 --- /dev/null +++ b/app/controllers/abuse_reports_controller.rb @@ -0,0 +1,23 @@ +class AbuseReportsController < ApplicationController + def new + @abuse_report = AbuseReport.new + @abuse_report.user_id = params[:user_id] + end + + def create + @abuse_report = AbuseReport.new(report_params) + @abuse_report.reporter = current_user + + if @abuse_report.save + redirect_to root_path, notice: 'Thank you for report. GitLab administrator will be able to see it' + else + render :new + end + end + + private + + def report_params + params.require(:abuse_report).permit(:user_id, :message) + end +end diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb new file mode 100644 index 00000000000..c8c39db11bc --- /dev/null +++ b/app/models/abuse_report.rb @@ -0,0 +1,9 @@ +class AbuseReport < ActiveRecord::Base + belongs_to :reporter, class_name: "User" + belongs_to :user + + validates :reporter, presence: true + validates :user, presence: true + validates :message, presence: true + validates :user_id, uniqueness: { scope: :reporter_id } +end diff --git a/app/views/abuse_reports/new.html.haml b/app/views/abuse_reports/new.html.haml new file mode 100644 index 00000000000..736456b67ba --- /dev/null +++ b/app/views/abuse_reports/new.html.haml @@ -0,0 +1,29 @@ +- page_title "Report abuse" +%h3.page-title Report abuse +%p Please use this form if user makes spam or inappropriate content +%hr += form_for @abuse_report, html: { class: 'form-horizontal'} do |f| + = f.hidden_field :user_id + - if @abuse_report.errors.any? + .alert.alert-danger + - @abuse_report.errors.full_messages.each do |msg| + %p= msg + .form-group + = f.label :user_id, class: 'control-label' + .col-sm-10 + = users_select_tag("abuse_reports[user_id]", placeholder: 'Select user to report abuse', + class: 'custom-form-control js-select2', selected: @abuse_report.user_id, scope: :all) + .form-group + = f.label :message, class: 'control-label' + .col-sm-10 + = f.text_area :message, class: "form-control", rows: 2, required: true + .help-block + Explain the problem with this account. + %br + If user sends spam please provide a link to spam issue or comment + + .form-actions + = f.submit "Send report", class: "btn btn-create" + +:coffeescript + new UsersSelect() diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 43d847831d6..64b7f25ad37 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -18,6 +18,16 @@ = link_to profile_path, class: 'btn btn-sm' do %i.fa.fa-pencil-square-o Edit Profile settings + - elsif current_user + .pull-right + %span.dropdown + %a.light.dropdown-toggle.btn.btn-sm{href: '#', "data-toggle" => "dropdown"} + = icon('exclamation-circle') + %ul.dropdown-menu.dropdown-menu-right + %li + = link_to new_abuse_report_path(user_id: @user.id) do + Report abuse + .username @#{@user.username} .description |