skip getting started is not ajaxy

This commit is contained in:
danielvincent 2010-12-04 12:05:49 -08:00
parent 544ab993ac
commit 34a1a35bf1
3 changed files with 33 additions and 46 deletions

View file

@ -19,37 +19,30 @@ class UsersController < ApplicationController
def update
@user = current_user
if params[:user][:getting_started]
boolean = params[:user][:getting_started] == "true"
@user.update_attributes( :getting_started => boolean )
redirect_to root_path
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
params[:user].delete(:language) if params[:user][:language].blank?
params[:user].delete(:grammatical_gender) if params[:user][:grammatical_gender].blank?
else
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
params[:user].delete(:language) if params[:user][:language].blank?
params[:user].delete(:grammatical_gender) if params[:user][:grammatical_gender].blank?
if params[:user][:password] && params[:user][:password_confirmation]
if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
flash[:notice] = I18n.t 'users.update.password_changed'
else
flash[:error] = I18n.t 'users.update.password_not_changed'
end
elsif params[:user][:language]
if @user.update_attributes(:language => params[:user][:language])
if params[:user][:grammatical_gender]
if @user.update_attributes(:grammatical_gender => params[:user][:grammatical_gender])
flash[:notice] = I18n.t 'users.update.language_changed'
else
flash[:error] = I18n.t 'users.update.language_not_changed'
end
else
if params[:user][:password] && params[:user][:password_confirmation]
if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
flash[:notice] = I18n.t 'users.update.password_changed'
else
flash[:error] = I18n.t 'users.update.password_not_changed'
end
elsif params[:user][:language]
if @user.update_attributes(:language => params[:user][:language])
if params[:user][:grammatical_gender]
if @user.update_attributes(:grammatical_gender => params[:user][:grammatical_gender])
flash[:notice] = I18n.t 'users.update.language_changed'
else
flash[:error] = I18n.t 'users.update.language_not_changed'
end
else
flash[:error] = I18n.t 'users.update.language_not_changed'
flash[:notice] = I18n.t 'users.update.language_changed'
end
else
flash[:error] = I18n.t 'users.update.language_not_changed'
end
redirect_to edit_user_path(@user)
@ -96,6 +89,12 @@ class UsersController < ApplicationController
render "users/getting_started"
end
def getting_started_completed
user = current_user
user.update_attributes( :getting_started => false )
redirect_to root_path
end
def export
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
send_data exporter.execute(current_user), :filename => "#{current_user.username}_diaspora_data.xml", :type => :xml

View file

@ -18,19 +18,6 @@
});
});
- if current_user.getting_started == true
:javascript
$("#getting_started_skip").live("click", function(evt){
evt.preventDefault();
$.ajax({
type: "PUT",
url: "/users/#{current_user.id}",
data: {"user":{"getting_started":'false'}},
success: function() { window.location = "#{root_path}"}
})
});
.span-8.append-1.last
%h1{:style => "text-align:right;"}
= t('.welcome')
@ -71,4 +58,4 @@
- if @user.getting_started
.bottom_notification
= link_to "#{t('.skip')} →", '#', :id => "getting_started_skip"
= link_to "#{t('.skip')} →", getting_started_completed_path

View file

@ -24,12 +24,13 @@ Diaspora::Application.routes.draw do
:password => "devise/passwords",
:invitations => "invitations"}
# added public route to user
match 'public/:username', :to => 'users#public'
match 'getting_started', :to => 'users#getting_started', :as => 'getting_started'
match 'users/export', :to => 'users#export'
match 'users/export_photos',:to => 'users#export_photos'
match 'login', :to => 'users#sign_up'
resources :users, :except => [:create, :new, :show]
match 'public/:username', :to => 'users#public'
match 'getting_started', :to => 'users#getting_started', :as => 'getting_started'
match 'getting_started_completed', :to => 'users#getting_started_completed'
match 'users/export', :to => 'users#export'
match 'users/export_photos', :to => 'users#export_photos'
match 'login', :to => 'users#sign_up'
resources :users, :except => [:create, :new, :show]
match 'aspects/move_contact', :to => 'aspects#move_contact', :as => 'move_contact'
match 'aspects/add_to_aspect', :to => 'aspects#add_to_aspect', :as => 'add_to_aspect'