From 9579cb6d93af19c43433c9684e6acd141d1ef68a Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Fri, 21 Jun 2024 20:23:31 -0500 Subject: [PATCH 01/18] Generated package --- Gemfile.lock | 4 + app/controllers/packages_controller.rb | 62 ++++++++ app/models/package.rb | 15 ++ app/views/packages/index.html.erb | 150 +++++++++++++++++++ app/views/packages/show.html.erb | 131 ++++++++++++++++ config/routes.rb | 21 ++- db/development.sqlite3 | Bin 20480 -> 28672 bytes db/migrate/20240622012201_create_packages.rb | 13 ++ db/schema.rb | 12 +- 9 files changed, 406 insertions(+), 2 deletions(-) create mode 100644 app/controllers/packages_controller.rb create mode 100644 app/models/package.rb create mode 100644 app/views/packages/index.html.erb create mode 100644 app/views/packages/show.html.erb create mode 100644 db/migrate/20240622012201_create_packages.rb diff --git a/Gemfile.lock b/Gemfile.lock index 10034745..6e05e9db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -219,6 +219,8 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) + nokogiri (1.15.5-arm64-darwin) + racc (~> 1.4) nokogiri (1.15.5-x86_64-darwin) racc (~> 1.4) nokogiri (1.15.5-x86_64-linux) @@ -347,6 +349,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sqlite3 (1.6.8-arm64-darwin) sqlite3 (1.6.8-x86_64-darwin) sqlite3 (1.6.8-x86_64-linux) stimulus-rails (1.2.2) @@ -404,6 +407,7 @@ GEM zeitwerk (2.6.12) PLATFORMS + arm64-darwin-21 x86_64-darwin-22 x86_64-linux diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb new file mode 100644 index 00000000..e29638f2 --- /dev/null +++ b/app/controllers/packages_controller.rb @@ -0,0 +1,62 @@ +class PackagesController < ApplicationController + def index + matching_packages = Package.all + + @list_of_packages = matching_packages.order({ :created_at => :desc }) + + render({ :template => "packages/index" }) + end + + def show + the_id = params.fetch("path_id") + + matching_packages = Package.where({ :id => the_id }) + + @the_package = matching_packages.at(0) + + render({ :template => "packages/show" }) + end + + def create + the_package = Package.new + the_package.description = params.fetch("query_description") + the_package.supposed_to_arrive = params.fetch("query_supposed_to_arrive") + the_package.actual_arrive = params.fetch("query_actual_arrive") + the_package.details = params.fetch("query_details") + the_package.user_id = params.fetch("query_user_id") + + if the_package.valid? + the_package.save + redirect_to("/packages", { :notice => "Package created successfully." }) + else + redirect_to("/packages", { :alert => the_package.errors.full_messages.to_sentence }) + end + end + + def update + the_id = params.fetch("path_id") + the_package = Package.where({ :id => the_id }).at(0) + + the_package.description = params.fetch("query_description") + the_package.supposed_to_arrive = params.fetch("query_supposed_to_arrive") + the_package.actual_arrive = params.fetch("query_actual_arrive") + the_package.details = params.fetch("query_details") + the_package.user_id = params.fetch("query_user_id") + + if the_package.valid? + the_package.save + redirect_to("/packages/#{the_package.id}", { :notice => "Package updated successfully."} ) + else + redirect_to("/packages/#{the_package.id}", { :alert => the_package.errors.full_messages.to_sentence }) + end + end + + def destroy + the_id = params.fetch("path_id") + the_package = Package.where({ :id => the_id }).at(0) + + the_package.destroy + + redirect_to("/packages", { :notice => "Package deleted successfully."} ) + end +end diff --git a/app/models/package.rb b/app/models/package.rb new file mode 100644 index 00000000..e30f4af2 --- /dev/null +++ b/app/models/package.rb @@ -0,0 +1,15 @@ +# == Schema Information +# +# Table name: packages +# +# id :integer not null, primary key +# actual_arrive :date +# description :string +# details :text +# supposed_to_arrive :date +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer +# +class Package < ApplicationRecord +end diff --git a/app/views/packages/index.html.erb b/app/views/packages/index.html.erb new file mode 100644 index 00000000..abefb8c4 --- /dev/null +++ b/app/views/packages/index.html.erb @@ -0,0 +1,150 @@ +
+
+

+ List of all packages +

+
+
+ +
+ +
+
+

+ Add a new package +

+ +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + <% @list_of_packages.each do |a_package| %> + + + + + + + + + + + + + + + + + + + <% end %> +
+ ID + + Description + + Supposed to arrive + + Actual arrive + + Details + + User + + Created at + + Updated at + +
+ <%= a_package.id %> + + <%= a_package.description %> + + <%= a_package.supposed_to_arrive %> + + <%= a_package.actual_arrive %> + + <%= a_package.details %> + + <%= a_package.user_id %> + + <%= time_ago_in_words(a_package.created_at) %> ago + + <%= time_ago_in_words(a_package.updated_at) %> ago + + + Show details + +
+
+
+ +
diff --git a/app/views/packages/show.html.erb b/app/views/packages/show.html.erb new file mode 100644 index 00000000..0061fb88 --- /dev/null +++ b/app/views/packages/show.html.erb @@ -0,0 +1,131 @@ +
+
+

+ Package #<%= @the_package.id %> details +

+ +
+
+ + Go back + +
+ +
+ + Delete package + +
+
+ +
+
+ Description +
+
+ <%= @the_package.description %> +
+ +
+ Supposed to arrive +
+
+ <%= @the_package.supposed_to_arrive %> +
+ +
+ Actual arrive +
+
+ <%= @the_package.actual_arrive %> +
+ +
+ Details +
+
+ <%= @the_package.details %> +
+ +
+ User +
+
+ <%= @the_package.user_id %> +
+ +
+ Created at +
+
+ <%= time_ago_in_words(@the_package.created_at) %> ago +
+ +
+ Updated at +
+
+ <%= time_ago_in_words(@the_package.updated_at) %> ago +
+
+
+
+ +
+ + +
+
+

+ Edit package +

+ +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+
+
+ +
diff --git a/config/routes.rb b/config/routes.rb index 262ffd54..1d90496a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,25 @@ Rails.application.routes.draw do - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + # Routes for the Package resource: + + # CREATE + post("/insert_package", { :controller => "packages", :action => "create" }) + + # READ + get("/packages", { :controller => "packages", :action => "index" }) + + get("/packages/:path_id", { :controller => "packages", :action => "show" }) + + # UPDATE + + post("/modify_package/:path_id", { :controller => "packages", :action => "update" }) + + # DELETE + get("/delete_package/:path_id", { :controller => "packages", :action => "destroy" }) + #------------------------------ + + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") # root "articles#index" + root "boards#index" end diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 664ceb100a102e875d1951eb38b2d287870d82b5..0b508b1b0dae7e21ba9dc90a8c491bcc3a2f3d4e 100644 GIT binary patch delta 443 zcmZozz}WDBae}lU3j+fKI}pPF^F$qENfrjZq6NJCKN#3})-&*1^Ka#o=KI9U$g_T9 zqd8A~02`aQwl-sANn%n?YH?vsW=U#%acW^{YF;urm)$wY)iK0XA;i(i$5jDMtwvsA zZmJGYr)HBlE4#R?EMp5J*vx{&l4K|?7sMM)tuuOu}+wMZc# z$kW#`C{n@OHB!MbG{oQ252(@C)h|TB&mV|GeSCBjlu}ZQlZ!G7N;32FloZMmi;^=E zi-5w#r3D4~#i=RrCHe7*MMarqsY(hdi6yB(sl?=x(!?CNs2Wr_CAB0mGpATdp(M4U z1gNaEIJGDq;hf2<_&hdC^SxwbW8{Cw!2fQupuiJ;839HnO(O#%69Y3NBLhPa<^qO1 dk_sU~W=&316^jfM7Wae}lUGXnzyD-go~(?lI(QDz3cv{$_RKNwi}q#5|F`M2^(^L^SZD6pJ& bvozmJ#?34NfA|@>HZuk=3v6aF_#+PhUeyuH diff --git a/db/migrate/20240622012201_create_packages.rb b/db/migrate/20240622012201_create_packages.rb new file mode 100644 index 00000000..336892b8 --- /dev/null +++ b/db/migrate/20240622012201_create_packages.rb @@ -0,0 +1,13 @@ +class CreatePackages < ActiveRecord::Migration[7.0] + def change + create_table :packages do |t| + t.string :description + t.date :supposed_to_arrive + t.date :actual_arrive + t.text :details + t.integer :user_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a3b04951..272badc7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,5 +10,15 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 0) do +ActiveRecord::Schema[7.0].define(version: 2024_06_22_012201) do + create_table "packages", force: :cascade do |t| + t.string "description" + t.date "supposed_to_arrive" + t.date "actual_arrive" + t.text "details" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end From 96deb9e3745e8e2680b2232716268bc24c0916e6 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Fri, 21 Jun 2024 20:31:34 -0500 Subject: [PATCH 02/18] house keeping --- app/models/user.rb | 24 ++++++++++ config/routes.rb | 7 ++- db/development.sqlite3 | Bin 28672 -> 40960 bytes .../20240622012528_devise_create_users.rb | 44 ++++++++++++++++++ db/schema.rb | 14 +++++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/models/user.rb create mode 100644 db/migrate/20240622012528_devise_create_users.rb diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 00000000..e47fc360 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# +class User < ApplicationRecord + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :validatable +end diff --git a/config/routes.rb b/config/routes.rb index 1d90496a..09041659 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,9 @@ Rails.application.routes.draw do + devise_for :users + root "packages#index" + # Routes for the Package resource: - + get("/", { :controller => "packages", :action => "index" }) # CREATE post("/insert_package", { :controller => "packages", :action => "create" }) @@ -21,5 +24,5 @@ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") # root "articles#index" - root "boards#index" + end diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 0b508b1b0dae7e21ba9dc90a8c491bcc3a2f3d4e..192e209eaf36efba589b9739e26add3d01af80c3 100644 GIT binary patch delta 642 zcmZp8z}RqrX@ayMD+2=q7ZAe$+e95>c~%C!q6NJCKNvWQzy`M2^(^L^rF Date: Fri, 21 Jun 2024 20:35:46 -0500 Subject: [PATCH 03/18] association created --- app/models/package.rb | 1 + app/models/user.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/models/package.rb b/app/models/package.rb index e30f4af2..a973e7cb 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -12,4 +12,5 @@ # user_id :integer # class Package < ApplicationRecord + belongs_to :user, class_name: "User", foreign_key: "user_id" end diff --git a/app/models/user.rb b/app/models/user.rb index e47fc360..cb2ef8e0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,4 +21,6 @@ class User < ApplicationRecord # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable + + has_many :packages, class_name: "Package", foreign_key: "user_id" end From eec0d29190b3df750a9010c0bb88eee59284f5a5 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Fri, 21 Jun 2024 20:59:19 -0500 Subject: [PATCH 04/18] before edit to dev.rake --- app/views/layouts/application.html.erb | 16 ++++ app/views/packages/index.html.erb | 116 ++++--------------------- 2 files changed, 35 insertions(+), 97 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cbc2f44f..354cd088 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,6 +11,22 @@ +
+ <%# <%if current_user == nil%> %> + Sign up + Sign in + <%# <%else%> %> + Delivery Tracker + Edit profile + Sign out + <%# <%end%> %> +
+ +
+ + <%= notice%> + <%= alert%> + <%= yield %> diff --git a/app/views/packages/index.html.erb b/app/views/packages/index.html.erb index abefb8c4..30d174ba 100644 --- a/app/views/packages/index.html.erb +++ b/app/views/packages/index.html.erb @@ -1,8 +1,9 @@

- List of all packages + Delivery Tracker

+

Know if something gets lost in the mail.

@@ -11,7 +12,7 @@

- Add a new package + Expecting a package?

@@ -31,14 +32,6 @@
-
- - - -
-
-
- - - -
-
@@ -65,85 +50,22 @@
- - - - - - - - - - - - - - - - - - - - - - <% @list_of_packages.each do |a_package| %> - - - - - - - - - - - - - - - +

+ Waiting on +
    + <% @list_of_packages.each do |package|%> +
  • +
    package.description
    +
    package.supposed_to_arrive
    +
    package.details
    +
    + + +
  • + <%end%> +
+

- - - <% end %> -
- ID - - Description - - Supposed to arrive - - Actual arrive - - Details - - User - - Created at - - Updated at - -
- <%= a_package.id %> - - <%= a_package.description %> - - <%= a_package.supposed_to_arrive %> - - <%= a_package.actual_arrive %> - - <%= a_package.details %> - - <%= a_package.user_id %> - - <%= time_ago_in_words(a_package.created_at) %> ago - - <%= time_ago_in_words(a_package.updated_at) %> ago - - - Show details - -
From e469c43dd217d1fa1a78a1e707bda965ce399a00 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Fri, 21 Jun 2024 21:33:40 -0500 Subject: [PATCH 05/18] Revert "before edit to dev.rake" This reverts commit eec0d29190b3df750a9010c0bb88eee59284f5a5. --- app/views/layouts/application.html.erb | 16 ---- app/views/packages/index.html.erb | 116 +++++++++++++++++++++---- 2 files changed, 97 insertions(+), 35 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 354cd088..cbc2f44f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,22 +11,6 @@ -
- <%# <%if current_user == nil%> %> - Sign up - Sign in - <%# <%else%> %> - Delivery Tracker - Edit profile - Sign out - <%# <%end%> %> -
- -
- - <%= notice%> - <%= alert%> - <%= yield %> diff --git a/app/views/packages/index.html.erb b/app/views/packages/index.html.erb index 30d174ba..abefb8c4 100644 --- a/app/views/packages/index.html.erb +++ b/app/views/packages/index.html.erb @@ -1,9 +1,8 @@

- Delivery Tracker + List of all packages

-

Know if something gets lost in the mail.

@@ -12,7 +11,7 @@

- Expecting a package? + Add a new package

@@ -32,6 +31,14 @@
+
+ + + +
+
+
+ + + +
+
@@ -50,22 +65,85 @@
-

- Waiting on -
    - <% @list_of_packages.each do |package|%> -
  • -
    package.description
    -
    package.supposed_to_arrive
    -
    package.details
    -
    - -
    -
  • - <%end%> -
-

+ + + + + + + + + + + + + + + + + + + + + + <% @list_of_packages.each do |a_package| %> + + + + + + + + + + + + + + + + + + <% end %> +
+ ID + + Description + + Supposed to arrive + + Actual arrive + + Details + + User + + Created at + + Updated at + +
+ <%= a_package.id %> + + <%= a_package.description %> + + <%= a_package.supposed_to_arrive %> + + <%= a_package.actual_arrive %> + + <%= a_package.details %> + + <%= a_package.user_id %> + + <%= time_ago_in_words(a_package.created_at) %> ago + + <%= time_ago_in_words(a_package.updated_at) %> ago + + + Show details + +
From f45474077bb57adc71c99f98f2396cd04cc064a5 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 10:32:34 -0500 Subject: [PATCH 06/18] fixed delivery? and added notice and alert --- app/controllers/deliveries_controller.rb | 62 ++++++++++++++++++ app/controllers/packages_controller.rb | 62 ------------------ app/models/{package.rb => delivery.rb} | 2 +- app/models/user.rb | 2 +- .../{packages => deliveries}/index.html.erb | 28 ++++---- .../{packages => deliveries}/show.html.erb | 38 +++++------ app/views/layouts/application.html.erb | 4 +- config/routes.rb | 16 ++--- db/development.sqlite3 | Bin 40960 -> 49152 bytes ...rb => 20240622012201_create_deliveries.rb} | 4 +- db/schema.rb | 2 +- db/test.sqlite3 | Bin 20480 -> 0 bytes lib/tasks/dev.rake | 8 +-- 13 files changed, 115 insertions(+), 113 deletions(-) create mode 100644 app/controllers/deliveries_controller.rb delete mode 100644 app/controllers/packages_controller.rb rename app/models/{package.rb => delivery.rb} (92%) rename app/views/{packages => deliveries}/index.html.erb (76%) rename app/views/{packages => deliveries}/show.html.erb (64%) rename db/migrate/{20240622012201_create_packages.rb => 20240622012201_create_deliveries.rb} (67%) delete mode 100644 db/test.sqlite3 diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb new file mode 100644 index 00000000..fc382d73 --- /dev/null +++ b/app/controllers/deliveries_controller.rb @@ -0,0 +1,62 @@ +class DeliveriesController < ApplicationController + def index + matching_deliveries = Delivery.all + + @list_of_deliveries = matching_deliveries.order({ :created_at => :desc }) + + render({ :template => "deliveries/index" }) + end + + def show + the_id = params.fetch("path_id") + + matching_deliveries = Delivery.where({ :id => the_id }) + + @the_delivery = matching_deliveries.at(0) + + render({ :template => "deliveries/show" }) + end + + def create + the_delivery = Delivery.new + the_delivery.description = params.fetch("query_description") + the_delivery.supposed_to_arrive = params.fetch("query_supposed_to_arrive") + the_delivery.actual_arrive = params.fetch("query_actual_arrive") + the_delivery.details = params.fetch("query_details") + the_delivery.user_id = params.fetch("query_user_id") + + if the_delivery.valid? + the_delivery.save + redirect_to("/deliveries", { :notice => "Delivery created successfully." }) + else + redirect_to("/deliveries", { :alert => the_delivery.errors.full_messages.to_sentence }) + end + end + + def update + the_id = params.fetch("path_id") + the_delivery = Delivery.where({ :id => the_id }).at(0) + + the_delivery.description = params.fetch("query_description") + the_delivery.supposed_to_arrive = params.fetch("query_supposed_to_arrive") + the_delivery.actual_arrive = params.fetch("query_actual_arrive") + the_delivery.details = params.fetch("query_details") + the_delivery.user_id = params.fetch("query_user_id") + + if the_delivery.valid? + the_delivery.save + redirect_to("/deliveries/#{the_delivery.id}", { :notice => "Delivery updated successfully."} ) + else + redirect_to("/deliveries/#{the_delivery.id}", { :alert => the_delivery.errors.full_messages.to_sentence }) + end + end + + def destroy + the_id = params.fetch("path_id") + the_delivery = Delivery.where({ :id => the_id }).at(0) + + the_delivery.destroy + + redirect_to("/deliveries", { :notice => "Delivery deleted successfully."} ) + end +end diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb deleted file mode 100644 index e29638f2..00000000 --- a/app/controllers/packages_controller.rb +++ /dev/null @@ -1,62 +0,0 @@ -class PackagesController < ApplicationController - def index - matching_packages = Package.all - - @list_of_packages = matching_packages.order({ :created_at => :desc }) - - render({ :template => "packages/index" }) - end - - def show - the_id = params.fetch("path_id") - - matching_packages = Package.where({ :id => the_id }) - - @the_package = matching_packages.at(0) - - render({ :template => "packages/show" }) - end - - def create - the_package = Package.new - the_package.description = params.fetch("query_description") - the_package.supposed_to_arrive = params.fetch("query_supposed_to_arrive") - the_package.actual_arrive = params.fetch("query_actual_arrive") - the_package.details = params.fetch("query_details") - the_package.user_id = params.fetch("query_user_id") - - if the_package.valid? - the_package.save - redirect_to("/packages", { :notice => "Package created successfully." }) - else - redirect_to("/packages", { :alert => the_package.errors.full_messages.to_sentence }) - end - end - - def update - the_id = params.fetch("path_id") - the_package = Package.where({ :id => the_id }).at(0) - - the_package.description = params.fetch("query_description") - the_package.supposed_to_arrive = params.fetch("query_supposed_to_arrive") - the_package.actual_arrive = params.fetch("query_actual_arrive") - the_package.details = params.fetch("query_details") - the_package.user_id = params.fetch("query_user_id") - - if the_package.valid? - the_package.save - redirect_to("/packages/#{the_package.id}", { :notice => "Package updated successfully."} ) - else - redirect_to("/packages/#{the_package.id}", { :alert => the_package.errors.full_messages.to_sentence }) - end - end - - def destroy - the_id = params.fetch("path_id") - the_package = Package.where({ :id => the_id }).at(0) - - the_package.destroy - - redirect_to("/packages", { :notice => "Package deleted successfully."} ) - end -end diff --git a/app/models/package.rb b/app/models/delivery.rb similarity index 92% rename from app/models/package.rb rename to app/models/delivery.rb index a973e7cb..a8aced02 100644 --- a/app/models/package.rb +++ b/app/models/delivery.rb @@ -11,6 +11,6 @@ # updated_at :datetime not null # user_id :integer # -class Package < ApplicationRecord +class Delivery < ApplicationRecord belongs_to :user, class_name: "User", foreign_key: "user_id" end diff --git a/app/models/user.rb b/app/models/user.rb index cb2ef8e0..cb2da6b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,5 +22,5 @@ class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable - has_many :packages, class_name: "Package", foreign_key: "user_id" + has_many :deliveries, class_name: "Delivery", foreign_key: "user_id" end diff --git a/app/views/packages/index.html.erb b/app/views/deliveries/index.html.erb similarity index 76% rename from app/views/packages/index.html.erb rename to app/views/deliveries/index.html.erb index abefb8c4..c8452713 100644 --- a/app/views/packages/index.html.erb +++ b/app/views/deliveries/index.html.erb @@ -1,7 +1,7 @@

