Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Project Creation form to be consistent with new requirements (6th November 2021) #262

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Project < ApplicationRecord
before_create :rename_file
before_update :rename_file

validates_presence_of :title, :description, :inspiration, :does_what, :built_how, :challenges, :accomplishments, :learned, :next, :built_with, message: '%{attribute} can\'t be blank.'
validates_presence_of :title, :description, :youtube_link, :inspiration, :does_what, :built_how, :challenges, :accomplishments, :learned, :next, :built_with, message: '%{attribute} can\'t be blank.'
validates_uniqueness_of :title, message: '%{attribute} has already been taken.'

has_many :user
Expand All @@ -14,7 +14,13 @@ class Project < ApplicationRecord
has_attached_file :projectimage,
path: 'project/:filename'


# validates the format of the youtube_link (allowed to be blank so that it doesn't show 2 errors if absent as we're
# already validating its presence above) if it is indeed present because it needs to start with "https://"
validates :youtube_link,
allow_blank: true,
if: -> { link.present? },
format: { with: /\G[hH][tT][tT][pP][sS]:\/\/.*/,
message: 'YouTube link must begin with \'https://\'' }

validates :link,
allow_blank: true,
Expand Down
11 changes: 7 additions & 4 deletions app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
<h3>
Do you have a YouTube video link?
</h3>
<p style="color: grey; ">A project video is optional. <b>The video should be between 30 and 60 seconds long, and demonstrate how your hack works.</b> No PowerPoint slides, please. Cinema-level video editing not required.</p>
<%= form.text_field :youtube_link, id: :youtube_link, class: 'form-control', placeholder: "This is optional, but if you don't upload a video then please upload a photo!" %>
<p style="color: grey; "><b>A project video is required. The video should be between 2 - 3 minutes long, and demonstrate how your hack works.</b> No PowerPoint slides, please. Cinema-level video editing not required.</p>
<%= form.text_field :youtube_link, id: :youtube_link, class: 'form-control', placeholder: "Link us to your project's video demonstration!" %>
</div>

<div class="form-group">
Expand Down Expand Up @@ -171,10 +171,13 @@
<div class='card'>
<div class='card-body'>
<h3>
For judging purposes, do you need a wall outlet?
For judging purposes, are you participating only virtually? Otherwise, leave blank.
</h3>
<%# Note that the question now asks for confirmation of being a virtual participant and not the wall outlet requirement so %>
<%# while this may not be the best practice for long term development, I am leaving the form field as supplying the :power %>
<%# symbol in the interest of not wrangling with model changes and creating updated migrations in the middle of the event %>
<%= form.check_box(:power)%>
<%= form.label :power,'Yes, I need an outlet to connect my project to.'%>
<%= form.label :power,'Yes, I am a virtual participant for HackUMass IX!'%>
</div>
</div>

Expand Down