mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-27 11:16:10 +01:00
get project integrations and login controller tests running
This commit is contained in:
parent
59a4d5ede0
commit
96db48dd86
36 changed files with 179 additions and 223 deletions
|
|
@ -9,7 +9,6 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
protect_from_forgery
|
||||
|
||||
helper :application
|
||||
include LoginSystem
|
||||
helper_method :current_user, :prefs, :format_date, :markdown
|
||||
|
||||
|
|
@ -143,14 +142,6 @@ class ApplicationController < ActionController::Base
|
|||
return json_elems
|
||||
end
|
||||
|
||||
# Uses RedCloth to transform text using either Textile or Markdown Need to
|
||||
# require redcloth above RedCloth 3.0 or greater is needed to use Markdown,
|
||||
# otherwise it only handles Textile
|
||||
#
|
||||
def markdown(text)
|
||||
RedCloth.new(text).to_html
|
||||
end
|
||||
|
||||
# Here's the concept behind this "mobile content negotiation" hack: In
|
||||
# addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature
|
||||
# 'mobile' version designed to be suitablef or use from a phone or PDA. It
|
||||
|
|
@ -223,7 +214,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def redirect_back_or_home
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default home_url }
|
||||
format.html { redirect_back_or_default root_url }
|
||||
format.m { redirect_back_or_default mobile_url }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class IntegrationsController < ApplicationController
|
|||
message = Mail.new(params[:message])
|
||||
|
||||
# find user
|
||||
user = User.where("preferences.sms_email = ?", message.from).includes(:preferences).first
|
||||
user = User.where("preferences.sms_email = ?", message.from).includes(:preference).first
|
||||
if user.nil?
|
||||
render :text => "No user found", :status => 404
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -27,15 +27,13 @@ class LoginController < ApplicationController
|
|||
@username = session[:cas_user]
|
||||
@login_url = CASClient::Frameworks::Rails::Filter.login_url(self)
|
||||
end
|
||||
if openid_enabled? && using_open_id?
|
||||
login_openid
|
||||
elsif cas_enabled? && session[:cas_user]
|
||||
if cas_enabled? && session[:cas_user]
|
||||
login_cas
|
||||
else
|
||||
@page_title = "TRACKS::Login"
|
||||
cookies[:preferred_auth] = prefered_auth? unless cookies[:preferred_auth]
|
||||
case request.method
|
||||
when :post
|
||||
when 'POST'
|
||||
if @user = User.authenticate(params['user_login'], params['user_password'])
|
||||
session['user_id'] = @user.id
|
||||
# If checkbox on login page checked, we don't expire the session after 1 hour
|
||||
|
|
@ -54,7 +52,7 @@ class LoginController < ApplicationController
|
|||
@login = params['user_login']
|
||||
notify :warning, t('login.unsuccessful')
|
||||
end
|
||||
when :get
|
||||
when 'GET'
|
||||
if User.no_users_yet?
|
||||
redirect_to signup_path
|
||||
return
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def index
|
||||
@source_view = params['_source_view'] || 'project_list'
|
||||
@new_project = current_user.projects.build
|
||||
if params[:projects_and_actions]
|
||||
projects_and_actions
|
||||
else
|
||||
|
|
@ -19,15 +18,22 @@ class ProjectsController < ApplicationController
|
|||
if params[:only_active_with_no_next_actions]
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
else
|
||||
@projects = current_user.projects
|
||||
@projects = current_user.projects.all
|
||||
end
|
||||
@new_project = current_user.projects.build
|
||||
respond_to do |format|
|
||||
format.html &render_projects_html
|
||||
format.m &render_projects_mobile
|
||||
format.xml { render :xml => @projects.to_xml( :except => :user_id ) }
|
||||
format.rss &render_rss_feed
|
||||
format.atom &render_atom_feed
|
||||
format.text &render_text_feed
|
||||
format.rss do
|
||||
@feed_title = I18n.t('models.project.feed_title')
|
||||
@feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
|
||||
end
|
||||
format.atom do
|
||||
@feed_title = I18n.t('models.project.feed_title')
|
||||
@feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
|
||||
end
|
||||
format.text
|
||||
format.autocomplete &render_autocomplete
|
||||
end
|
||||
end
|
||||
|
|
@ -144,16 +150,9 @@ class ProjectsController < ApplicationController
|
|||
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
||||
return
|
||||
end
|
||||
|
||||
@project = current_user.projects.build
|
||||
params_are_invalid = true
|
||||
if (params['project'] || (params['request'] && params['request']['project']))
|
||||
@project.attributes = params['project'] || params['request']['project']
|
||||
params_are_invalid = false
|
||||
end
|
||||
@project = current_user.projects.build(params['project'])
|
||||
@go_to_project = params['go_to_project']
|
||||
@saved = @project.save
|
||||
|
||||
@project_not_done_counts = { @project.id => 0 }
|
||||
@active_projects_count = current_user.projects.active.count
|
||||
@contexts = current_user.contexts
|
||||
|
|
@ -161,9 +160,7 @@ class ProjectsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js { @down_count = current_user.projects.size }
|
||||
format.xml do
|
||||
if @project.new_record? && params_are_invalid
|
||||
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
||||
elsif @project.new_record?
|
||||
if @project.new_record?
|
||||
render_failure @project.errors.full_messages.join(', ')
|
||||
else
|
||||
head :created, :location => project_url(@project), :text => @project.id
|
||||
|
|
@ -350,33 +347,6 @@ class ProjectsController < ApplicationController
|
|||
render :action => 'project_mobile'
|
||||
end
|
||||
end
|
||||
|
||||
def render_rss_feed
|
||||
lambda do
|
||||
render_rss_feed_for @projects, :feed => feed_options,
|
||||
:title => :name,
|
||||
:item => { :description => lambda { |p| @template.summary(p) } }
|
||||
end
|
||||
end
|
||||
|
||||
def render_atom_feed
|
||||
lambda do
|
||||
render_atom_feed_for @projects, :feed => feed_options,
|
||||
:item => { :description => lambda { |p| @template.summary(p) },
|
||||
:title => :name,
|
||||
:author => lambda { |p| nil } }
|
||||
end
|
||||
end
|
||||
|
||||
def feed_options
|
||||
Project.feed_options(current_user)
|
||||
end
|
||||
|
||||
def render_text_feed
|
||||
lambda do
|
||||
render :action => 'index', :layout => false, :content_type => Mime::TEXT
|
||||
end
|
||||
end
|
||||
|
||||
def render_autocomplete
|
||||
lambda do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue