#483: Update /maintainers page

This commit is contained in:
Vokhmin Alexey V 2015-07-09 00:54:57 +03:00
parent 028159b6af
commit 6563b3138e
7 changed files with 51 additions and 66 deletions

View File

@ -4,10 +4,10 @@ class Platforms::MaintainersController < Platforms::BaseController
def index def index
@maintainer = BuildList::Package.new(build_list_package_params) @maintainer = BuildList::Package.new(build_list_package_params)
@maintainers = BuildList::Package.includes(:project). @packages = @platform.packages.actual.like_name(@maintainer.name)
actual.by_platform(@platform). @projects = @platform.projects.joins(:packages).merge( @packages ).
like_name(@maintainer.name). includes(:maintainer).group('projects.id').reorder(:name).paginate(page: params[:page])
paginate(page: params[:page]) @packages = @packages.where(project_id: @projects.map(&:id)).group_by(&:project_id)
end end
def build_list_package_params def build_list_package_params

View File

@ -30,6 +30,7 @@ class Platform < ActiveRecord::Base
has_many :repositories, dependent: :destroy has_many :repositories, dependent: :destroy
has_many :key_pairs, through: :repositories has_many :key_pairs, through: :repositories
has_many :projects, through: :repositories
has_many :products, dependent: :destroy has_many :products, dependent: :destroy
has_many :tokens, as: :subject, dependent: :destroy has_many :tokens, as: :subject, dependent: :destroy

View File

@ -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

View File

@ -10,21 +10,30 @@
hr hr
table.table.table-striped table.table.table-striped
thead thead
tr tr
th.text-center= t("activerecord.attributes.maintainer.package_name") th.text-center= t('.project')
th.text-center= t("activerecord.attributes.maintainer.package_type") th.text-center= t('.packages')
th.text-center= t("activerecord.attributes.maintainer.version") th.text-center= t('.version')
th.text-center colspan=2 th.text-center= t('.maintainer')
= t("activerecord.models.maintainer") th.text-center= t('.updated_at')
th.text-center= t("activerecord.attributes.maintainer.updated_at")
tbody tbody
- MaintainerPresenter.present_collection(@maintainers) do |pr| - @projects.each do |project|
- packages = @packages[project.id]
tr tr
td= pr.package_link td= link_to project.name, project_path(project)
td= pr.package_type td= packages.map(&:name).uniq.sort * ', '
td= pr.package_version_release td
td= pr.maintainer_link = packages.map{ |p| "#{p.version}-#{p.release}" }.uniq * '; '
td= pr.maintainer_email_link.html_safe - if project.maintainer
td= pr.package_updated_at td
= link_to project.maintainer.fullname, project.maintainer
br
= mail_to project.maintainer.email, project.maintainer.email, encode: 'javascript'
- else
td
td= packages.map(&:updated_at).max
= will_paginate @projects

View File

@ -3,6 +3,6 @@
= render 'platforms/base/submenu' = render 'platforms/base/submenu'
.col-xs-12.col-md-10.col-md-offset-1 .col-xs-12.col-md-10.col-md-offset-1
.row .row
= render partial: 'list', object: @maintainers / = render partial: 'list', object: @maintainers
= will_paginate @maintainers / = will_paginate @maintainers
= render partial: 'list'

View File

@ -29,3 +29,12 @@ en:
placeholders: placeholders:
build_list_package: build_list_package:
name: Enter the package name here. name: Enter the package name here.
platforms:
maintainers:
list:
project: Project
packages: Packages
version: Version-Release
maintainer: Maintainer
updated_at: Last Update

View File

@ -29,3 +29,12 @@ ru:
placeholders: placeholders:
build_list_package: build_list_package:
name: Введите имя пакета здесь. name: Введите имя пакета здесь.
platforms:
maintainers:
list:
project: Проект
packages: Пакеты
version: Версия-Релиз
maintainer: Майнтейнер
updated_at: Обновлен