<s> from django . contrib . auth . models import User <EOL> from onadata . libs . permissions import ROLES <EOL> class ShareXForm ( object ) : <EOL> def __init__ ( self , xform , username , role ) : <EOL> self . xform = xform <EOL> self . username = username <EOL> self . role = role <EOL> @ property <EOL> def user ( self ) : <EOL> return User . objects . get ( username = self . username ) <EOL> def save ( self , ** kwargs ) : <EOL> role = ROLES . get ( self . role ) <EOL> if role and self . user and self . xform : <EOL> role . add ( self . user , self . xform ) </s>
