Merge branch 'master' into custom-domain
This commit is contained in:
commit
e3d41bcf7d
30 changed files with 271 additions and 21 deletions
|
|
@ -72,11 +72,12 @@ module Admin
|
|||
|
||||
def new
|
||||
@conference = Conference.new
|
||||
@organizations = Organization.accessible_by(current_ability, :update).pluck(:name, :id)
|
||||
end
|
||||
|
||||
def create
|
||||
@conference = Conference.new(conference_params)
|
||||
@conference.organization = Organization.find_or_create_by(name: 'organization')
|
||||
|
||||
if @conference.save
|
||||
# user that creates the conference becomes organizer of that conference
|
||||
current_user.add_role :organizer, @conference
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
module Admin
|
||||
class OrganizationsController < Admin::BaseController
|
||||
load_and_authorize_resource :organization
|
||||
before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins]
|
||||
|
||||
def index
|
||||
@organizations = Organization.all
|
||||
|
|
@ -43,8 +44,49 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def assign_org_admins
|
||||
if @user.has_role? 'organization_admin', @organization
|
||||
flash[:error] = "User #{@user.email} already has the role organization admin"
|
||||
elsif @user.add_role 'organization_admin', @organization
|
||||
flash[:notice] = "Successfully added role organization admin to user #{@user.email}"
|
||||
else
|
||||
flash[:error] = "Coud not add role organization admin to #{@user.email}"
|
||||
end
|
||||
|
||||
redirect_to admins_admin_organization_path(@organization)
|
||||
end
|
||||
|
||||
def unassign_org_admins
|
||||
if @user.remove_role 'organization_admin', @organization
|
||||
flash[:notice] = "Successfully removed role organization admin from user #{@user.email}"
|
||||
else
|
||||
flash[:error] = "Could not remove role organization admin from user #{@user.email}"
|
||||
end
|
||||
|
||||
redirect_to admins_admin_organization_path(@organization)
|
||||
end
|
||||
|
||||
def admins
|
||||
@role = @organization.roles.first
|
||||
@users = @role.users
|
||||
render 'show_org_admins'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:email)
|
||||
end
|
||||
|
||||
def verify_user
|
||||
@user = User.find_by(email: user_params[:email])
|
||||
unless @user
|
||||
redirect_to admins_admin_organization_path(@organization),
|
||||
error: 'Could not find user. Please provide a valid email!'
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def organization_params
|
||||
params.require(:organization).permit(:name, :description, :picture)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class PhysicalTicketController < ApplicationController
|
|||
@file_name = "ticket_for_#{@conference.short_title}"
|
||||
@user = @physical_ticket.user
|
||||
@ticket_layout = @conference.ticket_layout.to_sym
|
||||
@qrcode_image = RQRCode::QRCode.new(@physical_ticket.token).as_png(size: 180, border_modules: 0)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.pdf do
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ class TicketPurchasesController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
load_resource :conference, find_by: :short_title
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
authorize_resource
|
||||
|
||||
def create
|
||||
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue