Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create restaurants table and develop manager's manage menu page #24

Merged
merged 10 commits into from
Feb 28, 2020

Conversation

ChrisKheng
Copy link
Member

  1. Create restaurants table and link it to managers table.
  2. Refactor manager's manage pages (manage menu, promo & restaurant info).
  3. Develop basic manage menu page.

@ChrisKheng ChrisKheng self-assigned this Feb 27, 2020
@@ -82,5 +82,6 @@
add_foreign_key "admins", "users"
add_foreign_key "customers", "users"
add_foreign_key "managers", "users"
add_foreign_key "restaurants", "managers", on_delete: :cascade
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -46,7 +46,7 @@
t.decimal "minOrderCost", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["manager_id"], name: "index_restaurants_on_manager_id"
t.index ["manager_id"], name: "index_restaurants_on_manager_id", unique: true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [81/80]

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_02_25_011425) do
ActiveRecord::Schema.define(version: 2020_02_26_014752) do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [64/25]
Style/NumericLiterals: Use underscores(_) as decimal mark and separate every 3 digits with them.

@@ -0,0 +1,7 @@
class AddIndexToRestaurants < ActiveRecord::Migration[6.0]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.


# Returns a customised user which only consists of attributes that are chosen to be exposed.
def get_user_hash(user)
userHash = {id: user.id, username: user.username, email: user.email, roles: user.roles}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - userHash. Did you mean user?
Naming/VariableName: Use snake_case for variable names.
Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Metrics/LineLength: Line is too long. [93/80]
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.

user = current_user
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0]
restaurant = Restaurant.find_by_sql("SELECT * FROM restaurants WHERE manager_id = #{manager.id} LIMIT 1")[0]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

# Get the current user, manager, and restaurant
user = current_user
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0]
restaurant = Restaurant.find_by_sql("SELECT * FROM restaurants WHERE manager_id = #{manager.id} LIMIT 1")[0]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [112/80]

def get_current_manager()
# Get the current user, manager, and restaurant
user = current_user
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [97/80]

@@ -0,0 +1,15 @@
module ManagersHelper
def get_current_manager()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming/AccessorMethodName: Do not prefix reader method names with get_.
Style/DefWithParentheses: Omit the parentheses in defs when the method doesn't accept any arguments.

@@ -0,0 +1,15 @@
module ManagersHelper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level module documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

@ChrisKheng ChrisKheng linked an issue Feb 27, 2020 that may be closed by this pull request
@ChrisKheng ChrisKheng removed a link to an issue Feb 27, 2020
@ChrisKheng ChrisKheng linked an issue Feb 27, 2020 that may be closed by this pull request
@ChrisKheng ChrisKheng removed a link to an issue Feb 27, 2020
@ChrisKheng ChrisKheng linked an issue Feb 27, 2020 that may be closed by this pull request
else
return false
end
if rolelist.include?(role)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.

@@ -4,13 +4,18 @@ def user_has_role?(role)
return false
end

rolelist = current_user.roles.split(',')
rolelist = current_user.roles.split(',')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

@ChrisKheng ChrisKheng temporarily deployed to hungrydb-pip-manager1-b-jduro5 February 27, 2020 15:03 Inactive
@dcshzj dcshzj merged commit d457888 into master Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restaurant: Lay Groundwork
2 participants