- List of all packages + List of all deliveries

@@ -11,10 +11,10 @@

- Add a new package + Add a new delivery

-
+
@@ -103,41 +103,41 @@ - <% @list_of_packages.each do |a_package| %> + <% @list_of_deliveries.each do |a_delivery| %> - <%= a_package.id %> + <%= a_delivery.id %> - <%= a_package.description %> + <%= a_delivery.description %> - <%= a_package.supposed_to_arrive %> + <%= a_delivery.supposed_to_arrive %> - <%= a_package.actual_arrive %> + <%= a_delivery.actual_arrive %> - <%= a_package.details %> + <%= a_delivery.details %> - <%= a_package.user_id %> + <%= a_delivery.user_id %> - <%= time_ago_in_words(a_package.created_at) %> ago + <%= time_ago_in_words(a_delivery.created_at) %> ago - <%= time_ago_in_words(a_package.updated_at) %> ago + <%= time_ago_in_words(a_delivery.updated_at) %> ago - + Show details diff --git a/app/views/packages/show.html.erb b/app/views/deliveries/show.html.erb similarity index 64% rename from app/views/packages/show.html.erb rename to app/views/deliveries/show.html.erb index 0061fb88..c178c241 100644 --- a/app/views/packages/show.html.erb +++ b/app/views/deliveries/show.html.erb @@ -1,19 +1,19 @@

- Package #<%= @the_package.id %> details + elivery #<%= @the_delivery.id %> details

@@ -23,49 +23,49 @@ Description
- <%= @the_package.description %> + <%= @the_delivery.description %>
Supposed to arrive
- <%= @the_package.supposed_to_arrive %> + <%= @the_delivery.supposed_to_arrive %>
Actual arrive
- <%= @the_package.actual_arrive %> + <%= @the_delivery.actual_arrive %>
Details
- <%= @the_package.details %> + <%= @the_delivery.details %>
User
- <%= @the_package.user_id %> + <%= @the_delivery.user_id %>
Created at
- <%= time_ago_in_words(@the_package.created_at) %> ago + <%= time_ago_in_words(@the_delivery.created_at) %> ago
Updated at
- <%= time_ago_in_words(@the_package.updated_at) %> ago + <%= time_ago_in_words(@the_delivery.updated_at) %> ago
@@ -77,16 +77,16 @@

- Edit package + Edit delivery

