Skip to content

Commit

Permalink
Chore: Renames has_live_preview column to previewable. (#4039)
Browse files Browse the repository at this point in the history
## Because
The new column name is Railsyer.


## This PR
- Adds a migration to rename lesson.has_live_preview to
lesson.previewable
- Changes all instances of has_live_preview to be previewable in the
codebase.


## Issue
Closes #4003 

## Additional Information
As a matter of clarification, the task assumed the has_live_preview
column was in the project_submissions table. It was actually on the
lessons table.


## Pull Request Requirements
- [x] I have thoroughly read and understand [The Odin Project
Contributing
Guide](https://github.com/TheOdinProject/theodinproject/blob/main/CONTRIBUTING.md)
- [x] The title of this PR follows the `keyword: brief description of
change` format, using one of the following keywords:
  - `Feature` - adds new or amends existing user-facing behavior
- `Chore` - changes that have no user-facing value, refactors,
dependency bumps, etc
  - `Fix` - bug fixes
-   [x] The `Because` section summarizes the reason for this PR
- [x] The `This PR` section has a bullet point list describing the
changes in this PR
- [x] I have verified all tests and linters pass after making these
changes.
- [x] If this PR addresses an open issue, it is linked in the `Issue`
section
-   [x] If applicable, this PR includes new or updated automated tests
  • Loading branch information
ZachBaird authored Jul 29, 2023
1 parent 5313402 commit 6fd725d
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 83 deletions.
2 changes: 1 addition & 1 deletion app/components/project_submissions/item_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="flex flex-row md:items-center">
<%= link_to 'View code', project_submission.repo_url, target: '_blank', rel: 'noreferrer', class: 'button button--gray font-semibold mr-4', data: { test_id: 'view-code-btn' } %>
<% if project_submission.lesson.has_live_preview? %>
<% if project_submission.lesson.previewable? %>
<%= link_to 'Live preview', project_submission.live_preview_url, target: '_blank', rel: 'noreferrer', class: 'button button--gray font-semibold mr-4', data: { test_id: 'live-preview-btn' } %>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion app/models/project_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def unlike!(user = nil)
def live_preview_allowed
return if live_preview_url.blank?

unless lesson && lesson.has_live_preview?
unless lesson && lesson.previewable?
errors.add(:live_preview_url, 'Live preview is not allowed for this project')
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/project_submissions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<% end %>
</div>

<% if project_submission.lesson.has_live_preview? %>
<% if project_submission.lesson.previewable? %>
<div>
<%= form.label :live_preview_url, 'Live preview (optional)' %>
<%= form.text_field :live_preview_url, leading_icon: true, placeholder: 'http://example.com', class: 'text-sm', data: { test_id: 'live-preview-url-field' } do %>
Expand Down
2 changes: 1 addition & 1 deletion db/fixtures/lessons/database_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def database_lessons
is_project: true,
github_path: '/databases/databases/project_sql_zoo.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: 'a4baeee4-7bab-47ba-8157-c8f52b204734',
},
}
Expand Down
10 changes: 5 additions & 5 deletions db/fixtures/lessons/foundation_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def foundation_lessons
is_project: true,
github_path: '/foundations/javascript_basics/project_rock_paper_scissors.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '5cc2b83d-8024-4e07-82a0-38687b75c300',
},
'Clean Code' => {
Expand All @@ -152,7 +152,7 @@ def foundation_lessons
is_project: true,
github_path: '/foundations/javascript_basics/project_etch_a_sketch.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'fa9a5eea-a42c-4f89-9d53-6e1b8634d6ff',
},
'Fundamentals Part 5' => {
Expand All @@ -168,7 +168,7 @@ def foundation_lessons
is_project: true,
github_path: '/foundations/javascript_basics/project_calculator.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '2aa09e04-cbfa-4b48-97a6-140a760eda08',
},
'Introduction to the Back End' => {
Expand Down Expand Up @@ -242,7 +242,7 @@ def foundation_lessons
github_path: '/foundations/html_css/html-foundations/project-recipes.md',
identifier_uuid: '3c8ad955-4f4e-4555-86bc-98503e1b785d',
accepts_submission: true,
has_live_preview: true,
previewable: true,
},
'Intro to CSS' => {
title: 'Intro to CSS',
Expand Down Expand Up @@ -311,7 +311,7 @@ def foundation_lessons
is_project: true,
github_path: '/foundations/html_css/flexbox/project-landing-page.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '22e0c585-c146-4dab-9dc0-17a20f0ecbc5',
},
'DOM Manipulation and Events' => {
Expand Down
4 changes: 2 additions & 2 deletions db/fixtures/lessons/getting_hired_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def getting_hired_lessons
is_project: true,
github_path: '/getting_hired/preparing_for_job_search/project_portfolio.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '9e9f98a7-43bc-4e2b-9325-f858319604d5',
},
'Collecting Job Leads' => {
Expand All @@ -64,7 +64,7 @@ def getting_hired_lessons
is_project: true,
github_path: '/getting_hired/applying_and_interviewing/project_resume.md',
accepts_submission: false,
has_live_preview: false,
previewable: false,
identifier_uuid: '029f508f-8034-41b2-b330-bba88f0efe3b',
},
'Applying for Web Development Jobs' => {
Expand Down
6 changes: 3 additions & 3 deletions db/fixtures/lessons/html_and_css_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def html_and_css_lessons
description: 'Learn about how browsers style your HTML.',
is_project: true,
accepts_submission: true,
has_live_preview: true,
previewable: true,
github_path: '/intermediate_html_css/forms/project_sign_up_form.md',
identifier_uuid: '91ab41f2-9c9d-449a-8461-329a5f7ecb1e'
},
Expand Down Expand Up @@ -244,7 +244,7 @@ def html_and_css_lessons
description: "Use what you've learned to Complete this project",
is_project: true,
accepts_submission: true,
has_live_preview: true,
previewable: true,
github_path: '/intermediate_html_css/grid/project_admin_dashboard.md',
identifier_uuid: 'c35f0b7b-4d21-4d26-91e2-4af78519ae5f'
},
Expand Down Expand Up @@ -282,7 +282,7 @@ def html_and_css_lessons
description: 'Create a fully responsive personal portfolio.',
is_project: true,
accepts_submission: true,
has_live_preview: true,
previewable: true,
github_path: '/advanced_html_css/responsive_design/project_personal_portfolio.md',
identifier_uuid: 'd99b0c9d-cc6c-44e6-bab0-1c9a83edcfa3'
},
Expand Down
24 changes: 12 additions & 12 deletions db/fixtures/lessons/javascript_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/organizing_your_javascript_code/project_library.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '67338e32-0121-44bd-98c2-2f8e6b299adf',
},
'Factory Functions and the Module Pattern' => {
Expand All @@ -50,7 +50,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/organizing_your_javascript_code/project_tic_tac_toe.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '47798979-cdc8-4c86-a70d-05ffb51d5aac',
},
'Classes' => {
Expand Down Expand Up @@ -80,7 +80,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/organizing_your_javascript_code/project_restaurant_page.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'a1453e8f-d4e8-44ce-b30e-552c65162ac6',
},
'OOP Principles' => {
Expand All @@ -96,7 +96,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/organizing_your_javascript_code/project_todo_list.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '5934b09a-ca38-4968-8df1-720456b7af9a',
},
'Linting' => {
Expand Down Expand Up @@ -161,7 +161,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/asynchronous_javascript_and_apis/project_weather_app.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '5212a020-85ed-4e43-84ec-6b583b57e8cb',
},
'A Very Brief Intro to CS' => {
Expand All @@ -184,7 +184,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/computer_science/project_recursion.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: 'eaf37749-a971-4bd4-af79-6e166e55346a',
},
'Time Complexity' => {
Expand Down Expand Up @@ -214,7 +214,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/computer_science/project_linked_lists.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: 'd2c7044f-8a4a-4740-a455-e6467bcea25d',
},
'Binary Search Trees' => {
Expand All @@ -223,7 +223,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/computer_science/project_binary_search_trees.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: '6932753f-ca06-458e-af92-1871eaf5e211',
},
'Knights Travails' => {
Expand All @@ -232,7 +232,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/computer_science/project_knights_travails.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: 'd4c45487-98b8-4da6-8159-b75f7681b994',
},
'Testing Basics' => {
Expand All @@ -248,7 +248,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/testing_javascript/project_testing_practice.md',
accepts_submission: true,
has_live_preview: false,
previewable: false,
identifier_uuid: '319ce38c-f68b-4bba-b9f7-25df452f0523',
},
'More Testing' => {
Expand All @@ -264,7 +264,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/testing_javascript/project_battleship.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '62702165-7705-47ba-a308-dd39c561e057',
},
"Where's Waldo (A Photo Tagging App) (OLD)" => {
Expand All @@ -273,7 +273,7 @@ def javascript_lessons
is_project: true,
github_path: '/javascript/javascript_and_the_backend/project_wheres_waldo_a_photo_tagging_app.md',
accepts_submission: false,
has_live_preview: false,
previewable: false,
identifier_uuid: '386dd44a-31dc-45dc-a535-cd5508365c86',
},
'Conclusion' => {
Expand Down
14 changes: 7 additions & 7 deletions db/fixtures/lessons/node_js_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/introduction_to_nodeJS/project_basic_informational_site.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'de746d83-dcce-48f0-a0ba-72d117d0ac05',
},
'Introduction to MongoDB' => {
Expand Down Expand Up @@ -64,7 +64,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/express_and_mongoose/project_mini_message_board.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '0270683a-d1e1-49f1-996e-ab721c251354',
},
'Deployment' => {
Expand Down Expand Up @@ -94,7 +94,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/express_and_mongoose/project_express_105_forms_and_deployment.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'de07c671-e8c7-47c0-88fe-219b66308bd4',
},
'Inventory Application' => {
Expand All @@ -103,7 +103,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/express_and_mongoose/project_inventory_application.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '5b7bcdb8-38d5-46ea-846b-c12bfb0290ef',
},
'Authentication Basics' => {
Expand All @@ -126,7 +126,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/authentication/project_members_only.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'dc36f70d-cc3b-47c5-958f-0c09ca61ca78',
},
'API Basics' => {
Expand All @@ -149,7 +149,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/apis/project_blog_api.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'ad8a46e7-a42b-420b-804d-afafb0c60d2c',
},
'Testing Routes and Controllers' => {
Expand All @@ -172,7 +172,7 @@ def node_js_lessons
is_project: true,
github_path: '/nodeJS/final_project/project_odin_book.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'c0d6ba51-620e-49e0-8583-924f38754874',
},
'Conclusion' => {
Expand Down
10 changes: 5 additions & 5 deletions db/fixtures/lessons/react_lessons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def react_lessons
is_project: true,
github_path: '/react/states_and_effects/project_cv_application.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: 'f3b5cee3-a255-4c72-8022-942cbddf0b86',
},
'How To Deal With Side Effects' => {
Expand All @@ -92,7 +92,7 @@ def react_lessons
is_project: true,
github_path: '/react/states_and_effects/project_memory_card.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '87bbed05-daf2-4c45-a549-fc9ecfa2657c',
},
'Class Based Components' => {
Expand Down Expand Up @@ -157,7 +157,7 @@ def react_lessons
is_project: true,
github_path: '/react/the_react_ecosystem/project_shopping_cart.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '60bb8597-19db-4d6f-9eca-059743206de5',
},
'Managing State With The Context API' => {
Expand Down Expand Up @@ -201,7 +201,7 @@ def react_lessons
is_project: true,
github_path: '/react/react_and_the_backend/project_wheres_waldo_a_photo_tagging_app.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '386dd44a-31dc-45dc-a535-cd5508365c86',
},
'Messaging App' => {
Expand All @@ -210,7 +210,7 @@ def react_lessons
is_project: true,
github_path: '/react/react_and_the_backend/project_messaging_app.md',
accepts_submission: true,
has_live_preview: true,
previewable: true,
identifier_uuid: '8e0206b5-e189-4ec3-b58b-c7f0afb84570',
},
'Conclusion' => {
Expand Down
Loading

0 comments on commit 6fd725d

Please sign in to comment.