Skip to content

Commit

Permalink
Improved api with hook for ideal transactions
Browse files Browse the repository at this point in the history
- when adding an ideal type it should be changed in both tables in the betalingen database
  • Loading branch information
martijncasteel committed Mar 31, 2016
1 parent 07b6edb commit 82c4686
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/activities_controller.rb
Original file line number Diff line number Diff line change
@@ -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 )

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions app/controllers/api/participants_controller.rb
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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],
Expand All @@ -45,7 +45,7 @@ def hook
participant.update_attributes :paid => true
end

head :ok
head :ok # TODO redirect to target website
end

def destroy
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/mailgun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82c4686

Please sign in to comment.