mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 07:10:12 +01:00
More code style fixes
This commit is contained in:
parent
465419f46a
commit
d4c9041ccd
61 changed files with 406 additions and 422 deletions
|
|
@ -4,23 +4,23 @@ class DoneTodos
|
|||
return done_today(completed_todos), done_rest_of_week(completed_todos), done_rest_of_month(completed_todos)
|
||||
end
|
||||
|
||||
def self.done_today(todos, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
def self.done_today(todos, includes = { :include => Todo::DEFAULT_INCLUDES })
|
||||
# TODO: refactor to remove outer hash from includes param
|
||||
todos.completed_after(beginning_of_day).includes(includes[:include])
|
||||
end
|
||||
|
||||
def self.done_rest_of_week(todos, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
def self.done_rest_of_week(todos, includes = { :include => Todo::DEFAULT_INCLUDES })
|
||||
done_between(todos, includes, beginning_of_day, beginning_of_week)
|
||||
end
|
||||
|
||||
def self.done_rest_of_month(todos, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
def self.done_rest_of_month(todos, includes = { :include => Todo::DEFAULT_INCLUDES })
|
||||
done_between(todos, includes, beginning_of_week, beginning_of_month)
|
||||
end
|
||||
|
||||
def self.completed_period(date)
|
||||
return nil if date.nil?
|
||||
|
||||
return "today" if date >= end_of_day # treat todos with completed_at in future as done today (happens in tests)
|
||||
return "today" if date >= end_of_day # Treat todos with completed_at in future as done today (happens in tests)
|
||||
return "today" if date.between?(beginning_of_day, end_of_day)
|
||||
return "rest_of_week" if date >= beginning_of_week
|
||||
return "rest_of_month" if date >= beginning_of_month
|
||||
|
|
@ -28,7 +28,7 @@ class DoneTodos
|
|||
end
|
||||
|
||||
def self.remaining_in_container(todos, period)
|
||||
count = self.send("done_#{period}", todos.completed, {}).count
|
||||
count = send("done_#{period}", todos.completed, {}).count
|
||||
return nil if period.nil?
|
||||
return count
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ module IsTaggable
|
|||
has_many :taggings, :as => :taggable
|
||||
has_many :tags, :through => :taggings do
|
||||
def to_s
|
||||
self.to_a.map(&:name).sort.join(Tag::JOIN_DELIMITER)
|
||||
to_a.map(&:name).sort.join(Tag::JOIN_DELIMITER)
|
||||
end
|
||||
|
||||
def all_except_starred
|
||||
self.to_a.reject { |tag| tag.name == Todo::STARRED_TAG_NAME }
|
||||
to_a.reject { |tag| tag.name == Todo::STARRED_TAG_NAME }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ module IsTaggable
|
|||
# added following check to prevent empty tags from being saved (which will fail)
|
||||
if tag_name.present?
|
||||
begin
|
||||
tag = self.user.tags.where(:name => tag_name).first_or_create
|
||||
tag = user.tags.where(:name => tag_name).first_or_create
|
||||
raise Tag::Error, "tag could not be saved: #{tag_name}" if tag.new_record?
|
||||
tags << tag
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
|
|
@ -62,7 +62,7 @@ module IsTaggable
|
|||
# Removes tags from <tt>self</tt>. Accepts a string of tagnames, an array of tagnames, or an array of Tags.
|
||||
def _remove_tags(outgoing)
|
||||
outgoing = tag_cast_to_string(outgoing)
|
||||
tags.destroy(*(self.user.tags.select { |tag| outgoing.include? tag.name }))
|
||||
tags.destroy(*(user.tags.select { |tag| outgoing.include? tag.name }))
|
||||
end
|
||||
|
||||
def get_tag_name_from_item(item)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module LoginSystem
|
|||
# Logout the {#current_user} and redirect to login page
|
||||
#
|
||||
# @param [String] message notification to display
|
||||
def logout_user(message=t('login.logged_out'))
|
||||
def logout_user(message = t('login.logged_out'))
|
||||
@user.forget_me if logged_in?
|
||||
cookies.delete :auth_token
|
||||
session['user_id'] = nil
|
||||
|
|
@ -64,7 +64,7 @@ module LoginSystem
|
|||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
current_user.remember_me
|
||||
cookies[:auth_token] = { :value => current_user.remember_token , :expires => current_user.remember_token_expires_at, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
cookies[:auth_token] = { :value => current_user.remember_token, :expires => current_user.remember_token_expires_at, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
flash[:notice] = t('login.successful')
|
||||
end
|
||||
end
|
||||
|
|
@ -72,7 +72,7 @@ module LoginSystem
|
|||
def login_or_feed_token_required
|
||||
if ['rss', 'atom', 'txt', 'ics', 'xml'].include?(params[:format])
|
||||
# Login based on the token GET parameter
|
||||
if user = User.where(:token => params[:token]).first
|
||||
if (user = User.where(:token => params[:token]).first)
|
||||
set_current_user(user)
|
||||
return true
|
||||
end
|
||||
|
|
@ -209,8 +209,8 @@ module LoginSystem
|
|||
end
|
||||
|
||||
def basic_auth_denied
|
||||
response.headers["WWW-Authenticate"] = "Basic realm=\"'Tracks Login Required'\""
|
||||
render :body => t('login.unsuccessful'), :status => 401
|
||||
response.headers["WWW-Authenticate"] = "Basic realm=\"'Tracks Login Required'\""
|
||||
render :body => t('login.unsuccessful'), :status => 401
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ module Tracks
|
|||
end
|
||||
|
||||
def specified_by_name?(object_type)
|
||||
self.send("#{object_type}_specified_by_name?")
|
||||
send("#{object_type}_specified_by_name?")
|
||||
end
|
||||
|
||||
def project_specified_by_name?
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Tracks
|
||||
class Config
|
||||
def self.auth_schemes
|
||||
SITE_CONFIG['authentication_schemes'] || []
|
||||
SITE_CONFIG['authentication_schemes'] || []
|
||||
end
|
||||
|
||||
def self.openid_enabled?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue