#276: updated UI of platforms, some refactoring
This commit is contained in:
parent
b0880a2595
commit
55bc1a8096
|
@ -56,6 +56,15 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def regenerate_metadata
|
||||
if @platform.regenerate
|
||||
flash[:notice] = I18n.t('flash.platform.saved')
|
||||
else
|
||||
flash[:error] = I18n.t('flash.platform.save_error')
|
||||
end
|
||||
redirect_to edit_platform_path(@platform)
|
||||
end
|
||||
|
||||
def change_visibility
|
||||
if @platform.change_visibility
|
||||
flash[:notice] = I18n.t("flash.platform.saved")
|
||||
|
|
|
@ -122,6 +122,7 @@ class Ability
|
|||
can([:remove_members, :remove_member, :add_member, :signatures], Repository) {|repository| owner?(repository.platform) || local_admin?(repository.platform)}
|
||||
can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(:id => user.id)}
|
||||
can(:clear, Platform) {|platform| owner?(platform) && platform.personal?}
|
||||
can(:regenerate_metadata, Platform) {|platform| owner?(platform) || local_admin?(platform)}
|
||||
can([:settings, :destroy, :edit, :update], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can([:create, :destroy], KeyPair) {|key_pair| owner?(key_pair.repository.platform) || local_admin?(key_pair.repository.platform)}
|
||||
|
@ -161,7 +162,7 @@ class Ability
|
|||
end
|
||||
|
||||
# Shared cannot rights for all users (registered, admin)
|
||||
cannot :destroy, Platform, :platform_type => 'personal'
|
||||
cannot [:regenerate_metadata, :destroy], Platform, :platform_type => 'personal'
|
||||
cannot [:create, :destroy], Repository, :platform => {:platform_type => 'personal'}, :name => 'main'
|
||||
cannot [:remove_members, :remove_member, :add_member, :sync_lock_file, :add_repo_lock_file, :remove_repo_lock_file], Repository, :platform => {:platform_type => 'personal'}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
module RegenerationStatus
|
||||
|
||||
def human_regeneration_status
|
||||
self.class::HUMAN_REGENERATION_STATUSES[last_regenerated_status] || :no_data
|
||||
end
|
||||
|
||||
def human_status
|
||||
self.class::HUMAN_STATUSES[status] || :no_data
|
||||
end
|
||||
|
||||
READY = 0
|
||||
WAITING_FOR_REGENERATION = 100
|
||||
REGENERATING = 200
|
||||
|
||||
HUMAN_STATUSES = {
|
||||
READY => :ready,
|
||||
WAITING_FOR_REGENERATION => :waiting_for_regeneration,
|
||||
REGENERATING => :regenerating
|
||||
}
|
||||
|
||||
HUMAN_REGENERATION_STATUSES = {
|
||||
AbfWorker::BaseObserver::COMPLETED => :completed,
|
||||
AbfWorker::BaseObserver::FAILED => :failed,
|
||||
AbfWorker::BaseObserver::CANCELED => :canceled
|
||||
}.freeze
|
||||
|
||||
end
|
|
@ -1,16 +1,10 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Platform < ActiveRecord::Base
|
||||
include RegenerationStatus
|
||||
|
||||
VISIBILITIES = %w(open hidden)
|
||||
NAME_PATTERN = /[\w\-\.]+/
|
||||
|
||||
READY = RepositoryStatus::READY
|
||||
WAITING_FOR_REGENERATION = RepositoryStatus::WAITING_FOR_REGENERATION
|
||||
REGENERATING = RepositoryStatus::REGENERATING
|
||||
|
||||
HUMAN_STATUSES = { READY => :ready,
|
||||
WAITING_FOR_REGENERATION => :waiting_for_regeneration,
|
||||
REGENERATING => :regenerating
|
||||
}.freeze
|
||||
HUMAN_STATUSES = HUMAN_STATUSES.clone.freeze
|
||||
|
||||
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
||||
belongs_to :owner, :polymorphic => true
|
||||
|
@ -77,19 +71,18 @@ class Platform < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :regenerate do
|
||||
transition :waiting_for_regeneration => :regenerating
|
||||
transition :ready => :waiting_for_regeneration, :if => lambda{ |p| p.main? }
|
||||
end
|
||||
|
||||
event :start_regeneration do
|
||||
transition :waiting_for_regeneration => :regenerating
|
||||
end
|
||||
|
||||
HUMAN_STATUSES.each do |code,name|
|
||||
state name, :value => code
|
||||
end
|
||||
end
|
||||
|
||||
def human_status
|
||||
HUMAN_STATUSES[status]
|
||||
end
|
||||
|
||||
def clear
|
||||
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.name }/repository/*")
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
class RepositoryStatus < ActiveRecord::Base
|
||||
READY = 0
|
||||
WAITING_FOR_RESIGN = 100
|
||||
WAITING_FOR_REGENERATION = 200
|
||||
REGENERATING = 300
|
||||
include RegenerationStatus
|
||||
|
||||
WAITING_FOR_RESIGN = 300
|
||||
PUBLISH = 400
|
||||
RESIGN = 500
|
||||
WAITING_FOR_RESIGN_AFTER_PUBLISH = 600
|
||||
|
@ -13,11 +12,8 @@ class RepositoryStatus < ActiveRecord::Base
|
|||
WAITING_FOR_RESIGN_AND_REGENERATION = 1100
|
||||
|
||||
|
||||
HUMAN_STATUSES = {
|
||||
READY => :ready,
|
||||
HUMAN_STATUSES = HUMAN_STATUSES.clone.merge({
|
||||
WAITING_FOR_RESIGN => :waiting_for_resign,
|
||||
WAITING_FOR_REGENERATION => :waiting_for_regeneration,
|
||||
REGENERATING => :regenerating,
|
||||
PUBLISH => :publish,
|
||||
RESIGN => :resign,
|
||||
WAITING_FOR_RESIGN_AFTER_PUBLISH => :waiting_for_resign_after_publish,
|
||||
|
@ -26,7 +22,7 @@ class RepositoryStatus < ActiveRecord::Base
|
|||
WAITING_FOR_REGENERATION_AFTER_RESIGN => :waiting_for_regeneration_after_resign,
|
||||
WAITING_FOR_RESIGN_AND_REGENERATION_AFTER_PUBLISH => :waiting_for_resign_and_regeneration_after_publish,
|
||||
WAITING_FOR_RESIGN_AND_REGENERATION => :waiting_for_resign_and_regeneration
|
||||
}.freeze
|
||||
}).freeze
|
||||
|
||||
belongs_to :platform
|
||||
belongs_to :repository
|
||||
|
@ -34,7 +30,7 @@ class RepositoryStatus < ActiveRecord::Base
|
|||
validates :repository_id, :platform_id, :presence => true
|
||||
validates :repository_id, :uniqueness => {:scope => :platform_id}
|
||||
|
||||
attr_accessible :last_regenerated_at, :last_regenerated_status, :platform_id, :repository_id, :status
|
||||
attr_accessible :platform_id, :repository_id
|
||||
|
||||
scope :platform_ready, where(:platforms => {:status => READY}).joins(:platform)
|
||||
scope :for_regeneration, platform_ready.where(:status => WAITING_FOR_REGENERATION)
|
||||
|
@ -84,8 +80,4 @@ class RepositoryStatus < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def human_status
|
||||
HUMAN_STATUSES[status]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -15,6 +15,22 @@
|
|||
:class => 'button'
|
||||
.both
|
||||
|
||||
- if can? :regenerate_metadata, @platform
|
||||
.hr
|
||||
%h3= t('layout.platforms.metadata')
|
||||
.leftside
|
||||
.rightside= link_to t('layout.regeneration_statuses.regenerate_metadata'), regenerate_metadata_platform_path(@platform), :method => :put, :confirm => t('layout.confirm'), :class => 'button'
|
||||
.both
|
||||
.leftlist= t('activerecord.attributes.regeneration_status.status')
|
||||
.rightlist= t("layout.regeneration_statuses.statuses.#{@platform.human_status}")
|
||||
.both
|
||||
.leftlist= t('activerecord.attributes.regeneration_status.last_regenerated_at')
|
||||
.rightlist= @platform.last_regenerated_at
|
||||
.both
|
||||
.leftlist= t('activerecord.attributes.regeneration_status.last_regenerated_status')
|
||||
.rightlist= t("layout.regeneration_statuses.last_regenerated_statuses.#{@platform.human_regeneration_status}")
|
||||
.both
|
||||
|
||||
- if can? :destroy, @platform
|
||||
.hr
|
||||
.leftside= t("layout.platforms.delete_warning")
|
||||
|
|
|
@ -28,6 +28,7 @@ module Rosa
|
|||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
# config.autoload_paths += %W(#{config.root}/extras)
|
||||
config.autoload_paths += %W(#{config.root}/app/presenters)
|
||||
config.autoload_paths += %W(#{config.root}/app/models/concerns)
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
|
|
|
@ -52,6 +52,7 @@ en:
|
|||
change_visibility_from_hidden: Change status to "Public"
|
||||
change_visibility_from_open: Change status to "Private"
|
||||
confirm_change_visibility: Are you sure you want to change visibility of this platform?
|
||||
metadata: Metadata for Software Center
|
||||
|
||||
flash:
|
||||
platform:
|
||||
|
|
|
@ -52,6 +52,7 @@ ru:
|
|||
change_visibility_from_hidden: Сменить статус на "Публичный"
|
||||
change_visibility_from_open: Сменить статус на "Приватный"
|
||||
confirm_change_visibility: Вы уверены, что хотите сменить статус этой платформы?
|
||||
metadata: Метаданные для Software Center
|
||||
|
||||
flash:
|
||||
platform:
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
en:
|
||||
layout:
|
||||
regeneration_statuses:
|
||||
regenerate_metadata: Regenerate metadata
|
||||
statuses:
|
||||
no_data: No data
|
||||
ready: No actions
|
||||
waiting_for_regeneration: Waiting for regeneration metadata
|
||||
regenerating: Regeneration of metadata
|
||||
waiting_for_resign: Waiting for resign of packages
|
||||
publish: Publish
|
||||
resign: Resign of packages
|
||||
waiting_for_resign_after_publish: Publish, waiting for resign of packages
|
||||
waiting_for_resign_after_regeneration: Regeneration of metadata, waiting for resign of packages
|
||||
waiting_for_regeneration_after_publish: Publish, waiting for regeneration metadata
|
||||
waiting_for_regeneration_after_resign: Resign of packages, waiting for regeneration metadata
|
||||
waiting_for_resign_and_regeneration_after_publish: Publish, waiting for resign of packages and regeneration metadata
|
||||
waiting_for_resign_and_regeneration: Waiting for resign of packages and regeneration metadata
|
||||
last_regenerated_statuses:
|
||||
no_data: No data
|
||||
completed: Completed succesfully
|
||||
failed: Completed not succesfully
|
||||
canceled: Canceled
|
||||
|
||||
activerecord:
|
||||
attributes:
|
||||
regeneration_status:
|
||||
last_regenerated_at: Last regeneration of metadata
|
||||
last_regenerated_status: Last status of regeneration metadata
|
||||
status: Current status
|
|
@ -0,0 +1,30 @@
|
|||
ru:
|
||||
layout:
|
||||
regeneration_statuses:
|
||||
regenerate_metadata: Регенерировать метаданные
|
||||
statuses:
|
||||
no_data: Нет данных
|
||||
ready: Нет действий
|
||||
waiting_for_regeneration: Ожидание регенерации методанных
|
||||
regenerating: Идет регенерация методанных
|
||||
waiting_for_resign: Ожидание подписи пакетов
|
||||
publish: Идет публикация
|
||||
resign: Идет подпись пакетов
|
||||
waiting_for_resign_after_publish: Идет публикация, ожидание подписи пакетов
|
||||
waiting_for_resign_after_regeneration: Идет регенерация методанных, ожидание подписи пакетов
|
||||
waiting_for_regeneration_after_publish: Идет публикация, ожидание регенерации методанных
|
||||
waiting_for_regeneration_after_resign: Идет подпись пакетов, ожидание регенерации методанных
|
||||
waiting_for_resign_and_regeneration_after_publish: Идет публикация, ожидание подписи пакетов и регенерации методанных
|
||||
waiting_for_resign_and_regeneration: Ожидание подписи пакетов и регенерации методанных
|
||||
last_regenerated_statuses:
|
||||
no_data: Нет данных
|
||||
completed: Завершена успешно
|
||||
failed: Завершена с ошибкой
|
||||
canceled: Отменена
|
||||
|
||||
activerecord:
|
||||
attributes:
|
||||
regeneration_status:
|
||||
last_regenerated_at: Последняя регенерация методанных
|
||||
last_regenerated_status: Статус последней регенерации методанных
|
||||
status: Текущее состояние
|
|
@ -152,6 +152,7 @@ Rosa::Application.routes.draw do
|
|||
resources :platforms do
|
||||
resources :private_users, :except => [:show, :destroy, :update]
|
||||
member do
|
||||
put :regenerate_metadata
|
||||
put :clear
|
||||
get :clone
|
||||
get :members
|
||||
|
|
|
@ -335,7 +335,7 @@ module AbfWorker
|
|||
}.map{ |k, v| "#{k}=#{v}" }.join(' ')
|
||||
|
||||
statuses.each(&:start_regeneration)
|
||||
platform.regenerate
|
||||
platform.start_regeneration
|
||||
Resque.push(
|
||||
'publish_worker_default',
|
||||
'class' => 'AbfWorker::PublishWorkerDefault',
|
||||
|
|
Loading…
Reference in New Issue