From 82c4686286f9994c1b7a51835c4fdf8a61384c05 Mon Sep 17 00:00:00 2001 From: Martijn Casteel Date: Thu, 31 Mar 2016 19:09:29 +0200 Subject: [PATCH] Improved api with hook for ideal transactions - when adding an ideal type it should be changed in both tables in the betalingen database --- app/controllers/api/activities_controller.rb | 2 +- app/controllers/api/groups_controller.rb | 4 ++-- app/controllers/api/participants_controller.rb | 8 ++++---- app/mailers/mailgun.rb | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/activities_controller.rb b/app/controllers/api/activities_controller.rb index 03d64566b..fb3af7343 100644 --- a/app/controllers/api/activities_controller.rb +++ b/app/controllers/api/activities_controller.rb @@ -1,7 +1,7 @@ class Api::ActivitiesController < ApiController before_action -> { doorkeeper_authorize! 'activity-read' }, only: [ :show ] - def index # TODO index also activity-read + def index if params[:date].present? @activities = Activity.where('(end_date IS NULL AND start_date = ?) OR end_date <= ?', params[:date], params[:date] ).order( :start_date ).limit( params[:limit] ||= 10 ).offset( params[:offset] ||= 0 ) diff --git a/app/controllers/api/groups_controller.rb b/app/controllers/api/groups_controller.rb index 65da5b34a..43dc92849 100644 --- a/app/controllers/api/groups_controller.rb +++ b/app/controllers/api/groups_controller.rb @@ -1,12 +1,12 @@ class Api::GroupsController < ApiController before_action -> { doorkeeper_authorize! 'group-read' }, only: [:index, :show] - def index #TODO filter members on year + def index #TODO filter active groups on current year @groups = Group.where( :category => params[:category]).order(:name) and return unless params[:category].nil? @groups = Group.all.order( :category, :name ) end - def show #TODO filter activities and members on year + def show @group = Group.find_by_id!(params[:id]) end end diff --git a/app/controllers/api/participants_controller.rb b/app/controllers/api/participants_controller.rb index da1fffefe..cbe26a95d 100644 --- a/app/controllers/api/participants_controller.rb +++ b/app/controllers/api/participants_controller.rb @@ -1,6 +1,6 @@ class Api::ParticipantsController < ApiController - # before_action -> { doorkeeper_authorize! 'participant-read' }, only: :index - # before_action -> { doorkeeper_authorize! 'participant-write' }, only: [:create, :destroy] + before_action -> { doorkeeper_authorize! 'participant-read' }, only: :index + before_action -> { doorkeeper_authorize! 'participant-write' }, only: [:create, :destroy] def index if params[:activity_id].present? @@ -22,7 +22,7 @@ def create head :bad_request and return unless @participant.save render :status => :created and return unless params[:bank].present? - @transaction = IdealTransaction.new( + @transaction = IdealTransaction.new( # TODO add redirect website :description => @participant.activity.name, :amount => @participant.currency.to_f + Settings.mongoose_ideal_costs, :issuer => params[:bank], @@ -45,7 +45,7 @@ def hook participant.update_attributes :paid => true end - head :ok + head :ok # TODO redirect to target website end def destroy diff --git a/app/mailers/mailgun.rb b/app/mailers/mailgun.rb index 58c8cd41b..547febe98 100644 --- a/app/mailers/mailgun.rb +++ b/app/mailers/mailgun.rb @@ -7,7 +7,7 @@ class Mailgun < ActionMailer::Base #Devise::Mailer include ActionView::Helpers::SanitizeHelper def confirmation_instructions(record, token, opts={}) - puts "#{confirmation_url(record, confirmation_token: token)}" if Rails.env == 'development' + puts "#{confirmation_url(record, confirmation_token: token)}" if Rails.env.development? # TODO aanpasbaar maken @email = record.unconfirmed_email ||= record.email