diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index ddd132e73..101f9213f 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -3,11 +3,11 @@ class Platforms::MaintainersController < Platforms::BaseController skip_before_action :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access'] def index - @maintainer = BuildList::Package.new(build_list_package_params) - @maintainers = BuildList::Package.includes(:project). - actual.by_platform(@platform). - like_name(@maintainer.name). - paginate(page: params[:page]) + @maintainer = BuildList::Package.new(build_list_package_params) + @packages = @platform.packages.actual.like_name(@maintainer.name) + @projects = @platform.projects.joins(:packages).merge( @packages ). + includes(:maintainer).group('projects.id').reorder(:name).paginate(page: params[:page]) + @packages = @packages.where(project_id: @projects.map(&:id)).group_by(&:project_id) end def build_list_package_params diff --git a/app/models/platform.rb b/app/models/platform.rb index aa0a44a49..5f9109556 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -30,6 +30,7 @@ class Platform < ActiveRecord::Base has_many :repositories, dependent: :destroy has_many :key_pairs, through: :repositories + has_many :projects, through: :repositories has_many :products, dependent: :destroy has_many :tokens, as: :subject, dependent: :destroy diff --git a/app/presenters/maintainer_presenter.rb b/app/presenters/maintainer_presenter.rb deleted file mode 100644 index 14247766c..000000000 --- a/app/presenters/maintainer_presenter.rb +++ /dev/null @@ -1,43 +0,0 @@ -class MaintainerPresenter < ApplicationPresenter - - attr_reader :package, :package_link, :package_name, :package_type, - :package_version, :package_release, :package_version_release, - :package_updated_at - attr_reader :maintainer, :maintainer_fullname, :maintainer_email, - :maintainer_link, :maintainer_mail_link - delegate :package_type, to: :package - - [:name, :version, :release, :updated_at].each do |meth| - define_method "package_#{meth}" do - @package.send meth - end - end - - [:fullname, :email].each do |meth| - define_method "maintainer_#{meth}" do - @maintainer.send meth - end - end - - def initialize(package, opts = {}) - @package = package - @maintainer = package.try(:assignee) - end - - def package_link - link_to @package.name, @package.project - end - - def package_version_release - "#{@package.version}-#{@package.release}" - end - - def maintainer_link - link_to @maintainer.fullname, @maintainer - end - - def maintainer_email_link - mail_to @maintainer.email, @maintainer.email, encode: "javascript" - end - -end diff --git a/app/views/platforms/maintainers/_list.html.slim b/app/views/platforms/maintainers/_list.html.slim index 58a037952..33ac6367d 100644 --- a/app/views/platforms/maintainers/_list.html.slim +++ b/app/views/platforms/maintainers/_list.html.slim @@ -10,21 +10,29 @@ hr -table.table.table-striped + +table.table.table-condensed thead tr - th.text-center= t("activerecord.attributes.maintainer.package_name") - th.text-center= t("activerecord.attributes.maintainer.package_type") - th.text-center= t("activerecord.attributes.maintainer.version") - th.text-center colspan=2 - = t("activerecord.models.maintainer") - th.text-center= t("activerecord.attributes.maintainer.updated_at") + th.col-md-1.text-center= t('.project') + th.col-md-4.text-center= t('.packages') + th.col-md-2.text-center= t('.version') + th.col-md-3.text-center= t('.maintainer') + th.col-md-2.text-center= t('.updated_at') tbody - - MaintainerPresenter.present_collection(@maintainers) do |pr| + - @projects.each do |project| + - packages = @packages[project.id] tr - td= pr.package_link - td= pr.package_type - td= pr.package_version_release - td= pr.maintainer_link - td= pr.maintainer_email_link.html_safe - td= pr.package_updated_at + td= link_to project.name, project_path(project) + td= packages.map(&:name).uniq.sort * ', ' + td.text-center + = packages.map{ |p| "#{p.version}-#{p.release}" }.uniq * '; ' + - if project.maintainer + td + => link_to project.maintainer.fullname, project.maintainer + = mail_to project.maintainer.email, project.maintainer.email, encode: 'javascript' + - else + td + td.text-center= packages.map(&:updated_at).max + += will_paginate @projects diff --git a/app/views/platforms/maintainers/index.html.slim b/app/views/platforms/maintainers/index.html.slim index 702c9925e..5ca369922 100644 --- a/app/views/platforms/maintainers/index.html.slim +++ b/app/views/platforms/maintainers/index.html.slim @@ -3,6 +3,6 @@ = render 'platforms/base/submenu' .col-xs-12.col-md-10.col-md-offset-1 .row - = render partial: 'list', object: @maintainers - = will_paginate @maintainers - + / = render partial: 'list', object: @maintainers + / = will_paginate @maintainers + = render partial: 'list' diff --git a/config/locales/models/maintainer.en.yml b/config/locales/models/maintainer.en.yml index fc82dbf94..132563832 100644 --- a/config/locales/models/maintainer.en.yml +++ b/config/locales/models/maintainer.en.yml @@ -28,4 +28,13 @@ en: name: Package placeholders: build_list_package: - name: Enter the package name here. \ No newline at end of file + name: Enter the package name here. + + platforms: + maintainers: + list: + project: Project + packages: Packages + version: Version-Release + maintainer: Maintainer + updated_at: Last Update diff --git a/config/locales/models/maintainer.ru.yml b/config/locales/models/maintainer.ru.yml index 5a8cfb1fb..b0f82533a 100644 --- a/config/locales/models/maintainer.ru.yml +++ b/config/locales/models/maintainer.ru.yml @@ -28,4 +28,13 @@ ru: name: Пакет placeholders: build_list_package: - name: Введите имя пакета здесь. \ No newline at end of file + name: Введите имя пакета здесь. + + platforms: + maintainers: + list: + project: Проект + packages: Пакеты + version: Версия-Релиз + maintainer: Майнтейнер + updated_at: Обновлен