forked from railsbridge/bridge_troll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add organization show page & download subscriptions button for org le…
…aders - Move chapters table into a partial for use on org show page
- Loading branch information
1 parent
2443b77
commit 6ad1f46
Showing
12 changed files
with
173 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<table class="table table-striped table-bordered table-condensed responsive-table datatable-sorted"> | ||
<thead> | ||
<tr> | ||
<th data-default-sort="asc">Name</th> | ||
<th>Events</th> | ||
<% if current_user.try(:admin?) %> | ||
<th></th> | ||
<% end %> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% chapters.each do |chapter| %> | ||
<tr> | ||
<td><%= link_to chapter.name, chapter %></td> | ||
<td data-label="Events:"><%= chapter.events_count + chapter.external_events_count %></td> | ||
<td> | ||
<% if policy(chapter).update? %> | ||
<%= link_to 'Edit', edit_chapter_path(chapter), class: 'btn fa-before fa-edit' %> | ||
<% end %> | ||
<% if current_user.try(:admin?) && chapter.destroyable? %> | ||
<%= link_to 'Destroy', chapter, data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger' %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,5 @@ | ||
<%= content_for(:header_text, 'Listing chapters') %> | ||
<table class="table table-striped table-bordered table-condensed responsive-table datatable-sorted"> | ||
<thead> | ||
<tr> | ||
<th data-default-sort="asc">Name</th> | ||
<th>Events</th> | ||
<% if current_user.try(:admin?) %> | ||
<th></th> | ||
<% end %> | ||
</tr> | ||
</thead> | ||
<%= render 'table', chapters: @chapters %> | ||
<tbody> | ||
<% @chapters.each do |chapter| %> | ||
<tr> | ||
<td><%= link_to chapter.name, chapter %></td> | ||
<td data-label="Events:"><%= chapter.events_count + chapter.external_events_count %></td> | ||
<td> | ||
<% if policy(chapter).update? %> | ||
<%= link_to 'Edit', edit_chapter_path(chapter), class: 'btn fa-before fa-edit' %> | ||
<% end %> | ||
<% if current_user.try(:admin?) && chapter.destroyable? %> | ||
<%= link_to 'Destroy', chapter, data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger' %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= render 'shared/actions', links: crud_object_nav_links(:chapter, policy(Chapter).new? ? ['New Chapter', new_chapter_path] : nil) %> | ||
<%= render 'shared/actions', links: crud_object_nav_links(:chapter, policy(Chapter).new? ? ['New Chapter', new_chapter_path] : nil) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1><%= @organization.name %></h1> | ||
|
||
<% if @organization.leaders.present? %> | ||
<h2>Organization Leaders</h2> | ||
<i>These are people who can approve Bridge Troll postings for any <%= @organization.name %> event.</i> | ||
<ul> | ||
<% @organization.leaders.each do |leader| %> | ||
<li><%= link_to leader.full_name, user_profile_path(leader) %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<% if policy(@organization).manage_organization? %> | ||
<div class="org-leader-tools bg-info p20"> | ||
<h2>Organization Leader Tools</h2> | ||
<i>This section is only visible to admins & organization leaders.</i> | ||
<p> | ||
<%= link_to "Download subscribed user email addresses", organization_download_subscriptions_path(@organization, format: :csv), class: "btn mt10" %> | ||
</p> | ||
</div> | ||
<% end %> | ||
|
||
<h2 class="mt20">Chapters</h2> | ||
|
||
<%= render 'chapters/table', chapters: @organization.chapters %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'rails_helper' | ||
|
||
describe OrganizationsController do | ||
let(:organization) { create :organization, name: "RailsBridge" } | ||
|
||
describe "permissions" do | ||
context "a user that is not logged in" do | ||
it "can not download a subscription list" do | ||
expect( | ||
get :download_subscriptions, organization_id: organization.id | ||
).to redirect_to(new_user_session_path) | ||
end | ||
end | ||
end | ||
|
||
describe '#download_subscriptions' do | ||
context "logged in as an organization leader" do | ||
let(:organization_leader) { create :user } | ||
let(:subscriber) { create :user, email: "seven_lemurs@example.com" } | ||
|
||
before do | ||
sign_in organization_leader | ||
organization.leaders << organization_leader | ||
OrganizationSubscription.create(subscribed_organization: organization, user: subscriber) | ||
end | ||
|
||
it "should return the subscribed users" do | ||
expect( | ||
get :download_subscriptions, organization_id: organization.id, format: :csv | ||
).to be_success | ||
expect(response.headers["Content-Disposition"]).to include "railsbridge_subscribed_users" | ||
expect(response.body).to include "seven_lemurs@example.com" | ||
end | ||
end | ||
|
||
context "logged in as a regular user" do | ||
it "should redirect" do | ||
expect( | ||
get :download_subscriptions, organization_id: organization.id | ||
).to be_redirect | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters