Skip to content

Commit 1fdeb57

Browse files
add final project submissions
1 parent 9af9e5c commit 1fdeb57

File tree

25 files changed

+389
-27
lines changed

25 files changed

+389
-27
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ group :test do
6363
gem "selenium-webdriver"
6464
end
6565

66-
gem "plutonium"
66+
gem "plutonium" # , path: "/Users/stefan/Documents/plutonium/plutonium-core"
6767

6868
gem "annotated", "~> 0.1.1", group: :development
6969

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ GEM
341341
phlexi-field (~> 0.2.0)
342342
zeitwerk
343343
phonelib (0.10.12)
344-
plutonium (0.27.0)
344+
plutonium (0.28.0)
345345
action_policy (~> 0.7.0)
346346
listen (~> 3.8)
347347
pagy (~> 9.0)

db/schema.rb

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class AdminDashboardPortal::Hackathon::FinalSubmissionsController < ::Hackathon::FinalSubmissionsController
2+
include AdminDashboardPortal::Concerns::Controller
3+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class AdminDashboardPortal::Hackathon::FinalSubmissionDefinition < ::Hackathon::FinalSubmissionDefinition
2+
class IndexPage < IndexPage
3+
private
4+
5+
def render_after_toolbar
6+
# Calculate vote tallies
7+
vote_counts = Hackathon::FinalSubmission
8+
.group(:peoples_choice_vote_id)
9+
.count
10+
.sort_by { |_team_id, count| -count }
11+
12+
winner_team_id, winner_votes = vote_counts.first
13+
winner_team = Hackathon::Team.find_by(id: winner_team_id) if winner_team_id
14+
15+
div class: "mb-4 p-6 bg-gradient-to-r from-yellow-50 to-amber-50 dark:from-yellow-900/20 dark:to-amber-900/20 rounded-xl shadow-md border-2 border-yellow-200 dark:border-yellow-800" do
16+
div class: "flex items-start gap-4" do
17+
div class: "flex-shrink-0" do
18+
div class: "w-14 h-14 bg-yellow-500 dark:bg-yellow-600 rounded-full flex items-center justify-center" do
19+
svg class: "w-8 h-8 text-white", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" do |s|
20+
s.path stroke_linecap: "round", stroke_linejoin: "round", stroke_width: "2", d: "M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"
21+
end
22+
end
23+
end
24+
div class: "flex-1" do
25+
h3 class: "text-xl font-bold text-yellow-900 dark:text-yellow-100 mb-2" do
26+
"🏆 People's Choice Winner"
27+
end
28+
if winner_team
29+
p class: "text-lg font-semibold text-yellow-800 dark:text-yellow-200 mb-1" do
30+
winner_team.name
31+
end
32+
p class: "text-sm text-yellow-700 dark:text-yellow-300" do
33+
"#{winner_votes} #{winner_votes == 1 ? 'vote' : 'votes'} received"
34+
end
35+
else
36+
p class: "text-yellow-800 dark:text-yellow-200" do
37+
"No votes cast yet"
38+
end
39+
end
40+
end
41+
end
42+
end
43+
end
44+
end
45+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AdminDashboardPortal::Hackathon::FinalSubmissionPolicy < ::Hackathon::FinalSubmissionPolicy
2+
def create?
3+
false
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AdminDashboardPortal::Hackathon::ProjectSubmissionPolicy < ::Hackathon::ProjectSubmissionPolicy
2+
def create?
3+
false
4+
end
5+
end
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<%= render Plutonium::UI::Layout::Sidebar.new do %>
2-
<%=
3-
render Plutonium::UI::SidebarMenu.new(
2+
<%= render Plutonium::UI::SidebarMenu.new(
43
Phlexi::Menu::Builder.new do |m|
54
m.item "Dashboard",
65
url: root_path,
@@ -11,13 +10,14 @@
1110
[Hacker, Phlex::TablerIcons::User],
1211
[Hackathon::Invitation, Phlex::TablerIcons::MailForward],
1312
[Hackathon::CheckIn, Phlex::TablerIcons::CircleCheck],
14-
[Hackathon::Event, Phlex::TablerIcons::Calendar]
13+
[Hackathon::Event, Phlex::TablerIcons::Calendar],
14+
[Hackathon::ProjectSubmission, Phlex::TablerIcons::RocketOff],
15+
[Hackathon::FinalSubmission, Phlex::TablerIcons::Rocket]
1516
].each do |resource, icon|
1617
m.item resource.model_name.human.pluralize,
1718
url: resource_url_for(resource, parent: nil),
1819
icon: icon
1920
end
2021
end
21-
)
22-
%>
22+
) %>
2323
<% end %>

packages/admin_dashboard_portal/config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
register_resource ::Hackathon::CheckIn
1111
register_resource ::Hackathon::ProjectSubmission
1212
register_resource ::Hackathon::Event
13+
register_resource ::Hackathon::FinalSubmission
1314
# register resources above.
1415

1516
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Hackathon::FinalSubmissionsController < Hackathon::ResourceController
2+
end

0 commit comments

Comments
 (0)