From 3ab44a115c5f0be9d36c35a6e1ab0efdaa6f029b Mon Sep 17 00:00:00 2001 From: Postmodern Date: Thu, 21 Dec 2023 05:48:57 -0800 Subject: [PATCH 1/4] Ensure `scripts/console` uses `db/dev.sqlite3`. --- scripts/console | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/console b/scripts/console index 683fa2d..5030f2f 100755 --- a/scripts/console +++ b/scripts/console @@ -1,3 +1,7 @@ #!/usr/bin/env bash +if [[ -n $DATABASE_URL ]]; then + export DATABASE_URL="sqlite3:db/dev.sqlite3" +fi + bundle exec irb -Ilib -r ./app.rb From 28a1499cab5978562bee8c8194805a689af474db Mon Sep 17 00:00:00 2001 From: Postmodern Date: Thu, 21 Dec 2023 05:59:15 -0800 Subject: [PATCH 2/4] Fixed a bug where `DATABASE_URL` or `DATABASE_NAME` are specified. --- scripts/console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/console b/scripts/console index 5030f2f..053772d 100755 --- a/scripts/console +++ b/scripts/console @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if [[ -n $DATABASE_URL ]]; then +if [[ -z "$DATABASE_URL" ]] && [[ -n "$DATABASE_NAME" ]]; then export DATABASE_URL="sqlite3:db/dev.sqlite3" fi From aef0abac54510fe06a04364b75e23184762caec7 Mon Sep 17 00:00:00 2001 From: AI-Mozi Date: Fri, 22 Dec 2023 13:34:59 +0100 Subject: [PATCH 3/4] add /db to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 31b9df2..1a37534 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ *.swp *~ dump.rdb +/db From 501e0bffbcbd6a47a6cec1aaa483df243b2b3eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Bieniek?= Date: Fri, 22 Dec 2023 14:33:22 +0100 Subject: [PATCH 4/4] Add views and routes for Organization departments and members (#86) --- app.rb | 20 +++++ views/db/organizations/departments/show.erb | 82 +++++++++++++++++++ views/db/organizations/members/show.erb | 87 +++++++++++++++++++++ views/db/organizations/show.erb | 2 +- 4 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 views/db/organizations/departments/show.erb create mode 100644 views/db/organizations/members/show.erb diff --git a/app.rb b/app.rb index 3c27413..b287abb 100644 --- a/app.rb +++ b/app.rb @@ -730,6 +730,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 '/recon' do erb :recon end diff --git a/views/db/organizations/departments/show.erb b/views/db/organizations/departments/show.erb new file mode 100644 index 0000000..074e161 --- /dev/null +++ b/views/db/organizations/departments/show.erb @@ -0,0 +1,82 @@ +<% content_for :breadcrumbs do %> + +<% end %> + +

Organization Department: <%=h @organization_department %>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Organization:<%=h @organization_department.organization %>
Parent Department: + <% if @organization_department.parent_department %> + <%=h @organization_department.parent_department %> + <% end %> +
Street Address: + <% if @organization_department.street_address %> + <%=h @organization_department.street_address %> + <% end %> +
Email Address: + <% if @organization_department.email_address %> + <%=h @organization_department.email_address %> + <% end %> +
Phone Number: + <% if @organization_department.phone_number %> + <%=h @organization_department.phone_number %> + <% end %> +
Subdepartments: + <% @organization_department.subdepartments.each do |subdepartment| %> +

<%=h subdepartment %>

+ <% end %> +
Members: + <% @organization_department.members.each do |member| %> +

<%=h member %>

+ <% end %> +
Created:<%=h @organization_department.created_at %>
diff --git a/views/db/organizations/members/show.erb b/views/db/organizations/members/show.erb new file mode 100644 index 0000000..3bd0de9 --- /dev/null +++ b/views/db/organizations/members/show.erb @@ -0,0 +1,87 @@ +<% content_for :breadcrumbs do %> + +<% end %> + +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Active:<%=h @organization_member.active %>
Type:<%=h @organization_member.type %>
Role:<%=h @organization_member.role %>
Title:<%=h @organization_member.title %>
Rank:<%=h @organization_member.rank %>
Person:<%=h @organization_member.person %>
Department: + <% if @organization_member.department %> + <%=h @organization_member.department %> + <% end %> +
Organization:<%=h @organization_member.organization %>
Email Address: + <% if @organization_member.email_address %> + <%=h @organization_member.email_address %> + <% end %> +
Phone Number: + <% if @organization_member.phone_number %> + <%=h @organization_member.phone_number %> + <% end %> +
Created at:<%=h @organization_member.created_at %>
Updated at:<%=h @organization_member.updated_at %>
diff --git a/views/db/organizations/show.erb b/views/db/organizations/show.erb index dd077de..300f28c 100644 --- a/views/db/organizations/show.erb +++ b/views/db/organizations/show.erb @@ -57,7 +57,7 @@ Members: <% @organization.members.each do |member| %> -

<%=h member %>

+

<%=h member.person %>

<% end %>