<s> import httplib as http <EOL> from website . models import User <EOL> from framework . exceptions import HTTPError <EOL> from . . model import Badge , BadgeAssertion <EOL> def get_assertion_json ( * args , ** kwargs ) : <EOL> _id = kwargs . get ( '<STR_LIT>' , None ) <EOL> if _id : <EOL> assertion = BadgeAssertion . load ( _id ) <EOL> if not assertion . revoked : <EOL> return assertion . to_openbadge ( ) <EOL> return { '<STR_LIT>' : True } , http . GONE <EOL> raise HTTPError ( http . BAD_REQUEST ) <EOL> def get_badge_json ( * args , ** kwargs ) : <EOL> _id = kwargs . get ( '<STR_LIT>' , None ) <EOL> if _id : <EOL> badge = Badge . load ( _id ) <EOL> return badge . to_openbadge ( ) <EOL> raise HTTPError ( http . BAD_REQUEST ) <EOL> def get_organization_json ( * args , ** kwargs ) : <EOL> uid = kwargs . get ( '<STR_LIT>' , None ) <EOL> if uid : <EOL> user = User . load ( uid ) <EOL> if user : <EOL> badger = user . get_addon ( '<STR_LIT>' ) <EOL> if badger : <EOL> return badger . to_openbadge ( ) <EOL> raise HTTPError ( http . BAD_REQUEST ) </s>
