Sha256: 36f12e33bea6374be27c92e183bb636363a9ea317cdb2b81956a475ee2404ceb
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
module Bpl module InstitutionManagement module UserInstitutions extend ActiveSupport::Concern included do has_and_belongs_to_many :institutions end def institution_objects Bplmodels::Institution.find(self.list_institution_pids) end def list_institution_pids if superuser? #return all pids if superuser Institution.pluck(:pid) else #return only associated pids if normal user institutions.pluck(:pid) end end def list_institution_names if superuser? #return all pids if superuser Institution.pluck(:name) else #return only associated pids if normal user institutions.pluck(:name) end end def list_collection_pids collection_list = [] if superuser? #return all pids if superuser Bplmodels::Collection.find_in_batches("has_model_ssim"=>"info:fedora/afmodel:Bplmodels_Collection") do |collection_group| collection_group.each { |solr_objects| pid = solr_objects['id'] collection_list << pid } end else #return only associated pids if normal user self.institution_objects.each do |institution| institution.collections.each do |collection| collection_list << collection.pid end end end collection_list end def list_collection_names collection_list = [] if superuser? #return all pids if superuser Bplmodels::Collection.all.each do |collection| collection_list << collection.label end else #return only associated pids if normal user self.institution_objects.collections.each do |collection| collection_list << collection.label end end collection_list end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bpl-institution-management-0.0.2 | app/models/concerns/bpl/institution_management/user_institutions.rb |