Skip to content

Commit c6f14e3

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

8 files changed

Lines changed: 53 additions & 117 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ GEM
100100
aws-eventstream (~> 1, >= 1.0.2)
101101
base64 (0.3.0)
102102
bcrypt (3.1.20)
103-
bcrypt_pbkdf (1.1.1)
104103
bcrypt_pbkdf (1.1.1-arm64-darwin)
105-
bcrypt_pbkdf (1.1.1-x86_64-darwin)
106104
benchmark (0.4.1)
107105
bigdecimal (3.2.3)
108106
bindex (0.8.1)
@@ -150,14 +148,7 @@ GEM
150148
logger
151149
faraday-net_http (3.4.1)
152150
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)
157151
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)
161152
fiber-local (1.1.0)
162153
fiber-storage
163154
fiber-storage (1.0.1)
@@ -212,41 +203,13 @@ GEM
212203
listen (3.9.0)
213204
rb-fsevent (~> 0.10, >= 0.10.3)
214205
rb-inotify (~> 0.9, >= 0.9.10)
215-
litestream (0.14.0)
216-
actionpack (>= 7.0)
217-
actionview (>= 7.0)
218-
activejob (>= 7.0)
219-
activesupport (>= 7.0)
220-
railties (>= 7.0)
221-
sqlite3
222-
litestream (0.14.0-aarch64-linux)
223-
actionpack (>= 7.0)
224-
actionview (>= 7.0)
225-
activejob (>= 7.0)
226-
activesupport (>= 7.0)
227-
railties (>= 7.0)
228-
sqlite3
229206
litestream (0.14.0-arm64-darwin)
230207
actionpack (>= 7.0)
231208
actionview (>= 7.0)
232209
activejob (>= 7.0)
233210
activesupport (>= 7.0)
234211
railties (>= 7.0)
235212
sqlite3
236-
litestream (0.14.0-x86_64-darwin)
237-
actionpack (>= 7.0)
238-
actionview (>= 7.0)
239-
activejob (>= 7.0)
240-
activesupport (>= 7.0)
241-
railties (>= 7.0)
242-
sqlite3
243-
litestream (0.14.0-x86_64-linux)
244-
actionpack (>= 7.0)
245-
actionview (>= 7.0)
246-
activejob (>= 7.0)
247-
activesupport (>= 7.0)
248-
railties (>= 7.0)
249-
sqlite3
250213
logger (1.7.0)
251214
loofah (2.24.1)
252215
crass (~> 1.0.2)
@@ -290,22 +253,8 @@ GEM
290253
net-protocol
291254
net-ssh (7.3.0)
292255
nio4r (2.7.4)
293-
nokogiri (1.18.10-aarch64-linux-gnu)
294-
racc (~> 1.4)
295-
nokogiri (1.18.10-aarch64-linux-musl)
296-
racc (~> 1.4)
297-
nokogiri (1.18.10-arm-linux-gnu)
298-
racc (~> 1.4)
299-
nokogiri (1.18.10-arm-linux-musl)
300-
racc (~> 1.4)
301256
nokogiri (1.18.10-arm64-darwin)
302257
racc (~> 1.4)
303-
nokogiri (1.18.10-x86_64-darwin)
304-
racc (~> 1.4)
305-
nokogiri (1.18.10-x86_64-linux-gnu)
306-
racc (~> 1.4)
307-
nokogiri (1.18.10-x86_64-linux-musl)
308-
racc (~> 1.4)
309258
oauth2 (2.0.12)
310259
faraday (>= 0.17.3, < 4.0)
311260
jwt (>= 1.0, < 4.0)
@@ -337,13 +286,7 @@ GEM
337286
racc
338287
pastel (0.8.0)
339288
tty-color (~> 0.5)
340-
pg (1.6.2)
341-
pg (1.6.2-aarch64-linux)
342-
pg (1.6.2-aarch64-linux-musl)
343289
pg (1.6.2-arm64-darwin)
344-
pg (1.6.2-x86_64-darwin)
345-
pg (1.6.2-x86_64-linux)
346-
pg (1.6.2-x86_64-linux-musl)
347290
phlex (2.3.1)
348291
zeitwerk (~> 2.7)
349292
phlex-rails (2.3.1)
@@ -379,7 +322,7 @@ GEM
379322
phlexi-field (~> 0.2.0)
380323
zeitwerk
381324
phonelib (0.10.12)
382-
plutonium (0.26.10)
325+
plutonium (0.26.11)
383326
action_policy (~> 0.7.0)
384327
listen (~> 3.8)
385328
pagy (~> 9.0)
@@ -557,14 +500,7 @@ GEM
557500
fugit (~> 1.11.0)
558501
railties (>= 7.1)
559502
thor (>= 1.3.1)
560-
sqlite3 (2.7.3-aarch64-linux-gnu)
561-
sqlite3 (2.7.3-aarch64-linux-musl)
562-
sqlite3 (2.7.3-arm-linux-gnu)
563-
sqlite3 (2.7.3-arm-linux-musl)
564503
sqlite3 (2.7.3-arm64-darwin)
565-
sqlite3 (2.7.3-x86_64-darwin)
566-
sqlite3 (2.7.3-x86_64-linux-gnu)
567-
sqlite3 (2.7.3-x86_64-linux-musl)
568504
sshkit (1.24.0)
569505
base64
570506
logger
@@ -590,11 +526,7 @@ GEM
590526
tailwind_merge (1.3.1)
591527
sin_lru_redux (~> 2.5)
592528
thor (1.4.0)
593-
thruster (0.1.15)
594-
thruster (0.1.15-aarch64-linux)
595529
thruster (0.1.15-arm64-darwin)
596-
thruster (0.1.15-x86_64-darwin)
597-
thruster (0.1.15-x86_64-linux)
598530
tilt (2.6.1)
599531
timeout (0.4.3)
600532
tsort (0.2.0)
@@ -635,16 +567,7 @@ GEM
635567
zeitwerk (2.7.3)
636568

637569
PLATFORMS
638-
aarch64-linux
639-
aarch64-linux-gnu
640-
aarch64-linux-musl
641-
arm-linux-gnu
642-
arm-linux-musl
643570
arm64-darwin
644-
x86_64-darwin
645-
x86_64-linux
646-
x86_64-linux-gnu
647-
x86_64-linux-musl
648571

649572
DEPENDENCIES
650573
annotated (~> 0.1.1)
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)