Merge pull request #45 from ZeusWPI/api

Add transactions API
This commit is contained in:
Robbe De Proft 2019-04-10 16:37:44 +02:00 committed by GitHub
commit f884506abc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -6,6 +6,10 @@ class RequestsController < ApplicationController
def index def index
@requests = @user.incoming_requests.group_by(&:status) @requests = @user.incoming_requests.group_by(&:status)
respond_to do |format|
format.html { }
format.json { render json: @requests }
end
end end
def confirm def confirm

View file

@ -55,7 +55,7 @@
%input.live-updating.value-thing{type: 'text', placeholder: 'Filter on Message', %input.live-updating.value-thing{type: 'text', placeholder: 'Filter on Message',
class: "form-control" } class: "form-control" }
%table#transactions.pure-table.pure-table-striped{data: { source: user_transactions_path(@user) }} %table#transactions.pure-table.pure-table-striped{data: { source: user_transactions_datatable_path(@user) }}
%thead %thead
%tr %tr
%th Time %th Time

View file

@ -13,7 +13,7 @@ Rails.application.routes.draw do
root to: 'pages#sign_in_page' root to: 'pages#sign_in_page'
resources :transactions, only: [:index, :create] resources :transactions, only: [:create]
resources :users, only: [:index, :show] do resources :users, only: [:index, :show] do
resources :requests, only: [:index], shallow: true do resources :requests, only: [:index], shallow: true do
post :confirm post :confirm
@ -22,8 +22,9 @@ Rails.application.routes.draw do
resources :notifications, only: [:index], shallow: true do resources :notifications, only: [:index], shallow: true do
post :read post :read
end end
resources :transactions, only: [:index], shallow: true
post :reset_key, on: :member post :reset_key, on: :member
end end
get 'datatables/:id' => 'datatables#transactions_for_user', as: "user_transactions" get 'datatables/:id' => 'datatables#transactions_for_user', as: "user_transactions_datatable"
end end