def check_media_permissions(media, user, perm_type):
 media_type = media.__class__.__name__.lower()
 perm_name = ('gallery.%s_%s' % (perm_type, media_type))
 if ((user != media.creator) and (not user.has_perm(perm_name))):
  raise PermissionDenied

def check_media_permissions ( media , user , perm_type ) : media_type = media . __class__ . __name__ . lower ( ) perm_name = ( 'gallery.%s_%s' % ( perm_type , media_type ) ) if ( ( user != media . creator ) and ( not user . has_perm ( perm_name ) ) ) : raise PermissionDenied
checks the permissions for user on media .