diff --git a/app/assets/stylesheets/contests.scss b/app/assets/stylesheets/contests.scss
index 3b7c8ef1508..90cd61a4c58 100644
--- a/app/assets/stylesheets/contests.scss
+++ b/app/assets/stylesheets/contests.scss
@@ -173,4 +173,13 @@
color: white;
box-shadow: 0 0 5px 0px #0000004d;
}
- }
\ No newline at end of file
+ }
+.project-submission {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 10px;
+ background: #f9fffc;
+ border: 1px solid #42b983;
+ margin-bottom: 1rem;
+}
diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index 7a821e1211e..ac68bd8e721 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -61,6 +61,23 @@ def create
end
end
+ # GET /contests/new_submission
+ def new_submission
+ @projects = current_user.projects
+ @contest = Contest.find(params[:id])
+ @submission = Submission.new
+ end
+
+ # POST /contests/:id/create_submission
+ def create_submission
+ @submission = Submission.new
+ @submission.project_id = params[:submission][:project_id]
+ @submission.contest_id = params[:contest_id]
+ if @submission.save
+ redirect_to contest_page_path(params[:contest_id]), notice: "Submission was successfully added."
+ end
+ end
+
private
def authorize_admin
diff --git a/app/views/contests/_view.html.erb b/app/views/contests/_view.html.erb
index 772abe6cdd3..e2ef9ebde16 100644
--- a/app/views/contests/_view.html.erb
+++ b/app/views/contests/_view.html.erb
@@ -7,7 +7,7 @@
-
+
-s
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/contests/new_submission.erb b/app/views/contests/new_submission.erb
new file mode 100644
index 00000000000..31bc85f6900
--- /dev/null
+++ b/app/views/contests/new_submission.erb
@@ -0,0 +1,30 @@
+
+
+
+
Project Submission
+
Contest #<%= @contest.id %>
+
+
+
+
Select your circuit
+
+
+ <%= form_with(model: Submission.new, url: create_submission_path, local: true) do |form| %>
+ <% @projects.each do |project| %>
+
\ No newline at end of file
diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb
index 7109d55b846..74ffb7127fe 100644
--- a/app/views/contests/show.html.erb
+++ b/app/views/contests/show.html.erb
@@ -15,7 +15,9 @@
<% if @contest.status == 'Live' %>
Time Left: ...
-
+ <%= link_to new_submission_path(@contest.id), class: "contest-submission-button" do %>
+ Register your circuit
+ <% end %>
<% else %>
diff --git a/config/routes.rb b/config/routes.rb
index 7fa48b4e3c7..a249fc55ab9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -109,6 +109,8 @@
get "/contests/:id", to: "contests#show", as: "contest_page"
post "/contests/host", to: "contests#create", as: "new_contest"
put "/contests/:id/close", to: "contests#close_contest", as: "close_contest"
+ get "/contests/:id/new_submission", to: "contests#new_submission", as: "new_submission"
+ post "/contests/:id/create_submission", to: "contests#create_submission", as: "create_submission"
# lti
scope "lti" do