Defect #28264 » fix_not_initialized_variable_in_query_model_V2.patch
| app/models/query.rb (Arbeitskopie) | ||
|---|---|---|
|
errors.add(:base, l(:label_role_plural) + ' ' + l('activerecord.errors.messages.blank')) if query.visibility == VISIBILITY_ROLES && roles.blank?
|
||
|
end
|
||
|
after_initialize :set_global_attribute
|
||
|
after_save do |query|
|
||
|
if query.saved_change_to_visibility? && query.visibility != VISIBILITY_ROLES
|
||
|
query.roles.clear
|
||
| ... | ... | |
|
@queried_table_name ||= self.class.queried_class.table_name
|
||
|
end
|
||
|
def initialize(attributes=nil, *args)
|
||
|
super attributes
|
||
|
@is_for_all = project.nil?
|
||
|
def set_global_attribute
|
||
|
@global_query = project.nil?
|
||
|
end
|
||
|
def is_for_all_projects?
|
||
|
@global_query ||= project.nil?
|
||
|
end
|
||
|
# Builds the query from the given params
|
||
|
def build_from_params(params, defaults={})
|
||
|
if params[:fields] || params[:f]
|
||
| ... | ... | |
|
# Admin can edit them all and regular users can edit their private queries
|
||
|
return true if user.admin? || (is_private? && self.user_id == user.id)
|
||
|
# Members can not edit public queries that are for all project (only admin is allowed to)
|
||
|
is_public? && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
||
|
is_public? && !is_for_all_projects? && user.allowed_to?(:manage_public_queries, project)
|
||
|
end
|
||
|
def trackers
|
||
- « Previous
- 1
- 2
- 3
- Next »