Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
f.inputs "Members" do
f.has_many :members do |m|
m.input :organization, collection: Organization.order(id: :asc).pluck(:name, :id)
m.input :active
m.input :manager
end
end
Expand All @@ -59,6 +60,9 @@
panel "Memberships" do
table_for user.members do
column :organization
column :active do |member|
"✔" if member.active
end
column :manager do |member|
"✔" if member.manager
end
Expand Down
8 changes: 0 additions & 8 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,7 @@ html {
overflow-x: inherit;
}

table.users {
padding: 10px;
}

@media screen {

html {
min-height: 100%;
position: relative;
Expand Down Expand Up @@ -280,18 +275,15 @@ table.users {
}

@media print {

body {
padding-top: 0px;
}

.table {
border-collapse: collapse;
}

}


.error {
color: red;
}
Expand Down
23 changes: 5 additions & 18 deletions app/assets/stylesheets/application/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@
}
}

.landing-page, .login-page, .pages, .unlocks-page, .confirmations-page, .passwords-page {
.footer {
position: absolute;
bottom: 0;
left: 0;
}
.footer {
position: absolute;
bottom: 0;
left: 0;
}

.language-selector {
Expand All @@ -65,23 +63,12 @@
border: 1px solid white;
padding: 4px 8px;
}

&:hover {
background-color: transparent;
}
}

&.open > a.btn-default.dropdown-toggle {
& {
background-color: transparent;
color: white;
border-color: #ddd;
}

&:hover {
background-color: transparent;
color: white;
border-color: #ddd;
border: 1px solid white;
}
}
}
20 changes: 0 additions & 20 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
class OrganizationsController < ApplicationController
before_action :load_resource, only: [:show, :edit, :update, :set_current]

def new
@organization = Organization.new

authorize @organization
end

def index
@organizations = Organization.all.page(params[:page]).per(25)
end
Expand All @@ -20,18 +14,6 @@ def show
per(10)
end

def create
@organization = Organization.new(organization_params)

authorize @organization

if @organization.save
redirect_to @organization
else
render action: :new, status: :unprocessable_entity
end
end

def update
if @organization.update(organization_params)
redirect_to @organization
Expand All @@ -40,8 +22,6 @@ def update
end
end

# POST /organizations/:organization_id/set_current
#
def set_current
if current_user
session[:current_organization_id] = @organization.id
Expand Down
4 changes: 0 additions & 4 deletions app/policies/organization_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ def index?
true
end

def create?
user&.superadmin?
end

def update?
user&.superadmin? || user&.admins?(organization)
end
Expand Down
67 changes: 29 additions & 38 deletions app/views/organizations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,32 @@
<%= Organization.model_name.human(count: :many) %>
</h1>

<ul class="nav navbar-nav pull-right">
<% if superadmin? %>
<li>
<%= link_to new_organization_path do %>
<%= glyph :plus %>
<%= t 'global.add_new' %>
<% end %>
</li>
<% end %>
</ul>

<table class="table table-hover table-condensed">
<thead>
<tr>
<th><%= Organization.model_name.human(count: :one) %></th>
<th><%= t '.member_count' %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @organizations.each do |org| %>
<tr>
<td><%= link_to org.name, org %></td>
<td><%= org.users.count %></td>
<td>
<% if current_user&.admins?(org) %>
<%= link_to edit_organization_path(org), class: 'action' do %>
<%= glyph :pencil %>
<%= t 'global.edit' %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>

<%= paginate @organizations %>
<div class="panel panel-default table-responsive">
<div class="panel-body">
<table class="table table-hover table-condensed panel">
<thead>
<tr>
<th></th>
<th><%= t '.city' %></th>
<th><%= t '.neighborhood' %></th>
<th><%= t '.web' %></th>
<th><%= t '.member_count' %></th>
</tr>
</thead>
<tbody>
<% @organizations.each do |org| %>
<tr>
<td><%= link_to(org.name, org) %></td>
<td><%= org.city %></td>
<td><%= org.neighborhood %></td>
<td><%= link_to(org.web, org.web) if org.web.present? %></td>
<td><%= org.members.count %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="paginate-align">
<%= paginate @organizations %>
</div>
</div>
</div>
4 changes: 0 additions & 4 deletions app/views/organizations/new.html.erb

This file was deleted.

8 changes: 0 additions & 8 deletions app/views/organizations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@
</div>
<div class="col-sm-5">
<ul class="nav nav-pills pull-right">
<% if superadmin? %>
<li>
<%= link_to organizations_path do %>
<%= glyph :hand_left %>
<%= t 'global.back' %>
<% end %>
</li>
<% end %>
<% if admin? %>
<li>
<%= link_to edit_organization_path(@organization) do %>
Expand Down
14 changes: 4 additions & 10 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1><%= t(".members") %></h1>
<h1>
<%= link_to current_organization.name, current_organization %>
<%= t(".members") %>
</h1>
</div>
</div>
</div>
Expand All @@ -22,15 +25,6 @@
</div>

<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h2>
<%= link_to current_organization.name,
organization_path(current_organization) %>
</h2>
</div>
</div>

<div class="row to-member-cards">
<%= render partial: 'member_card', collection: @member_view_models, as: :member %>
</div>
Expand Down
13 changes: 6 additions & 7 deletions app/views/users/manage.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1><%= t(".members") %></h1>
<h1>
<%= link_to current_organization.name, current_organization %>
<%= t("users.index.members") %>
</h1>
</div>
</div>
</div>
Expand Down Expand Up @@ -30,17 +33,13 @@
</div>
</div>
</div>
<br>

<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h2>
<%= link_to current_organization.name,
organization_path(current_organization) %>
</h2>

<div class="table-responsive">
<table class="table table-hover table-condensed users panel">
<table class="table table-hover table-condensed panel">
<thead>
<tr>
<th></th>
Expand Down
1 change: 1 addition & 0 deletions config/initializers/active_admin.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ActiveAdmin.setup do |config|
config.site_title = "TimeOverflow"
config.site_title_link = "/"
config.footer = "TimeOverflow Admin | www.timeoverflow.org"
config.authentication_method = :authenticate_superuser!
config.current_user_method = :current_user
config.logout_link_path = :destroy_user_session_path
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
get :give_time, on: :member
end

resources :organizations, concerns: :accountable, except: :destroy do
resources :organizations, except: [:new, :create, :destroy], concerns: :accountable do
member do
post :set_current
end
Expand All @@ -41,7 +41,7 @@
end
end

resources :transfers, only: [:create, :new] do
resources :transfers, only: [:new, :create] do
member do
put :delete_reason
end
Expand Down
10 changes: 0 additions & 10 deletions spec/controllers/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@
end
end

describe 'POST #create' do
it 'only superdamins are authorized create to new organizations' do
login(member.user)

expect {
post :create, params: { organization: { name: 'New cool organization' } }
}.not_to change { Organization.count }
end
end

describe 'POST #update' do
context 'with a logged user (admins organization)' do
let(:member) { Fabricate(:member, organization: organization, manager: true) }
Expand Down