def follow_user(context, data_dict):
 if ('user' not in context):
  raise logic.NotAuthorized(_('You must be logged in to follow users'))
 model = context['model']
 session = context['session']
 userobj = model.User.get(context['user'])
 if (not userobj):
  raise logic.NotAuthorized(_('You must be logged in to follow users'))
 schema = (context.get('schema') or ckan.logic.schema.default_follow_user_schema())
 (validated_data_dict, errors) = _validate(data_dict, schema, context)
 if errors:
  model.Session.rollback()
  raise ValidationError(errors)
 if (userobj.id == validated_data_dict['id']):
  message = _('You cannot follow yourself')
  raise ValidationError({'message': message}, error_summary=message)
 if model.UserFollowingUser.is_following(userobj.id, validated_data_dict['id']):
  followeduserobj = model.User.get(validated_data_dict['id'])
  name = followeduserobj.display_name
  message = _('You are already following {0}').format(name)
  raise ValidationError({'message': message}, error_summary=message)
 follower = model_save.follower_dict_save(validated_data_dict, context, model.UserFollowingUser)
 if (not context.get('defer_commit')):
  model.repo.commit()
 log.debug(u'User {follower} started following user {object}'.format(follower=follower.follower_id, object=follower.object_id))
 return model_dictize.user_following_user_dictize(follower, context)

def follow_user ( context , data_dict ) : if ( 'user' not in context ) : raise logic . NotAuthorized ( _ ( 'You must be logged in to follow users' ) ) model = context [ 'model' ] session = context [ 'session' ] userobj = model . User . get ( context [ 'user' ] ) if ( not userobj ) : raise logic . NotAuthorized ( _ ( 'You must be logged in to follow users' ) ) schema = ( context . get ( 'schema' ) or ckan . logic . schema . default_follow_user_schema ( ) ) ( validated_data_dict , errors ) = _validate ( data_dict , schema , context ) if errors : model . Session . rollback ( ) raise ValidationError ( errors ) if ( userobj . id == validated_data_dict [ 'id' ] ) : message = _ ( 'You cannot follow yourself' ) raise ValidationError ( { 'message' : message } , error_summary = message ) if model . UserFollowingUser . is_following ( userobj . id , validated_data_dict [ 'id' ] ) : followeduserobj = model . User . get ( validated_data_dict [ 'id' ] ) name = followeduserobj . display_name message = _ ( 'You are already following {0}' ) . format ( name ) raise ValidationError ( { 'message' : message } , error_summary = message ) follower = model_save . follower_dict_save ( validated_data_dict , context , model . UserFollowingUser ) if ( not context . get ( 'defer_commit' ) ) : model . repo . commit ( ) log . debug ( u'User {follower} started following user {object}' . format ( follower = follower . follower_id , object = follower . object_id ) ) return model_dictize . user_following_user_dictize ( follower , context )
adds the current user as follower of the given user .