Skip to content

Commit e17ba5e

Browse files
overhaul dashboard and qualification logic (#18)
* give hacker dashboard a good overhaul * update minimum qualifications check
1 parent 0065940 commit e17ba5e

File tree

26 files changed

+586
-116
lines changed

26 files changed

+586
-116
lines changed
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
class ProfileDefinition < ::ResourceDefinition
2-
new_page_title "Complete Your Profile"
3-
show_page_title "Profile"
4-
5-
edit_page_title "Edit Your Profile"
6-
index_page_title "Team Members"
7-
8-
input :skillsets, as: :select, multiple: true, choices: Profile::SKILLSETS.invert
9-
10-
class Form < Form
11-
private
12-
13-
def render_actions
14-
input name: "return_to", value: request.params[:return_to], type: :hidden, hidden: true
15-
16-
actions_wrapper {
17-
render submit_button
18-
}
19-
end
2+
input :skillsets, as: :slim_select, multiple: true, choices: Profile::SKILLSETS.invert
3+
input :sex, choices: Profile::SEXES.invert
4+
display :skillsets, wrapper: {class: "col-span-full"} do |a|
5+
Profile::SKILLSETS.invert.slice(*a.value).values.join ", "
206
end
217
end

app/javascript/controllers/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
// Run that command whenever you add a new controller or create them with
33
// ./bin/rails generate stimulus controllerName
44

5-
import { application } from "./application";
5+
import { application } from "./application"
66

7-
import HelloController from "./hello_controller";
8-
application.register("hello", HelloController);
7+
import { registerControllers } from "@radioactive-labs/plutonium"
8+
registerControllers(application);
99

10-
import MobileMenuController from "./mobile_menu_controller";
11-
application.register("mobile-menu", MobileMenuController);
10+
import HelloController from "./hello_controller"
11+
application.register("hello", HelloController)
1212

13-
import { registerControllers } from "@radioactive-labs/plutonium";
14-
registerControllers(application);
13+
import MobileMenuController from "./mobile_menu_controller"
14+
application.register("mobile-menu", MobileMenuController)
15+
16+
import ModalController from "./modal_controller"
17+
application.register("modal", ModalController)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
static targets = ["modal"]
5+
6+
open() {
7+
this.modalTarget.classList.remove("hidden")
8+
}
9+
10+
close() {
11+
this.modalTarget.classList.add("hidden")
12+
}
13+
14+
stopPropagation(event) {
15+
event.stopPropagation()
16+
}
17+
}

app/models/profile.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# id :integer not null, primary key
66
# name :string not null
77
# region :string
8+
# sex :string
89
# skillsets :text
910
# telephone_number :string
1011
# created_at :datetime not null
@@ -50,6 +51,11 @@ class Profile < ::ResourceRecord
5051
"Ahafo"
5152
].freeze
5253

54+
SEXES = {
55+
"Male" => "male",
56+
"Female" => "female"
57+
}.freeze
58+
5359
belongs_to :hacker
5460
has_one :team, through: :hacker
5561
has_one :emergency_contact, through: :hacker
@@ -60,6 +66,7 @@ class Profile < ::ResourceRecord
6066
validates :telephone_number, presence: true, phone: {possible: true, types: :mobile}
6167
validates :skillsets, presence: true
6268
validates :region, presence: true, inclusion: {in: REGIONS}
69+
validates :sex, presence: true, inclusion: {in: SEXES.values}, allow_blank: true
6370

6471
def telephone_number=(value)
6572
parsed = Phonelib.parse(value)
@@ -71,6 +78,14 @@ def skillsets=(value)
7178
super
7279
end
7380

81+
def completed?
82+
name.present? &&
83+
telephone_number.present? &&
84+
region.present? &&
85+
sex.present? &&
86+
skillsets.present?
87+
end
88+
7489
private
7590

7691
def skillsets_must_be_valid

app/policies/profile_policy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ def read?
1010
# Core attributes
1111

1212
def permitted_attributes_for_create
13-
[:hacker, :name, :telephone_number, :region, :skillsets]
13+
[:hacker, :name, :telephone_number, :sex, :region, :skillsets]
1414
end
1515

1616
def permitted_attributes_for_read
17-
%i[hacker name telephone_number region skillsets]
17+
%i[hacker name telephone_number sex region skillsets]
1818
end
1919

2020
# Associations

app/views/homepage/about.html.erb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,20 @@
3232
<div>
3333
<h3 class="text-lg font-semibold text-gray-900">Team Requirements</h3>
3434
<p class="mt-2 text-gray-600">2-4 members per team</p>
35-
<p class="text-sm text-gray-500">Diverse backgrounds encouraged</p>
35+
<div class="mt-2 space-y-1">
36+
<p class="text-sm text-gray-700 flex items-center">
37+
<svg class="w-4 h-4 text-primary-600 mr-1.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
38+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
39+
</svg>
40+
At least 1 member from outside Greater Accra
41+
</p>
42+
<p class="text-sm text-gray-700 flex items-center">
43+
<svg class="w-4 h-4 text-primary-600 mr-1.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
44+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
45+
</svg>
46+
At least 1 female member
47+
</p>
48+
</div>
3649
</div>
3750
</div>
3851

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddSexToProfiles < ActiveRecord::Migration[8.0]
2+
def change
3+
add_column :profiles, :sex, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/admin_dashboard_portal/app/views/admin_dashboard_portal/dashboard/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
Qualified Teams
7979
</h3>
8080
<p class="text-sm text-gray-600 dark:text-gray-400 leading-relaxed">
81-
Qualified teams are teams with a minimum of <%= Hackathon::Team::MINIMUM_TEAM_MEMBERSHIPS %> registered members.
81+
Qualified teams have <%= Hackathon::Team::MINIMUM_TEAM_MEMBERSHIPS %>+ members, with at least 1 from outside Greater Accra and 1 female member.
8282
</p>
8383
</div>
8484
</div>
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
11
class Hackathon::HealthAndSafetyDefinition < Hackathon::ResourceDefinition
2-
show_page_description "This person will be contacted in case of an emergency"
3-
4-
class Form < Form
5-
private
6-
7-
def render_actions
8-
input name: "return_to", value: request.params[:return_to], type: :hidden, hidden: true
9-
10-
actions_wrapper {
11-
render submit_button
12-
}
13-
end
14-
end
152
end

0 commit comments

Comments
 (0)