mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-06 12:50:19 +01:00
Merge branch 'master' of git://github.com/bsag/tracks
Conflicts: config/routes.rb
This commit is contained in:
commit
952a73e39d
1092 changed files with 52802 additions and 20798 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Likewise will all the methods added be available for all controllers.
|
||||
|
||||
require_dependency "login_system"
|
||||
require_dependency "source_view"
|
||||
require_dependency "tracks/source_view"
|
||||
require "redcloth"
|
||||
|
||||
require 'date'
|
||||
|
|
@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base
|
|||
layout proc{ |controller| controller.mobile? ? "mobile" : "standard" }
|
||||
|
||||
before_filter :set_session_expiration
|
||||
before_filter :set_time_zone
|
||||
prepend_before_filter :login_required
|
||||
prepend_before_filter :enable_mobile_content_negotiation
|
||||
after_filter :restore_content_type_for_mobile
|
||||
|
|
@ -178,6 +179,14 @@ class ApplicationController < ActionController::Base
|
|||
raise ArgumentError.new("invalid value for Boolean: \"#{s}\"")
|
||||
end
|
||||
|
||||
def self.openid_enabled?
|
||||
Tracks::Config.openid_enabled?
|
||||
end
|
||||
|
||||
def openid_enabled?
|
||||
self.class.openid_enabled?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_date_per_user_prefs( s )
|
||||
|
|
@ -213,4 +222,8 @@ class ApplicationController < ActionController::Base
|
|||
logger.error("ERROR: #{message}") if type == :error
|
||||
end
|
||||
|
||||
def set_time_zone
|
||||
Time.zone = current_user.prefs.time_zone if logged_in?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ class LoginController < ApplicationController
|
|||
skip_before_filter :login_required
|
||||
before_filter :login_optional
|
||||
before_filter :get_current_user
|
||||
open_id_consumer if Tracks::Config.openid_enabled?
|
||||
open_id_consumer if openid_enabled?
|
||||
|
||||
def login
|
||||
@page_title = "TRACKS::Login"
|
||||
@openid_url = cookies[:openid_url] if Tracks::Config.openid_enabled?
|
||||
@openid_url = cookies[:openid_url] if openid_enabled?
|
||||
case request.method
|
||||
when :post
|
||||
if @user = User.authenticate(params['user_login'], params['user_password'])
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ class StatsController < ApplicationController
|
|||
@max=0
|
||||
@actions_creation_hour_array = Array.new(24) { |i| 0}
|
||||
@actions_creation_hour.each do |r|
|
||||
hour = current_user.prefs.tz.adjust(r.created_at).hour
|
||||
hour = r.created_at.hour
|
||||
@actions_creation_hour_array[hour] += 1
|
||||
end
|
||||
0.upto(23) { |i| @max = @actions_creation_hour_array[i] if @actions_creation_hour_array[i] > @max}
|
||||
|
|
@ -423,7 +423,7 @@ class StatsController < ApplicationController
|
|||
# convert to hash to be able to fill in non-existing days
|
||||
@actions_completion_hour_array = Array.new(24) { |i| 0}
|
||||
@actions_completion_hour.each do |r|
|
||||
hour = current_user.prefs.tz.adjust(r.completed_at).hour
|
||||
hour = r.completed_at.hour
|
||||
@actions_completion_hour_array[hour] += 1
|
||||
end
|
||||
0.upto(23) { |i| @max = @actions_completion_hour_array[i] if @actions_completion_hour_array[i] > @max}
|
||||
|
|
@ -446,7 +446,7 @@ class StatsController < ApplicationController
|
|||
@max=0
|
||||
@actions_creation_hour_array = Array.new(24) { |i| 0}
|
||||
@actions_creation_hour.each do |r|
|
||||
hour = current_user.prefs.tz.adjust(r.created_at).hour
|
||||
hour = r.created_at.hour
|
||||
@actions_creation_hour_array[hour] += 1
|
||||
end
|
||||
0.upto(23) { |i| @max = @actions_creation_hour_array[i] if @actions_creation_hour_array[i] > @max}
|
||||
|
|
@ -454,7 +454,7 @@ class StatsController < ApplicationController
|
|||
# convert to hash to be able to fill in non-existing days
|
||||
@actions_completion_hour_array = Array.new(24) { |i| 0}
|
||||
@actions_completion_hour.each do |r|
|
||||
hour = current_user.prefs.tz.adjust(r.completed_at).hour
|
||||
hour = r.completed_at.hour
|
||||
@actions_completion_hour_array[hour] += 1
|
||||
end
|
||||
0.upto(23) { |i| @max = @actions_completion_hour_array[i] if @actions_completion_hour_array[i] > @max}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
class UsersController < ApplicationController
|
||||
|
||||
if Tracks::Config.openid_enabled?
|
||||
if openid_enabled?
|
||||
open_id_consumer
|
||||
before_filter :begin_open_id_auth, :only => :update_auth_type
|
||||
end
|
||||
|
|
@ -153,7 +153,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def update_auth_type
|
||||
if (params[:user][:auth_type] == 'open_id') && Tracks::Config.openid_enabled?
|
||||
if (params[:user][:auth_type] == 'open_id') && openid_enabled?
|
||||
case open_id_response.status
|
||||
when OpenID::SUCCESS
|
||||
# The URL was a valid identity URL. Now we just need to send a redirect
|
||||
|
|
@ -179,7 +179,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def complete
|
||||
return unless Tracks::Config.openid_enabled?
|
||||
return unless openid_enabled?
|
||||
openid_url = session['openid_url']
|
||||
if openid_url.blank?
|
||||
notify :error, "expected an openid_url"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
module ApplicationHelper
|
||||
|
||||
def user_time
|
||||
current_user.time
|
||||
Time.zone.now
|
||||
end
|
||||
|
||||
# Replicates the link_to method but also checks request.request_uri to find
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
class Preference < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
composed_of :tz,
|
||||
:class_name => 'TimeZone',
|
||||
:mapping => %w(time_zone name)
|
||||
|
||||
def self.due_styles
|
||||
{ :due_in_n_days => 0, :due_on => 1}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Project < ActiveRecord::Base
|
||||
has_many :todos, :dependent => :delete_all, :include => :context
|
||||
has_many :notes, :dependent => :delete_all, :order => "created_at DESC"
|
||||
belongs_to :default_context, :dependent => :nullify, :class_name => "Context", :foreign_key => "default_context_id"
|
||||
belongs_to :default_context, :class_name => "Context", :foreign_key => "default_context_id"
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :name, :message => "project must have a name"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class Todo < ActiveRecord::Base
|
||||
|
||||
belongs_to :context, :order => 'name'
|
||||
belongs_to :context
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def time
|
||||
prefs.tz.adjust(Time.now.utc)
|
||||
Time.now.in_time_zone(prefs.time_zone)
|
||||
end
|
||||
|
||||
def date
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<li>Last name: <span class="highlight"><%= current_user.last_name %></span></li>
|
||||
<li>Date format: <span class="highlight"><%= prefs.date_format %></span> Your current date: <%= format_date(user_time) %></li>
|
||||
<li>Title date format: <span class="highlight"><%= prefs.title_date_format %></span> Your current title date: <%= user_time.strftime(prefs.title_date_format) %></li>
|
||||
<li>Time zone: <span class="highlight"><%= prefs.tz %></span> Your current time: <%= user_time.strftime('%I:%M %p') %></li>
|
||||
<li>Time zone: <span class="highlight"><%= prefs.time_zone %></span> Your current time: <%= user_time.strftime('%I:%M %p') %></li>
|
||||
<li>Week starts on: <span class="highlight"><%= Preference.day_number_to_name_map[prefs.week_starts] %></span></li>
|
||||
<li>Show the last <span class="highlight"><%= prefs.show_number_completed %></span> completed items</li>
|
||||
<li>Show completed projects in sidebar: <span class="highlight"><%= prefs.show_completed_projects_in_sidebar %></span></li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue