Skip to content

Commit

Permalink
Merge pull request #128 from codidact/luap42/own-answers
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- authored Aug 6, 2020
2 parents 2e85331 + 8b3481f commit afd57af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Lint/StructNewOverride:
Enabled: true

Metrics/AbcSize:
Max: 50
Enabled: false
Metrics/BlockLength:
Max: 30
Metrics/ClassLength:
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/advertisement_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Neccessary due to rmagick
# rubocop:disable Metrics/ClassLength
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/BlockLength
class AdvertisementController < ApplicationController
include Magick
Expand Down Expand Up @@ -359,5 +358,5 @@ def article_ad(article)
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/ClassLength
# rubocop:enable Metrics/AbcSize

# rubocop:enable Metrics/BlockLength
2 changes: 0 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def posts
end
end

# rubocop:disable Metrics/AbcSize
def activity
@posts = Post.undeleted.where(user: @user).count
@comments = Comment.undeleted.where(user: @user).where(post: Post.undeleted).count
Expand Down Expand Up @@ -118,7 +117,6 @@ def full_log

render layout: 'without_sidebar'
end
# rubocop:enable Metrics/AbcSize

def destroy
if @user.votes.count > 100
Expand Down
18 changes: 10 additions & 8 deletions app/controllers/votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ def create
recent_votes = Vote.where(created_at: 24.hours.ago..Time.now, user: current_user).count
max_votes_per_day = SiteSetting['FreeVotes'] + (@current_user.reputation - SiteSetting['NewUserInitialRep'])

if recent_votes >= max_votes_per_day
vote_limit_msg = 'You have used your daily vote limit of ' + recent_votes.to_s + 'votes. Gain more reputation' \
' or come back tomorrow to continue voting.'
unless post.parent&.user_id == current_user.id
if recent_votes >= max_votes_per_day
vote_limit_msg = 'You have used your daily vote limit of ' + recent_votes.to_s + 'votes. Gain more reputation' \
' or come back tomorrow to continue voting.'

if max_votes_per_day <= 0
vote_limit_msg = 'You need to gain some reputation on this site before you can start voting.'
end
if max_votes_per_day <= 0
vote_limit_msg = 'You need to gain some reputation on this site before you can start voting.'
end

render json: { status: 'failed', message: vote_limit_msg }, status: 403
return
render json: { status: 'failed', message: vote_limit_msg }, status: 403
return
end
end

destroyed = post.votes.where(user: current_user).destroy_all
Expand Down

0 comments on commit afd57af

Please sign in to comment.