-
+
- +
@@ -94,7 +94,7 @@ Supposed to arrive - +
@@ -102,7 +102,7 @@ Actual arrive - +
@@ -110,7 +110,7 @@ Details - +
@@ -118,11 +118,11 @@ User - +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cbc2f44f..3b4e1d2a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,8 +9,10 @@ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> - + + <%= notice %> + <%= alert %> <%= yield %> diff --git a/config/routes.rb b/config/routes.rb index 09041659..87630c09 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,23 +1,23 @@ Rails.application.routes.draw do devise_for :users - root "packages#index" + root "deliveries#index" - # Routes for the Package resource: - get("/", { :controller => "packages", :action => "index" }) + # Routes for the deliverie resource: + get("/", { :controller => "deliveries", :action => "index" }) # CREATE - post("/insert_package", { :controller => "packages", :action => "create" }) + post("/insert_deliveries", { :controller => "deliveries", :action => "create" }) # READ - get("/packages", { :controller => "packages", :action => "index" }) + get("/deliveries", { :controller => "deliveries", :action => "index" }) - get("/packages/:path_id", { :controller => "packages", :action => "show" }) + get("/deliveries/:path_id", { :controller => "deliveries", :action => "show" }) # UPDATE - post("/modify_package/:path_id", { :controller => "packages", :action => "update" }) + post("/modify_delivery/:path_id", { :controller => "deliveries", :action => "update" }) # DELETE - get("/delete_package/:path_id", { :controller => "packages", :action => "destroy" }) + get("/delete_delivery/:path_id", { :controller => "deliveries", :action => "destroy" }) #------------------------------ diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 192e209eaf36efba589b9739e26add3d01af80c3..b552a74590deb1845e84de42f5a28dfe40ee2a32 100644 GIT binary patch literal 49152 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 W(c&qZ0N?Rfq!7I_1TeN`RPt}ak=LsL delta 249 zcmZo@U~V|TG(nn`m4ShQYoda^JS&4<(E?un9}Jvaz6|`<{9E~?`9AS7@~r3fyeRY3_V zJUO4+Y;z88vXP;&u7QQFfsultnU#T&m5H&Qxuu!0iLsG^5e}I}4gzevKvyydY!-BQ Qz&~+<6ag+5s$x_w0NO%5D*ylh diff --git a/db/migrate/20240622012201_create_packages.rb b/db/migrate/20240622012201_create_deliveries.rb similarity index 67% rename from db/migrate/20240622012201_create_packages.rb rename to db/migrate/20240622012201_create_deliveries.rb index 336892b8..8a89847e 100644 --- a/db/migrate/20240622012201_create_packages.rb +++ b/db/migrate/20240622012201_create_deliveries.rb @@ -1,6 +1,6 @@ -class CreatePackages < ActiveRecord::Migration[7.0] +class CreateDeliveries < ActiveRecord::Migration[7.0] def change - create_table :packages do |t| + create_table :deliveries do |t| t.string :description t.date :supposed_to_arrive t.date :actual_arrive diff --git a/db/schema.rb b/db/schema.rb index 85614c93..f0effcba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[7.0].define(version: 2024_06_22_012528) do - create_table "packages", force: :cascade do |t| + create_table "deliveries", force: :cascade do |t| t.string "description" t.date "supposed_to_arrive" t.date "actual_arrive" diff --git a/db/test.sqlite3 b/db/test.sqlite3 deleted file mode 100644 index 0fb86e4757ee8a679f4343af511ddf0308c023ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI&J#W)M7zgmPowO9GF-w)911D!`B-;8V4o+DxD59vLKuCuQA?spah(+RneTm9g zz7u>ORyLTBSU5*f6qJ}1QTX17`QOH9|2_fah zDmU|{%D%K1=Nn~ZTr@0`qrtab{U<3^_KE&L|6JLx{3uFB90Cx400bZa0SG_<0uX=z z1pbM@bx+%_x~}r+OtAilvowek!PA6|f-x5?VuEdol^%E7ey>e?{-aKt8k(v-agZYRuSZ%9mL(5T=|79tBJoRQ^5}@t7Yp z>&yLR%Jh9cQJhkLQrfD%b`=sQ5x>eljO68Sz@}m{{~T=kyMeVSTE0@YtH;O6_1!s7 z77qEC1>^W_%0xU#vbBKvC(PP>t}^3kCU;)eysT_hrtYg-)r;ez64t&ru+~DFJfm*q zXVtD;75x{H3mOC<009U<00Izz00bZa0SG_<0yj@UQ&io&E$hPd|IItNs0acOfB*y_ z009U<00Izz00bbg5GZN-j+sCISM^h(e~}#;1Rwwb2tWV=5P$##AOHafKmY=N6&R`I z+8f_ryl9^dnPod6YkC7OYB0yKJeT!NyXko$^Q?ZKH6rG=?pskfuua=JG+T$ZNp0uE z_D-zEk!8A8t64mAs+4PczR#0coKBK4PlVu^*qrZ}EvI-UfBvuPUy1%*c4!cQ00bZa i0SG_<0uX=z1Rwwb2>hP{x>i$G?n :environment}) do delivery.user_id = user.id delivery.description = Faker::Commerce.product_name delivery.details = "#{["FedEx", "UPS", "USPS"].sample} tracking ##{rand(1000000000000)}" if rand < 0.5 - delivery.supposed_to_arrive_on = Faker::Date.between(from: 1.month.ago, to: 2.weeks.from_now) + delivery.supposed_to_arrive = Faker::Date.between(from: 1.month.ago, to: 2.weeks.from_now) - if delivery.supposed_to_arrive_on < Time.now - delivery.arrived = [true, false].sample + if delivery.supposed_to_arrive < Time.now + delivery.actual_arrive = [true, false].sample else - delivery.arrived = false + delivery.actual_arrive = false end delivery.save From 6b9d9aa11f7c51545b4b633df8b5746cd06531df Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 11:16:18 -0500 Subject: [PATCH 07/18] fixed some html for index --- .DS_Store | Bin 0 -> 6148 bytes app/.DS_Store | Bin 0 -> 6148 bytes app/controllers/deliveries_controller.rb | 2 +- app/models/delivery.rb | 4 +- app/views/.DS_Store | Bin 0 -> 6148 bytes app/views/deliveries/index.html.erb | 136 +++++++----------- db/development.sqlite3 | Bin 49152 -> 49152 bytes ...40623154546_delivery_change_column_type.rb | 5 + db/schema.rb | 4 +- db/test.sqlite3 | Bin 0 -> 40960 bytes 10 files changed, 62 insertions(+), 89 deletions(-) create mode 100644 .DS_Store create mode 100644 app/.DS_Store create mode 100644 app/views/.DS_Store create mode 100644 db/migrate/20240623154546_delivery_change_column_type.rb create mode 100644 db/test.sqlite3 diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fadd49af93a07740151b4698fdea46e28fdbf625 GIT binary patch literal 6148 zcmeH~I}XA?3`A{6fkcy%avKi74OR$FzyR_M(RA8jQJo4Vo|2_QM{6A`8N(HFEpDCc- z?y%e9rSfe3cs;8hvuf)G2mNw{x1Rtcb`-DRZrCrj0Bf=ZQGxMCz-3^d0zXyY1qdw> AZU6uP literal 0 HcmV?d00001 diff --git a/app/.DS_Store b/app/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..467f3545dbad16fad71e0514a8eba50303509390 GIT binary patch literal 6148 zcmeHKyG{c!5S)d8BGIIz^e^xSRusN~A3$&vNQbV7fc7fBi%(toC zW6M+A-U6`g>u>{X0Icbb`0!zAzVE)Uvx+!coH1fQ>>tO6X&M*VzXzOqi5E;5@Pr@y z3%uc(;rH)jd5=sANC7Dz1*Cu!I6{G{rR%FB&Ja}!NP*K-z`qZT?$`_G#Q1b@h!%jj zVmOTR=p~5F1H@i9Co)2_q!N>A)nZuE8E=)>3+Ke7!{TP1Q#V_6C>FOf-Xa~=6E#W! zDR8L3c`i3z|8MDk^#6w>t)zeyI4K2ewY%GG`J}3?i^qAbZS;G(=X}!LI1dVkD96Mo i$6R-rxD!BB>aesk7SXJc<_yHc_fD|bbp_RDh#&0vW7nCaPl>-_}_GG=D zU1bh&48XSg?he=hSkoQxQ@4m2$mT|N=NBWPk oHp&^I6%(TsbK$M{c2-yXnftZjlo)j8gHF_sfa@ZY0)L^vH

- List of all deliveries + Delivery Tracker

+

Know if something gets lost in the mail.


-
+<%#

Add a new delivery

-
+
-
- - - -
-
-
+
%> -
- - - +

+ Expecting a package? +

- + + + + - + - + + - + + + + + + + + + + +
+
+
+

+ Waiting on +
    + <% @list_of_deliveries.each do |delivery|%> +
  • +
    delivery.description
    +
    delivery.supposed_to_arrive
    +
    delivery.details
    +
    + + +
  • + <%end%> +
+

