From 9dadc61cae2c4c01a97880e89ca86a0e760fc8d1 Mon Sep 17 00:00:00 2001 From: hukl Date: Wed, 7 Oct 2009 21:03:28 +0200 Subject: implemented complete restful user management interface including functional tests. this enables basic user operation. note that only admins are allowed to create, edit, destroy other users --- app/views/users/_admin_user_item.html.erb | 12 ++++++++++++ app/views/users/_user_item.html.erb | 4 ++++ app/views/users/create.html.erb | 2 -- app/views/users/destroy.html.erb | 2 -- app/views/users/edit.html.erb | 32 +++++++++++++++++++++++++++++-- app/views/users/index.html.erb | 15 ++++++++------- app/views/users/new.html.erb | 32 +++++++++++++++++++++++++++++-- app/views/users/show.html.erb | 22 +++++++++++++++++++-- app/views/users/update.html.erb | 2 -- 9 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 app/views/users/_admin_user_item.html.erb create mode 100644 app/views/users/_user_item.html.erb delete mode 100644 app/views/users/create.html.erb delete mode 100644 app/views/users/destroy.html.erb delete mode 100644 app/views/users/update.html.erb (limited to 'app/views') diff --git a/app/views/users/_admin_user_item.html.erb b/app/views/users/_admin_user_item.html.erb new file mode 100644 index 0000000..d882dc4 --- /dev/null +++ b/app/views/users/_admin_user_item.html.erb @@ -0,0 +1,12 @@ + + <%= admin_user_item.login %> + + <%= link_to "Show", user_path(admin_user_item) %> + <%= link_to( + "Destroy", + user_path(admin_user_item), + :method => "delete", + :confirm => "Are you sure to delete user: #{admin_user_item.login}?" + ) %> + + \ No newline at end of file diff --git a/app/views/users/_user_item.html.erb b/app/views/users/_user_item.html.erb new file mode 100644 index 0000000..c3389ba --- /dev/null +++ b/app/views/users/_user_item.html.erb @@ -0,0 +1,4 @@ + + <%= user_item.login %> + + \ No newline at end of file diff --git a/app/views/users/create.html.erb b/app/views/users/create.html.erb deleted file mode 100644 index 48ea02e..0000000 --- a/app/views/users/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Users#create

-

Find me in app/views/users/create.html.erb

diff --git a/app/views/users/destroy.html.erb b/app/views/users/destroy.html.erb deleted file mode 100644 index de4bd26..0000000 --- a/app/views/users/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Users#destroy

-

Find me in app/views/users/destroy.html.erb

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 1881fbd..5b73242 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,2 +1,30 @@ -

Users#edit

-

Find me in app/views/users/edit.html.erb

+

Edit existing user

+ +<% form_for @user do |f| %> + + + + + + + + + + + + + + + + + + + + + + + + + +
Login<%= f.text_field :login %>
E-Mail<%= f.text_field :email %>
Password<%= f.text_field :password %>
Confirm<%= f.text_field :password_confirmation %>
Admin?<%= f.check_box :admin %>
<%= f.submit "Create" %>
+<% end %> \ No newline at end of file diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index f0b5b28..8526d84 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,12 +1,13 @@

Users

- +
- <% @users.each do |user| %> - - - - <% end %> -
login
<%= user.login %>
\ No newline at end of file + <%= user_list_by_admin_status %> + + + +<% content_for :subnavigation do %> + <%= link_to "create", new_user_path %> +<% end %> \ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index c21a1ad..0629641 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,2 +1,30 @@ -

Users#new

-

Find me in app/views/users/new.html.erb

+

Create new user

+ +<% form_for @user do |f| %> + + + + + + + + + + + + + + + + + + + + + + + + + +
Login<%= f.text_field :login %>
E-Mail<%= f.text_field :email %>
Password<%= f.text_field :password %>
Confirm<%= f.text_field :password_confirmation %>
Admin?<%= f.check_box :admin %>
<%= f.submit "Create" %>
+<% end %> \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e5fa3ad..3055d24 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,2 +1,20 @@ -

Users#show

-

Find me in app/views/users/show.html.erb

+

User: <%= @user.login %>

+ + + + + + + + + + + + + + +
Login<%= @user.login %>
E-Mail<%= @user.email %>
Admin?<%= @user.admin ? "yes" : "no" %>
+ +<% content_for :subnavigation do %> + <%= link_to 'Edit', edit_user_path(@user) %> +<% end %> diff --git a/app/views/users/update.html.erb b/app/views/users/update.html.erb deleted file mode 100644 index cabbde1..0000000 --- a/app/views/users/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Users#update

-

Find me in app/views/users/update.html.erb

-- cgit v1.3