Skip to content

Instantly share code, notes, and snippets.

@cbeer
Created November 24, 2009 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbeer/241901 to your computer and use it in GitHub Desktop.
Save cbeer/241901 to your computer and use it in GitHub Desktop.
require 'dispatcher'
require 'odrl/lib/odrl'
module Rights_DocumentPatch
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
end
module ClassMethods
end
module InstanceMethods
end
end
module Rights_UserPatch
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
end
module ClassMethods
end
module InstanceMethods
def uid
email
end
def name
email
end
def groups
tags
end
end
end
Dispatcher.to_prepare do
SolrDocument.send(:include, Rights_DocumentPatch)
User.send(:include, Rights_UserPatch)
User.acts_as_taggable
end
require 'open-uri'
module FedoraHelper
[...]
def fedora_check_rights(pid, permission)
d = ODRL::Rights::Document.new
d.doc = open('http://openvaultresearch.wgbh.org:8080/fedora/get/' + pid + '/Rights')
d.eval permission, {}, current_user, {}
end
def render_fedora_partial(pid, cmodel)
begin
fedora_check_rights pid, 'play'
render :partial=>"fedora/_show_partials/#{cmodel}", :locals=>{:fedora_object=>pid}
rescue ODRL::Rights::InsufficientPrivileges
render :partial => "fedora/_show_partials/odrl_rights_insufficientprivileges", :locals=>{:fedora_object=>pid}
end
end
[...]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment