Skip to content

Commit 560c7cd

Browse files
use resource pages for project submission and make editing easier
1 parent 63caf3a commit 560c7cd

8 files changed

Lines changed: 77 additions & 67 deletions

File tree

Gemfile.lock

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
PATH
2+
remote: /Users/stefan/Documents/plutonium/plutonium-core
3+
specs:
4+
plutonium (0.26.11)
5+
action_policy (~> 0.7.0)
6+
listen (~> 3.8)
7+
pagy (~> 9.0)
8+
phlex (~> 2.0)
9+
phlex-rails
10+
phlex-slotable (>= 1.0.0)
11+
phlex-tabler_icons
12+
phlexi-display (>= 0.2.0)
13+
phlexi-field (>= 0.2.0)
14+
phlexi-form (>= 0.10.0)
15+
phlexi-menu (>= 0.4.0)
16+
phlexi-table (>= 0.2.0)
17+
rabl (~> 0.16.1)
18+
rails (>= 7.2)
19+
redcarpet
20+
semantic_range (~> 3.0)
21+
tailwind_merge
22+
tty-prompt (~> 0.23.1)
23+
zeitwerk
24+
125
GEM
226
remote: https://rubygems.org/
327
specs:
@@ -150,14 +174,7 @@ GEM
150174
logger
151175
faraday-net_http (3.4.1)
152176
net-http (>= 0.5.0)
153-
ffi (1.17.2-aarch64-linux-gnu)
154-
ffi (1.17.2-aarch64-linux-musl)
155-
ffi (1.17.2-arm-linux-gnu)
156-
ffi (1.17.2-arm-linux-musl)
157177
ffi (1.17.2-arm64-darwin)
158-
ffi (1.17.2-x86_64-darwin)
159-
ffi (1.17.2-x86_64-linux-gnu)
160-
ffi (1.17.2-x86_64-linux-musl)
161178
fiber-local (1.1.0)
162179
fiber-storage
163180
fiber-storage (1.0.1)
@@ -379,26 +396,6 @@ GEM
379396
phlexi-field (~> 0.2.0)
380397
zeitwerk
381398
phonelib (0.10.12)
382-
plutonium (0.26.10)
383-
action_policy (~> 0.7.0)
384-
listen (~> 3.8)
385-
pagy (~> 9.0)
386-
phlex (~> 2.0)
387-
phlex-rails
388-
phlex-slotable (>= 1.0.0)
389-
phlex-tabler_icons
390-
phlexi-display (>= 0.2.0)
391-
phlexi-field (>= 0.2.0)
392-
phlexi-form (>= 0.10.0)
393-
phlexi-menu (>= 0.4.0)
394-
phlexi-table (>= 0.2.0)
395-
rabl (~> 0.16.1)
396-
rails (>= 7.2)
397-
redcarpet
398-
semantic_range (~> 3.0)
399-
tailwind_merge
400-
tty-prompt (~> 0.23.1)
401-
zeitwerk
402399
postmark (1.25.1)
403400
json
404401
postmark-rails (0.22.1)
@@ -670,7 +667,7 @@ DEPENDENCIES
670667
omniauth-google-oauth2 (~> 1.2)
671668
pg (~> 1.6)
672669
phonelib (~> 0.10.12)
673-
plutonium
670+
plutonium!
674671
postmark-rails (~> 0.22.1)
675672
propshaft
676673
puma (>= 5.0)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
class Hackathon::ProjectSubmissionsController < Hackathon::ResourceController
2+
def new
3+
authorize_current! resource_class
4+
5+
unless current_user.owns_team?(current_user.team) && current_user.team.project_submission.nil?
6+
redirect_to root_path
7+
return
8+
end
9+
10+
super
11+
end
12+
13+
private
14+
15+
def resource_params
16+
super.merge(team: current_user.team)
17+
end
218
end

packages/hackathon/app/interactions/hackathon/teams/submit_project_interaction.rb

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/hacker_dashboard_portal/app/definitions/hacker_dashboard_portal/hackathon/project_submission_definition.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def render_actions
1313
end
1414
end
1515

16+
new_page_title "Submit your team's project"
17+
edit_page_title "Edit your team's project"
18+
1619
class IndexPage < IndexPage
1720
include NavigatesBackToTeam
1821
end
@@ -21,6 +24,10 @@ class ShowPage < ShowPage
2124
include NavigatesBackToTeam
2225
end
2326

27+
class NewPage < NewPage
28+
include NavigatesBackToTeam
29+
end
30+
2431
class EditPage < EditPage
2532
include NavigatesBackToTeam
2633
end

packages/hacker_dashboard_portal/app/definitions/hacker_dashboard_portal/hackathon/team_definition.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,25 @@ class HackerDashboardPortal::Hackathon::TeamDefinition < ::Hackathon::TeamDefini
2020
action :invite_member,
2121
interaction: Hackathon::Teams::InviteMember
2222

23-
action :submit_project,
24-
interaction: Hackathon::Teams::SubmitProjectInteraction
23+
action(:submit_project,
24+
record_action: true,
25+
icon: Phlex::TablerIcons::FileText,
26+
label: "Submit Project",
27+
route_options: Plutonium::Action::RouteOptions.new(
28+
url_resolver: ->(team) {
29+
resource_url_for(Hackathon::ProjectSubmission, action: :new)
30+
}
31+
))
32+
33+
action(:edit_project,
34+
record_action: true,
35+
icon: Phlex::TablerIcons::FileText,
36+
label: "Edit Project",
37+
route_options: Plutonium::Action::RouteOptions.new(
38+
url_resolver: ->(team) {
39+
resource_url_for(team.project_submission, action: :edit)
40+
}
41+
))
2542

2643
class ShowPage < ShowPage
2744
include Phlex::Rails::Helpers::LinkTo

packages/hacker_dashboard_portal/app/policies/hacker_dashboard_portal/hackathon/project_submission_policy.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
class HackerDashboardPortal::Hackathon::ProjectSubmissionPolicy < ::Hackathon::ProjectSubmissionPolicy
2+
def new?
3+
true
4+
end
5+
26
def create?
3-
false
7+
user.owns_team?(user.team) && user.team.project_submission.nil?
48
end
59

610
def read?

packages/hacker_dashboard_portal/app/policies/hacker_dashboard_portal/hackathon/team_policy.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def submit_project?
2222
user.owns_team?(record) && record.project_submission.nil?
2323
end
2424

25+
def edit_project?
26+
user.owns_team?(record) && record.project_submission.present?
27+
end
28+
2529
# Core attributes
2630

2731
def permitted_attributes_for_create

packages/hacker_dashboard_portal/app/views/hacker_dashboard_portal/dashboard/_team_dashboard.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<p class="text-green-800 dark:text-green-200 mb-4">
3333
Congratulations! Your team has met all the qualification requirements. The next step is to submit your project information so we can learn more about what you're building.
3434
</p>
35-
<a href="<%= resource_url_for(team) %>" class="inline-flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600 text-white font-semibold rounded-lg shadow-md hover:shadow-lg transition-all">
35+
<a href="<%= resource_url_for(Hackathon::ProjectSubmission, action: :new) %>" class="inline-flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600 text-white font-semibold rounded-lg shadow-md hover:shadow-lg transition-all">
3636
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
3737
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
3838
</svg>

0 commit comments

Comments
 (0)