-
- - - - - - - - - <% @list_of_deliveries.each do |a_delivery| %> - - - - - - - - - - - - - - - - - - - <% end %> -
- ID - +
+
+
+
+
- Actual arrive - +
+
- User - - Created at - - Updated at - -
- <%= a_delivery.id %> - - <%= a_delivery.description %> - - <%= a_delivery.supposed_to_arrive %> - - <%= a_delivery.actual_arrive %> - - <%= a_delivery.details %> - - <%= a_delivery.user_id %> - - <%= time_ago_in_words(a_delivery.created_at) %> ago - - <%= time_ago_in_words(a_delivery.updated_at) %> ago - - - Show details - -
diff --git a/db/development.sqlite3 b/db/development.sqlite3 index b552a74590deb1845e84de42f5a28dfe40ee2a32..3650fac5f4f5ddbe290ffc146992b6efe6c598b9 100644 GIT binary patch delta 449 zcmZo@U~Xt&o**sg%D}+D1H>@EF;T}@-jzYGXaO(JZw5||e+>NA{9E~?`9ATiJRCE-SQc{bPi!uvJGV}A46v`5dk~0#E z6kJ^097BCV6#PPcd?q*WN;{*70CgoMmy{;v#3vRNWtOEXDJ13R=cFd)fsHFk%*-iP zQYcBSC_&LR`5><_FRI9DKKIS;Tw9n}_GxC3B;Qz}1bhDttP5#YK^W_aDvuu!K;!@nK67ZMP z-`ALvL0FMNkkQdG)x->BovwkIuAxbB8as?*WUOFlYGrC^WoV*jY+_+*VSpiHVytIs RVq#`swz*)}1lC0h1OTU!cw_(o delta 179 zcmZo@U~Xt&o**sgz`(%31H>@EHc`h|-hn}{XaO((4+c&ycLsiI{;hn{e4luJ^Q`1{ z=DNe>zFAPRe6C{Gx0xV;Qz}16exd_fAiCPd4tU? U8~*T5TA&29%a3bw!Kw+Y0On~l9{>OV diff --git a/db/migrate/20240623154546_delivery_change_column_type.rb b/db/migrate/20240623154546_delivery_change_column_type.rb new file mode 100644 index 00000000..20844382 --- /dev/null +++ b/db/migrate/20240623154546_delivery_change_column_type.rb @@ -0,0 +1,5 @@ +class DeliveryChangeColumnType < ActiveRecord::Migration[7.0] + def change + change_column(:deliveries, :actual_arrive, :boolean) + end +end diff --git a/db/schema.rb b/db/schema.rb index f0effcba..9f1fa9c8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_22_012528) do +ActiveRecord::Schema[7.0].define(version: 2024_06_23_154546) do create_table "deliveries", force: :cascade do |t| t.string "description" t.date "supposed_to_arrive" - t.date "actual_arrive" + t.boolean "actual_arrive" t.text "details" t.integer "user_id" t.datetime "created_at", null: false diff --git a/db/test.sqlite3 b/db/test.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..66d6db533715cee410f821a2716ec51cbde5ef77 GIT binary patch literal 40960 zcmeI($!^<57zc1tw53S0O*KHlLk}I(2x20OwV0}uQ`K5cj3{#ANI;FEAjaZ2CL)mv zIdYw&jrP=+=u`CAbI@1l0`vs}^bILoX(x-$-l9U>(VizrOv0WJ)hdX)Vc+p`>y6^w6zP2ePQ+v|JZyVpQ-&*@= z%}Cqn-&1?(j~1PVI0PU70SG_<0uX?}br!g2+(>AqDPKP3^tjEaZ#gb!zDwIyhjD6C zPUppvpC48$jVftWKC4xUJ}-+-w)L0nwNB2c-#Vo}sUI{*y;-Y~r-%DbDu+kparNjf z(a&hR$40qCpye~lnQc+76LEjWoetYB8l&??mR>hZSe(Upn2c**nX=@#HaibqwZ-4b z7VU8_`fSZBu9ce?O`XRR+Rl!A@o~fxv`$%vS{>(wPr2i{!IeN_8se8(5KWkRWetoa{CDGsGY@Hm`MI(hb2?b!?r4W8ekzC)s5EO0a{KmFCb#9k?uLDK2t988`De^k8xAIM+nMx$ zxqNoWM7cVwbIg2e!Ke~h7Nks;{%^vp|Bv>W%tbHf*f=s%T25^eFGcuo$Z$DSu1psq-;#go%%i@wj;00bZa0SG_<0uX=z z1RyXL!2Ew~fg=b&00Izz00bZa0SG_<0uX?}vI>O%Ra_!vBLrZ2tWV= z5P$##AOHafKmY;|fWWmD$S5%*pUv-Pi}`#umpAjJOl&G5q8WJ?DK!CwSGOUVEL literal 0 HcmV?d00001 From df1cdd879eeaf8accdd5292d678c7eda16d8f79e Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 11:34:12 -0500 Subject: [PATCH 08/18] html is mostly up to date --- app/controllers/deliveries_controller.rb | 3 +- app/views/deliveries/index.html.erb | 47 ++++++++++++++++-------- app/views/layouts/application.html.erb | 17 ++++++++- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb index 551e5449..8930e1e3 100644 --- a/app/controllers/deliveries_controller.rb +++ b/app/controllers/deliveries_controller.rb @@ -23,7 +23,8 @@ def create the_delivery.supposed_to_arrive = params.fetch("query_supposed_to_arrive") the_delivery.actual_arrive = false the_delivery.details = params.fetch("query_details") - the_delivery.user_id = params.fetch("query_user_id") + # the_delivery.user_id = params.fetch("query_user_id") + the_delivery.user_id = current_user_id if the_delivery.valid? the_delivery.save diff --git a/app/views/deliveries/index.html.erb b/app/views/deliveries/index.html.erb index adb69f25..b9035f9a 100644 --- a/app/views/deliveries/index.html.erb +++ b/app/views/deliveries/index.html.erb @@ -72,7 +72,7 @@
@@ -95,23 +95,40 @@
-
+

Waiting on -
    - <% @list_of_deliveries.each do |delivery|%> -
  • -
    delivery.description
    -
    delivery.supposed_to_arrive
    -
    delivery.details
    -
    - -
    -
  • - <%end%> -
-

+ +
    + <% @list_of_deliveries.each do |delivery|%> +
  • +
    <%= delivery.description%>
    +
    <%=delivery.supposed_to_arrive%>
    +
    <%=delivery.details%>
    +
    + +
    +
  • + <%end%> +
+
+
+

+ Received +

+
    + <% @list_of_deliveries.each do |delivery|%> +
  • +
    <%= delivery.description%>
    +
    <%=delivery.supposed_to_arrive%>
    +
    <%=delivery.details%>
    +
    + +
    +
  • + <%end%> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3b4e1d2a..8a311c58 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,8 +11,21 @@ - <%= notice %> - <%= alert %> +
+ <%# <%if current_user == nil%> + Sign up + Sign in + <%# <%else%> + Delivery Tracker + Edit profile + Sign out + <%# <%end%> +
+ +
+ + <%= notice%> + <%= alert%> <%= yield %> From ee8ad8e1e363f0cb0e2abf23708f4ec2adee9d43 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 12:40:13 -0500 Subject: [PATCH 09/18] on marking as recived --- app/controllers/deliveries_controller.rb | 22 ++++++++++++++++++--- app/models/delivery.rb | 1 + app/models/user.rb | 1 + app/views/deliveries/index.html.erb | 24 +++++++++++------------ app/views/layouts/application.html.erb | 6 +++--- config/routes.rb | 1 + db/development.sqlite3 | Bin 49152 -> 49152 bytes 7 files changed, 36 insertions(+), 19 deletions(-) diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb index 8930e1e3..563d4664 100644 --- a/app/controllers/deliveries_controller.rb +++ b/app/controllers/deliveries_controller.rb @@ -1,8 +1,10 @@ class DeliveriesController < ApplicationController def index - matching_deliveries = Delivery.all - + matching_deliveries = Delivery.where(:user_id => current_user.id) @list_of_deliveries = matching_deliveries.order({ :created_at => :desc }) + @not_arrived = @list_of_deliveries.where(:actual_arrive => false) + @arrived = @list_of_deliveries.where(:actual_arrive => true) + render({ :template => "deliveries/index" }) end @@ -24,7 +26,7 @@ def create the_delivery.actual_arrive = false the_delivery.details = params.fetch("query_details") # the_delivery.user_id = params.fetch("query_user_id") - the_delivery.user_id = current_user_id + the_delivery.user_id = current_user.id if the_delivery.valid? the_delivery.save @@ -34,6 +36,20 @@ def create end end + def mark_as_received + the_id = params.fetch("path_id") + the_delivery = Delivery.where({ :id => the_id }).at(0) + + the_delivery.actual_arrive = true + + if the_delivery.valid? + the_delivery.save + redirect_to("/deliveries", { :notice => "Delivery marked received successfully." }) + else + redirect_to("/deliveries", { :alert => the_delivery.errors.full_messages.to_sentence }) + end + end + def update the_id = params.fetch("path_id") the_delivery = Delivery.where({ :id => the_id }).at(0) diff --git a/app/models/delivery.rb b/app/models/delivery.rb index cd693d0c..fc88406e 100644 --- a/app/models/delivery.rb +++ b/app/models/delivery.rb @@ -13,4 +13,5 @@ # class Delivery < ApplicationRecord belongs_to :user, class_name: "User", foreign_key: "user_id" + end diff --git a/app/models/user.rb b/app/models/user.rb index cb2da6b5..83be2da2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,4 +23,5 @@ class User < ApplicationRecord :recoverable, :rememberable, :validatable has_many :deliveries, class_name: "Delivery", foreign_key: "user_id" + end diff --git a/app/views/deliveries/index.html.erb b/app/views/deliveries/index.html.erb index b9035f9a..63731abe 100644 --- a/app/views/deliveries/index.html.erb +++ b/app/views/deliveries/index.html.erb @@ -3,6 +3,7 @@

Delivery Tracker

+

<%= params%>

Know if something gets lost in the mail.

@@ -61,7 +62,7 @@ Expecting a package? -
+
@@ -123,7 +123,7 @@ <% @arrived.each do |delivery|%>
  • <%= delivery.description%>
    - <%= delivery.updated_at%> Delete + <%= delivery.updated_at%> Delete
  • <%end%> diff --git a/config/routes.rb b/config/routes.rb index 52aee090..7a308ead 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ # Routes for the deliverie resource: get("/", { :controller => "deliveries", :action => "index" }) + # CREATE post("/insert_deliveries", { :controller => "deliveries", :action => "create" }) @@ -15,7 +16,7 @@ # UPDATE post("/modify_delivery/:path_id", { :controller => "deliveries", :action => "update" }) - post("/mark_received/:path_id", { :controller => "deliveries", :action => "mark_as_received" }) + get("/mark_received/:path_id", { :controller => "deliveries", :action => "mark_as_received" }) # DELETE get("/delete_delivery/:path_id", { :controller => "deliveries", :action => "destroy" }) diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 876d1c0bbb4e473179a894f9a7e30198a2edf71c..2ee0a8a25d65494aa3c62d99072ba1ea978dc24a 100644 GIT binary patch delta 185 zcmZo@U~Xt&o*>QWGf~Ew(Pv}AlKITMTm_Ta7sxT**sKKtl~Uz3@Qxe4E*!>)%lL{rSZP!oy=>(vvaakfaT`E0A3yz O1_p-c%}IOaF#`Zrmn`uB delta 81 zcmV-X0IvUlfCGSl1CSd5Mv)vt0YAqbNz nsyCBJst&Vos*wc^0000b0CxZno)0Gu#j_4j?GFVvGc`Fk$5j@t From ca547d0935d4c163f9161017a0c770cefd030462 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 12:55:11 -0500 Subject: [PATCH 11/18] color added and html clean up --- app/views/deliveries/index.html.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/deliveries/index.html.erb b/app/views/deliveries/index.html.erb index 0f66d465..2ed2d0d1 100644 --- a/app/views/deliveries/index.html.erb +++ b/app/views/deliveries/index.html.erb @@ -3,7 +3,6 @@

    Delivery Tracker

    -

    <%= params%>

    Know if something gets lost in the mail.

    @@ -96,7 +95,7 @@
    -
    +

    Waiting on

    @@ -104,7 +103,6 @@ <% @not_arrived.each do |delivery|%>
  • -
    <%=delivery.id%>
    <%= delivery.description%>
    Supposed to arrive on <%= delivery.supposed_to_arrive%>
    <%= delivery.details%>
    @@ -115,7 +113,7 @@
  • -
    +

    Received

    From 5d553fc3979c69ff5e721fe1b388ed41f748f292 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 12:57:25 -0500 Subject: [PATCH 12/18] Done! --- app/views/layouts/application.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bb410d20..80afa0dc 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,14 +12,14 @@
    - <%# <%if current_user == nil%> + <%if current_user == nil%> Sign up | Sign in - <%# <%else%> + <%else%> Delivery Tracker | Edit profile | Sign out - <%# <%end%> + <%end%>

    From 48658e8cdf585dacf76f264bfe03467151513483 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 12:59:29 -0500 Subject: [PATCH 13/18] changed color again --- app/views/deliveries/index.html.erb | 50 ++--------------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/app/views/deliveries/index.html.erb b/app/views/deliveries/index.html.erb index 2ed2d0d1..1464f040 100644 --- a/app/views/deliveries/index.html.erb +++ b/app/views/deliveries/index.html.erb @@ -9,52 +9,6 @@
    -<%#
    -
    -

    - Add a new delivery -

    - - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - - - -
    -
    %> -

    @@ -95,7 +49,7 @@
    -
    +

    Waiting on

    @@ -113,7 +67,7 @@
    -
    +

    Received

    From a473fa8b1c3462111b373ee55a63b826849d19b4 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sun, 23 Jun 2024 13:31:41 -0500 Subject: [PATCH 14/18] Fixed spacing --- app/models/delivery.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/delivery.rb b/app/models/delivery.rb index fc88406e..cd693d0c 100644 --- a/app/models/delivery.rb +++ b/app/models/delivery.rb @@ -13,5 +13,4 @@ # class Delivery < ApplicationRecord belongs_to :user, class_name: "User", foreign_key: "user_id" - end From fdb0eec9fbb8835d1ca8446849a3a2e6180a15e7 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Mon, 24 Jun 2024 10:32:44 -0500 Subject: [PATCH 15/18] Revert "Generated package" This reverts commit 9579cb6d93af19c43433c9684e6acd141d1ef68a. --- Gemfile.lock | 4 ---- config/routes.rb | 7 +++++++ db/schema.rb | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6e05e9db..10034745 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -219,8 +219,6 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) - nokogiri (1.15.5-arm64-darwin) - racc (~> 1.4) nokogiri (1.15.5-x86_64-darwin) racc (~> 1.4) nokogiri (1.15.5-x86_64-linux) @@ -349,7 +347,6 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.8-arm64-darwin) sqlite3 (1.6.8-x86_64-darwin) sqlite3 (1.6.8-x86_64-linux) stimulus-rails (1.2.2) @@ -407,7 +404,6 @@ GEM zeitwerk (2.6.12) PLATFORMS - arm64-darwin-21 x86_64-darwin-22 x86_64-linux diff --git a/config/routes.rb b/config/routes.rb index 7a308ead..4b5c630f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do +<<<<<<< HEAD devise_for :users root "deliveries#index" @@ -23,8 +24,14 @@ #------------------------------ +======= +>>>>>>> parent of 9579cb6 (Generated package) # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + # Defines the root path route ("/") # root "articles#index" +<<<<<<< HEAD +======= +>>>>>>> parent of 9579cb6 (Generated package) end diff --git a/db/schema.rb b/db/schema.rb index 9f1fa9c8..1569bfaa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,6 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. +<<<<<<< HEAD ActiveRecord::Schema[7.0].define(version: 2024_06_23_154546) do create_table "deliveries", force: :cascade do |t| t.string "description" @@ -33,4 +34,7 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end +======= +ActiveRecord::Schema[7.0].define(version: 0) do +>>>>>>> parent of 9579cb6 (Generated package) end From 7e3d6541497fb67bfff792474b90b84397267b18 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Mon, 24 Jun 2024 10:44:57 -0500 Subject: [PATCH 16/18] jump file lock update --- Gemfile.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 10034745..6e05e9db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -219,6 +219,8 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) + nokogiri (1.15.5-arm64-darwin) + racc (~> 1.4) nokogiri (1.15.5-x86_64-darwin) racc (~> 1.4) nokogiri (1.15.5-x86_64-linux) @@ -347,6 +349,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sqlite3 (1.6.8-arm64-darwin) sqlite3 (1.6.8-x86_64-darwin) sqlite3 (1.6.8-x86_64-linux) stimulus-rails (1.2.2) @@ -404,6 +407,7 @@ GEM zeitwerk (2.6.12) PLATFORMS + arm64-darwin-21 x86_64-darwin-22 x86_64-linux From 949173ae131f78355a38a174543845447243c336 Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Mon, 24 Jun 2024 10:59:26 -0500 Subject: [PATCH 17/18] added before user to login --- app/controllers/deliveries_controller.rb | 2 ++ config/routes.rb | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb index fde25f20..5498dfbf 100644 --- a/app/controllers/deliveries_controller.rb +++ b/app/controllers/deliveries_controller.rb @@ -1,4 +1,6 @@ class DeliveriesController < ApplicationController + before_action :authenticate_user! + def index matching_deliveries = Delivery.where(:user_id => current_user.id) @list_of_deliveries = matching_deliveries.order({ :created_at => :desc }) diff --git a/config/routes.rb b/config/routes.rb index 4b5c630f..15d3fb42 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Rails.application.routes.draw do -<<<<<<< HEAD devise_for :users root "deliveries#index" @@ -24,14 +23,9 @@ #------------------------------ -======= ->>>>>>> parent of 9579cb6 (Generated package) # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") # root "articles#index" -<<<<<<< HEAD -======= ->>>>>>> parent of 9579cb6 (Generated package) end From 6c6981058894f9a258375696bafeec809bfdd5ca Mon Sep 17 00:00:00 2001 From: MayaS111 Date: Sat, 29 Jun 2024 10:00:48 -0500 Subject: [PATCH 18/18] added render file --- db/development.sqlite3 | Bin 49152 -> 49152 bytes index.html | 65 +++++++++++++++++++++++++++++++++++++++++ render.yaml | 7 +++++ 3 files changed, 72 insertions(+) create mode 100644 index.html create mode 100644 render.yaml diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 2ee0a8a25d65494aa3c62d99072ba1ea978dc24a..31acb9f0afada6bcbdb70426cf2492c0d48d27e9 100644 GIT binary patch delta 76 zcmZo@U~Xt&o*>QWH&Mo!(Qjiy{2oTm$p>PR1uYc}O{`3ftV~Sx3{1=o42?IN#9A-{ YC3EB41>lnAdPW8&W+t1D?6YA606a4k*Z=?k delta 30 lcmZo@U~Xt&o*>QWGf~Ew(Pv{q{GQGGV{DjN&5cbh%>kOq35fsz diff --git a/index.html b/index.html new file mode 100644 index 00000000..54061c9f --- /dev/null +++ b/index.html @@ -0,0 +1,65 @@ + + + + + Maya Sheriff + + + + + + + + +
    +

    Welcome to my page. Take a look at my projects!

    +
    + + + + + diff --git a/render.yaml b/render.yaml new file mode 100644 index 00000000..50fad049 --- /dev/null +++ b/render.yaml @@ -0,0 +1,7 @@ +services: + - type: web + name: deliverytracker # the name of this service, eg hello-world + env: ruby # this app is written in ruby + plan: free # make sure to set this to free or you'll get billed $$$ + buildCommand: "./bin/render-build.sh" # we already created these two files for you + startCommand: "./bin/render-start.sh"