Compare commits

...

2 Commits

Author SHA1 Message Date
Trevor Vallender 7b9f27815b Remove learning goals and their associated todos
/ test (push) Has been cancelled Details
2024-03-05 16:07:05 +00:00
Trevor Vallender 5281d2e972 No longer using devenv 2024-03-05 14:54:32 +00:00
39 changed files with 8 additions and 773 deletions

View File

@ -1,4 +1,4 @@
form#blog_post_form, form#learning_goal_form { form#blog_post_form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 55em; max-width: 55em;

View File

@ -1,26 +0,0 @@
.learning_goal {
margin: 1em auto;
padding: .5em;
background-color: var(--inset-background-color);
border: 1px solid var(--border-color);
> .created_at {
text-align: right;
font-size: .8em;
}
}
ul#learning_goals {
list-style-type: none;
}
ul.todos {
list-style-type: none;
}
ul.tags {
list-style-type: none;
> li {
display: inline;
}
}

View File

@ -1,44 +0,0 @@
form#blog_post_form, form#learning_goal_form, form#todo_form {
display: flex;
flex-direction: column;
max-width: 55em;
> h2 {
width: 100%;
}
> trix-toolbar {
max-width: 95%;
}
> trix-editor {
width: 95%;
> ul {
list-style-type: disc;
}
}
input[type=text] {
width: 95%;
}
> input[type=submit] {
width: 95%;
}
}
.blog_post {
margin: 1em auto;
padding: .5em;
background-color: var(--inset-background-color);
border: 1px solid var(--border-color);
> .created_at {
text-align: right;
font-size: .8em;
}
}
ul#blog_posts {
list-style-type: none;
}

View File

@ -1,62 +0,0 @@
# frozen_string_literal: true
class LearningGoalsController < ApplicationController
skip_before_action :require_login, only: [:index, :show]
before_action :set_learning_goal, only: [:show, :edit, :update, :destroy]
def index ; end
def new
@learning_goal = LearningGoal.new
end
def create
@learning_goal = LearningGoal.new(learning_goal_params)
@learning_goal.user = helpers.current_user
if @learning_goal.save
redirect_to @learning_goal, notice: t(".created")
else
render :new, status: :unprocessable_entity
end
end
def show ; end
def edit; end
def update
if @learning_goal.update(learning_goal_params)
redirect_to @learning_goal, notice: t(".updated")
else
render :edit, status: :unprocessable_entity
end
end
def destroy
if @learning_goal.destroy
redirect_to learning_goals_path, notice: t(".deleted")
else
render :edit, status: :unprocessable_entity
end
end
private
def learning_goal_params
params.require(:learning_goal).permit(
:title,
:starts_on,
:ends_on,
:description,
:retrospective,
:completed,
:user,
tag_ids: [],
)
end
def set_learning_goal
@learning_goal = LearningGoal.find(params[:id])
end
end

View File

@ -1,51 +0,0 @@
class TodosController < ApplicationController
before_action :set_todo, only: [:edit, :update, :destroy]
def new
@todo = Todo.new
end
def create
@todo = Todo.new(todo_params)
if @todo.save
redirect_to @todo.learning_goal, notice: t(".created")
else
render :new, status: :unprocessable_entity
end
end
def edit ; end
def update
if @todo.update(todo_params)
redirect_to @todo.learning_goal, notice: t(".updated")
else
render :edit, status: :unprocessable_entity
end
end
def destroy
learning_goal = @todo.learning_goal
if @todo.destroy
redirect_to learning_goal, notice: t(".deleted")
else
render :edit, status: :unprocessable_entity
end
end
private
def set_todo
@todo = Todo.find(params[:id])
end
def todo_params
params.require(:todo).permit(
:learning_goal_id,
:description,
:done,
:title,
:due,
)
end
end

View File

@ -1,5 +0,0 @@
module LearningGoalsHelper
def learning_goal_completed_text(learning_goal)
learning_goal.completed ? t(".completed") : t(".not_completed")
end
end

View File

@ -1,2 +0,0 @@
module TodosHelper
end

View File

@ -1,21 +0,0 @@
class LearningGoal < ApplicationRecord
belongs_to :user
has_many :todos
has_and_belongs_to_many :tags
accepts_nested_attributes_for :tags
has_rich_text :description
has_rich_text :retrospective
validates :completed, inclusion: { in: [true, false] }
validates :title, presence: true
scope :current, -> { where(starts_on: ..Date.today, ends_on: Date.today..) }
scope :past, -> { where(ends_on: ..Date.today) }
scope :future, -> { where(starts_on: Date.today..) }
def microposts
microposts = Micropost.none
tags.each { |tag| microposts = microposts.or(tag.microposts) }
microposts.uniq
end
end

View File

@ -4,7 +4,6 @@ class Tag < ApplicationRecord
validates :name, presence: true validates :name, presence: true
has_many :microposts_tags has_many :microposts_tags
has_many :microposts, through: :microposts_tags has_many :microposts, through: :microposts_tags
has_and_belongs_to_many :learning_goals
def to_param def to_param
name name

View File

@ -1,6 +0,0 @@
class Todo < ApplicationRecord
belongs_to :learning_goal
validates :done, inclusion: { in: [true, false] }
has_rich_text :description
has_one :user, through: :learning_goal
end

View File

@ -22,7 +22,6 @@
<li><%= link_to t(".microposts"), microposts_path %></li> <li><%= link_to t(".microposts"), microposts_path %></li>
<% if logged_in? %> <% if logged_in? %>
<li><%= link_to t(".diary_entries"), diary_entries_path %></li> <li><%= link_to t(".diary_entries"), diary_entries_path %></li>
<li><%= link_to t(".learning_goals"), learning_goals_path %></li>
<li><%= link_to t(".profile"), user_path(current_user) %></li> <li><%= link_to t(".profile"), user_path(current_user) %></li>
<li><%= link_to t(".log_out"), log_out_path, data: { turbo_method: :delete } %></li> <li><%= link_to t(".log_out"), log_out_path, data: { turbo_method: :delete } %></li>
<% end %> <% end %>

View File

@ -1,25 +0,0 @@
<%= form_with model: @learning_goal, id: "learning_goal_form" do |f| %>
<h2><%= title %></h2>
<%= f.text_field :title, placeholder: t(".title") %>
<%= f.rich_text_area :description %>
<%= f.label :starts_on %>
<%= f.date_field :starts_on %>
<%= f.label :ends_on %>
<%= f.date_field :ends_on %>
<%= f.rich_text_area :retrospective %>
<%= f.label :completed %>
<%= f.check_box :completed %>
<%= f.label :microposts_tag %>
<%= f.collection_check_boxes :tag_ids, Tag.all, :id, :name %>
<%= f.submit button_text %>
<% end %>

View File

@ -1,4 +0,0 @@
<div id="learning_goal_<%= learning_goal.id %>" class="learning_goal">
<h2><%= link_to learning_goal.title, learning_goal %></h2>
<%= learning_goal.description %>
</div>

View File

@ -1,10 +0,0 @@
<% @title = t(".edit") %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".edit"),
title: t(".edit"),
} %>
<%= link_to t(".delete"), @learning_goal, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>

View File

@ -1,25 +0,0 @@
<h2><%= t(".learning_goals") %></h2>
<%= link_to t(".new"), new_learning_goal_path if logged_in? %>
<%= link_to t(".new_todo"), new_todo_path if logged_in? %>
<h3><%= t(".current") %></h3>
<% if LearningGoal.current.any? %>
<%= render LearningGoal.current %>
<% else %>
<p><%= t(".no_current_goals") %></p>
<% end %>
<h3><%= t(".future") %></h3>
<% if LearningGoal.future.any? %>
<%= render LearningGoal.future %>
<% else %>
<p><%= t(".no_future_goals") %></p>
<% end %>
<h3><%= t(".past") %></h3>
<% if LearningGoal.past.any? %>
<%= render LearningGoal.past %>
<% else %>
<p><%= t(".no_past_goals") %></p>
<% end %>

View File

@ -1,8 +0,0 @@
<% @title = t(".create") %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".create"),
title: t(".create"),
} %>

View File

@ -1,28 +0,0 @@
<div id="learning_goal_<%= @learning_goal.id %>" class="learning_goal">
<%= link_to t(".edit"), edit_learning_goal_path(@learning_goal) if @learning_goal.user == current_user %>
<h2><%= @learning_goal.title %></h2>
<p><%= @learning_goal.starts_on %>-<%= @learning_goal.ends_on %></p>
<h3><%= t(".description") %></h3>
<p><%= @learning_goal.description %></p>
<% if @learning_goal.completed? %>
<h3><%= t(".retrospective") %></h3>
<p><%= @learning_goal.retrospective %></p>
<% end %>
<h3><%= t(".todos") %></h3>
<ul class="todos">
<% @learning_goal.todos.each do |todo| %>
<li><%= render todo %></li>
<% end %>
</ul>
<h3><%= t(".tags") %></h3>
<ul class="tags">
<% @learning_goal.tags.each do |tag| %>
<li><%= link_to tag.name, tag %></li>
<% end %>
</ul>
<h3><%= t(".related_microposts") %></h3>
<p><%= render @learning_goal.microposts %></p>
</div>

