mirror of
https://github.com/redmine/redmine.git
synced 2024-09-01 17:56:34 +02:00
![Eric Davis](/assets/img/avatar_default.png)
This filter will check an issue's assigned to field for users who have (or don't have) a specific Role(s). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4078 e93f8b46-1217-0410-a6f0-8f06a7374b81
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
module ObjectDaddyHelpers
|
|
# TODO: Remove these three once everyone has ported their code to use the
|
|
# new object_daddy version with protected attribute support
|
|
def User.generate_with_protected(attributes={})
|
|
User.generate(attributes)
|
|
end
|
|
|
|
def User.generate_with_protected!(attributes={})
|
|
User.generate!(attributes)
|
|
end
|
|
|
|
def User.spawn_with_protected(attributes={})
|
|
User.spawn(attributes)
|
|
end
|
|
|
|
def User.add_to_project(user, project, roles)
|
|
roles = [roles] unless roles.is_a?(Array)
|
|
Member.generate!(:principal => user, :project => project, :roles => roles)
|
|
end
|
|
|
|
# Generate the default Query
|
|
def Query.generate_default!(attributes={})
|
|
query = Query.spawn(attributes)
|
|
query.name ||= '_'
|
|
query.save!
|
|
query
|
|
end
|
|
|
|
# Generate an issue for a project, using it's trackers
|
|
def Issue.generate_for_project!(project, attributes={})
|
|
issue = Issue.spawn(attributes) do |issue|
|
|
issue.project = project
|
|
issue.tracker = project.trackers.first unless project.trackers.empty?
|
|
yield issue if block_given?
|
|
end
|
|
issue.save!
|
|
issue
|
|
end
|
|
|
|
end
|