summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-06-17 01:27:55 -0700
committerelijah <elijah@riseup.net>2013-07-04 04:00:47 -0700
commite58fd0550b4a29fac9d52dc8a78d04333ccc8c06 (patch)
tree6267b104a0578645aa3a2f6a88cf2211a47d3d0d
parentd00fe5bded29ad816bb70caa31414f86c69aaa53 (diff)
new ui - initial user changes
-rw-r--r--users/app/controllers/account_settings_controller.rb0
-rw-r--r--users/app/controllers/email_settings_controller.rb0
-rw-r--r--users/app/controllers/overviews_controller.rb9
-rw-r--r--users/app/controllers/users_base_controller.rb18
-rw-r--r--users/app/helpers/users_helper.rb2
-rw-r--r--users/app/views/_login_or_signup.html.haml25
-rw-r--r--users/app/views/emails/edit.html.haml5
-rw-r--r--users/app/views/overviews/show.html.haml15
-rw-r--r--users/app/views/sessions/_new.html.haml7
-rw-r--r--users/app/views/sessions/new.html.haml2
-rw-r--r--users/app/views/users/_login_field.html.haml2
-rw-r--r--users/app/views/users/_new.html.haml7
-rw-r--r--users/app/views/users/_password_fields.html.haml4
-rw-r--r--users/app/views/users/edit.html.haml20
-rw-r--r--users/app/views/users/new.html.haml5
-rw-r--r--users/config/locales/en.yml17
-rw-r--r--users/config/routes.rb3
17 files changed, 110 insertions, 31 deletions
diff --git a/users/app/controllers/account_settings_controller.rb b/users/app/controllers/account_settings_controller.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/users/app/controllers/account_settings_controller.rb
diff --git a/users/app/controllers/email_settings_controller.rb b/users/app/controllers/email_settings_controller.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/users/app/controllers/email_settings_controller.rb
diff --git a/users/app/controllers/overviews_controller.rb b/users/app/controllers/overviews_controller.rb
new file mode 100644
index 0000000..52ce267
--- /dev/null
+++ b/users/app/controllers/overviews_controller.rb
@@ -0,0 +1,9 @@
+class OverviewsController < UsersBaseController
+
+ before_filter :authorize
+ before_filter :fetch_user
+
+ def show
+ end
+
+end
diff --git a/users/app/controllers/users_base_controller.rb b/users/app/controllers/users_base_controller.rb
new file mode 100644
index 0000000..dc2fa16
--- /dev/null
+++ b/users/app/controllers/users_base_controller.rb
@@ -0,0 +1,18 @@
+#
+# common base class for all user related controllers
+#
+
+class UsersBaseController < ApplicationController
+
+ protected
+
+ def fetch_user
+ @user = User.find_by_param(params[:user_id] || params[:id])
+ if !@user && admin?
+ redirect_to users_url, :alert => t(:no_such_thing, :thing => 'user')
+ elsif !admin? && @user != current_user
+ access_denied
+ end
+ end
+
+end
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index 9feae62..559b3f7 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -24,7 +24,7 @@ module UsersHelper
end
def user_form_html_classes(options)
- classes = %W/form-horizontal user form/
+ classes = %W/user form/
classes << options[:legend]
classes << (@user.new_record? ? 'new' : 'edit')
classes.compact
diff --git a/users/app/views/_login_or_signup.html.haml b/users/app/views/_login_or_signup.html.haml
new file mode 100644
index 0000000..b353526
--- /dev/null
+++ b/users/app/views/_login_or_signup.html.haml
@@ -0,0 +1,25 @@
+//
+// displays a little widget to login or sign up
+//
+
+%ul.nav.nav-tabs
+ %li.active
+ %a{:href => ''}= t(:login)
+ %li
+ = link_to t(:signup), new_user_path
+
+= render 'sessions/new'
+
+//
+// this is nice, but it doesn't work because both forms have the same names for fields.
+//
+// %ul.nav.nav-tabs
+// %li.active
+// %a{:href => '#login', 'data-toggle' => 'tab'}= t(:login)
+// %li
+// %a{:href => '#signup', 'data-toggle' => 'tab'}= t(:signup)
+// .tab-content
+// #login.tab-pane.active
+// = render 'sessions/new'
+// #signup.tab-pane
+// = render 'users/new'
diff --git a/users/app/views/emails/edit.html.haml b/users/app/views/emails/edit.html.haml
new file mode 100644
index 0000000..b44b569
--- /dev/null
+++ b/users/app/views/emails/edit.html.haml
@@ -0,0 +1,5 @@
+
+
+= user_form_with 'public_key_field', :legend => :public_key
+= user_form_with 'email_forward_field', :legend => :forward_email
+= user_form_with 'email_aliases', :legend => :add_email_alias
diff --git a/users/app/views/overviews/show.html.haml b/users/app/views/overviews/show.html.haml
new file mode 100644
index 0000000..eda9899
--- /dev/null
+++ b/users/app/views/overviews/show.html.haml
@@ -0,0 +1,15 @@
+%p
+ Username:
+ = @user.login
+
+%p
+ User since:
+ = @user.created_at
+
+%p
+ Last update:
+ = @user.updated_at
+
+%p
+ Quota:
+ N/A \ No newline at end of file
diff --git a/users/app/views/sessions/_new.html.haml b/users/app/views/sessions/_new.html.haml
new file mode 100644
index 0000000..640fec5
--- /dev/null
+++ b/users/app/views/sessions/_new.html.haml
@@ -0,0 +1,7 @@
+- @session ||= Session.new
+= simple_form_for @session, :validate => true, :html => { :id => :new_session, :class => '' } do |f|
+ = f.input :login, :required => false, :label => t(:username), :input_html => { :id => :srp_username }
+ = f.input :password, :required => false, :input_html => { :id => :srp_password }
+ .form-actions
+ = f.button :submit, :value => t(:login), :class => 'btn-primary'
+ // = f.button :submit, :value => t(:login), :class => 'btn-primary' \ No newline at end of file
diff --git a/users/app/views/sessions/new.html.haml b/users/app/views/sessions/new.html.haml
index 6743407..960919a 100644
--- a/users/app/views/sessions/new.html.haml
+++ b/users/app/views/sessions/new.html.haml
@@ -6,4 +6,4 @@
= f.input :login, :input_html => { :id => :srp_username }
= f.input :password, :required => true, :input_html => { :id => :srp_password }
= f.button :submit, :value => t(:login), :class => 'btn-primary'
- = link_to t(:cancel), root_url, :class => :btn \ No newline at end of file
+ = link_to t(:cancel), root_url, :class => :btn
diff --git a/users/app/views/users/_login_field.html.haml b/users/app/views/users/_login_field.html.haml
index 8ab36c3..e58c36f 100644
--- a/users/app/views/users/_login_field.html.haml
+++ b/users/app/views/users/_login_field.html.haml
@@ -1 +1 @@
-= f.input :login, :input_html => { :id => :srp_username }
+= f.input :login, :label => t(:username), :required => false, :input_html => { :id => :srp_username }
diff --git a/users/app/views/users/_new.html.haml b/users/app/views/users/_new.html.haml
new file mode 100644
index 0000000..3d0f2ac
--- /dev/null
+++ b/users/app/views/users/_new.html.haml
@@ -0,0 +1,7 @@
+- @user ||= User.new
+= user_form do |f|
+ = render :partial => 'users/login_field', :locals => {:f => f}
+ = render :partial => 'users/password_fields', :locals => {:f => f}
+ .form-actions
+ = f.button :submit, :value => t(:signup), :class => 'btn-primary'
+ = link_to t(:cancel), root_url, :class => :btn
diff --git a/users/app/views/users/_password_fields.html.haml b/users/app/views/users/_password_fields.html.haml
index 47b7b07..7b3358d 100644
--- a/users/app/views/users/_password_fields.html.haml
+++ b/users/app/views/users/_password_fields.html.haml
@@ -1,2 +1,2 @@
-= f.input :password, :required => true, :validate => true, :input_html => { :id => :srp_password }
-= f.input :password_confirmation, :required => true, :hint => local_assigns[:password_confirmation_hint], :input_html => { :id => :srp_password_confirmation }
+= f.input :password, :required => false, :validate => true, :input_html => { :id => :srp_password }
+= f.input :password_confirmation, :required => false, :hint => local_assigns[:password_confirmation_hint], :input_html => { :id => :srp_password_confirmation }
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 97bd48d..4e70d69 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -1,17 +1,3 @@
-.span8.offset2
- %h2=t :settings
- - tabs = []
- - content_for :account do
- = user_form_with 'login_and_password_fields', :legend => :update_login_and_password if @user == current_user
- = render 'cancel_account'
- - tabs << :account
- - if @user == current_user
- - content_for :email do
- %legend=t :email_address
- =t :associated_email
- = render @user.email_address, :as => :span
- = user_form_with 'public_key_field', :legend => :public_key
- = user_form_with 'email_forward_field', :legend => :forward_email
- = user_form_with 'email_aliases', :legend => :add_email_alias
- - tabs << :email
- = render 'tabs/tabs', :tabs => tabs
+= user_form_with 'login_and_password_fields', :legend => :update_login_and_password if @user == current_user
+= render 'cancel_account'
+
diff --git a/users/app/views/users/new.html.haml b/users/app/views/users/new.html.haml
index 80482b2..7d29de2 100644
--- a/users/app/views/users/new.html.haml
+++ b/users/app/views/users/new.html.haml
@@ -5,8 +5,7 @@
%legend= t(:signup_message)
= render :partial => 'login_field', :locals => {:f => f}
= render :partial => 'password_fields', :locals => {:f => f}
- .pull-right
- = f.button :submit, :class => 'btn-primary'
+ .form-actions
+ = f.button :submit, :value => t(:signup), :class => 'btn-primary'
= link_to t(:cancel), root_url, :class => :btn
- .clearfix
diff --git a/users/config/locales/en.yml b/users/config/locales/en.yml
index 32d183b..3c42b55 100644
--- a/users/config/locales/en.yml
+++ b/users/config/locales/en.yml
@@ -1,9 +1,14 @@
en:
- none: "None."
- signup: "Sign up"
+ email_settings: "Email Settings"
+ account_settings: "Account Settings"
+ logout: "Logout"
+ none: "None"
+ signup: "Sign Up"
signup_message: "Please create an account."
cancel: "Cancel"
- login: "Login"
+ login: "Log In"
+ username: "Username"
+ password: "Password"
login_message: "Please login with your account."
invalid_user_pass: "Not a valid username/password combination"
all_strategies_failed: "Could not understand your login attempt. Please first send your login and a SRP ephemeral value A and then send the client_auth in the same session (using cookies)."
@@ -20,7 +25,7 @@ en:
user_updated_successfully: "Settings have been updated successfully."
user_created_successfully: "Successfully created your account."
email_alias_destroyed_successfully: "Successfully removed the alias '%{alias}'."
- use_ascii_key: "Use ASCII-armored PGP key"
+ use_ascii_key: "Use ASCII-armored OpenPGP key"
can_retype_old_password: "Retype your old password if you would like to keep that"
associated_email: "The associated email address is"
cookie_disabled_warning: "You have cookies disabled. You will not be able to login until you enable cookies."
@@ -28,7 +33,7 @@ en:
activemodel:
models:
- user:
+ user:
one: User
other: "%{count} Users"
simple_form:
@@ -42,4 +47,4 @@ en:
placeholders:
user:
email_forward: "my_other_email@domain.net"
-
+
diff --git a/users/config/routes.rb b/users/config/routes.rb
index 9a9a40e..d07cda9 100644
--- a/users/config/routes.rb
+++ b/users/config/routes.rb
@@ -14,6 +14,9 @@ Rails.application.routes.draw do
get "signup" => "users#new", :as => "signup"
resources :users do
+ resource :overview, :only => [:show]
+ resource :email_settings, :only => [:edit, :update]
+ resource :account_settings, :only => [:edit, :update]
resources :email_aliases, :only => [:destroy], :id => /.*/
end