View File

@ -1,18 +0,0 @@
<%= form_with model: @todo, id: "todo_form" do |f| %>
<h2><%= title %></h2>
<%= f.text_field :title, placeholder: t(".title") %>
<%= f.label :learning_goal %>
<%= f.collection_select :learning_goal_id, LearningGoal.all, :id, :title %>
<%= f.rich_text_area :description %>
<%= f.label :due %>
<%= f.date_field :due %>
<%= f.label :done %>
<%= f.check_box :done %>
<%= f.submit button_text %>
<% end %>

View File

@ -1,10 +0,0 @@
<input type="checkbox" class="todo" disabled
<% if todo.done? %>
checked
<% end %>>
<%= todo.title %>
<% if todo.user == current_user %>
<%= link_to t(".edit"), edit_todo_path(todo) %>
<%= link_to t(".delete"), todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
<% end %>
<%= todo.description %>

View File

@ -1,10 +0,0 @@
<% @title = t(".edit") %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".edit"),
title: t(".edit"),
} %>
<%= link_to t(".delete"), @todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>

View File

@ -1,8 +0,0 @@
<% @title = t(".create") %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".create"),
title: t(".create"),
} %>

View File

@ -1,5 +0,0 @@
en:
learning_goals:
created: Successfully created learning goal
updated: Successfully updated learning goal
deleted: Successfully deleted learning goal

View File

@ -1,5 +0,0 @@
en:
todos:
created: Successfully created todo
updated: Successfully updated todo
deleted: Successfully deleted todo

View File

@ -10,4 +10,3 @@ en:
blog_posts: Blog blog_posts: Blog
microposts: μposts microposts: μposts
diary_entries: Diary diary_entries: Diary
learning_goals: Learning Goals

View File

@ -1,29 +0,0 @@
en:
learning_goals:
index:
learning_goals: Learning Goals
new: New learning goal
new_todo: New todo
current: Current
future: Future
past: Past
no_current_goals: You have no current goals
no_future_goals: You have no future goals
no_past_goals: You have no past goals
new:
create: Create learning goal
edit:
edit: Edit learning goal
delete: Delete learning goal
confirm: Are you sure you want to delete this learning goal?
form:
title: Title
show:
completed: Learning goal is complete
not_completed: Learning goal is incomplete
edit: Edit
description: Description
retrospective: Retrospective
tags: Tags
todos: Todos
related_microposts: Related μposts

View File

@ -1,14 +0,0 @@
en:
todos:
new:
create: Create todo
edit:
edit: Edit todo
delete: Delete todo
confirm: Are you sure you want to delete this todo?
form:
title: Title
todo:
edit: Edit
delete: Delete
confirm: Are you sure you want to delete this todo?

View File

@ -13,10 +13,8 @@ Rails.application.routes.draw do
get "confirm_email", to: "email_confirmations#confirm" get "confirm_email", to: "email_confirmations#confirm"
resources :blog_posts resources :blog_posts
resources :learning_goals
resources :microposts resources :microposts
resources :tags, only: [:index, :show] resources :tags, only: [:index, :show]
resources :todos, only: [:new, :create, :edit, :update, :destroy]
resources :diary_entries, except: [:destroy] resources :diary_entries, except: [:destroy]
get "up" => "rails/health#show", as: :rails_health_check get "up" => "rails/health#show", as: :rails_health_check

View File

@ -0,0 +1,6 @@
class RemoveLearningGoals < ActiveRecord::Migration[7.1]
def change
drop_table :todos
drop_table :learning_goals
end
end

