Looks good, and works save one nit that needs to be changed and a 
couple of comments below.

On 09/24/2010 10:35 AM, [email protected] wrote:
> From: Jozef Zigmund<[email protected]>
>
> ---
>   src/app/controllers/users_controller.rb |   22 ++++++++++++------
>   src/app/views/users/_form.haml          |    7 ++++++
>   src/app/views/users/_treatment.haml     |   37 
> +++++++++++++++++++++++++++++++
>   src/app/views/users/edit.haml           |   27 ++++++++++++++++------
>   4 files changed, 79 insertions(+), 14 deletions(-)
>   create mode 100644 src/app/views/users/_treatment.haml
>
> diff --git a/src/app/controllers/users_controller.rb 
> b/src/app/controllers/users_controller.rb
> index f61c6d2..20cbfdf 100644
> --- a/src/app/controllers/users_controller.rb
> +++ b/src/app/controllers/users_controller.rb
> @@ -51,19 +51,27 @@ class UsersController<  ApplicationController
>
>     def edit
>       @user = @current_user
> +    @is_admin = @current_user.permissions.collect { |p| p.role }.
> +                              find { |r| r.name == "Administrator" }
>     end
>
This is fine for now, but I'd image at some point we'd want to set this 
based on whether the user has the 'user_modify' privilege.

Checking for admin has the same effect though since that is the only 
role that does currently.

>     def update
> -    @user = @current_user # makes our views "cleaner" and more consistent
> -    if @user.update_attributes(params[:user])
> -      flash[:notice] = "User updated!"
> -      redirect_to account_url
> -    else
> -      render :action =>  :edit
> +    if params[:make_changes] || params[:save]
> +      @user = @current_user # makes our views "cleaner" and more consistent
> +      if @user.update_attributes(params[:user])
> +        flash[:notice] = "User updated!"
> +        redirect_to account_url
> +      else
> +        render :action =>  :edit
> +      end
> +    elsif  params[:reset]
> +      redirect_to :action =>  "edit", :user =>  @user
> +    elsif params[:back]
> +      redirect_to users_path
>       end
>     end
>
>     def index
>       @users = User.all
>     end
> -end
> \ No newline at end of file
> +end
> diff --git a/src/app/views/users/_form.haml b/src/app/views/users/_form.haml
> index 8311c16..de07f3a 100644
> --- a/src/app/views/users/_form.haml
> +++ b/src/app/views/users/_form.haml
> @@ -7,6 +7,13 @@
>   %fieldset
>     = form.label :password_confirmation, "Confirm password:"
>     = form.password_field :password_confirmation
> +-if @is_admin
> +  %fieldset
> +      = form.label :user_status
> +      = radio_button_tag "user_status","Active",true
> +      = label_tag "user_status", "Active"
> +      = radio_button_tag "user_status","Inactive"
> +      = label_tag "user_status", "Inactive"
This is indented too far here. Need to remove a couple spaces be pushing.

Also changing this status doesn't have any permanent effect, will this 
be added at some point?

>   %fieldset
>     = form.label :first_name
>     = form.text_field :first_name
> diff --git a/src/app/views/users/_treatment.haml 
> b/src/app/views/users/_treatment.haml
> new file mode 100644
> index 0000000..f6ab887
> --- /dev/null
> +++ b/src/app/views/users/_treatment.haml
> @@ -0,0 +1,37 @@
> +%h3 USER TREATMENT
> +- form_tag '/treatment' do
> +  = label_tag 'apply_treatment', "Apply User Treatment:"
> +  = select_tag 'user_treatment', options_for_select(["Choose Treatment"])
> +  = submit_tag 'Apply', :disabled =>  true
> +%h3 TEMPLATES
> +- form_tag '/template' do
> +  = label_tag 'template_group', "Template Group:"
> +  %br/
> +  = label_tag 'permissions', "Permissions:"
> +  = text_field_tag 'permissions_text', "General Usage"
> +  = select_tag 'template_group', options_for_select(["Choose Template 
> Group"])
These select boxes are supposed to be empty save the "choose" item correct?

> +  %br/
> +  %hr
> +  = label_tag 'role', "Role:"
> +  = text_field_tag 'role_text', "Basic Template User"
> +  (
> +  = link_to 'Remove'
> +  )
> +  %br/
> +  = radio_button_tag "role", "Basic Template User", true
> +  = label_tag "role", "Basic Template User"
> +  %br/
> +  %hr
> +  = radio_button_tag "role", "General Template User"
> +  = label_tag "role", "General Template User"
> +  %br/
> +  = radio_button_tag "role", "Advanced Template User"
> +  = label_tag "role", "Advanced Template User"
> +  %br/
> +  = radio_button_tag "role", "Custom ..."
> +  = label_tag "role", "Custom ..."
> +  %br/
> +  %hr
> +  = label_tag 'quota', "Quota:"
> +  = text_field_tag 'quota'
> +  (instances)
The fields on this form, don't seem to have an impact on the user update 
operation. Are these a placeholder as well for something else?

> diff --git a/src/app/views/users/edit.haml b/src/app/views/users/edit.haml
> index 7654866..f580482 100644
> --- a/src/app/views/users/edit.haml
> +++ b/src/app/views/users/edit.haml
> @@ -1,8 +1,21 @@
> -.dcloud_form
> -  %h2 Edit my profile.
> -  - form_for @user, :url =>  account_path do |f|
> -    = f.error_messages
> -    = render :partial =>  "form", :object =>  f
> -    = f.submit "Update", :class =>  "submit"
> +.formwindow
> +- if @is_admin
> +  %h2
> +    EDITING USER:
> +    = @user.first_name + " " + @user.last_name
> +  %h3 BASIC USER INFORMATION
> +- else
> +  %h2 Edit an Account
> +- form_for @user, :url =>  account_path, :html =>  {:id =>  "login"} do |f|
> +  = f.error_messages
> +  = render :partial =>  "form", :object =>  f
> +  - if @is_admin
> +    = f.submit "Back", :class =>  "formbutton", :name =>  "back"
> +    = f.submit "Reset", :class =>  "formbutton", :name =>  "reset"
> +    = f.submit "Save", :class =>  "formbutton", :name =>  "save"
> +  - else
> +    = f.submit "Make Changes", :class =>  "formbutton", :name =>  
> "make_changes"
>       %br/
> -    = link_to "Cancel", account_path, :class =>  'actionlink'
> +    = link_to "Cancel", account_path, :class =>  "formbuton"
> +- if @is_admin
> +  =render :partial =>'treatment'
ACK after the spacing in the haml is fixed and provided the placeholder 
stuff should be there.

   -Mo
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to