mirror of
https://github.com/System-End/highway.git
synced 2026-04-20 00:25:16 +00:00
Partially add projects
This commit is contained in:
parent
648199a2fe
commit
b4e7464c07
11 changed files with 162 additions and 1 deletions
48
site/app/controllers/projects_controller.rb
Normal file
48
site/app/controllers/projects_controller.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
class ProjectsController < ApplicationController
|
||||
before_action :set_project, only: %i[ show edit update ]
|
||||
before_action :require_authentication, only: [:show, :edit, :update]
|
||||
|
||||
|
||||
def index
|
||||
@projects = Project.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@project = Project.new
|
||||
end
|
||||
|
||||
def create
|
||||
# @project = project.new(project_params)
|
||||
# if @project.save
|
||||
# redirect_to @project
|
||||
# else
|
||||
# render :new, status: :unprocessable_entity
|
||||
# end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @project.update(project_params)
|
||||
redirect_to @project, notice: "Project was successfully updated."
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_project
|
||||
@project = Project.find(params[:id])
|
||||
end
|
||||
|
||||
def project_params
|
||||
params.expect(project: [ :github_repo, :kitted_guide, :proposed_tier, :proposed_tier_explanation, :group_project ])
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
2
site/app/models/project.rb
Normal file
2
site/app/models/project.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class Project < ApplicationRecord
|
||||
end
|
||||
2
site/app/views/projects/index.html.erb
Normal file
2
site/app/views/projects/index.html.erb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<%= link_to "Create new project", new_project_path, class: "opacity-70 hover:opacity-100 transition duration-100" %>
|
||||
|
||||
55
site/app/views/projects/new.html.erb
Normal file
55
site/app/views/projects/new.html.erb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<div class="bg-[#3A5CE1] rounded-md border-2 border-[#96ABF9] p-8 mx-24 mt-24">
|
||||
|
||||
<div class="opacity-70 hover:opacity-100 transition duration-100"><%= link_to "← back", projects_path %></div>
|
||||
|
||||
<h1 class="text-3xl font-bold">Make a new project!</h1>
|
||||
|
||||
<%= form_with model: @project do |form|%>
|
||||
<div class="">
|
||||
|
||||
<div class="mt-4">
|
||||
<%= form.label :github_repo %>
|
||||
<div class="">
|
||||
<%= form.url_field :github_repo, class: "bg-[#B8DCFC] text-black border border-gray-300 p-2 rounded w-[400px]" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<%= form.label :proposed_tier %>
|
||||
<div class="">
|
||||
<%= form.select :proposed_tier, [["Tier 1", "Tier 1"], ["Tier 2", "Tier 2"], ["Tier 3", "Tier 3"]], {}, class: "bg-[#B8DCFC] text-black border border-gray-300 p-2 rounded w-[400px]" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-4">
|
||||
<%= form.label :proposed_tier_explanation, class: "block" %>
|
||||
<%= form.rich_text_area :proposed_tier_explanation, class: "bg-[#B8DCFC] text-black border border-gray-300 p-2 rounded" %>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="flex flex-row gap-4 items-center">
|
||||
<%= form.check_box :group_project, { style: "width: 26px; height: 26px; flex-shrink: 0;" }, "true", "false" %>
|
||||
<%= form.label :group_project, "Is this a group project? You’re allowed to work with 1 other person! Both people must do technical work.", class: "block" %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @project.errors.any? %>
|
||||
<div class="bg-red-100 text-red-700 p-4 rounded mb-4">
|
||||
<h2><%= pluralize(@project.errors.count, "thing") %> you need to fix before projecting!</h2>
|
||||
<ul>
|
||||
<% @project.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="mt-8">
|
||||
<%= form.submit "Submit", class: "bg-[#62D5C3] text-[#3A5CE1] px-4 py-2 rounded cursor-pointer hover:opacity-100 opacity-80" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<div class="text-center grid grid-cols-1 gap-2 text-xl font-dystopian">
|
||||
<%= link_to "Main", posts_path, class: "#{current_page?(posts_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>
|
||||
<%= link_to "Projects", projects_path, class: "#{current_page?(projects_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>
|
||||
<%= link_to "Leaderboards", root_path, class: "#{current_page?(root_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>
|
||||
<%= link_to "Info", info_path, class: "#{current_page?(info_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ Rails.application.routes.draw do
|
|||
root "landing#index"
|
||||
resources :posts
|
||||
resources :users
|
||||
resources :projects
|
||||
|
||||
get "/info", to: "info#show"
|
||||
|
||||
|
|
|
|||
13
site/db/migrate/20250505014600_create_projects.rb
Normal file
13
site/db/migrate/20250505014600_create_projects.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class CreateProjects < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :projects do |t|
|
||||
t.string :kitted_guide
|
||||
t.string :github_repo
|
||||
t.string :proposed_tier
|
||||
t.string :proposed_tier_explanation
|
||||
t.boolean :group_project
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
12
site/db/schema.rb
generated
12
site/db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_04_204551) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_05_014600) do
|
||||
create_table "action_text_rich_texts", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "body"
|
||||
|
|
@ -58,6 +58,16 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_04_204551) do
|
|||
t.index ["user_id"], name: "index_posts_on_user_id"
|
||||
end
|
||||
|
||||
create_table "projects", force: :cascade do |t|
|
||||
t.string "kitted_guide"
|
||||
t.string "github_repo"
|
||||
t.string "proposed_tier"
|
||||
t.string "proposed_tier_explanation"
|
||||
t.boolean "group_project"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email"
|
||||
t.string "login_code"
|
||||
|
|
|
|||
7
site/test/controllers/projects_controller_test.rb
Normal file
7
site/test/controllers/projects_controller_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class ProjectsControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
15
site/test/fixtures/projects.yml
vendored
Normal file
15
site/test/fixtures/projects.yml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
kitted_guide: MyString
|
||||
github_repo: MyString
|
||||
proposed_tier: MyString
|
||||
proposed_tier_explanation: MyString
|
||||
group_project: false
|
||||
|
||||
two:
|
||||
kitted_guide: MyString
|
||||
github_repo: MyString
|
||||
proposed_tier: MyString
|
||||
proposed_tier_explanation: MyString
|
||||
group_project: false
|
||||
7
site/test/models/project_test.rb
Normal file
7
site/test/models/project_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class ProjectTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue