app/views/organizations/show.html.erb
<h1>
<%= @organization.name %>
<%= image_tag @organization.org_logo %>
</h1>
<p>
<%= @organization.information %>
</p>
<% unless @organization.website.blank? %>
<p>
<strong>Website:</strong> <%= link_to @organization.website, @organization.website, target: "_blank" %>
</p>
<% end %>
<% if !@organization.verified? && can?(:teach, @organization) %>
<p>
<strong>
This organization is not verified yet by an administrator. Courses are fully functional, but some
features, like model answers, are not enabled.
</strong>
<% if can? :view, :unverified_organizations %>
<br>
<%= link_to 'Verify', verify_organization_path(@organization), method: :post, class: 'btn btn-success' %>
<%= link_to 'Disable', disable_reason_input_organization_path(@organization), class: 'btn btn-danger' %>
<% end %>
</p>
<% end %>
<% if @organization.disabled? %>
<p>
<strong>This organization is disabled by an administrator. Reason:</strong>
<i><%= @organization.disabled_reason %></i>
</p>
<% end %>
<% if can? :teach, @organization %>
<div class="teacher-panel">
<h4>Teacher functions</h4>
<ul>
<% if can? :toggle_visibility, @organization %>
<li>
<strong>Visibility:</strong>
<% if @organization.hidden %>
Hidden! Organization is not shown on the front page, but courses can be accessed normally.
<% else %>
Visible
<% end %>
<%= link_to "#{@organization.hidden ? 'make organization visible' : 'hide organization'}", toggle_visibility_organization_path(@organization),
method: :post, class: "btn btn-sm #{@organization.hidden ? 'btn-info' : 'btn-danger' }", data: { confirm: "Are you sure?" } %>
</li>
<% end %>
<% if can? :view_statistics, @organization %>
<li>
<%= link_to 'Show statistics', organization_stats_path(@organization), class: 'btn btn-link btn-sm' %>
</li>
<% end %>
<% if can? :edit, @organization %>
<li>
<%= link_to 'Edit organization info', edit_setup_organization_path(@organization), class: 'btn btn-link btn-sm' %>
</li>
<% end %>
<% if can? :view_participant_list, @organization%>
<li>
<%= link_to 'List of registered users', organization_participants_path(@organization), class: 'btn btn-link btn-sm' %>
</li>
<% end %>
<% if can? :teach, @organization %>
<li>
<%= link_to 'Show teachers in this organization', organization_teachers_path(@organization), class: 'btn btn-link btn-sm' %>
</li>
<% end %>
</ul>
</div>
<% end %>
<% if current_user.administrator? %>
<div class="admin-panel">
<h4>Admin functions</h4>
<ul>
<li>
<strong>Organization ID:</strong>
<%= @organization.slug %>
</li>
<li>
<strong>Created by:</strong>
<% created_by = @organization.creator %>
<%= link_to created_by.username, participant_path(created_by) unless created_by.nil? %>
</li>
<li>
<strong>Created at:</strong>
<%= @organization.created_at %>
</li>
<li>
<strong>Contact person:</strong>
<%= @organization.contact_information %>
</li>
<li>
<strong>Contact phone:</strong>
<%= @organization.phone %>
</li>
<li>
<strong>Contact email:</strong>
<%= mail_to @organization.email %>
</li>
<% if @organization.verified %>
<li>
<strong>Verified at:</strong>
<%= @organization.verified_at %>
</li>
<% end %>
</ul>
</div>
<% end %>
<% unless @my_assisted_courses.empty? %>
<%=
render partial: 'courses/list_my_assisted_courses',
locals: { courses: @my_assisted_courses, title: 'Courses I assist' }
%>
<% end %>
<% unless current_user.guest? %>
<%=
render partial: 'courses/list_my_courses',
locals: { courses: @my_courses, title: 'My courses', percent_completed: @my_courses_percent_completed }
%>
<% end %>
<div>
<%= render template: 'courses/index', locals: { title: 'Courses' } %>
</div>
<% if can? :teach, @organization %>
<%= link_to 'View all courses', all_courses_organization_path(@organization), class: 'btn btn-secondary'%>
<% end %>
<br>