-
Notifications
You must be signed in to change notification settings - Fork 32
Views for polls fixed. has_admin_rights method created #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class PollsController < ApplicationController | ||
load_and_authorize_resource only: [:new, :create, :edit, :update, | ||
:destroy, :published] | ||
before_action :admin_user, only: [:new, :create, :edit, :update, :destroy] | ||
before_action :authenticate_user! | ||
|
||
# GET /polls | ||
|
@@ -100,9 +101,16 @@ def answer | |
end | ||
|
||
private | ||
|
||
def poll_params | ||
params.require(:poll).permit( | ||
:question, :published | ||
) | ||
end | ||
|
||
def admin_user | ||
redirect_to(root_url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not 1) spaces for indentation. |
||
unless current_user.admin? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tab detected. |
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tab detected. |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,7 @@ def display_name(user) | |
user.hide_last_name? ? first_name(user) : user.name | ||
end | ||
|
||
def has_admin_rights | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename |
||
current_user.admin? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not -1) spaces for indentation. |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,9 @@ | |
.poll{'data-id' => poll.id} | ||
%h2= poll.question | ||
.publish | ||
= if current_user.admin? | ||
= render :partial => "polls/publish_link", :locals => {:poll => poll}.actions | ||
= link_to 'Edit', edit_poll_path(poll) | ||
= link_to 'Destroy', poll, method: :delete, data: { confirm: 'Are you sure?' } | ||
= link_to 'Show', poll | ||
= render :partial => "polls/publish_link", :locals => {:poll => poll}.actions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [81/80] |
||
= link_to 'Edit', edit_poll_path(poll) if has_admin_rights | ||
= link_to 'Destroy', poll, method: :delete, data: { confirm: 'Are you sure?' } if has_admin_rights | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [105/80] |
||
= link_to 'Show', poll | ||
|
||
= link_to 'New Poll', new_poll_path if current_user.admin? | ||
= link_to 'New Poll', new_poll_path if has_admin_rights |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.