Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* My profile page

* code review changes

* fix failing cucumber test

* Code Review Changes

* Further code review changes
  • Loading branch information
hin101 authored and patmbolger committed Feb 8, 2017
1 parent ed7ab29 commit ec4edb1
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 14 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/my_profile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.my-profile-info {
left: 50%;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
}
21 changes: 21 additions & 0 deletions app/assets/stylesheets/user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,25 @@
// You can use Sass (SCSS) here: http://sass-lang.com/
.has-error {
color: red;
}

.edit-profile-btn {
background-color: #0c7ba1;
border-radius: 8px;
color: #fff;
font-weight: bold;
height: 50px;
padding: 12px 16px;
width: 250px;
margin-top: 20px;
&:hover {
color: #fff;
}
}

.my-profile-header {
font-size: 48px;
color: #0c7ba1;
font-weight: 700;
padding-bottom: 20px;
}
5 changes: 5 additions & 0 deletions app/controllers/agency_people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ def my_js_as_jd
end
end

def my_profile
@agency_person = AgencyPerson.find(params[:id])
authorize @agency_person
end

private

def agency_person_params
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/company_people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def home
@admin_aa, @admin_ca = determine_if_admin(pets_user)
end

def my_profile; end

private

def load_and_authorize_company_person
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/job_seekers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def download_resume
end
end

def my_profile
@jobseeker = JobSeeker.find(params[:id])
authorize @jobseeker
@current_resume = @jobseeker.resumes[0]
end

private

def address_is_empty?(jobseeker_params)
Expand Down
4 changes: 4 additions & 0 deletions app/policies/agency_person_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ def edit_profile?
update_profile?
end

def my_profile?
user.is_agency_person? record.agency
end

end
5 changes: 5 additions & 0 deletions app/policies/company_person_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def home?
def update_profile?
user.is_company_person? record.company and user == record
end

def my_profile?
(agency_admin? user and agency_related_to_company?(user.agency, record.company)) or
user.is_company_person? record.company
end

def edit_profile?
update_profile?
Expand Down
4 changes: 4 additions & 0 deletions app/policies/job_seeker_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def edit?
update?
end

def my_profile?
user == record
end

def home?
# account owner
user == record
Expand Down
18 changes: 18 additions & 0 deletions app/views/agency_people/my_profile.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.row
.col-md-4.my-profile-info
%h1.my-profile-header Your Profile
%table.table
%tbody
%tr
%td
%strong Full Name
%td= @agency_person.first_name + ' ' + @agency_person.last_name
%tr
%td
%strong Email
%td= @agency_person.email
%tr
%td
%strong Phone
%td= @agency_person.phone
= link_to "Edit", edit_profile_agency_person_path(@agency_person), class: "btn btn-lg edit-profile-btn"
26 changes: 26 additions & 0 deletions app/views/company_people/my_profile.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.row
.col-md-4.my-profile-info
%h1.my-profile-header Your Profile
%table.table
%tbody
%tr
%td
%strong Title
%td= @company_person.title
%tr
%td
%strong Full Name
%td= @company_person.first_name + ' ' + @company_person.last_name
%tr
%td
%strong Email
%td= @company_person.email
%tr
%td
%strong Phone
%td= @company_person.phone
%tr
%td
%strong Address
%td= @company_person.address.street + ', ' + @company_person.address.city + ', ' + @company_person.address.zipcode
= link_to "Edit", edit_profile_company_person_path(@company_person), class: "btn btn-lg edit-profile-btn"
9 changes: 6 additions & 3 deletions app/views/job_seekers/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
%div{class:'row'}
%div{class:'col-sm-8 col-sm-offset-2'}
%h1 Edit JobSeeker Registration
.row
.col-sm-8.col-sm-offset-2
- if pets_user.is_a?(AgencyPerson) || pets_user.is_a?(CompanyPerson)
%h1 Edit JobSeeker Registration
- else
%h1 Update Your Profile
%br
= render partial: 'form'
%br
40 changes: 40 additions & 0 deletions app/views/job_seekers/my_profile.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.row
.col-md-8.my-profile-info
%h1.my-profile-header Your Profile
%table.table
%tbody
%tr
%td
%strong Full Name
%td= @jobseeker.first_name + ' ' + @jobseeker.last_name
%tr
%td
%strong Email
%td= @jobseeker.email
%tr
%td
%strong Phone
%td= @jobseeker.phone
%tr
%td
%strong Year Of Birth
%td= @jobseeker.year_of_birth
%tr
%td
%strong Resume
%td
- if @current_resume
Your current resume is #{@current_resume.file_name} and was uploaded on
%span.utc_to_local_time= @current_resume.updated_at
- else
You have no current resume
- if @jobseeker.address.present?
%tr
%td
%strong Address
%td= @jobseeker.address.street + ', ' + @jobseeker.address.city + ', ' + @jobseeker.address.zipcode
%tr
%td
%strong Status
%td= @jobseeker.status.short_description
= link_to "Edit", edit_job_seeker_path(@jobseeker), class: "btn btn-lg edit-profile-btn"
6 changes: 3 additions & 3 deletions app/views/layouts/_menu.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
%ul.dropdown-menu{ 'aria-labelledby' => 'dd_menu' }
%li
- if current_user.actable_type == 'JobSeeker'
= link_to 'Edit Profile', edit_job_seeker_path(current_user.actable_id)
= link_to 'My Profile', my_profile_job_seeker_path(current_user.actable_id)
- elsif current_user.actable_type == 'CompanyPerson'
= link_to 'Edit Profile', edit_profile_company_person_path(current_user.actable_id)
= link_to 'My Profile', my_profile_company_person_path(current_user.actable_id)
- elsif current_user.actable_type == 'AgencyPerson'
= link_to 'Edit Profile', edit_profile_agency_person_path(current_user.actable_id)
= link_to 'My Profile', my_profile_agency_person_path(current_user.actable_id)
- else
= link_to 'Edit Profile', edit_user_registration_path(current_user)
%li
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
member do
get :home
get :edit_profile, to: 'agency_people#edit_profile'
get :my_profile, to: :my_profile
patch :update_profile, to: 'agency_people#update_profile'
patch 'assign_job_seeker/:job_seeker_id/:agency_role',
to: 'agency_people#assign_job_seeker',
Expand Down Expand Up @@ -87,6 +88,7 @@
member do
get 'edit_profile', as: :edit_profile
patch 'update_profile', as: :update_profile
get 'my_profile', as: :my_profile
get 'home', as: :home
end
end
Expand Down Expand Up @@ -157,6 +159,7 @@
get 'home', on: :member, as: :home
get 'match_jobs', on: :member, as: :match_jobs
get 'list_match_jobs', on: :member, as: :list_match_jobs
get 'my_profile', on: :member, as: :my_profile
end

