Cleanup groups view on profile page

This commit is contained in:
wvengen 2014-12-16 21:09:04 +01:00
parent b080fb5fda
commit bf6a31a032
3 changed files with 32 additions and 17 deletions

View file

@ -46,20 +46,19 @@ class HomeController < ApplicationController
@financial_transactions = @financial_transactions.where("note LIKE ?", "%#{params[:query]}%") if params[:query].present?
else
redirect_to root_path, :alert => I18n.t('home.no_ordergroups')
redirect_to root_path, alert: I18n.t('home.no_ordergroups')
end
end
# cancel personal memberships direct from the myProfile-page
def cancel_membership
membership = Membership.find(params[:membership_id])
if membership.user == current_user
membership.destroy
flash[:notice] = I18n.t('home.ordergroup_cancelled', :group => membership.group.name)
if params[:membership_id]
membership = @current_user.memberships.find!(params[:membership_id])
else
flash[:error] = I18n.t('errors.general')
membership = @current_user.memberships.find_by_group_id!(params[:group_id])
end
redirect_to my_profile_path
membership.destroy
redirect_to my_profile_path, notice: I18n.t('home.ordergroup_cancelled', :group => membership.group.name)
end
end