Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21_Final_Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chanelle Lunod
MIS21_Final_Project
Commits
cafc98c4
Commit
cafc98c4
authored
Jul 16, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
d5c4efc5
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
219 additions
and
86 deletions
+219
-86
orders.coffee
app/assets/javascripts/orders.coffee
+3
-0
supplies.coffee
app/assets/javascripts/supplies.coffee
+3
-0
orders.scss
app/assets/stylesheets/orders.scss
+3
-0
supplies.scss
app/assets/stylesheets/supplies.scss
+3
-0
comments_controller.rb
app/controllers/comments_controller.rb
+22
-2
orders_controller.rb
app/controllers/orders_controller.rb
+25
-0
supplies_controller.rb
app/controllers/supplies_controller.rb
+28
-0
transactions_controller.rb
app/controllers/transactions_controller.rb
+0
-41
orders_helper.rb
app/helpers/orders_helper.rb
+2
-0
supplies_helper.rb
app/helpers/supplies_helper.rb
+2
-0
comment.rb
app/models/comment.rb
+1
-1
product.rb
app/models/product.rb
+1
-0
user.rb
app/models/user.rb
+2
-1
new.html.erb
app/views/comments/new.html.erb
+7
-2
create.html.erb
app/views/orders/create.html.erb
+2
-0
new.html.erb
app/views/orders/new.html.erb
+8
-0
index.html.erb
app/views/products/index.html.erb
+0
-3
create.html.erb
app/views/supplies/create.html.erb
+2
-0
index.html.erb
app/views/supplies/index.html.erb
+44
-0
new.html.erb
app/views/supplies/new.html.erb
+10
-0
order.html.erb
app/views/transactions/order.html.erb
+0
-11
supply.html.erb
app/views/transactions/supply.html.erb
+0
-11
routes.rb
config/routes.rb
+6
-1
20180716152823_create_comments.rb
db/migrate/20180716152823_create_comments.rb
+1
-1
schema.rb
db/schema.rb
+3
-3
seeds.rb
db/seeds.rb
+6
-7
orders_controller_test.rb
test/controllers/orders_controller_test.rb
+14
-0
supplies_controller_test.rb
test/controllers/supplies_controller_test.rb
+19
-0
comments.yml
test/fixtures/comments.yml
+2
-2
No files found.
app/assets/javascripts/orders.coffee
0 → 100644
View file @
cafc98c4
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/javascripts/supplies.coffee
0 → 100644
View file @
cafc98c4
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/stylesheets/orders.scss
0 → 100644
View file @
cafc98c4
// Place all the styles related to the Orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
app/assets/stylesheets/supplies.scss
0 → 100644
View file @
cafc98c4
// Place all the styles related to the Supplies controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
app/controllers/comments_controller.rb
View file @
cafc98c4
class
CommentsController
<
ApplicationController
class
CommentsController
<
ApplicationController
def
new
def
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@comment
=
@product
.
comments
.
new
end
def
create
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@comment
=
@product
.
comments
.
new
(
comment_params
)
@comment
.
user
=
current_user
if
@comment
.
save
redirect_to
transaction_path
(
@product
),
notice:
"Comment has been added."
else
render
'new'
end
end
private
def
comment_params
params
.
require
(
:comment
).
permit!
end
end
end
end
app/controllers/orders_controller.rb
0 → 100644
View file @
cafc98c4
class
OrdersController
<
ApplicationController
def
new
@orders
=
Order
.
new
end
def
create
@orders
=
Order
.
new
(
product_params
)
if
@orders
.
save
redirect_to
products_path
,
notice:
"You have successfully placed a new order"
else
render
'new'
end
end
def
show
if
params
[
:status
]
==
'Active'
@products
=
Product
.
Active
else
@products
=
Product
.
Inactive
end
end
end
\ No newline at end of file
app/controllers/supplies_controller.rb
0 → 100644
View file @
cafc98c4
class
SuppliesController
<
ApplicationController
def
index
@products
=
Product
.
all
end
def
new
@supplies
=
Supply
.
new
end
def
create
@supplies
=
Supply
.
new
(
product_params
)
if
@supplies
.
save
redirect_to
products_path
,
notice:
"You have successfully added a new supply."
else
render
'new'
end
end
def
show
if
params
[
:status
]
==
'Active'
@products
=
Product
.
Active
else
@products
=
Product
.
Inactive
end
end
end
\ No newline at end of file
app/controllers/transactions_controller.rb
deleted
100644 → 0
View file @
d5c4efc5
class
TransactionsController
<
ApplicationController
before_action
:authenticate_user!
def
index
@products
=
Product
.
all
end
def
display
@product
=
Product
.
find_by
(
id:
params
[
:id
])
end
def
new
@product
.
order
=
Order
.
new
@products
.
supply
=
Supply
.
new
end
def
order
@product
.
order
=
Order
.
new
(
transaction_params
)
if
@product
.
order
.
save
redirect_to
transaction_path
,
notice:
"You have successfuly placed a new order."
else
render
'new'
end
end
def
supply
@product
.
supply
=
Supply
.
new
(
transaction_params
)
if
@product
.
supply
.
save
redirect_to
transaction_path
,
notice:
"You have successfully placed a new supply."
else
render
'new'
end
end
private
def
product_params
params
.
require
(
:product
).
permit!
end
end
\ No newline at end of file
app/helpers/orders_helper.rb
0 → 100644
View file @
cafc98c4
module
OrdersHelper
end
app/helpers/supplies_helper.rb
0 → 100644
View file @
cafc98c4
module
SuppliesHelper
end
app/models/comment.rb
View file @
cafc98c4
class
Comment
<
ApplicationRecord
class
Comment
<
ApplicationRecord
belongs_to
:user
belongs_to
:user
belongs_to
:p
os
t
belongs_to
:p
roduc
t
end
end
app/models/product.rb
View file @
cafc98c4
class
Product
<
ApplicationRecord
class
Product
<
ApplicationRecord
has_many
:transactions
has_many
:transactions
has_many
:comments
end
end
app/models/user.rb
View file @
cafc98c4
...
@@ -5,7 +5,8 @@ class User < ApplicationRecord
...
@@ -5,7 +5,8 @@ class User < ApplicationRecord
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:transactions
has_many
:transactions
# has_many :comments
has_many
:comments
def
to_s
def
to_s
if
first_name
&&
last_name
if
first_name
&&
last_name
"
#{
first_name
}
#{
last_name
}
"
"
#{
first_name
}
#{
last_name
}
"
...
...
app/views/comments/new.html.erb
View file @
cafc98c4
<h1>
Comments#new
</h1>
<h3>
Add Review
</h3>
<p>
Find me in app/views/comments/new.html.erb
</p>
Comment for:
<%=
@product
.
name
%>
<%=
simple_form_for
([
@product
,
@comment
])
do
|
f
|
%>
<%=
f
.
input
:comment
%>
<%=
f
.
button
:submit
,
"Add Review"
%>
<%
end
%>
app/views/orders/create.html.erb
0 → 100644
View file @
cafc98c4
<h1>
Orders#create
</h1>
<p>
Find me in app/views/orders/create.html.erb
</p>
app/views/orders/new.html.erb
0 → 100644
View file @
cafc98c4
<h1>
New Order
</h1>
<%=
simple_form_for
@order
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add Order"
,
class:
"btn btn-primary"
%>
<%
end
%>
\ No newline at end of file
app/views/products/index.html.erb
View file @
cafc98c4
...
@@ -33,9 +33,6 @@
...
@@ -33,9 +33,6 @@
</td>
</td>
<td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
</td>
<td>
<%=
link_to
"Add Comment"
,
new_post_comment_path
(
post
),
class:
"btn btn-info"
%>
</td>
</td>
<td>
<td>
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
...
...
app/views/supplies/create.html.erb
0 → 100644
View file @
cafc98c4
<h1>
Supplies#create
</h1>
<p>
Find me in app/views/supplies/create.html.erb
</p>
app/views/
transaction
s/index.html.erb
→
app/views/
supplie
s/index.html.erb
View file @
cafc98c4
<h1>
Transaction
s
</h1>
<h1>
Supplie
s
</h1>
<%
if
@products
.
empty?
%>
<div>
<%=
link_to
"Add New Supply"
,
new_product_supply_path
,
class:
"btn btn-primary"
%>
</div>
<br>
<%
if
@supplies
.
empty?
%>
<small>
<small>
No
products have been created
.
No
supplies available
.
</small>
</small>
<%
else
%>
<%
else
%>
<table
class=
"table"
>
<table
class=
"table"
>
<thead>
<thead>
<th>
Name
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Date Added
</th>
<th>
Time Created
</th>
<th>
Quantity
</th>
<th
colspan=
"4"
></th>
<th
colspan=
"4"
></th>
</thead>
</thead>
<tbody>
<tbody>
<%
@
products
.
each
do
|
product
|
%>
<%
@
supplies
.
each
do
|
supply
|
%>
<tr>
<tr>
<td>
<td>
<%=
link_to
product
.
name
,
product_path
(
product
)
%>
<%=
link_to
supply
.
name
,
supply_path
(
supply
)
%>
</td>
<td>
<%=
supply
.
description
%>
</td>
</td>
<td>
<td>
<%=
product
.
description
%>
<%=
time_ago_in_words
(
supply
.
created_at
)
%>
ago
</td>
</td>
<td>
<td>
<%=
product
.
status
%>
<%=
supply
.
quantity
%>
</td>
</td>
<td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</td>
</tr>
</tr>
<%
end
%>
<%
end
%>
...
...
app/views/supplies/new.html.erb
0 → 100644
View file @
cafc98c4
<h1>
New Supply
</h1>
<%=
simple_form_for
@supply
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
supplies_path
,
class:
"btn btn-default"
%>
<%
end
%>
app/views/transactions/order.html.erb
deleted
100644 → 0
View file @
d5c4efc5
<h1>
Add Order
</h1>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:product_id
,
as: :integer
%>
<%=
f
.
input
:user_id
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:mode
,
as: :string
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Add Order"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
\ No newline at end of file
app/views/transactions/supply.html.erb
deleted
100644 → 0
View file @
d5c4efc5
<h1>
Add Supply
</h1>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:product_id
,
as: :integer
%>
<%=
f
.
input
:user_id
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:mode
,
as: :string
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
\ No newline at end of file
config/routes.rb
View file @
cafc98c4
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
get
'orders/new'
get
'orders/create'
get
'supplies/index'
get
'supplies/new'
get
'supplies/create'
get
'comments/new'
get
'comments/new'
devise_for
:admin_users
devise_for
:admin_users
devise_scope
:admin_user
do
devise_scope
:admin_user
do
...
@@ -17,7 +22,7 @@ Rails.application.routes.draw do
...
@@ -17,7 +22,7 @@ Rails.application.routes.draw do
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:comments
,
only:
[
:new
,
:create
]
resources
:comments
,
only:
[
:new
,
:create
]
end
end
root
to:
'
transaction
s#index'
,
as: :authenticated_user_root
root
to:
'
supplie
s#index'
,
as: :authenticated_user_root
end
end
end
end
...
...
db/migrate/201807161
32511
_create_comments.rb
→
db/migrate/201807161
52823
_create_comments.rb
View file @
cafc98c4
...
@@ -3,7 +3,7 @@ class CreateComments < ActiveRecord::Migration[5.2]
...
@@ -3,7 +3,7 @@ class CreateComments < ActiveRecord::Migration[5.2]
create_table
:comments
do
|
t
|
create_table
:comments
do
|
t
|
t
.
text
:comment
t
.
text
:comment
t
.
references
:user
,
foreign_key:
true
t
.
references
:user
,
foreign_key:
true
t
.
references
:p
os
t
,
foreign_key:
true
t
.
references
:p
roduc
t
,
foreign_key:
true
t
.
timestamps
t
.
timestamps
end
end
...
...
db/schema.rb
View file @
cafc98c4
...
@@ -10,7 +10,7 @@
...
@@ -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
.
define
(
version:
2018_07_16_1
32511
)
do
ActiveRecord
::
Schema
.
define
(
version:
2018_07_16_1
52823
)
do
create_table
"admin_users"
,
force: :cascade
do
|
t
|
create_table
"admin_users"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"email"
,
default:
""
,
null:
false
...
@@ -32,10 +32,10 @@ ActiveRecord::Schema.define(version: 2018_07_16_132511) do
...
@@ -32,10 +32,10 @@ ActiveRecord::Schema.define(version: 2018_07_16_132511) do
create_table
"comments"
,
force: :cascade
do
|
t
|
create_table
"comments"
,
force: :cascade
do
|
t
|
t
.
text
"comment"
t
.
text
"comment"
t
.
integer
"user_id"
t
.
integer
"user_id"
t
.
integer
"p
os
t_id"
t
.
integer
"p
roduc
t_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"p
ost_id"
],
name:
"index_comments_on_pos
t_id"
t
.
index
[
"p
roduct_id"
],
name:
"index_comments_on_produc
t_id"
t
.
index
[
"user_id"
],
name:
"index_comments_on_user_id"
t
.
index
[
"user_id"
],
name:
"index_comments_on_user_id"
end
end
...
...
db/seeds.rb
View file @
cafc98c4
...
@@ -2,12 +2,11 @@ if AdminUser.count == 0
...
@@ -2,12 +2,11 @@ if AdminUser.count == 0
AdminUser
.
create!
(
AdminUser
.
create!
(
{
{
email:
'andrea.dolendo@obf.ateneo.edu'
,
email:
'andrea.dolendo@obf.ateneo.edu'
,
password:
'Andrea25'
,
password:
'Andrea25'
password_confirmation
:'Andrea25'
},
},
{
#
{
email:
'chanelle.lunod@obf.ateneo.edu'
,
#
email: 'chanelle.lunod@obf.ateneo.edu',
password:
'December5'
,
# password: 'December5'
password_confirmation
:'December5'
# }
}
)
)
end
end
\ No newline at end of file
test/controllers/orders_controller_test.rb
0 → 100644
View file @
cafc98c4
require
'test_helper'
class
OrdersControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get new"
do
get
orders_new_url
assert_response
:success
end
test
"should get create"
do
get
orders_create_url
assert_response
:success
end
end
test/controllers/supplies_controller_test.rb
0 → 100644
View file @
cafc98c4
require
'test_helper'
class
SuppliesControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get index"
do
get
supplies_index_url
assert_response
:success
end
test
"should get new"
do
get
supplies_new_url
assert_response
:success
end
test
"should get create"
do
get
supplies_create_url
assert_response
:success
end
end
test/fixtures/comments.yml
View file @
cafc98c4
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
one
:
one
:
comment
:
MyText
comment
:
MyText
user
:
one
user
:
one
p
os
t
:
one
p
roduc
t
:
one
two
:
two
:
comment
:
MyText
comment
:
MyText
user
:
two
user
:
two
p
os
t
:
two
p
roduc
t
:
two
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment