Skip to content
Snippets Groups Projects
Select Git revision
  • issue/70-hotfix-error-collection-resource-deleted
  • develop default protected
  • issue-68/streak-high_streak-last_action_at
  • issue/65-govbr
  • issue/54-curator-queue
  • issue/58-testar-s3
  • master protected
  • pre-submission
  • pre-languages
  • video-cache
  • tag-clustering-task
  • pre-api
  • orientdb
13 results

user_serializer.rb

Blame
  • Forked from PortalMEC / portalmec
    642 commits behind the upstream repository.
    user_serializer.rb 766 B
    class UserSerializer < ActiveModel::Serializer
      cache key: 'user', expires_in: 4.hours, except: [ :complained, :followed ]
    
      def complained
        object.complained? current_user
      end
    
      def followed
        current_user.try( :following?, object)
      end
    
      def email
        object.email if (current_user != nil)&&(object.id == current_user.id || current_user.is_admin?)
      end
    
      def learning_objects_count
        object.learning_objects.where('state = ?', LearningObject.states[:published]).count
      end
    
      attributes :id, :email, :provider, :name, :description, :education, :score, :cover, :role_ids, :institution_ids, :avatar, :likes_count, :followed, :complained, :follows_count, :learning_objects_count, :collections_count, :created_at, :updated_at
      has_many :subjects
    end