Skip to content

Commit

Permalink
Extra information on group detail (#171)
Browse files Browse the repository at this point in the history
* Show email of group admin on group detail

* Show users join date to group on group detail
  • Loading branch information
walbertus authored and giosakti committed Sep 17, 2019
1 parent 633abba commit ac5ab33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Show email of group admin on group detail
- Show users join date to group on group detail

## [1.1.1] - 2019-09-02
### Changed
Expand Down
1 change: 1 addition & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def show
name,
email,
active,
group_associations.created_at AS join_date,
group_associations.expiration_date AS group_expiration_date
}).
joins('LEFT OUTER JOIN group_associations ON users.id = group_associations.user_id').
Expand Down
11 changes: 8 additions & 3 deletions app/views/groups/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
- @group.group_admins.each do |admin|
.row
.col
= "#{admin.user.try(:name)}"
= "#{admin.user.try(:name)}"
.col
= "#{admin.user.try(:email)}"
.col
- if (current_user.admin?)
= link_to "Remove?", [@group, admin], method: :delete, data: {confirm: "Are you sure to remove #{admin.user.try(:name)} ?"}
- if (current_user.admin?)
.row
.col
.col-8
= text_field_tag "user_id", "", id: "assign_admin_user_id", class: "form-control"
.col
= submit_tag "Assign admin", class: "form-control btn btn-md btn-primary", disabled: true
.row
.col
.col-8
= check_box_tag "assign_admin_include_inactive_user", "true", false
= " Include Inactive User"
.col
Expand All @@ -43,6 +45,7 @@
tr
th User Details
th Email Address
th Join Date
th Expiration Date
th
tbody
Expand All @@ -55,6 +58,8 @@
= link_to "#{user.name} (inactive)", user_path(user)
td
= "#{user.email}"
td
= "#{user.join_date.strftime("%v")}"
td
= "#{user.group_expiration_date}"
td
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/groups_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@
sign_in admin
user = create(:user)
group = create(:group)
create(:group_association, group_id: group.id, user_id: user.id, expiration_date: '2020-01-01')
group_association = create(:group_association, group_id: group.id, user_id: user.id, expiration_date: '2020-01-01')
get :show, params: { id: group.id }
expect(assigns(:group_users).first.to_json).to eq(
{
id: user.id,
email: user.email,
name: user.name,
active: user.active,
group_expiration_date: '2020-01-01'
join_date: group_association.created_at,
group_expiration_date: group_association.expiration_date,
}.to_json
)
end
Expand Down

0 comments on commit ac5ab33

Please sign in to comment.