-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into HER-23-add-teacher-to-roles-in-user
- Loading branch information
Showing
22 changed files
with
4,575 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class Api::V1::OrdersController < ApplicationController | ||
load_and_authorize_resource | ||
|
||
# GET /api/v1/orders | ||
def index | ||
render json: @orders, status: :ok | ||
end | ||
|
||
# POST /api/v1/orders | ||
def create | ||
@order.user = current_user # Automatically associate user | ||
|
||
if @order.save | ||
render json: @order, status: :created | ||
else | ||
render json: { errors: @order.errors.full_messages }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# GET /api/v1/orders/:id | ||
def show | ||
render json: @order, status: :ok | ||
end | ||
|
||
# PATCH/PUT /api/v1/orders/:id | ||
def update | ||
if @order.update(order_params) | ||
render json: @order, status: :ok | ||
else | ||
render json: { errors: @order.errors.full_messages }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# DELETE /api/v1/orders/:id | ||
def destroy | ||
@order.destroy | ||
render json: { message: "Order successfully deleted." }, status: :no_content | ||
end | ||
|
||
|
||
private | ||
|
||
def order_params | ||
params.require(:order).permit(:phone, :school_name, :school_address, :school_year, :kit_id, :comments) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class KitRequest < ApplicationRecord | ||
class Order < ApplicationRecord | ||
belongs_to :kit | ||
belongs_to :user | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class OrderSerializer < ActiveModel::Serializer | ||
# Defines how to display the Order model | ||
attributes :id, :order_name, :order_email, :ordered_kit, :kit_id, :user_id, :school_name, :school_address, :school_year, :comments, :phone, :created_at | ||
|
||
def order_name | ||
object.user.name if object.user.present? | ||
end | ||
|
||
def ordered_kit | ||
object.kit.name if object.kit.present? | ||
end | ||
|
||
def order_email | ||
object.user.email if object.user.present? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
lb3sm1G2uY1hyRbmz1v+gB16QKPzLMoVLVEUgEDuGVNtQVWu3h3PND2FpMi2xza+ffh5FhR2Awv5f9w5Ke1nAubo+PAaXV8XNebRM9Gi65/lNHGKfaBn6WvZwZn/rJPynp05mlU/+QsGLTZjJ1Ed+1rE/C6bYZ3qdKmiqHTXrmA0pTS4H3k5PAaJUkWZL9Yq0TKyo/v1iHQQtxDsqyxsNjXZZpFWcvmUPHLxNXY/iZqFP2+ApP1ot+2isL5VO5rHbaeJODXmhg1NvbO73UJRECok/EIKiaIKMQPM7PEJ4Q6cXOYnsHbamyszcdDlzeM8+7uWSONk0SUHbMvp7o6iqQ1hXEtRYPW7kpuwE7IUjbe2vstOHQ/ADvHwMEiQyTPAWGJroGesmJaMx065FI2a7isssMKv--JLpaTvFQzsCEDEYh--0AmLOnu/mo4CfzKtkig9yQ== | ||
# aws: | ||
# access_key_id: 123 | ||
# secret_access_key: 345 | ||
|
||
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies. | ||
secret_key_base: 3373452bfea693dbb70c378706f87e31819a445d845d7d967477c389936eb07769620b88e80092374c89cd3290685710f876f469f58afe49b1ff54f983a4b070 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lb3sm1G2uY1hyRbmz1v+gB16QKPzLMoVLVEUgEDuGVNtQVWu3h3PND2FpMi2xza+ffh5FhR2Awv5f9w5Ke1nAubo+PAaXV8XNebRM9Gi65/lNHGKfaBn6WvZwZn/rJPynp05mlU/+QsGLTZjJ1Ed+1rE/C6bYZ3qdKmiqHTXrmA0pTS4H3k5PAaJUkWZL9Yq0TKyo/v1iHQQtxDsqyxsNjXZZpFWcvmUPHLxNXY/iZqFP2+ApP1ot+2isL5VO5rHbaeJODXmhg1NvbO73UJRECok/EIKiaIKMQPM7PEJ4Q6cXOYnsHbamyszcdDlzeM8+7uWSONk0SUHbMvp7o6iqQ1hXEtRYPW7kpuwE7IUjbe2vstOHQ/ADvHwMEiQyTPAWGJroGesmJaMx065FI2a7isssMKv--JLpaTvFQzsCEDEYh--0AmLOnu/mo4CfzKtkig9yQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9682574f0b7086363f4e838d4509b74d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RenameKitRequestsToOrders < ActiveRecord::Migration[7.2] | ||
def change | ||
rename_table :kit_requests, :orders | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.