Skip to content

Commit

Permalink
Merge branch 'main' into add_person_routes_and_view
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern authored Dec 22, 2023
2 parents 9c31350 + 501e0bf commit bcf6cbe
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
*.swp
*~
dump.rdb
/db
20 changes: 20 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,26 @@ class App < Sinatra::Base
end
end

get '/db/organization_departments/:id' do
@organization_department = Ronin::DB::OrganizationDepartment.find(params[:id])

if @organization_department
erb :"db/organizations/departments/show"
else
halt 404
end
end

get '/db/organization_members/:id' do
@organization_member = Ronin::DB::OrganizationMember.find(params[:id])

if @organization_member
erb :"db/organizations/members/show"
else
halt 404
end
end

get '/db/people' do
@pagy, @people = pagy(Ronin::DB::Person)

Expand Down
4 changes: 4 additions & 0 deletions scripts/console
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env bash

if [[ -z "$DATABASE_URL" ]] && [[ -n "$DATABASE_NAME" ]]; then
export DATABASE_URL="sqlite3:db/dev.sqlite3"
fi

bundle exec irb -Ilib -r ./app.rb
82 changes: 82 additions & 0 deletions views/db/organizations/departments/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<% content_for :breadcrumbs do %>
<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/db">Database</a></li>
<li><a href="/db/organizations/<%=h @organization_department.organization.id %>"><%=h @organization_department.organization %></a></li>
<% if @organization_department.parent_department %>
<li><a href="/db/organization_departments/<%=h @organization_department.parent_department.id %>"><%=h @organization_department.parent_department %></a></li>
<% end %>
</ul>
</nav>
<% end %>

<h1>Organization Department: <%=h @organization_department %></h1>

<table class="table">
<tbody>
<tr>
<td><strong>Organization:</strong></td>
<td><a href="/db/organizations/<%=h @organization_department.organization.id %>"><%=h @organization_department.organization %></a></td>
</tr>

<tr>
<td><strong>Parent Department:</strong></td>
<td>
<% if @organization_department.parent_department %>
<a href="/db/organization_departments/<%=h @organization_department.parent_department.id %>"><%=h @organization_department.parent_department %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Street Address:</strong></td>
<td>
<% if @organization_department.street_address %>
<a href="/db/street_addresses/<%=h @organization_department.street_address.id %>"><%=h @organization_department.street_address %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Email Address:</strong></td>
<td>
<% if @organization_department.email_address %>
<a href="/db/email_addresses/<%=h @organization_department.email_address.id %>"><%=h @organization_department.email_address %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Phone Number:</strong></td>
<td>
<% if @organization_department.phone_number %>
<a href="/db/phone_numbers/<%=h @organization_department.phone_number.id %>"><%=h @organization_department.phone_number %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Subdepartments:</strong></td>
<td>
<% @organization_department.subdepartments.each do |subdepartment| %>
<p><a href="/db/organization_departments/<%=h subdepartment.id %>"><%=h subdepartment %></a></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Members:</strong></td>
<td>
<% @organization_department.members.each do |member| %>
<p><a href="/db/organization_members/<%=h member.id %>"><%=h member %></a></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Created:</strong></td>
<td><%=h @organization_department.created_at %></td>
</tr>
</tbody>
</table>
87 changes: 87 additions & 0 deletions views/db/organizations/members/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<% content_for :breadcrumbs do %>
<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/db">Database</a></li>
<li><a href="/db/organizations">Organization Member</a></li>
</ul>
</nav>
<% end %>

<h1>Organization Member: <%=h @organization_member.person %></h1>

<table class="table">
<tbody>
<tr>
<td><strong>Active:</strong></td>
<td><%=h @organization_member.active %></td>
</tr>

<tr>
<td><strong>Type:</strong></td>
<td><%=h @organization_member.type %></td>
</tr>

<tr>
<td><strong>Role:</strong></td>
<td><%=h @organization_member.role %></td>
</tr>

<tr>
<td><strong>Title:</strong></td>
<td><%=h @organization_member.title %></td>
</tr>

<tr>
<td><strong>Rank:</strong></td>
<td><%=h @organization_member.rank %></td>
</tr>

<tr>
<td><strong>Person:</strong></td>
<td><a href="/db/people/<%=h @organization_member.person.id %>"><%=h @organization_member.person %></a></td>
</tr>

<tr>
<td><strong>Department:</strong></td>
<td>
<% if @organization_member.department %>
<a href="/db/departments/<%=h @organization_member.department.id %>"><%=h @organization_member.department %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Organization:</strong></td>
<td><a href="/db/organizations/<%=h @organization_member.organization.id %>"><%=h @organization_member.organization %></a></td>
</tr>

<tr>
<td><strong>Email Address:</strong></td>
<td>
<% if @organization_member.email_address %>
<a href="/db/email_addresses/<%=h @organization_member.email_address.id %>"><%=h @organization_member.email_address %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Phone Number:</strong></td>
<td>
<% if @organization_member.phone_number %>
<a href="/db/phone_numbers/<%=h @organization_member.phone_number.id %>"><%=h @organization_member.phone_number %></a>
<% end %>
</td>
</tr>

<tr>
<td><strong>Created at:</strong></td>
<td><%=h @organization_member.created_at %></td>
</tr>

<tr>
<td><strong>Updated at:</strong></td>
<td><%=h @organization_member.updated_at %></td>
</tr>
</tbody>
</table>
2 changes: 1 addition & 1 deletion views/db/organizations/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<td><strong>Members:</strong></td>
<td>
<% @organization.members.each do |member| %>
<p><a href="/db/organization_members/<%=h member.id %>"><%=h member %></a></p>
<p><a href="/db/organization_members/<%=h member.id %>"><%=h member.person %></a></p>
<% end %>
</td>
</tr>
Expand Down

0 comments on commit bcf6cbe

Please sign in to comment.