Skip to content

Commit

Permalink
Release OpenProject 14.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Aug 28, 2024
2 parents 2e04baf + 86c276b commit c678f49
Show file tree
Hide file tree
Showing 135 changed files with 1,037 additions and 987 deletions.
1 change: 0 additions & 1 deletion app/contracts/notifications/create_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class CreateContract < ::ModelContract
attribute :recipient
attribute :subject
attribute :reason
attribute :project
attribute :actor
attribute :resource
attribute :journal
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/sort_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def sort_link(column, caption, default_order, allowed_params: nil, **html_option
allowed_params ||= %w[filters per_page expand columns]

# Don't lose other params.
link_to_content_update(h(caption), safe_query_params(allowed_params).merge(sort_options), html_options)
link_to_content_update(h(caption), safe_query_params(allowed_params).merge(sort_options), html_options.merge(rel: :nofollow))
end

# Returns a table header <th> tag with a sort link for the named column
Expand Down
3 changes: 1 addition & 2 deletions app/mailers/digest_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ def work_packages(recipient_id, notification_ids)
def load_notifications(notification_ids)
Notification
.where(id: notification_ids)
.includes(:project, :resource)
.includes(:resource)
.reject do |notification|
notification.resource.nil? ||
notification.project.nil? ||
(notification.journal.nil? && !notification.date_alert?)
end
end
Expand Down
1 change: 0 additions & 1 deletion app/models/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class Notification < ApplicationRecord

belongs_to :recipient, class_name: "User"
belongs_to :actor, class_name: "User"
belongs_to :project
belongs_to :journal
belongs_to :resource, polymorphic: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/queries/filters/shared/custom_fields/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def error_messages

def condition
[
custom_field_context.where_subselect_conditions(custom_field, context),
custom_field_context.where_subselect_conditions,
operator_strategy.sql_for_field(values_replaced, CustomValue.table_name, "value")
].compact.join(" AND ")
end
Expand Down
11 changes: 11 additions & 0 deletions app/models/queries/notifications/filters/project_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,15 @@

class Queries::Notifications::Filters::ProjectFilter < Queries::Notifications::Filters::NotificationFilter
include Queries::Filters::Shared::ProjectFilter::Optional

# This is currently work package specific same as all the other parts of the NotificationQuery
self.model = WorkPackage

def joins
<<~SQL.squish
JOIN #{WorkPackage.table_name}
ON #{WorkPackage.table_name}.id = #{Notification.table_name}.resource_id
AND #{Notification.table_name}.resource_type = 'WorkPackage'
SQL
end
end
10 changes: 10 additions & 0 deletions app/models/queries/notifications/group_bys/group_by_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def self.key
:project
end

def joins
# Only Notifications for work_packages are currently supported via the query.
# E.g. the visible statement used in the query is WorkPackage specific.
<<~SQL.squish
JOIN work_packages
ON notifications.resource_id = work_packages.id
AND notifications.resource_type = 'WorkPackage'
SQL
end

def name
:project_id
end
Expand Down
16 changes: 12 additions & 4 deletions app/models/queries/notifications/orders/project_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ def self.key
end

def joins
:project
<<~SQL.squish
JOIN #{WorkPackage.table_name} work_packages_order
ON work_packages_order.id = #{Notification.table_name}.resource_id
AND #{Notification.table_name}.resource_type = 'WorkPackage'
JOIN #{Project.table_name}
ON #{Project.table_name}.id = work_packages_order.project_id
SQL
end

protected

def order(scope)
order_string = "projects.name"
order_string += " DESC" if direction == :desc
with_raise_on_invalid do
order_string = "#{Project.table_name}.name"
order_string += " DESC" if direction == :desc

scope.order(order_string)
scope.order(order_string)
end
end
end
4 changes: 2 additions & 2 deletions app/models/queries/projects/filters/custom_field_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def where_subselect_joins(custom_field)
SQL
end

def where_subselect_conditions(_custom_field, context)
def where_subselect_conditions
# Allow searching projects only with :view_project_attributes permission
allowed_project_ids = Project.allowed_to(context.user, :view_project_attributes)
allowed_project_ids = Project.allowed_to(User.current, :view_project_attributes)
.select(:id)
<<~SQL.squish
#{project_db_table}.id IN (#{allowed_project_ids.to_sql})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def where_subselect_joins(custom_field)
joins
end

def where_subselect_conditions(_custom_field, _context)
def where_subselect_conditions
nil
end
end
Expand Down
23 changes: 9 additions & 14 deletions app/models/work_packages/scopes/include_spent_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ module WorkPackages::Scopes::IncludeSpentTime

class_methods do
def include_spent_time(user, work_package = nil)
query = join_time_entries(user)

scope = left_join_self_and_descendants(user, work_package)
.joins(query.join_sources)
.with(visible_time_entries_cte.name => allowed_to_view_time_entries(user))
.joins(join_visible_time_entries.join_sources)
.group(:id)
.select("SUM(time_entries.hours) AS hours")
.select("SUM(#{visible_time_entries_cte.name}.hours) AS hours")

if work_package
scope.where(id: work_package.id)
Expand All @@ -47,18 +46,14 @@ def include_spent_time(user, work_package = nil)

protected

def join_time_entries(user)
join_condition = time_entries_table[:work_package_id]
.eq(wp_descendants[:id])
.and(allowed_to_view_time_entries(user))

def join_visible_time_entries
wp_table
.outer_join(time_entries_table)
.on(join_condition)
.outer_join(visible_time_entries_cte)
.on(visible_time_entries_cte[:work_package_id].eq(wp_descendants[:id]))
end

def allowed_to_view_time_entries(user)
time_entries_table[:id].in(TimeEntry.not_ongoing.visible(user).select(:id).arel)
TimeEntry.not_ongoing.visible(user).select(:id, :work_package_id, :hours).arel
end

def wp_table
Expand All @@ -71,8 +66,8 @@ def wp_descendants
@wp_descendants ||= wp_table.alias("descendants")
end

def time_entries_table
@time_entries_table ||= TimeEntry.arel_table
def visible_time_entries_cte
@visible_time_entries_cte ||= Arel::Table.new("visible_time_entries")
end
end
end
1 change: 0 additions & 1 deletion app/services/notifications/create_from_model_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def update_or_create_notification(recipient_id, reason)
def create_notification(recipient_id, reason)
notification_attributes = {
recipient_id:,
project:,
resource:,
journal:,
actor: user_with_fallback,
Expand Down
17 changes: 1 addition & 16 deletions app/services/notifications/set_attributes_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,5 @@
#++

module Notifications
class SetAttributesService < ::BaseServices::SetAttributes
private

def set_default_attributes(params)
super

set_default_project unless model.project
end

##
# Try to determine the project context from the journal (if any)
# or the resource if it has a project set
def set_default_project
model.project = model.journal&.project || model.resource.try(:project)
end
end
class SetAttributesService < ::BaseServices::SetAttributes; end
end
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def create_date_alert_notification(user, work_package, reason)
create_service = Notifications::CreateService.new(user:)
create_service.call(
recipient_id: user.id,
project_id: work_package.project_id,
resource: work_package,
reason:
)
Expand Down
4 changes: 2 additions & 2 deletions config/locales/crowdin/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ de:
status: "Arbeitspaket-Status"
token/api:
one: Zugangs-Token
other: Access tokens
other: Zugangs-Token
type: "Typ"
user: "Benutzer"
version: "Version"
Expand Down Expand Up @@ -1814,7 +1814,7 @@ de:
label_add_another_file: "Eine weitere Datei hinzufügen"
label_add_columns: "Ausgewählte Spalten hinzufügen"
label_add_note: "Kommentar hinzufügen"
label_add_projects: "Projekte erstellen"
label_add_projects: "Projekte hinzufügen"
label_add_related_work_packages: "Zugehöriges Arbeitspaket hinzufügen"
label_add_subtask: "Unteraufgabe hinzufügen"
label_added: "hinzugefügt"
Expand Down
16 changes: 8 additions & 8 deletions config/locales/crowdin/fr.seeders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ fr:
item_1:
name: Normal
item_2:
name: Haut
name: Haute
item_3:
name: Immédiat
name: Immédiate
projects:
demo-project:
name: Projet de démonstration
Expand Down Expand Up @@ -142,7 +142,7 @@ fr:
Si vous avez des questions ou si avez besoin d'aide, n'hésitez pas à nous contacter : [support[at]openproject.com](mailto:[email protected]).
item_5:
options:
name: Lots de Travaux
name: Lots de travaux
item_6:
options:
name: Étapes
Expand Down Expand Up @@ -312,7 +312,7 @@ fr:
N'hésitez pas à nous contacter si vous avez des questions ou si vous avez besoin d'aide. N'hésitez pas à nous contacter : [support[at]openproject.com(mailto:[email protected]).
item_5:
options:
name: Lots de Travaux
name: Lots de travaux
item_6:
options:
name: Plan de projet
Expand Down Expand Up @@ -414,7 +414,7 @@ fr:
* L'équipe discute du sprint : ce qui s'est bien passé, ce qui doit être amélioré pour améliorer la productivité pour le prochain sprint ou même avoir plus de plaisir.
statuses:
item_0:
name: nouveau
name: Nouveau
item_1:
name: En cous de spécification
item_2:
Expand All @@ -440,7 +440,7 @@ fr:
item_12:
name: En attente
item_13:
name: rejeté
name: Rejeté
time_entry_activities:
item_0:
name: Gestion
Expand All @@ -449,7 +449,7 @@ fr:
item_2:
name: Développement
item_3:
name: Test
name: En test
item_4:
name: Support
item_5:
Expand All @@ -466,7 +466,7 @@ fr:
item_4:
name: Epic
item_5:
name: Récit utilisateur
name: User story
item_6:
name: Bug
welcome:
Expand Down
Loading

0 comments on commit c678f49

Please sign in to comment.