#408: added description to MassBuild
This commit is contained in:
parent
790ea62670
commit
7ded629ca6
|
@ -1,4 +1,5 @@
|
|||
class Platforms::MassBuildsController < Platforms::BaseController
|
||||
include DatatableHelper
|
||||
|
||||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access']
|
||||
|
@ -41,7 +42,13 @@ class Platforms::MassBuildsController < Platforms::BaseController
|
|||
end
|
||||
|
||||
def index
|
||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(page: params[:page], per_page: 20)
|
||||
if request.xhr?
|
||||
@mass_builds = @platform.mass_builds
|
||||
@total_mass_builds = @mass_builds.count
|
||||
@mass_builds = @mass_builds.order("id #{sort_dir}")
|
||||
@mass_builds = @mass_builds.search(params[:sSearch]).
|
||||
paginate(page: page, per_page: per_page)
|
||||
end
|
||||
end
|
||||
|
||||
def cancel
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Platforms::RepositoriesController < Platforms::BaseController
|
||||
include DatatableHelper
|
||||
include FileStoreHelper
|
||||
include RepositoriesHelper
|
||||
|
||||
|
@ -117,7 +118,6 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
ON projects.owner_id = owner.id AND projects.owner_type = owner.type"
|
||||
colName = ['projects.name']
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0] == 'asc' ? 'asc' : 'desc'
|
||||
order = "#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
|
||||
if params[:added] == "true"
|
||||
|
@ -126,10 +126,7 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
@projects = Project.joins(owner_subquery).addable_to_repository(@repository.id)
|
||||
@projects = @projects.opened if @repository.platform.main? && !@repository.platform.hidden?
|
||||
end
|
||||
@projects = @projects.paginate(
|
||||
page: (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
|
||||
per_page: params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
|
||||
)
|
||||
@projects = @projects.paginate(page: page, per_page: per_page)
|
||||
|
||||
@total_projects = @projects.count
|
||||
@projects = @projects.by_owner(params[:owner_name]).
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Projects::BuildListsController < Projects::BaseController
|
||||
include DatatableHelper
|
||||
include FileStoreHelper
|
||||
|
||||
NESTED_ACTIONS = [:index, :new, :create]
|
||||
|
@ -166,15 +167,11 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
def list
|
||||
@build_lists = @project.build_lists
|
||||
sort_col = params[:ol_0] || 7
|
||||
sort_dir = params[:sSortDir_0] == 'asc' ? 'asc' : 'desc'
|
||||
order = "build_lists.updated_at #{sort_dir}"
|
||||
|
||||
@build_lists = @build_lists.paginate(page: (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, per_page: params[:iDisplayLength])
|
||||
@build_lists = @build_lists.paginate(page: page, per_page: per_page)
|
||||
@total_build_lists = @build_lists.count
|
||||
@build_lists = @build_lists.where(user_id: current_user) if params[:owner_filter] == 'true'
|
||||
@build_lists = @build_lists.where(status: [BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH]) if params[:status_filter] == 'true'
|
||||
@build_lists = @build_lists.order(order)
|
||||
@build_lists = @build_lists.order("build_lists.updated_at #{sort_dir}")
|
||||
|
||||
render partial: 'build_lists_ajax', layout: false
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Projects::ProjectsController < Projects::BaseController
|
||||
include DatatableHelper
|
||||
include ProjectsHelper
|
||||
before_filter :authenticate_user!
|
||||
load_and_authorize_resource id_param: :name_with_owner # to force member actions load
|
||||
|
@ -172,12 +173,6 @@ class Projects::ProjectsController < Projects::BaseController
|
|||
|
||||
def prepare_list(projects, groups, owners)
|
||||
res = {}
|
||||
|
||||
colName = ['name']
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0] == "desc" ? 'desc' : 'asc'
|
||||
order = "#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
|
||||
res[:total_count] = projects.count
|
||||
|
||||
if groups.present? || owners.present?
|
||||
|
@ -188,13 +183,9 @@ class Projects::ProjectsController < Projects::BaseController
|
|||
|
||||
res[:filtered_count] = projects.count
|
||||
|
||||
projects = projects.order(order)
|
||||
projects = projects.order("name #{sort_dir}")
|
||||
res[:projects] = if params[:iDisplayLength].present?
|
||||
start = params[:iDisplayStart].present? ? params[:iDisplayStart].to_i : 0
|
||||
length = params[:iDisplayLength].to_i
|
||||
page = start/length + 1
|
||||
|
||||
projects.paginate(page: page, per_page: length)
|
||||
projects.paginate(page: page, per_page: per_page)
|
||||
else
|
||||
projects
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module DatatableHelper
|
||||
def page
|
||||
(params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1
|
||||
end
|
||||
|
||||
def per_page
|
||||
params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
|
||||
end
|
||||
|
||||
def sort_dir
|
||||
params[:sSortDir_0] == 'asc' ? 'asc' : 'desc'
|
||||
end
|
||||
|
||||
end
|
|
@ -1,11 +1,60 @@
|
|||
module MassBuildHelper
|
||||
|
||||
COLUMNS = [
|
||||
{
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'html',
|
||||
sortable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
searchable: false,
|
||||
class: 'buttons'
|
||||
}
|
||||
]
|
||||
|
||||
def link_to_list platform, mass_build, which
|
||||
link_to t("layout.mass_builds.#{which}"),
|
||||
get_list_platform_mass_build_path(@platform, mass_build, kind: which, format: :txt),
|
||||
get_list_platform_mass_build_path(platform, mass_build, kind: which, format: :txt),
|
||||
target: "_blank" if can?(:get_list, mass_build)
|
||||
end
|
||||
|
||||
def link_to_mass_build(mass_build)
|
||||
link_to mass_build.name, build_lists_path+"#?#{{filter: {mass_build_id: mass_build.id, ownership: 'everything'}}.to_param}"
|
||||
end
|
||||
|
||||
def mass_builds_datatable(platform)
|
||||
datatable(
|
||||
COLUMNS,
|
||||
{
|
||||
sort_by: "[0, 'asc']",
|
||||
search_label: '',
|
||||
placeholder: t('layout.mass_builds.placeholder.description'),
|
||||
processing: t('layout.processing'),
|
||||
pagination_labels: {
|
||||
previous: t('datatables.previous_label'),
|
||||
next: t('datatables.next_label')
|
||||
},
|
||||
empty_label: t('datatables.empty_label'),
|
||||
info_label: t('datatables.info_label'),
|
||||
info_empty_label: t('datatables.info_empty_label'),
|
||||
filtered_label: t('datatables.filtered_label'),
|
||||
table_dom_id: 'datatable',
|
||||
auto_width: 'false',
|
||||
ajax_source: platform_mass_builds_path(platform, format: :json)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,11 +10,12 @@ class MassBuild < ActiveRecord::Base
|
|||
scope :recent, -> { order(created_at: :desc) }
|
||||
scope :by_platform, -> (platform) { where(save_to_platform_id: platform.id) }
|
||||
scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) }
|
||||
scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? }
|
||||
|
||||
attr_accessor :arches
|
||||
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
|
||||
:extra_repositories, :extra_build_lists, :increase_release_tag,
|
||||
:use_cached_chroot, :use_extra_tests
|
||||
:use_cached_chroot, :use_extra_tests, :description
|
||||
|
||||
validates :save_to_platform_id,
|
||||
:build_for_platform_id,
|
||||
|
@ -27,6 +28,9 @@ class MassBuild < ActiveRecord::Base
|
|||
presence: true,
|
||||
length: { maximum: 500_000 }
|
||||
|
||||
validates :description,
|
||||
length: { maximum: 255 }
|
||||
|
||||
validates :auto_publish,
|
||||
:increase_release_tag,
|
||||
:use_cached_chroot,
|
||||
|
|
|
@ -3,18 +3,16 @@
|
|||
|
||||
= link_to t('layout.mass_builds.new'), new_platform_mass_build_path(@platform), class: 'button' if can? :create, @platform.mass_builds.build
|
||||
|
||||
%table.tablesorter.unbordered{cellpadding: "0", cellspacing: "0"}
|
||||
|
||||
= raw mass_builds_datatable(@platform)
|
||||
|
||||
%table#datatable.tablesorter{cellspacing: 0, cellpadding: 0}
|
||||
%thead
|
||||
%tr
|
||||
%th.lpadding16= t('activerecord.attributes.mass_build.id')
|
||||
%th.lpadding16= t('activerecord.attributes.mass_build.name')
|
||||
%th.th2= t('activerecord.attributes.mass_build.description')
|
||||
%th.lpadding16= t('activerecord.attributes.mass_build.created_at')
|
||||
%th.lpadding16
|
||||
- @mass_builds.each do |mass_build|
|
||||
%tr
|
||||
%td= mass_build.id
|
||||
%td= link_to_mass_build(mass_build)
|
||||
%td= mass_build.created_at
|
||||
%td.right.mass-build-actions
|
||||
= link_to t('layout.show'), platform_mass_build_path(@platform, mass_build.id)
|
||||
= will_paginate @mass_builds
|
||||
%th.buttons
|
||||
%tbody
|
||||
%br
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
mass_builds = @mass_builds.map do |mass_build|
|
||||
[
|
||||
mass_build.id,
|
||||
|
||||
link_to_mass_build(mass_build),
|
||||
|
||||
mass_build.description,
|
||||
|
||||
mass_build.created_at.to_s,
|
||||
|
||||
link_to(t('layout.show'), platform_mass_build_path(@platform, mass_build.id))
|
||||
]
|
||||
end
|
||||
|
||||
json.sEcho params[:sEcho].to_i || -1
|
||||
json.iTotalRecords @total_mass_builds
|
||||
json.iTotalDisplayRecords @mass_builds.count
|
||||
json.aaData mass_builds || []
|
|
@ -10,6 +10,9 @@
|
|||
.both
|
||||
= check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), id: "repositories_#{rep.id}", href: "#{projects_list_platform_repository_path(@platform, rep)}?text=true"
|
||||
= label_tag "repositories_#{rep.id}", rep.name
|
||||
%h3=t('activerecord.attributes.mass_build.description')
|
||||
= f.text_area :description
|
||||
%br
|
||||
%h3=t('layout.mass_builds.projects_list')
|
||||
= f.text_area :projects_list
|
||||
%br
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
%b= t('activerecord.attributes.mass_build.name')
|
||||
%td= link_to_mass_build(@mass_build)
|
||||
|
||||
- %i(id arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at).each do |field|
|
||||
- %i(id arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at description).each do |field|
|
||||
%tr
|
||||
%td
|
||||
%b= t("activerecord.attributes.mass_build.#{field}")
|
||||
|
|
|
@ -16,6 +16,9 @@ en:
|
|||
cancel_confirm: Are you sure you want to cancel mass build?
|
||||
projects_list: Projects list
|
||||
missed_projects_list: 'Missed projects: '
|
||||
|
||||
placeholder:
|
||||
description: Description
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Mass Build
|
||||
|
@ -23,6 +26,7 @@ en:
|
|||
mass_build:
|
||||
id: Id
|
||||
name: Name
|
||||
description: Description
|
||||
created_at: Created
|
||||
updated_at: Updated
|
||||
arch_names: Architectures
|
||||
|
|
|
@ -16,6 +16,10 @@ ru:
|
|||
cancel_confirm: Вы уверены, что хотите отменить массовую сборку?
|
||||
projects_list: Проекты
|
||||
missed_projects_list: 'Несуществующие проекты: '
|
||||
|
||||
placeholder:
|
||||
description: Описание
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Массовая Сборка
|
||||
|
@ -23,6 +27,7 @@ ru:
|
|||
mass_build:
|
||||
id: Id
|
||||
name: Название
|
||||
description: Описание
|
||||
created_at: Создан
|
||||
updated_at: Обновлен
|
||||
arch_names: Архитектуры
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddDescriptionToMassBuilds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :description, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140625204136) do
|
||||
ActiveRecord::Schema.define(version: 20140626195741) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -327,6 +327,7 @@ ActiveRecord::Schema.define(version: 20140625204136) do
|
|||
t.boolean "increase_release_tag", default: false, null: false
|
||||
t.boolean "use_cached_chroot", default: true, null: false
|
||||
t.boolean "use_extra_tests", default: false, null: false
|
||||
t.string "description"
|
||||
end
|
||||
|
||||
create_table "users", force: true do |t|
|
||||
|
|
|
@ -23,6 +23,7 @@ describe MassBuild do
|
|||
it { should validate_presence_of(:projects_list)}
|
||||
it { should ensure_length_of(:projects_list).is_at_most(500_000) }
|
||||
|
||||
it { should ensure_length_of(:description).is_at_most(255) }
|
||||
|
||||
it { should_not allow_mass_assignment_of(:name) }
|
||||
it { should_not allow_mass_assignment_of(:arch_names) }
|
||||
|
|
Loading…
Reference in New Issue