mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
More Rubocop
This commit is contained in:
parent
318c99202e
commit
dd64614fff
@ -1,5 +1,5 @@
|
||||
Metrics/LineLength:
|
||||
Max: 99
|
||||
Max: 120
|
||||
|
||||
Documentation:
|
||||
Enabled: false
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
class Admin::AdminController < ApplicationController
|
||||
module Admin
|
||||
class AdminController < ApplicationController
|
||||
layout 'admin/layouts/admin'
|
||||
before_filter :authenticate_admin_user!
|
||||
before_filter :admin_menu
|
||||
@ -12,4 +13,5 @@ class Admin::AdminController < ApplicationController
|
||||
photos: '',
|
||||
pages: '' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Admin::AdminUsersController < Admin::AdminController
|
||||
|
||||
module Admin
|
||||
class AdminUsersController < Admin::AdminController
|
||||
def index
|
||||
@admin_users = AdminUser.all
|
||||
end
|
||||
@ -25,14 +25,12 @@ class Admin::AdminUsersController < Admin::AdminController
|
||||
def create
|
||||
@admin_user = AdminUser.new(permitted_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @admin_user.save
|
||||
redirect_to admin_admin_users_path, notice: 'Admin User was successfully added.'
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@admin_user = AdminUser.find(params[:id])
|
||||
@ -51,7 +49,7 @@ class Admin::AdminUsersController < Admin::AdminController
|
||||
|
||||
if @admin_user.update_with_password(permitted_params)
|
||||
sign_in @admin_user, bypass: true
|
||||
redirect_to admin_dashboard_path, notice: "Password updated!"
|
||||
redirect_to admin_dashboard_path, notice: 'Password updated!'
|
||||
else
|
||||
render :edit_password
|
||||
end
|
||||
@ -62,5 +60,5 @@ class Admin::AdminUsersController < Admin::AdminController
|
||||
def permitted_params
|
||||
params.require(:admin_user).permit(:email, :password, :password_confirmable, :remember_me)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Admin::CategoriesController < Admin::AdminController
|
||||
|
||||
module Admin
|
||||
class CategoriesController < Admin::AdminController
|
||||
def index
|
||||
@categories = Category.all
|
||||
end
|
||||
@ -44,5 +44,5 @@ class Admin::CategoriesController < Admin::AdminController
|
||||
def permitted_params
|
||||
params.require(:category).permit(:name, :slug, :description, :base_colour, :sort)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,26 +1,19 @@
|
||||
class Admin::ConfirmationsController < ::Devise::PasswordsController
|
||||
layout "admin/layouts/login"
|
||||
module Admin
|
||||
class ConfirmationsController < ::Devise::PasswordsController
|
||||
layout 'admin/layouts/login'
|
||||
|
||||
skip_before_filter(:authenticate_user!)
|
||||
|
||||
def update
|
||||
with_unconfirmed_confirmable do
|
||||
if @confirmable.has_no_password?
|
||||
@confirmable.attempt_set_password(params[:admin_user])
|
||||
if @confirmable.valid?
|
||||
do_confirm
|
||||
update_password
|
||||
else
|
||||
do_show
|
||||
@confirmable.errors.clear #so that we wont render :new
|
||||
end
|
||||
else
|
||||
self.class.add_error_on(self, :email, :password_allready_set)
|
||||
self.class.add_error_on(self, :email, :password_already_set)
|
||||
end
|
||||
end
|
||||
|
||||
if !@confirmable.errors.empty?
|
||||
render_with_scope :new
|
||||
end
|
||||
render_with_scope :new unless confirmable.errors.empty?
|
||||
end
|
||||
|
||||
def show
|
||||
@ -31,8 +24,19 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController
|
||||
do_confirm
|
||||
end
|
||||
end
|
||||
if !@confirmable.errors.empty?
|
||||
render_with_scope :new
|
||||
|
||||
render_with_scope :new unless @confirmable.errors.empty?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_password
|
||||
@confirmable.attempt_set_password(params[:admin_user])
|
||||
if @confirmable.valid?
|
||||
do_confirm
|
||||
else
|
||||
do_show
|
||||
@confirmable.errors.clear # so that we won't render :new
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,9 +44,8 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController
|
||||
|
||||
def with_unconfirmed_confirmable
|
||||
@confirmable = AdminUser.find_or_initialize_with_error_by(:confirmation_token, params[:confirmation_token])
|
||||
if !@confirmable.new_record?
|
||||
@confirmable.only_if_unconfirmed {yield}
|
||||
end
|
||||
|
||||
@confirmable.only_if_unconfirmed { yield } unless @confirmable.new_record?
|
||||
end
|
||||
|
||||
def do_show
|
||||
@ -57,4 +60,5 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController
|
||||
set_flash_message :notice, :confirmed
|
||||
sign_in_and_redirect(resource_name, @confirmable)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +1,4 @@
|
||||
class Admin::DashboardController < Admin::AdminController
|
||||
module Admin
|
||||
class DashboardController < Admin::AdminController
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Admin::PagesController < Admin::AdminController
|
||||
|
||||
module Admin
|
||||
class PagesController < Admin::AdminController
|
||||
def index
|
||||
@pages = Page.all
|
||||
end
|
||||
@ -49,5 +49,5 @@ class Admin::PagesController < Admin::AdminController
|
||||
def permitted_params
|
||||
params.require(:page).permit(:name, :title, :content)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
class Admin::PasswordsController < ::Devise::PasswordsController
|
||||
layout "admin/layouts/login"
|
||||
module Admin
|
||||
class PasswordsController < ::Devise::PasswordsController
|
||||
layout 'admin/layouts/login'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
class Admin::PhotosController < Admin::AdminController
|
||||
before_filter :get_categories
|
||||
module Admin
|
||||
class PhotosController < Admin::AdminController
|
||||
before_filter :categories
|
||||
|
||||
def index
|
||||
@photos = Photo.paginate(page: params[:page], per_page: 16)
|
||||
@ -42,12 +43,13 @@ class Admin::PhotosController < Admin::AdminController
|
||||
|
||||
private
|
||||
|
||||
def get_categories
|
||||
def categories
|
||||
@categories = Category.all
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.require(:photo).permit(:image, :title, :description, :flickr_url, :featured, :enabled, :taken_at, category_ids: [])
|
||||
params.require(:photo).permit(:image, :title, :description, :flickr_url, :featured,
|
||||
:enabled, :taken_at, category_ids: [])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
class Admin::RegistrationsController < ::Devise::RegistrationsController
|
||||
layout "admin/layouts/login"
|
||||
module Admin
|
||||
class RegistrationsController < ::Devise::RegistrationsController
|
||||
layout 'admin/layouts/login'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
class Admin::SessionsController < ::Devise::SessionsController
|
||||
layout "admin/layouts/login"
|
||||
module Admin
|
||||
class SessionsController < ::Devise::SessionsController
|
||||
layout 'admin/layouts/login'
|
||||
|
||||
before_filter :check_https
|
||||
|
||||
@ -9,4 +10,5 @@ class Admin::SessionsController < ::Devise::SessionsController
|
||||
secure_link = url_for(protocol: 'https')
|
||||
flash[:alert] = I18n.t('insecure_alert', secure_link: secure_link).html_safe unless request.scheme == 'https'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
class Admin::UnlocksController < ::Devise::UnlocksController
|
||||
layout "admin/layouts/login"
|
||||
module Admin
|
||||
class UnlocksController < ::Devise::UnlocksController
|
||||
layout 'admin/layouts/login'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
module Admin::AdminHelper
|
||||
def inputs_field_set &block
|
||||
module Admin
|
||||
module AdminHelper
|
||||
def inputs_field_set(&block)
|
||||
field_set_tag nil, class: :inputs, &block
|
||||
end
|
||||
|
||||
def actions_field_set &block
|
||||
def actions_field_set(&block)
|
||||
field_set_tag nil, class: :actions, &block
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module Admin::DashboardHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module Admin::DownloadsHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module Admin::UnlocksHelper
|
||||
end
|
||||
@ -3,8 +3,6 @@ class Notifier < ActionMailer::Base
|
||||
|
||||
def contact_notification(sender)
|
||||
@sender = sender
|
||||
mail( to: 'enquiries@danbarberphoto.com',
|
||||
from: sender.email,
|
||||
subject: sender.subject)
|
||||
mail(to: 'enquiries@danbarberphoto.com', from: sender.email, subject: sender.subject)
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,11 +5,7 @@ class Heartbeat
|
||||
|
||||
def call(env)
|
||||
if env['PATH_INFO'] == '/heartbeat'
|
||||
[
|
||||
200,
|
||||
{"Content-Type" => "text/plain"},
|
||||
["OK"]
|
||||
]
|
||||
[200, { 'Content-Type' => 'text/plain' }, ['OK']]
|
||||
else
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
@ -10,8 +10,8 @@ class AdminUser < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# new function to return whether a password has been set
|
||||
def has_no_password?
|
||||
self.encrypted_password.blank?
|
||||
def no_password?
|
||||
encrypted_password.blank?
|
||||
end
|
||||
|
||||
# new function to provide access to protected method unless_confirmed
|
||||
|
||||
@ -9,12 +9,12 @@ class Contact
|
||||
|
||||
def initialize(attributes = {})
|
||||
attributes.each do |key, value|
|
||||
self.send("#{key}=", value)
|
||||
send("#{key}=", value)
|
||||
end
|
||||
end
|
||||
|
||||
def read_attribute_for_validation(key)
|
||||
self.send(key)
|
||||
send(key)
|
||||
end
|
||||
|
||||
def save
|
||||
@ -22,7 +22,6 @@ class Contact
|
||||
Notifier.contact_notification(self).deliver
|
||||
return true
|
||||
end
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
class Photo < ActiveRecord::Base
|
||||
|
||||
has_and_belongs_to_many :categories
|
||||
|
||||
dragonfly_accessor :image
|
||||
@ -8,25 +7,24 @@ class Photo < ActiveRecord::Base
|
||||
|
||||
@@per_page = 11
|
||||
|
||||
scope :enabled, lambda { where(enabled: true) }
|
||||
scope :enabled, -> { where(enabled: true) }
|
||||
|
||||
scope :featured, lambda { enabled.where(featured: true) }
|
||||
scope :featured, -> { enabled.where(featured: true) }
|
||||
|
||||
def to_s
|
||||
self.title
|
||||
title
|
||||
end
|
||||
|
||||
def name
|
||||
self.title
|
||||
title
|
||||
end
|
||||
|
||||
def log_view
|
||||
if self.views.nil?
|
||||
if views.nil?
|
||||
self.views = 1
|
||||
else
|
||||
self.views += 1
|
||||
end
|
||||
self.save
|
||||
save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -4,6 +4,6 @@ class PagePresenter < SimpleDelegator
|
||||
end
|
||||
|
||||
def self.markdown
|
||||
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {})
|
||||
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions: {})
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
# lib/email_validator.rb
|
||||
class EmailValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(object, attribute, value)
|
||||
unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||
object.errors[attribute] << (options[:message] || "is not valid")
|
||||
return if value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||
object.errors[attribute] << (options[:message] || 'is not valid')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
|
||||
require 'commands/about'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/console'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/dbconsole'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/destroy'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/generate'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../../config/boot', __FILE__)
|
||||
require 'commands/performance/benchmarker'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../../config/boot', __FILE__)
|
||||
require 'commands/performance/profiler'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/plugin'
|
||||
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'rails/commands'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/runner'
|
||||
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/server'
|
||||
Loading…
Reference in New Issue
Block a user