get 'job_seekers/:id/preview_info' => 'job_seekers#preview_info'
Expand Down
9 changes: 6 additions & 3 deletions features/agency_person.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Scenario: Case Manager actions
And I should be on the Agency Person 'jane@metplus.org' Home page
And I should see "Your Job Seekers (as case manager)"
And I should not see "Job Seekers without a Job Developer"
Then I press "edit-profile"
And I click the "Hello, Jane" link
And I click the "My Profile" link
Then I click the "Edit" link
And I should see "Jane"
And I fill in "First Name" with "Janey"

Expand All @@ -62,8 +64,9 @@ Scenario: Case Manager actions
When I open the email
And I follow "Confirm my account" in the email
Then I should see "Your email address has been successfully confirmed."
When I click the "Janey" link
And I click the "Edit Profile" link
When I click the "Hello, Janey" link
And I click the "My Profile" link
And I click the "Edit" link
Then I should see "janey@metplus.org" in the email field

# See tasks on home page
Expand Down
3 changes: 2 additions & 1 deletion features/job_application_by_jd.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ Background: data is added to database
Given I am on the home page
And I login as "john.seeker@places.com" with password "password"
Then I click the "Hello, John" link
Then I click the "Edit Profile" link
And I click the "My Profile" link
Then I click the "Edit" link
Then I update my profile to not permit job developer to apply a job for me

Then I am in Job Developer's browser
Expand Down
10 changes: 6 additions & 4 deletions features/job_seeker.feature
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,17 @@ Scenario: edit Js profile
Given I am on the home page
And I login as "mike.smith@gmail.com" with password "password"
Then I should see "Signed in successfully"
When I click the "Mike" link
And I click the "Edit Profile" link
When I click the "Hello, Mike" link
And I click the "My Profile" link
And I click the "Edit" link
And I fill in "First Name" with "Mikes"
Then I select "Employed Not Looking" in select list "Status"
Then I click the "Update Job seeker" button
Then I should see "Jobseeker was updated successfully."
# edit profile with address fields missing
Then I click the "Mikes" link
And I click the "Edit Profile" link
Then I click the "Hello, Mike" link
And I click the "My Profile" link
And I click the "Edit" link
And I fill in "City" with ""
Then I click the "Update Job seeker" button
Then I should see "Address city can't be blank"
Expand Down

0 comments on commit ec4edb1

Please sign in to comment.