From 1ed460507715313de91960526ec814e55a111bd0 Mon Sep 17 00:00:00 2001 From: AVS1508 Date: Sun, 7 Nov 2021 00:58:19 -0400 Subject: [PATCH 1/3] Updated the Project model to validate presence and format of YouTube link --- app/models/project.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index fe19ff24..7604256e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 @@ -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, From 82608ad1c8218f85fc0b0b117c0485fd37aff2bf Mon Sep 17 00:00:00 2001 From: AVS1508 Date: Sun, 7 Nov 2021 00:59:36 -0400 Subject: [PATCH 2/3] Updated the Project Creation view to be consistent with model changes and new requirements --- app/views/projects/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index a35afc55..a57130a4 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -77,8 +77,8 @@

Do you have a YouTube video link?

-

A project video is optional. The video should be between 30 and 60 seconds long, and demonstrate how your hack works. No PowerPoint slides, please. Cinema-level video editing not required.

- <%= 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!" %> +

A project video is required. The video should be between 2 - 3 minutes long, and demonstrate how your hack works. No PowerPoint slides, please. Cinema-level video editing not required.

+ <%= form.text_field :youtube_link, id: :youtube_link, class: 'form-control', placeholder: "Link us to your project's video demonstration!" %>
From d45f01d7c6412595f287288f19b9c4cc5546c81e Mon Sep 17 00:00:00 2001 From: AVS1508 Date: Sun, 7 Nov 2021 01:14:55 -0400 Subject: [PATCH 3/3] Updated the Project creation form view to have checkbox for virtual participants --- app/views/projects/_form.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index a57130a4..6ec1a3b0 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -171,10 +171,13 @@

- For judging purposes, do you need a wall outlet? + For judging purposes, are you participating only virtually? Otherwise, leave blank.

+ <%# 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!'%>