Skip to content

Instantly share code, notes, and snippets.

@Findeton
Created January 26, 2017 14:37
Show Gist options
  • Select an option

  • Save Findeton/a86c4e9b8e42f602c4f7d27ab7e45687 to your computer and use it in GitHub Desktop.

Select an option

Save Findeton/a86c4e9b8e42f602c4f7d27ab7e45687 to your computer and use it in GitHub Desktop.
Disable editing/removing comments, editing issues on gitlab, editing user name
From 10609b0bd79e8d981a3f8bf6c6a2393c20e9924a Mon Sep 17 00:00:00 2001
From: Findeton <felrobelv@gmail.com>
Date: Wed, 25 Jan 2017 13:12:04 +0100
Subject: [PATCH 1/2] disable editing and removing comments, editing issues
---
app/controllers/projects/issues_controller.rb | 1 +
app/controllers/projects/notes_controller.rb | 2 ++
app/views/projects/issues/show.html.haml | 3 ---
app/views/projects/notes/_note.html.haml | 6 ------
4 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 8472cec..e9df1fc 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -68,6 +68,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def edit
+ raise "nVotes decided you can't edit issues"
respond_with(@issue)
end
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index c5d93ce..5eefe72 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -37,6 +37,7 @@ class Projects::NotesController < Projects::ApplicationController
end
def update
+ raise "nVotes decided you can't edit comments"
@note = Notes::UpdateService.new(project, current_user, note_params).execute(note)
if @note.is_a?(Note)
@@ -50,6 +51,7 @@ class Projects::NotesController < Projects::ApplicationController
end
def destroy
+ raise "nVotes decided you can't remove comments"
if note.editable?
Notes::DeleteService.new(project, current_user).execute(note)
end
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index 9fa0081..6dd52c5 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -38,8 +38,6 @@
= link_to 'Reopen issue', issue_path(@issue, issue: { state_event: :reopen }, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn-reopen #{issue_button_visibility(@issue, false)}", title: 'Reopen issue'
%li
= link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue'
- %li
- = link_to 'Edit', edit_namespace_project_issue_path(@project.namespace, @project, @issue)
- if @issue.submittable_as_spam? && current_user.admin?
%li
= link_to 'Submit as spam', mark_as_spam_namespace_project_issue_path(@project.namespace, @project, @issue), method: :post, class: 'btn-spam', title: 'Submit as spam'
@@ -52,7 +50,6 @@
= link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "hidden-xs hidden-sm btn btn-grouped btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue'
- if @issue.submittable_as_spam? && current_user.admin?
= link_to 'Submit as spam', mark_as_spam_namespace_project_issue_path(@project.namespace, @project, @issue), method: :post, class: 'hidden-xs hidden-sm btn btn-grouped btn-spam', title: 'Submit as spam'
- = link_to 'Edit', edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: 'hidden-xs hidden-sm btn btn-grouped issuable-edit'
.issue-details.issuable-details
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index 36c388c..ca23db8 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -55,12 +55,6 @@
= link_to '#', title: 'Award Emoji', class: 'note-action-button note-emoji-button js-add-award js-note-emoji', data: { position: 'right' } do
= icon('spinner spin')
= icon('smile-o', class: 'link-highlight')
-
- - if note_editable
- = link_to '#', title: 'Edit comment', class: 'note-action-button js-note-edit' do
- = icon('pencil', class: 'link-highlight')
- = link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'note-action-button hidden-xs js-note-delete danger' do
- = icon('trash-o', class: 'danger-highlight')
.note-body{ class: note_editable ? 'js-task-list-container' : '' }
.note-text.md
= preserve do
--
2.7.4
From 6102243748b33bc40abbdaf1d8e01badb543c70b Mon Sep 17 00:00:00 2001
From: Findeton <felrobelv@gmail.com>
Date: Thu, 26 Jan 2017 15:35:29 +0100
Subject: [PATCH 2/2] disable editing user name
---
app/views/profiles/show.html.haml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml
index c0c82cd..a4e3ef0 100644
--- a/app/views/profiles/show.html.haml
+++ b/app/views/profiles/show.html.haml
@@ -44,8 +44,8 @@
.col-lg-9
.form-group
= f.label :name, class: "label-light"
- = f.text_field :name, class: "form-control", required: true
- %span.help-block Enter your name, so people you know can recognize you.
+ = f.text_field :name, class: "form-control", required: true, readonly: true
+ %span.help-block This is your name, so people you know can recognize you.
.form-group
= f.label :email, class: "label-light"
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment