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
864ef5bf
Commit
864ef5bf
authored
Jul 15, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
e67ef1de
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
74 additions
and
49 deletions
+74
-49
application_controller.rb
app/controllers/application_controller.rb
+2
-8
products_controller.rb
app/controllers/products_controller.rb
+4
-2
transactions_controller.rb
app/controllers/transactions_controller.rb
+1
-4
transaction.rb
app/models/transaction.rb
+5
-0
user.rb
app/models/user.rb
+9
-9
index.html.erb
app/views/publics/index.html.erb
+0
-2
index.html.erb
app/views/transactions/index.html.erb
+1
-8
routes.rb
config/routes.rb
+2
-6
20180715111200_create_transactions.rb
db/migrate/20180715111200_create_transactions.rb
+12
-0
schema.rb
db/schema.rb
+10
-1
seeds.rb
db/seeds.rb
+8
-9
transactions.yml
test/fixtures/transactions.yml
+13
-0
transaction_test.rb
test/models/transaction_test.rb
+7
-0
No files found.
app/controllers/application_controller.rb
View file @
864ef5bf
...
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
...
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
def
after_sign_in_path_for
(
resource
)
def
after_sign_in_path_for
(
resource
)
if
resource
.
is_a?
(
AdminUser
)
if
resource
.
is_a?
(
AdminUser
)
authenticated_admin_user_root_url
authenticated_admin_user_root_url
els
if
resource
.
is_a?
(
User
)
els
e
resource
.
is_a?
(
User
)
authenticated_user_root_url
authenticated_user_root_url
end
end
#authenticated_root_url
#authenticated_root_url
...
@@ -14,12 +14,6 @@ class ApplicationController < ActionController::Base
...
@@ -14,12 +14,6 @@ class ApplicationController < ActionController::Base
end
end
def
after_sign_out_path_for
(
resource
)
def
after_sign_out_path_for
(
resource
)
if
resource
==
:user
new_user_session_path
elsif
resource
==
:admin_user
new_admin_user_session_path
else
root_path
root_path
end
end
end
end
end
\ No newline at end of file
app/controllers/products_controller.rb
View file @
864ef5bf
...
@@ -3,8 +3,6 @@ class ProductsController < ApplicationController
...
@@ -3,8 +3,6 @@ class ProductsController < ApplicationController
def
index
def
index
@products
=
Product
.
all
@products
=
Product
.
all
#if @product.status == active
#else
end
end
def
show
def
show
...
@@ -39,6 +37,10 @@ class ProductsController < ApplicationController
...
@@ -39,6 +37,10 @@ class ProductsController < ApplicationController
end
end
end
end
def
count
@products
.
count
end
private
private
def
product_params
def
product_params
params
.
require
(
:product
).
permit!
params
.
require
(
:product
).
permit!
...
...
app/controllers/transactions_controller.rb
View file @
864ef5bf
...
@@ -6,10 +6,7 @@ class TransactionsController < ApplicationController
...
@@ -6,10 +6,7 @@ class TransactionsController < ApplicationController
end
end
def
display
def
display
if
@product
.
status
==
active
@product
=
Product
.
find_by
(
id:
params
[
:id
])
Products
.
find_by
(
id:
[
pramas
[
:id
])
else
#dont display
end
end
def
new
def
new
...
...
app/models/transaction.rb
0 → 100644
View file @
864ef5bf
class
Transaction
<
ApplicationRecord
belongs_to
:product
belongs_to
:user
end
app/models/user.rb
View file @
864ef5bf
...
@@ -4,14 +4,14 @@ class User < ApplicationRecord
...
@@ -4,14 +4,14 @@ class User < ApplicationRecord
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
: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
}
"
#
else
else
#
email
email
#
end
end
#
end
end
end
end
app/views/publics/index.html.erb
View file @
864ef5bf
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
<%=
simple_form_for
:admin_user
,
url:
session_path
(
:admin_user
)
do
|
f
|
%>
<%=
simple_form_for
:admin_user
,
url:
session_path
(
:admin_user
)
do
|
f
|
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password_confirmation
%>
<%=
f
.
button
:submit
,
"Log In"
%>
<%=
f
.
button
:submit
,
"Log In"
%>
<%
end
%>
<%
end
%>
</div>
</div>
...
@@ -15,7 +14,6 @@
...
@@ -15,7 +14,6 @@
<%=
simple_form_for
:user
,
url:
session_path
(
:user
)
do
|
f
|
%>
<%=
simple_form_for
:user
,
url:
session_path
(
:user
)
do
|
f
|
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password_confirmation
%>
<%=
f
.
button
:submit
,
"Log In"
%>
<%=
f
.
button
:submit
,
"Log In"
%>
<%=
link_to
"Sign Up"
,
new_user_registration_path
,
:class
=>
'navbar-link'
%>
<%=
link_to
"Sign Up"
,
new_user_registration_path
,
:class
=>
'navbar-link'
%>
<%
end
%>
<%
end
%>
...
...
app/views/transactions/index.html.erb
View file @
864ef5bf
<h1>
Transactions
</h1>
<h1>
Transactions
</h1>
<%
if
@products
.
empty?
%>
<%
if
@products
.
empty?
%>
<small>
<small>
No products have been created.
No products have been created.
</small>
</small>
<%
els
if
@products
.
status
==
active
%>
<%
els
e
%>
<table
class=
"table"
>
<table
class=
"table"
>
<thead>
<thead>
<th>
Name
</th>
<th>
Name
</th>
...
@@ -29,12 +28,6 @@
...
@@ -29,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>
...
...
config/routes.rb
View file @
864ef5bf
...
@@ -5,9 +5,7 @@ Rails.application.routes.draw do
...
@@ -5,9 +5,7 @@ Rails.application.routes.draw 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
unauthenticated
:admin_user
do
root
to:
'publics#index'
,
as: :unauthenticated_admin_user_root
end
end
end
devise_for
:users
devise_for
:users
...
@@ -19,9 +17,7 @@ Rails.application.routes.draw do
...
@@ -19,9 +17,7 @@ Rails.application.routes.draw do
end
end
root
to:
'transactions#index'
,
as: :authenticated_user_root
root
to:
'transactions#index'
,
as: :authenticated_user_root
end
end
unauthenticated
:user
do
root
to:
'publics#index'
,
as: :unauthenticated_user_root
end
end
end
root
to:
'publics#index'
root
to:
'publics#index'
end
end
db/migrate/20180715111200_create_transactions.rb
0 → 100644
View file @
864ef5bf
class
CreateTransactions
<
ActiveRecord
::
Migration
[
5.2
]
def
change
create_table
:transactions
do
|
t
|
t
.
integer
:product_id
t
.
integer
:user_id
t
.
integer
:quantity
t
.
string
:mode
t
.
timestamps
end
end
end
db/schema.rb
View file @
864ef5bf
...
@@ -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_1
2_181949
)
do
ActiveRecord
::
Schema
.
define
(
version:
2018_07_1
5_111200
)
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
...
@@ -37,6 +37,15 @@ ActiveRecord::Schema.define(version: 2018_07_12_181949) do
...
@@ -37,6 +37,15 @@ ActiveRecord::Schema.define(version: 2018_07_12_181949) do
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
end
create_table
"transactions"
,
force: :cascade
do
|
t
|
t
.
integer
"product_id"
t
.
integer
"user_id"
t
.
integer
"quantity"
t
.
string
"mode"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
create_table
"users"
,
force: :cascade
do
|
t
|
create_table
"users"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
...
...
db/seeds.rb
View file @
864ef5bf
if
AdminUser
.
count
==
0
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'
password_confirmation
:'Andrea25'
},
{
email:
'chanelle.lunod@obf.ateneo.edu'
,
password:
'December5'
,
password_confirmation
:'December5'
})
})
end
end
\ No newline at end of file
if
AdminUser
.
valid?
admin
.
save
()
# email: 'chanelle.lunod@obf.ateneo.edu',
# password: 'December5',
# password_confirmation:'December5'
\ No newline at end of file
test/fixtures/transactions.yml
0 → 100644
View file @
864ef5bf
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one
:
product_id
:
1
user_id
:
1
quantity
:
1
mode
:
MyString
two
:
product_id
:
1
user_id
:
1
quantity
:
1
mode
:
MyString
test/models/transaction_test.rb
0 → 100644
View file @
864ef5bf
require
'test_helper'
class
TransactionTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
end
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