25
db/schema.rb generated
View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_01_26_101316) do ActiveRecord::Schema[7.1].define(version: 2024_03_05_160037) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -105,17 +105,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_101316) do
t.index ["name"], name: "index_feature_flags_on_name", unique: true t.index ["name"], name: "index_feature_flags_on_name", unique: true
end end
create_table "learning_goals", force: :cascade do |t|
t.string "title", null: false
t.date "starts_on"
t.date "ends_on"
t.boolean "completed", default: false, null: false
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_learning_goals_on_user_id"
end
create_table "learning_goals_tags", id: false, force: :cascade do |t| create_table "learning_goals_tags", id: false, force: :cascade do |t|
t.bigint "learning_goal_id", null: false t.bigint "learning_goal_id", null: false
t.bigint "tag_id", null: false t.bigint "tag_id", null: false
@ -148,16 +137,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_101316) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
create_table "todos", force: :cascade do |t|
t.bigint "learning_goal_id", null: false
t.boolean "done", default: false, null: false
t.string "title", default: "", null: false
t.date "due"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["learning_goal_id"], name: "index_todos_on_learning_goal_id"
end
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "username", null: false t.string "username", null: false
t.string "password_digest", null: false t.string "password_digest", null: false
@ -177,7 +156,5 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_101316) do
add_foreign_key "diary_entries", "users" add_foreign_key "diary_entries", "users"
add_foreign_key "exercises", "diary_entries" add_foreign_key "exercises", "diary_entries"
add_foreign_key "exercises", "exercise_types" add_foreign_key "exercises", "exercise_types"
add_foreign_key "learning_goals", "users"
add_foreign_key "microposts", "users" add_foreign_key "microposts", "users"
add_foreign_key "todos", "learning_goals"
end end

View File

@ -1,228 +0,0 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1697058441,
"narHash": "sha256-gjtW+nkM9suMsjyid63HPmt6WZQEvuVqA5cOAf4lLM0=",
"owner": "cachix",
"repo": "devenv",
"rev": "55294461a62d90c8626feca22f52b0d3d0e18e39",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1697009197,
"narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-ruby": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1695879717,
"narHash": "sha256-r7q/6XOYptP1TbPR09p2olGKJEa9DKqsMCX5o6Myrtk=",
"owner": "bobvanderlinden",
"repo": "nixpkgs-ruby",
"rev": "a8612cd33ac2944cae93894bd0077e30c6b0f6e9",
"type": "github"
},
"original": {
"owner": "bobvanderlinden",
"repo": "nixpkgs-ruby",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1696846637,
"narHash": "sha256-0hv4kbXxci2+pxhuXlVgftj/Jq79VSmtAyvfabCCtYk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "42e1b6095ef80a51f79595d9951eb38e91c4e6ca",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"nixpkgs-ruby": "nixpkgs-ruby",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,39 +0,0 @@
{ pkgs, nixpkgs-ruby, ... }:
{
# Set environment variables
env = {
APPLICATION_HOST = "localhost:3000";
DB_HOST = "localhost";
PSQLPAGER = "pspg";
};
# Packages to install
packages = with pkgs; [
git
pspg
openssl
libyaml
];
languages.ruby.enable = true;
languages.ruby.versionFile = ./.ruby-version;
services.postgres = {
enable = true;
listen_addresses = "127.0.0.1";
initialScript = ''
CREATE ROLE soc WITH LOGIN PASSWORD 'postgres' SUPERUSER;
'';
};
scripts = {
prodshell.exec = ''
kamal app exec -i --reuse bash
'';
};
services.mailhog = {
enable = true;
};
}

View File

@ -1,8 +0,0 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
nixpkgs-ruby:
url: github:bobvanderlinden/nixpkgs-ruby
inputs:
nixpkgs:
follows: nixpkgs

View File

@ -1,7 +0,0 @@
require "test_helper"
class LearningGoalsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

View File

@ -1,7 +0,0 @@
require "test_helper"
class TodosControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

View File

@ -10,7 +10,3 @@ draft_blog_post:
record: draft (BlogPost) record: draft (BlogPost)
name: content name: content
body: <p>Just some text</p> body: <p>Just some text</p>
learning_goal_one:
record: linux (LearningGoal)
name: content
body: <p>Learning about Linux</p>

View File

@ -1,13 +0,0 @@
sql:
title: SQL
starts_on: 2024-01-06
ends_on: 2024-06-06
completed: false
user: trevor
linux:
title: Linux
starts_on: 2023-03-06
ends_on: 2023-06-06
completed: true
user: trevor

View File

@ -1,10 +0,0 @@
one:
learning_goal: sql
done: false
title: Read SQL for Mere Mortals
due: <%= 3.years.from_now %>
two:
learning_goal: linux
done: true
title: Install Debian

View File

@ -1,4 +0,0 @@
require "test_helper"
class LearningGoalTest < ActiveSupport::TestCase
end

View File

@ -1,7 +0,0 @@
require "test_helper"
class TodoTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end