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
30167da0
Commit
30167da0
authored
Jul 16, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Plain Diff
initial commit
parents
dc2de209
cafc98c4
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
73 additions
and
71 deletions
+73
-71
comments_controller.rb
app/controllers/comments_controller.rb
+22
-2
orders_controller.rb
app/controllers/orders_controller.rb
+8
-8
supplies_controller.rb
app/controllers/supplies_controller.rb
+13
-8
comment.rb
app/models/comment.rb
+1
-1
product.rb
app/models/product.rb
+1
-0
new.html.erb
app/views/comments/new.html.erb
+7
-2
create.html.erb
app/views/orders/create.html.erb
+1
-1
index.html.erb
app/views/products/index.html.erb
+0
-3
create.html.erb
app/views/supplies/create.html.erb
+0
-2
index.html.erb
app/views/supplies/index.html.erb
+1
-1
new.html.erb
app/views/supplies/new.html.erb
+5
-5
index.html.erb
app/views/transactions/index.html.erb
+0
-6
order.html.erb
app/views/transactions/order.html.erb
+0
-11
supply.html.erb
app/views/transactions/supply.html.erb
+0
-11
20180716152823_create_comments.rb
db/migrate/20180716152823_create_comments.rb
+1
-1
schema.rb
db/schema.rb
+3
-3
seeds.rb
db/seeds.rb
+8
-4
comments.yml
test/fixtures/comments.yml
+2
-2
No files found.
app/controllers/comments_controller.rb
View file @
30167da0
class
CommentsController
<
ApplicationController
class
CommentsController
<
ApplicationController
def
new
end
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
app/controllers/orders_controller.rb
View file @
30167da0
class
OrdersController
<
ApplicationController
class
OrdersController
<
ApplicationController
def
new
def
new
@order
=
Order
.
new
@order
s
=
Order
.
new
end
end
def
create
def
create
@order
=
Order
.
new
(
product_params
)
@order
s
=
Order
.
new
(
product_params
)
if
@order
.
save
if
@order
s
.
save
redirect_to
products_path
,
notice:
"You have successfully placed a new order"
redirect_to
products_path
,
notice:
"You have successfully placed a new order"
else
else
render
'new'
render
'new'
...
@@ -15,11 +15,11 @@ class OrdersController < ApplicationController
...
@@ -15,11 +15,11 @@ class OrdersController < ApplicationController
end
end
def
show
def
show
if
params
[
:status
]
==
"activated"
if
params
[
:status
]
==
'Active'
@products
=
Product
.
activated
@products
=
Product
.
Active
else
else
@products
=
Product
.
inactivated
@products
=
Product
.
Inactive
end
end
end
end
end
end
app/controllers/supplies_controller.rb
View file @
30167da0
class
SuppliesController
<
ApplicationController
class
SuppliesController
<
ApplicationController
def
index
def
index
if
params
[
:status
]
==
"activated"
@products
=
Product
.
all
@products
=
Product
.
activated
else
@products
=
Product
.
inactivated
end
end
end
def
new
def
new
@suppl
y
=
Supply
.
new
@suppl
ies
=
Supply
.
new
end
end
def
create
def
create
@suppl
y
=
Supply
.
new
(
product_params
)
@suppl
ies
=
Supply
.
new
(
product_params
)
if
@suppl
y
.
save
if
@suppl
ies
.
save
redirect_to
products_path
,
notice:
"You have successfully added a new supply."
redirect_to
products_path
,
notice:
"You have successfully added a new supply."
else
else
render
'new'
render
'new'
end
end
end
end
def
show
if
params
[
:status
]
==
'Active'
@products
=
Product
.
Active
else
@products
=
Product
.
Inactive
end
end
end
end
app/models/comment.rb
View file @
30167da0
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 @
30167da0
class
Product
<
ApplicationRecord
class
Product
<
ApplicationRecord
has_many
:transactions
has_many
:transactions
has_many
:comments
end
end
app/views/comments/new.html.erb
View file @
30167da0
<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
View file @
30167da0
<h1>
Create Order
</h1>
<h1>
Create Order
s
</h1>
app/views/products/index.html.erb
View file @
30167da0
...
@@ -34,9 +34,6 @@
...
@@ -34,9 +34,6 @@
<td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
</td>
</td>
<td>
<%=
link_to
"Add Comment"
,
new_post_comment_path
(
post
),
class:
"btn btn-info"
%>
</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"
%>
</td>
</td>
...
...
app/views/supplies/create.html.erb
View file @
30167da0
<h1>
Create Supply
</h1>
<h1>
Create Supply
</h1>
app/views/supplies/index.html.erb
View file @
30167da0
<h1>
Supplies
</h1>
<h1>
Supplies
</h1>
<div>
<div>
<%=
link_to
"Add New Supply"
,
new_supply_path
,
class:
"btn btn-primary"
%>
<%=
link_to
"Add New Supply"
,
new_
product_
supply_path
,
class:
"btn btn-primary"
%>
</div>
</div>
<br>
<br>
...
...
app/views/supplies/new.html.erb
View file @
30167da0
<h1>
New Supply
</h1>
<h1>
New Supply
</h1>
<%=
simple_form_for
@supply
do
|
f
|
%>
<%=
simple_form_for
@supply
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary"
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
supplies_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Back"
,
supplies_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
app/views/transactions/index.html.erb
View file @
30167da0
...
@@ -28,12 +28,6 @@
...
@@ -28,12 +28,6 @@
<td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
</td>
</td>
<!-- <td>
<%=
link_to
"Add Order"
,
order_transaction_path
(
product
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
"Add Supply"
,
supply_transaction_path
(
product
),
class:
"btn btn-primary"
%>
</td> -->
</tr>
</tr>
<%
end
%>
<%
end
%>
</tbody>
</tbody>
...
...
app/views/transactions/order.html.erb
deleted
100644 → 0
View file @
dc2de209
<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 @
dc2de209
<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
db/migrate/201807161
32511
_create_comments.rb
→
db/migrate/201807161
52823
_create_comments.rb
View file @
30167da0
...
@@ -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 @
30167da0
...
@@ -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 @
30167da0
if
AdminUser
.
count
==
0
if
AdminUser
.
count
==
0
AdminUser
.
add
AdminUser
.
create!
(
(
{
email:
'andrea.dolendo@obf.ateneo.edu'
,
password:
'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/fixtures/comments.yml
View file @
30167da0
...
@@ -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