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
7eb1cfec
Commit
7eb1cfec
authored
Jul 20, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Plain Diff
initial commit
parents
9c21722b
6e675488
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
229 additions
and
184 deletions
+229
-184
application.css.scss
app/assets/stylesheets/application.css.scss
+1
-3
orders_controller.rb
app/controllers/orders_controller.rb
+7
-7
products_controller.rb
app/controllers/products_controller.rb
+15
-3
supplies_controller.rb
app/controllers/supplies_controller.rb
+8
-8
transaction.rb
app/models/transaction.rb
+2
-0
application.html.erb
app/views/layouts/application.html.erb
+10
-1
index.html.erb
app/views/products/index.html.erb
+173
-147
routes.rb
config/routes.rb
+4
-6
seeds.rb
db/seeds.rb
+0
-4
admin_users.yml
test/fixtures/admin_users.yml
+9
-5
No files found.
app/assets/stylesheets/application.css.scss
View file @
7eb1cfec
...
@@ -5,6 +5,4 @@
...
@@ -5,6 +5,4 @@
@import
"bootstrap"
;
@import
"bootstrap"
;
#container
{
padding-top
:
5rem
;
}
#container
{
padding-top
:
5rem
;
}
body
{
body
{
background-color
:
#d9e6f2
;}
background-color
:
#d9e6f2
;
}
app/controllers/orders_controller.rb
View file @
7eb1cfec
...
@@ -6,21 +6,21 @@ class OrdersController < ApplicationController
...
@@ -6,21 +6,21 @@ class OrdersController < ApplicationController
def
new
def
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
@order
=
@order
.
transactions
.
new
end
end
def
create
def
create
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
(
supply_params
)
@order
=
@order
.
transactions
.
new
(
supply_params
)
@order
.
mode
=
"Order"
@order
.
mode
=
"Order"
@order
.
user_id
=
current_user
.
id
@order
.
user_id
=
current_user
.
id
@order
.
quantity
=
@order
.
quantity
*
-
1
@order
.
quantity
=
@order
.
quantity
*
-
1
if
@product
.
save
if
@product
.
save
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully placed a new order"
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully placed a new order"
else
else
render
'new'
render
'new'
end
end
end
end
private
private
...
...
app/controllers/products_controller.rb
View file @
7eb1cfec
...
@@ -3,6 +3,7 @@ class ProductsController < ApplicationController
...
@@ -3,6 +3,7 @@ class ProductsController < ApplicationController
def
index
def
index
@products
=
Product
.
all
@products
=
Product
.
all
@products
=
Product
.
where
([
"name LIKE ?"
,
"%
#{
params
[
:search
]
}
%"
])
end
end
def
show
def
show
...
@@ -17,9 +18,9 @@ class ProductsController < ApplicationController
...
@@ -17,9 +18,9 @@ class ProductsController < ApplicationController
@product
=
Product
.
new
(
product_params
)
@product
=
Product
.
new
(
product_params
)
if
@product
.
save
if
@product
.
save
redirect_to
products_path
,
notice:
"You have successfully created a new product!"
redirect_to
products_path
,
notice:
"You have successfully created a new product!"
else
else
render
'new'
render
'new'
end
end
end
end
...
@@ -37,13 +38,24 @@ class ProductsController < ApplicationController
...
@@ -37,13 +38,24 @@ class ProductsController < ApplicationController
end
end
end
end
def
destroy
@product
=
Product
.
find_by
(
id:
params
[
:id
])
if
@product
.
status
==
"Inactive"
@product
.
status
=
"Active"
else
@product
.
status
=
"Inactive"
end
@product
.
save
redirect_to
products_path
,
alert:
alert
end
def
count
def
count
@products
.
count
@products
.
count
end
end
private
private
def
product_params
def
product_params
params
.
require
(
:product
).
permit!
params
.
require
(
:product
).
permit!
end
end
end
end
app/controllers/supplies_controller.rb
View file @
7eb1cfec
class
SuppliesController
<
ApplicationController
class
SuppliesController
<
ApplicationController
def
index
def
index
@products
=
Product
.
all
@products
=
Product
.
all
end
end
def
new
def
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@supply
=
@product
.
transactions
.
new
@supply
=
@product
.
transactions
.
new
end
end
def
create
def
create
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@supply
=
@product
.
transactions
.
new
(
supply_params
)
@supply
=
@product
.
transactions
.
new
(
supply_params
)
@supply
.
mode
=
"Supply"
@supply
.
mode
=
"Supply"
@supply
.
user_id
=
current_user
.
id
@supply
.
user_id
=
current_user
.
id
@supply
.
quantity
=
@supply
.
quantity
@supply
.
quantity
=
@supply
.
quantity
if
@product
.
save
if
@product
.
save
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully added a new supply."
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully added a new supply."
else
else
render
'new'
render
'new'
end
end
end
end
private
private
...
...
app/models/transaction.rb
View file @
7eb1cfec
class
Transaction
<
ApplicationRecord
class
Transaction
<
ApplicationRecord
has_many
:supplies
has_many
:orders
belongs_to
:product
belongs_to
:product
belongs_to
:user
belongs_to
:user
has_many
:supplies
has_many
:supplies
...
...
app/views/layouts/application.html.erb
View file @
7eb1cfec
...
@@ -48,9 +48,18 @@
...
@@ -48,9 +48,18 @@
<input
class=
"form-control mr-sm-2"
type=
"search"
placeholder=
"Search"
>
<input
class=
"form-control mr-sm-2"
type=
"search"
placeholder=
"Search"
>
<button
class=
"btn btn-outline-info my-2 my-sm-0"
type=
"submit"
>
Search
</button>
<button
class=
"btn btn-outline-info my-2 my-sm-0"
type=
"submit"
>
Search
</button>
</form>
</form>
<%=
form_tag
products_path
,
:method
=>
'get'
do
%>
<%=
text_field_tag
:search
,
params
[
:search
]
%>
<%=
submit_tag
"Search"
%>
<%
end
%>
</div>
</div>
</nav>
</nav>
<div
id=
"google_translate_element"
></div><script
type=
"text/javascript"
>
function
googleTranslateElementInit
()
{
new
google
.
translate
.
TranslateElement
({
pageLanguage
:
'en'
,
includedLanguages
:
'af,ar,da,de,en,es,fi,fr,hi,id,is,ja,ko,mi,ms,my,nl,no,pt,sw,tl,zh-CN'
,
layout
:
google
.
translate
.
TranslateElement
.
InlineLayout
.
HORIZONTAL
},
'google_translate_element'
);
}
</script><script
type=
"text/javascript"
src=
"//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"
></script>
>
<div
class=
"container"
id=
"container"
>
<div
class=
"container"
id=
"container"
>
<%
if
notice
%>
<%
if
notice
%>
...
...
app/views/products/index.html.erb
View file @
7eb1cfec
This diff is collapsed.
Click to expand it.
config/routes.rb
View file @
7eb1cfec
...
@@ -4,20 +4,18 @@ Rails.application.routes.draw do
...
@@ -4,20 +4,18 @@ Rails.application.routes.draw do
authenticated
:admin_user
do
authenticated
:admin_user
do
resources
:products
resources
:products
root
to:
'products#index'
,
as: :authenticated_admin_user_root
root
to:
'products#index'
,
as: :authenticated_admin_user_root
end
end
end
end
devise_for
:users
devise_for
:users
devise_scope
:user
do
devise_scope
:user
do
authenticated
:user
do
authenticated
:user
do
resources
:products
,
only:
[]
do
resources
:products
,
only:
[
:new
,
:show
]
do
resources
:orders
,
only:
[
:new
,
:create
]
resources
:orders
,
only:
[
:new
,
:create
]
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:comments
,
only:
[
:new
,
:create
]
end
end
root
to:
'products#index'
,
as: :authenticated_user_root
root
to:
'products#index'
,
as: :authenticated_user_root
end
end
end
end
root
to:
'publics#index'
root
to:
'publics#index'
end
end
\ No newline at end of file
db/seeds.rb
View file @
7eb1cfec
if
AdminUser
.
count
==
0
if
AdminUser
.
count
==
0
AdminUser
.
create!
([
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'
...
...
test/fixtures/admin_users.yml
View file @
7eb1cfec
...
@@ -4,8 +4,12 @@
...
@@ -4,8 +4,12 @@
# model remove the '{}' from the fixture names and add the columns immediately
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
# below each fixture, per the syntax in the comments below
#
#
one
:
{}
admin_user
:
# column: value
name
:
Andrea Dolendo
#
email
:
andrea.dolendo@obf.ateneo.edu
two
:
{}
password
:
Andrea25
# column: value
user
:
name
:
Chanelle Lunod
email
:
chanelle.lunod@obf.ateneo.edu
password
:
December5
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