Sha256: f188cb669a1de723840f76daf63577a8fdecdfb5e6849637ea900ae4ab4f22fe
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
module Redmineup module Liquid class UsersDrop < ::Liquid::Drop def self.default_drop self.new User.sorted end def initialize(users) @users = users end def before_method(login) user = @users.where(:login => login).first || User.new UserDrop.new user end def current UserDrop.new User.current end def all @all ||= @users.map do |user| UserDrop.new user end end def each(&block) all.each(&block) end def size @users.size end end class UserDrop < ::Liquid::Drop delegate :id, :name, :firstname, :lastname, :mail, :active?, :admin?, :logged?, :language, :to => :@user, allow_nil: true def initialize(user) @user = user end def avatar ApplicationController.helpers.avatar(@user) end def permissions roles = @user.memberships.collect { |m| m.roles }.flatten.uniq roles << (@user.logged? ? Role.non_member : Role.anonymous) roles.map(&:permissions).flatten.uniq.map(&:to_s) end def groups @user.groups.map(&:name) end def projects ProjectsDrop.new @user.memberships.map(&:project).flatten.select(&:visible?).uniq end def custom_field_values @user.custom_field_values end end end end
Version data entries
4 entries across 4 versions & 1 rubygems