From 4e579e5a34a73701a2806546701489fc6091fb0e Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Tue, 24 Sep 2024 15:32:44 -0400 Subject: [PATCH] Rename Project to Bucket --- .../stylesheets/{projects.css => buckets.css} | 4 +- app/controllers/assignments_controller.rb | 6 +-- app/controllers/boosts_controller.rb | 2 +- app/controllers/bubbles/images_controller.rb | 4 +- app/controllers/bubbles_controller.rb | 16 ++++---- .../buckets/accesses_controller.rb | 17 +++++++++ app/controllers/buckets_controller.rb | 38 +++++++++++++++++++ app/controllers/comments_controller.rb | 4 +- app/controllers/concerns/bubble_scoped.rb | 2 +- app/controllers/concerns/bucket_scoped.rb | 12 ++++++ app/controllers/concerns/project_scoped.rb | 12 ------ .../projects/accesses_controller.rb | 17 --------- app/controllers/projects_controller.rb | 38 ------------------- app/controllers/tags_controller.rb | 8 ++-- app/helpers/buckets_helper.rb | 2 + app/helpers/projects_helper.rb | 2 - app/models/access.rb | 2 +- app/models/account.rb | 4 +- app/models/bubble.rb | 2 +- app/models/{project.rb => bucket.rb} | 2 +- app/models/{project => bucket}/accessible.rb | 2 +- app/models/user.rb | 4 +- app/views/boosts/_boosts.html.erb | 2 +- app/views/bubbles/_assignments.html.erb | 2 +- app/views/bubbles/_bubble.html.erb | 4 +- app/views/bubbles/_color.html.erb | 2 +- app/views/bubbles/_date.html.erb | 2 +- app/views/bubbles/_image.html.erb | 4 +- app/views/bubbles/_tags.html.erb | 4 +- app/views/bubbles/edit.html.erb | 4 +- app/views/bubbles/index.html.erb | 14 +++---- app/views/bubbles/list/_bubble.html.erb | 4 +- app/views/bubbles/show.html.erb | 2 +- app/views/buckets/accesses/edit.html.erb | 14 +++++++ app/views/{projects => buckets}/edit.html.erb | 4 +- .../{projects => buckets}/index.html.erb | 20 +++++----- app/views/buckets/new.html.erb | 8 ++++ app/views/comments/_comment.html.erb | 2 +- app/views/comments/_new.html.erb | 2 +- app/views/projects/accesses/edit.html.erb | 14 ------- app/views/projects/new.html.erb | 8 ---- app/views/tags/new.html.erb | 2 +- config/routes.rb | 6 +-- ...20240924191654_rename_project_to_bucket.rb | 8 ++++ db/schema.rb | 32 ++++++++-------- ...ler_test.rb => buckets_controller_test.rb} | 2 +- test/fixtures/accesses.yml | 6 +-- test/fixtures/bubbles.yml | 6 +-- test/fixtures/{projects.yml => buckets.yml} | 0 .../{project_test.rb => bucket_test.rb} | 2 +- 50 files changed, 194 insertions(+), 186 deletions(-) rename app/assets/stylesheets/{projects.css => buckets.css} (93%) create mode 100644 app/controllers/buckets/accesses_controller.rb create mode 100644 app/controllers/buckets_controller.rb create mode 100644 app/controllers/concerns/bucket_scoped.rb delete mode 100644 app/controllers/concerns/project_scoped.rb delete mode 100644 app/controllers/projects/accesses_controller.rb delete mode 100644 app/controllers/projects_controller.rb create mode 100644 app/helpers/buckets_helper.rb delete mode 100644 app/helpers/projects_helper.rb rename app/models/{project.rb => bucket.rb} (82%) rename app/models/{project => bucket}/accessible.rb (94%) create mode 100644 app/views/buckets/accesses/edit.html.erb rename app/views/{projects => buckets}/edit.html.erb (55%) rename app/views/{projects => buckets}/index.html.erb (53%) create mode 100644 app/views/buckets/new.html.erb delete mode 100644 app/views/projects/accesses/edit.html.erb delete mode 100644 app/views/projects/new.html.erb create mode 100644 db/migrate/20240924191654_rename_project_to_bucket.rb rename test/controllers/{projects_controller_test.rb => buckets_controller_test.rb} (55%) rename test/fixtures/{projects.yml => buckets.yml} (100%) rename test/models/{project_test.rb => bucket_test.rb} (63%) diff --git a/app/assets/stylesheets/projects.css b/app/assets/stylesheets/buckets.css similarity index 93% rename from app/assets/stylesheets/projects.css rename to app/assets/stylesheets/buckets.css index 5dab0c184..fc73a98a1 100644 --- a/app/assets/stylesheets/projects.css +++ b/app/assets/stylesheets/buckets.css @@ -1,4 +1,4 @@ -.projects { +.buckets { --gap: 2cqi; --hover-size: 0; --column-gap: var(--gap); @@ -8,7 +8,7 @@ padding: var(--gap); } -.project__windshield { +.bucket__windshield { --border-radius: 1.5em; margin-block: 0; diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 77b742618..96c213ded 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -1,16 +1,16 @@ class AssignmentsController < ApplicationController - include BubbleScoped, ProjectScoped + include BubbleScoped, BucketScoped before_action :set_assignment, only: :update def create @assignment = @bubble.assignments.create!(assignment_params) - redirect_to project_bubble_url(@project, @bubble) + redirect_to bucket_bubble_url(@bucket, @bubble) end def update @assignment.update!(assignment_params) - redirect_to project_bubble_url(@project, @bubble) + redirect_to bucket_bubble_url(@bucket, @bubble) end private diff --git a/app/controllers/boosts_controller.rb b/app/controllers/boosts_controller.rb index 5cd02388f..166b7e634 100644 --- a/app/controllers/boosts_controller.rb +++ b/app/controllers/boosts_controller.rb @@ -1,5 +1,5 @@ class BoostsController < ApplicationController - include BubbleScoped, ProjectScoped + include BubbleScoped, BucketScoped def create @bubble.boosts.create! diff --git a/app/controllers/bubbles/images_controller.rb b/app/controllers/bubbles/images_controller.rb index d77902dec..5342dfcf1 100644 --- a/app/controllers/bubbles/images_controller.rb +++ b/app/controllers/bubbles/images_controller.rb @@ -1,8 +1,8 @@ class Bubbles::ImagesController < ApplicationController - include BubbleScoped, ProjectScoped + include BubbleScoped, BucketScoped def destroy @bubble.image.purge_later - redirect_to project_bubble_url(@bubble.project, @bubble) + redirect_to bucket_bubble_url(@bubble.bucket, @bubble) end end diff --git a/app/controllers/bubbles_controller.rb b/app/controllers/bubbles_controller.rb index e1d992064..31cb98787 100644 --- a/app/controllers/bubbles_controller.rb +++ b/app/controllers/bubbles_controller.rb @@ -1,5 +1,5 @@ class BubblesController < ApplicationController - include ProjectScoped + include BucketScoped before_action :set_bubble, only: %i[ show edit update ] @@ -9,18 +9,18 @@ class BubblesController < ApplicationController @bubbles = @tag.bubbles @most_active_bubbles = @tag.bubbles.left_joins(:comments, :boosts).group(:id).order(Arel.sql("COUNT(comments.id) + COUNT(boosts.id) DESC")).limit(10) else - @bubbles = @project.bubbles.order(created_at: :desc) - @most_active_bubbles = @project.bubbles.left_joins(:comments, :boosts).group(:id).order(Arel.sql("COUNT(comments.id) + COUNT(boosts.id) DESC")).limit(10) + @bubbles = @bucket.bubbles.order(created_at: :desc) + @most_active_bubbles = @bucket.bubbles.left_joins(:comments, :boosts).group(:id).order(Arel.sql("COUNT(comments.id) + COUNT(boosts.id) DESC")).limit(10) end end def new - @bubble = @project.bubbles.build + @bubble = @bucket.bubbles.build end def create - @bubble = @project.bubbles.create!(bubble_params) - redirect_to project_bubble_url(@project, @bubble) + @bubble = @bucket.bubbles.create!(bubble_params) + redirect_to bucket_bubble_url(@bucket, @bubble) end def show @@ -31,13 +31,13 @@ class BubblesController < ApplicationController def update @bubble.update!(bubble_params) - redirect_to project_bubble_url(@project, @bubble) + redirect_to bucket_bubble_url(@bucket, @bubble) end private def set_bubble - @bubble = @project.bubbles.find(params[:id]) + @bubble = @bucket.bubbles.find(params[:id]) end def bubble_params diff --git a/app/controllers/buckets/accesses_controller.rb b/app/controllers/buckets/accesses_controller.rb new file mode 100644 index 000000000..9421e5ba4 --- /dev/null +++ b/app/controllers/buckets/accesses_controller.rb @@ -0,0 +1,17 @@ +class Buckets::AccessesController < ApplicationController + include BucketScoped + + def edit + @users = @bucket.users + end + + def update + @bucket.update_access [ Current.user, *find_users ] + redirect_to edit_bucket_access_url(@bucket) + end + + private + def find_users + Current.account.users.active.where(id: params[:user_ids]) + end +end diff --git a/app/controllers/buckets_controller.rb b/app/controllers/buckets_controller.rb new file mode 100644 index 000000000..bc6ffe8c7 --- /dev/null +++ b/app/controllers/buckets_controller.rb @@ -0,0 +1,38 @@ +class BucketsController < ApplicationController + before_action :set_bucket, except: %i[ index new create ] + + def index + @buckets = Current.user.buckets.all + end + + def new + @bucket = Current.account.buckets.build + end + + def create + @bucket = Current.account.buckets.create!(bucket_params) + redirect_to bucket_bubbles_url(@bucket) + end + + def edit + end + + def update + @bucket.update!(bucket_params) + redirect_to bucket_bubbles_url(@bucket) + end + + def destroy + @bucket.destroy + redirect_to buckets_url + end + + private + def set_bucket + @bucket = Current.user.buckets.find(params[:id]) + end + + def bucket_params + params.require(:bucket).permit(:name) + end +end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c0e2f4fd5..3a6a650ac 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,9 +1,9 @@ class CommentsController < ApplicationController - include BubbleScoped, ProjectScoped + include BubbleScoped, BucketScoped def create @bubble.comments.create!(comment_params) - redirect_to project_bubble_url(@project, @bubble) + redirect_to bucket_bubble_url(@bucket, @bubble) end private diff --git a/app/controllers/concerns/bubble_scoped.rb b/app/controllers/concerns/bubble_scoped.rb index db7798cc3..bf123910c 100644 --- a/app/controllers/concerns/bubble_scoped.rb +++ b/app/controllers/concerns/bubble_scoped.rb @@ -7,6 +7,6 @@ module BubbleScoped private def set_bubble - @bubble = @project.bubbles.find(params[:bubble_id]) + @bubble = @bucket.bubbles.find(params[:bubble_id]) end end diff --git a/app/controllers/concerns/bucket_scoped.rb b/app/controllers/concerns/bucket_scoped.rb new file mode 100644 index 000000000..c0dd1176f --- /dev/null +++ b/app/controllers/concerns/bucket_scoped.rb @@ -0,0 +1,12 @@ +module BucketScoped + extend ActiveSupport::Concern + + included do + before_action :set_bucket + end + + private + def set_bucket + @bucket = Current.user.buckets.find(params[:bucket_id]) + end +end diff --git a/app/controllers/concerns/project_scoped.rb b/app/controllers/concerns/project_scoped.rb deleted file mode 100644 index fefceecec..000000000 --- a/app/controllers/concerns/project_scoped.rb +++ /dev/null @@ -1,12 +0,0 @@ -module ProjectScoped - extend ActiveSupport::Concern - - included do - before_action :set_project - end - - private - def set_project - @project = Current.user.projects.find(params[:project_id]) - end -end diff --git a/app/controllers/projects/accesses_controller.rb b/app/controllers/projects/accesses_controller.rb deleted file mode 100644 index 19d43b778..000000000 --- a/app/controllers/projects/accesses_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Projects::AccessesController < ApplicationController - include ProjectScoped - - def edit - @users = @project.users - end - - def update - @project.update_access [ Current.user, *find_users ] - redirect_to edit_project_access_url(@project) - end - - private - def find_users - Current.account.users.active.where(id: params[:user_ids]) - end -end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb deleted file mode 100644 index 1f6371fc1..000000000 --- a/app/controllers/projects_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -class ProjectsController < ApplicationController - before_action :set_project, except: %i[ index new create ] - - def index - @projects = Current.user.projects.all - end - - def new - @project = Current.account.projects.build - end - - def create - @project = Current.account.projects.create!(project_params) - redirect_to project_bubbles_url(@project) - end - - def edit - end - - def update - @project.update!(project_params) - redirect_to project_bubbles_url(@project) - end - - def destroy - @project.destroy - redirect_to projects_url - end - - private - def set_project - @project = Current.user.projects.find(params[:id]) - end - - def project_params - params.require(:project).permit(:name) - end -end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 1e0e7eb80..ba145b365 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,5 @@ class TagsController < ApplicationController - include ProjectScoped + include BucketScoped before_action :set_bubble, only: %i[ new create ] before_action :set_tag, only: :destroy @@ -13,12 +13,12 @@ class TagsController < ApplicationController def create @bubble.tags << Tag.find_or_create_by!(tag_params) - redirect_to project_bubble_url(@project, @bubble) + redirect_to bucket_bubble_url(@bucket, @bubble) end def destroy @tag.destroy - redirect_to project_tags_url(@project) + redirect_to bucket_tags_url(@bucket) end private @@ -31,6 +31,6 @@ class TagsController < ApplicationController end def set_bubble - @bubble = @project.bubbles.find(params[:bubble_id]) + @bubble = @bucket.bubbles.find(params[:bubble_id]) end end diff --git a/app/helpers/buckets_helper.rb b/app/helpers/buckets_helper.rb new file mode 100644 index 000000000..f75862f00 --- /dev/null +++ b/app/helpers/buckets_helper.rb @@ -0,0 +1,2 @@ +module BucketsHelper +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb deleted file mode 100644 index db5c5ce1a..000000000 --- a/app/helpers/projects_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ProjectsHelper -end diff --git a/app/models/access.rb b/app/models/access.rb index 014c5caee..dbbb11590 100644 --- a/app/models/access.rb +++ b/app/models/access.rb @@ -1,4 +1,4 @@ class Access < ApplicationRecord - belongs_to :project + belongs_to :bucket belongs_to :user end diff --git a/app/models/account.rb b/app/models/account.rb index 623862de8..a0b8c8bd4 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,6 +3,6 @@ class Account < ApplicationRecord has_many :users, dependent: :destroy - has_many :projects, dependent: :destroy - has_many :bubbles, through: :projects + has_many :buckets, dependent: :destroy + has_many :bubbles, through: :buckets end diff --git a/app/models/bubble.rb b/app/models/bubble.rb index 27dd5bceb..759a8317c 100644 --- a/app/models/bubble.rb +++ b/app/models/bubble.rb @@ -1,7 +1,7 @@ class Bubble < ApplicationRecord include Colored - belongs_to :project + belongs_to :bucket belongs_to :creator, class_name: "User", default: -> { Current.user } has_many :comments, dependent: :destroy diff --git a/app/models/project.rb b/app/models/bucket.rb similarity index 82% rename from app/models/project.rb rename to app/models/bucket.rb index dc90aa588..9a53a54c3 100644 --- a/app/models/project.rb +++ b/app/models/bucket.rb @@ -1,4 +1,4 @@ -class Project < ApplicationRecord +class Bucket < ApplicationRecord include Accessible belongs_to :account diff --git a/app/models/project/accessible.rb b/app/models/bucket/accessible.rb similarity index 94% rename from app/models/project/accessible.rb rename to app/models/bucket/accessible.rb index 394edae35..4b4e7c031 100644 --- a/app/models/project/accessible.rb +++ b/app/models/bucket/accessible.rb @@ -1,4 +1,4 @@ -module Project::Accessible +module Bucket::Accessible extend ActiveSupport::Concern included do diff --git a/app/models/user.rb b/app/models/user.rb index 2bc00913e..71544ca4a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,8 +5,8 @@ class User < ApplicationRecord has_secure_password validations: false has_many :accesses, dependent: :destroy - has_many :projects, through: :accesses - has_many :bubbles, through: :projects + has_many :buckets, through: :accesses + has_many :bubbles, through: :buckets has_many :assignments has_many :assigned_bubbles, through: :assignments, source: :bubble diff --git a/app/views/boosts/_boosts.html.erb b/app/views/boosts/_boosts.html.erb index f3ea7092a..1e2b1998b 100644 --- a/app/views/boosts/_boosts.html.erb +++ b/app/views/boosts/_boosts.html.erb @@ -1,4 +1,4 @@ -<%= button_to project_bubble_boosts_path(bubble.project, bubble), +<%= button_to bucket_bubble_boosts_path(bubble.bucket, bubble), class: "btn btn--plain", data: { action: "toggle-class#toggle" }, form_class: "full-width" do %> diff --git a/app/views/bubbles/_assignments.html.erb b/app/views/bubbles/_assignments.html.erb index 65f923f3a..f156844a5 100644 --- a/app/views/bubbles/_assignments.html.erb +++ b/app/views/bubbles/_assignments.html.erb @@ -1,5 +1,5 @@ "> - <%= form_with model: Assignment.new, url: project_bubble_assignments_path(bubble.project, bubble), data: { controller: "form" } do |form| %> + <%= form_with model: Assignment.new, url: bucket_bubble_assignments_path(bubble.bucket, bubble), data: { controller: "form" } do |form| %>