team.rb revision b2dbef8c73faa240d208f3ff9fb49b21d9a894a5
db7b1bfd41eb01238f00c7df022f4c11d6414e8cEugen Kuksa # create admin user after team creation
2bc45485d0fe7200960bd17f1b81ea477bf16befTim Reddehase validates :name,
268e4c0f7fc6630f88604079ab4ede1b8963ec6aSascha Graef :presence => true,
d327eb79653cf7820fe583473ab35816d44cd757Eugen Kuksa :length => { :minimum => 3, :maximum => 50 },
e276f66fed51be31fe120ad73f369f497aebdabbEileen Bolloff :uniqueness => { :case_sensitive => false }
aa6a6b29584351c27210c27d29151fccbba61212Tim Reddehase # does the given user have admin-privileges in this team?
d327eb79653cf7820fe583473ab35816d44cd757Eugen Kuksa def admin?(user)
aa6a6b29584351c27210c27d29151fccbba61212Tim Reddehase user && (user.admin? || team_users.admin.find_by_user_id(user.id))
8e48b4c76e2fa30469470d03d6e7e403e8419ac4Sascha Graef # create admin user after team-creation
86ef19586a07f694886961e298f793803b8f4d54henning mueller def create_admin_user
41292ec9bfaafec2c0592a3ac0092e4c412ee7e8henning mueller if admin_user
19c33b67e5f1d783f812f85d2f681949484f925bEugen Kuksa team_users.create! \
0af513ab5680818fba780f05ef7cf16e0c0cb0d8henning mueller user: admin_user