Merge branch 'catalog'

Conflicts:
	Gemfile
	Gemfile.lock
	app/views/layouts/application.html.haml
	app/views/repositories/show.html.haml
	config/locales/ru.yml
	config/routes.rb
	db/schema.rb
This commit is contained in:
Pavel Chipiga 2011-10-21 17:55:41 +03:00
commit 644d57b420
28 changed files with 458 additions and 96 deletions

15
Gemfile
View File

@ -6,20 +6,22 @@ gem 'pg', '~> 0.11.0'
gem 'silent-postgres', '~> 0.1.1'
gem 'devise', '~> 1.4.8'
gem 'omniauth', '~> 0.3.0'
gem 'oa-openid', '~> 0.3.0', :require => 'omniauth/openid'
gem 'cancan', '~> 1.6.7'
gem 'omniauth', '~> 0.3.2'
gem 'oa-openid', '~> 0.3.2', :require => 'omniauth/openid'
# gem 'cancan', '~> 1.6.7'
gem "haml-rails", '~> 0.3.4'
gem "compass", '~> 0.11.5'
gem 'jammit'
gem "yui-compressor", "0.9.5" # Higher versions depends on Platform gem which conflicts with Platform model
gem 'ancestry', '~> 1.2.4'
gem 'paperclip', "~> 2.3"
gem "will_paginate", "~> 3.0.2"
gem "russian"
gem "grit"
gem 'whenever', :require => false
gem 'delayed_job'
gem 'unicorn'
@ -54,13 +56,10 @@ end
group :development, :test do
gem 'mysql2', '<= 0.2.9'
end
gem "capistrano"
gem "capistrano-ext"
gem 'whenever', :require => false
group :test do
gem 'rspec-rails', '~> 2.6.1'
gem 'factory_girl_rails', '~> 1.2.0'
gem 'rspec-rails', '~> 2.7.0'
gem 'factory_girl_rails', '~> 1.3.0'
# gem 'spork', '>= 0.9.0.rc9'
# gem 'guard-spork', '~> 0.3.1'
# gem 'guard-rspec', '~> 0.5.0'

View File

@ -34,10 +34,11 @@ GEM
airbrake (3.0.4)
activesupport
builder
ancestry (1.2.4)
activerecord (>= 2.2.2)
arel (2.0.10)
bcrypt-ruby (3.0.1)
builder (2.1.2)
cancan (1.6.7)
capistrano (2.9.0)
highline
net-scp (>= 1.0.0)
@ -66,10 +67,10 @@ GEM
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (2.1.2)
factory_girl (2.2.0)
activesupport
factory_girl_rails (1.2.0)
factory_girl (~> 2.1.0)
factory_girl_rails (1.3.0)
factory_girl (~> 2.2.0)
railties (>= 3.0.0)
faraday (0.7.5)
addressable (~> 2.2.6)
@ -116,45 +117,45 @@ GEM
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.0)
oa-basic (0.3.0)
oa-core (= 0.3.0)
oa-basic (0.3.2)
oa-core (= 0.3.2)
rest-client (~> 1.6.0)
oa-core (0.3.0)
oa-enterprise (0.3.0)
oa-core (0.3.2)
oa-enterprise (0.3.2)
XMLCanonicalizer (~> 1.0.1)
addressable (~> 2.2.6)
net-ldap (~> 0.2.2)
nokogiri (~> 1.5.0)
oa-core (= 0.3.0)
oa-core (= 0.3.2)
pyu-ruby-sasl (~> 0.0.3.1)
rubyntlm (~> 0.1.1)
uuid
oa-more (0.3.0)
oa-more (0.3.2)
multi_json (~> 1.0.0)
oa-core (= 0.3.0)
oa-core (= 0.3.2)
rest-client (~> 1.6.0)
oa-oauth (0.3.0)
oa-oauth (0.3.2)
faraday (~> 0.7.3)
multi_json (~> 1.0.0)
multi_xml (~> 0.4.0)
oa-core (= 0.3.0)
oa-core (= 0.3.2)
oauth (~> 0.4.0)
oauth2 (~> 0.5.0)
oa-openid (0.3.0)
oa-core (= 0.3.0)
oa-openid (0.3.2)
oa-core (= 0.3.2)
rack-openid (~> 1.3.1)
ruby-openid-apps-discovery (~> 1.2.0)
oauth (0.4.5)
oauth2 (0.5.1)
faraday (~> 0.7.4)
multi_json (~> 1.0.3)
omniauth (0.3.0)
oa-basic (= 0.3.0)
oa-core (= 0.3.0)
oa-enterprise (= 0.3.0)
oa-more (= 0.3.0)
oa-oauth (= 0.3.0)
oa-openid (= 0.3.0)
omniauth (0.3.2)
oa-basic (= 0.3.2)
oa-core (= 0.3.2)
oa-enterprise (= 0.3.2)
oa-more (= 0.3.2)
oa-oauth (= 0.3.2)
oa-openid (= 0.3.2)
orm_adapter (0.0.5)
paperclip (2.4.4)
activerecord (>= 2.3.0)
@ -195,19 +196,19 @@ GEM
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
rspec-mocks (~> 2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
rspec-mocks (2.7.0)
rspec-rails (2.7.0)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
rspec (~> 2.7.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
@ -249,26 +250,26 @@ PLATFORMS
DEPENDENCIES
airbrake
cancan (~> 1.6.7)
ancestry (~> 1.2.4)
capistrano
capistrano-ext
capistrano_colors
compass (~> 0.11.5)
delayed_job
devise (~> 1.4.8)
factory_girl_rails (~> 1.2.0)
factory_girl_rails (~> 1.3.0)
grit
haml-rails (~> 0.3.4)
hpricot
jammit
mysql2 (<= 0.2.9)
oa-openid (~> 0.3.0)
omniauth (~> 0.3.0)
oa-openid (~> 0.3.2)
omniauth (~> 0.3.2)
paperclip (~> 2.3)
pg (~> 0.11.0)
rails (= 3.0.10)
rails3-generators
rspec-rails (~> 2.6.1)
rspec-rails (~> 2.7.0)
ruby-debug
ruby_parser
russian

View File

@ -0,0 +1,71 @@
class CategoriesController < ApplicationController
before_filter :authenticate_user!
before_filter :find_category, :only => [:show, :edit, :update, :destroy]
before_filter :find_platform, :only => [:show, :index]
def platforms
@platforms = Platform.all
@platforms_count = Platform.joins(:repositories => :projects).group('platforms.id').count
end
def index
if @platform
@categories = Category.joins(:projects => :repositories).where('repositories.platform_id = ?', @platform.id).
having('count(projects.id) > 0').group('categories.id').default_order
@categories_count = @categories.count
render 'index2'
else
@categories = Category.default_order.paginate(:page => params[:page])
end
end
def show
@projects = @category.projects
@projects = @projects.joins(:repositories).where("repositories.platform_id = ?", @platform.id) if @platform
@projects = @projects.paginate :page => params[:page]
end
def new
@category = Category.new
end
def edit
end
def destroy
@category.destroy
flash[:notice] = t("flash.category.destroyed")
redirect_to categories_path
end
def create
@category = Category.new params[:category]
if @category.save
flash[:notice] = t('flash.category.saved')
redirect_to categories_path
else
flash[:error] = t('flash.category.save_error')
render :action => :new
end
end
def update
if @category.update_attributes(params[:category])
flash[:notice] = t('flash.category.saved')
redirect_to categories_path
else
flash[:error] = t('flash.category.save_error')
render :action => :edit
end
end
protected
def find_category
@category = Category.find(params[:id])
end
def find_platform
@platform = Platform.find(params[:platform_id]) if params[:platform_id]
end
end

View File

@ -46,11 +46,12 @@ class ProjectsController < ApplicationController
def create
@project = Project.new params[:project]
@project.owner = get_acter
# @project.owner = get_acter
if @project.save
flash[:notice] = t('flash.project.saved')
redirect_to @project.owner
# redirect_to @project.owner
redirect_to @project
else
flash[:error] = t('flash.project.save_error')
render :action => :new

9
app/models/category.rb Normal file
View File

@ -0,0 +1,9 @@
class Category < ActiveRecord::Base
has_many :projects, :dependent => :nullify
validates :name, :presence => true
scope :default_order, order('categories.name')
has_ancestry
end

View File

@ -1,4 +1,5 @@
class Project < ActiveRecord::Base
belongs_to :category, :counter_cache => true
belongs_to :owner, :polymorphic => true
has_many :build_lists, :dependent => :destroy

View File

@ -0,0 +1,9 @@
%tr{:class => cycle("odd", "even")}
%td
= link_to category.name, category
(#{category.projects_count})
%td= category.parent.try(:name)
%td.last
= link_to t("layout.edit"), edit_category_path(category)
|
= link_to t("layout.delete"), category_path(category), :method => :delete, :confirm => t("layout.categories.confirm_delete")

View File

@ -0,0 +1,15 @@
= form_for @category, :html => { :class => :form } do |f|
.group
= f.label :parent_id, :class => :label
= f.collection_select :parent_id, Category.roots, :id, :name, :include_blank => true
.group
= f.label :name, :class => :label
= f.text_field :name, :class => 'text_field'
.group.navform.wat-cf
%button.button{:type => "submit"}
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), categories_path, :class => "text_button_padding link_button"

View File

View File

@ -0,0 +1,11 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.categories.list"), categories_path
%li= link_to t("layout.categories.platforms"), platforms_categories_path
%li= link_to t("layout.categories.new"), new_category_path
%li.active= link_to t("layout.categories.edit"), edit_category_path
.content
%h2.title= t("layout.categories.edit_header")
.inner= render "form"
- content_for :sidebar, render('sidebar')

View File

@ -0,0 +1,17 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.categories.list"), categories_path
%li= link_to t("layout.categories.platforms"), platforms_categories_path
%li= link_to t("layout.categories.new"), new_category_path
.content
%h2.title= t("layout.categories.list_header")
.inner
%table.table
%tr
%th= t("activerecord.attributes.category.name")
%th= t("activerecord.attributes.category.parent_id")
%th.last &nbsp;
= render @categories
.actions-bar.wat-cf
.actions= will_paginate @categories

View File

@ -0,0 +1,14 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.categories.list"), categories_path
%li.active= link_to t("layout.categories.platforms"), platforms_categories_path
.content
%h2.title= @platform.name
.inner
%table.table
- @categories.each do |category|
%tr{:class => cycle("odd", "even")}
%td= link_to category.name, [@platform, category]
%td= category.parent.name
%td.last= @categories_count[category.id].to_i

View File

@ -0,0 +1,9 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to "#{t("layout.categories.list")}", @categories_path
%li= link_to t("layout.categories.platforms"), platforms_categories_path
%li.active= link_to "#{t("layout.categories.new")}", @new_category_path
.content
%h2.title= t("layout.categories.new_header")
.inner= render "form"

View File

@ -0,0 +1,13 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.categories.list"), categories_path
%li.active= link_to t("layout.categories.platforms"), platforms_categories_path
.content
%h2.title= t("layout.platforms.list_header")
.inner
%table.table
- @platforms.each do |platform|
%tr{:class => cycle("odd", "even")}
%td= link_to platform.name, platform_categories_path(platform)
%td.last= @platforms_count[platform.id].to_i

View File

@ -0,0 +1,15 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.categories.list"), categories_path
%li= link_to t("layout.categories.platforms"), platforms_categories_path
- if @platform
%li.active= link_to @platform.name, platform_categories_path(@platform)
.content
%h2.title
= @category.name
(#{@category.parent.name})
.inner
%table.table= render @projects
.actions-bar.wat-cf
.actions= will_paginate @projects

View File

@ -26,6 +26,8 @@
%a{:href => downloads_path}= t("layout.menu.downloads")
%li{:class => controller.controller_path == 'event_logs' ? 'active' : '' }
%a{:href => event_logs_path}= t("layout.menu.event_logs")
%li{:class => controller.controller_path == 'categories' ? 'active' : '' }
%a{:href => categories_path}= t("layout.menu.categories")
#wrapper.wat-cf
= render :partial => "layouts/flashes"
#main

View File

@ -34,7 +34,7 @@
%b
= t('layout.platforms.owner')
\:
= link_to @platform.owner.name, url_for(@platform.owner)
= link_to @platform.owner.try(:name), url_for(@platform.owner)
%p
%b

View File

@ -1,9 +1,15 @@
.group
= f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label
= f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true
.group
= f.label :name, t("activerecord.attributes.project.name"), :class => :label
= f.text_field :name, :class => 'text_field'
.group
= f.label :unixname, t("activerecord.attributes.project.unixname"), :class => :label
= f.text_field :unixname, :class => 'text_field'
.group
= f.label :description, t("activerecord.attributes.project.description"), :class => :label
= f.text_area :description, :class => 'text_field', :cols => 80
.group.navform.wat-cf
%button.button{:type => "submit"}

View File

@ -0,0 +1,4 @@
%tr{:class => cycle("odd", "even")}
%td= link_to project.name, project_path(project)
%td= project.unixname
%td= project.description

View File

@ -23,7 +23,7 @@
%b
= t("activerecord.attributes.project.owner")
\:
= link_to @project.owner.name, url_for(@project.owner)
= link_to @project.owner.try(:name), url_for(@project.owner)
%p
%b
= t("activerecord.attributes.project.visibility")

View File

@ -1,4 +1,4 @@
.block.notice
%h3= t("layout.platforms.current_platform_header")
.content
%p= link_to @platform.name, platform_path(@platform)
/ %p= link_to @platform.name, platform_path(@platform)

View File

@ -40,6 +40,7 @@ ru:
groups: Группы
downloads: Статистика
event_logs: Лог событий
categories: Категории
sessions:
sign_in_header: Вход в систему
@ -50,6 +51,16 @@ ru:
list_header: Пары логин/пароль
confirm_delete: Вы уверены, что хотите удалить эту пару логин/пароль?
categories:
list: Список
new: Создать
edit: Редактировать
platforms: По платформам
list_header: Категории
new_header: Новая категория
edit_header: Редактировать категорию
confirm_delete: Вы уверены, что хотите удалить эту категорию?
platforms:
list: Список
new: Создать
@ -206,6 +217,11 @@ ru:
branch_not_found: бранч не найден
flash:
category:
saved: Категория успешно сохранена
save_error: Не удалось сохранить категорию
destroyed: Категория успешно удалена
project:
saved: Проект успешно сохранен
save_error: Не удалось сохранить проект
@ -263,6 +279,7 @@ ru:
activerecord:
models:
category: Категория
repository: Репозиторий
arch: Arch
container: Container
@ -282,6 +299,10 @@ ru:
login: Логин
password: Пароль
category:
parent_id: Родитель
name: Название
repository:
name: Название
platform_id: Платформа
@ -339,8 +360,10 @@ ru:
description: Описание события
project:
category_id: Категория
name: Название
unixname: Unixname
description: Описание
owner: Владелец
visibility: Видимость
repository_id: Репозиторий

View File

@ -7,42 +7,11 @@ Rosa::Application.routes.draw do
resources :event_logs, :only => :index
resources :downloads, :only => :index
# resources :platforms do
# member do
# get 'freeze'
# get 'unfreeze'
# get 'clone'
# end
#
# resources :products do
# member do
# get :clone
# get :build
# end
# end
#
# resources :repositories do
# resources :projects do
# resource :repo, :controller => "git/repositories", :only => [:show]
# resources :build_lists, :only => [:index, :show] do
# collection do
# get :recent
# post :filter
# end
# member do
# post :publish
# end
# end
#
# member do
# get :build
# post :process_build
# end
#
# end
# end
# end
#resources :privates
resources :categories do
get :platforms, :on => :collection
end
match '/private/:platform_name/*file_path' => 'privates#show'
resources :platforms do
@ -63,6 +32,8 @@ Rosa::Application.routes.draw do
resources :repositories do
end
resources :categories, :only => [:index, :show]
end
resources :projects do

View File

@ -0,0 +1,15 @@
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.string :ancestry
t.integer :projects_count, :default => 0, :null => false
t.timestamps
end
end
def self.down
drop_table :categories
end
end

View File

@ -0,0 +1,14 @@
class AddCategoryIdAndDescriptionToProjects < ActiveRecord::Migration
def self.up
change_table :projects do |t|
t.references :category
t.text :description
end
add_index :projects, :category_id
end
def self.down
remove_column :projects, :description
remove_column :projects, :category_id
end
end

View File

@ -61,6 +61,14 @@ ActiveRecord::Schema.define(:version => 20111019173246) do
add_index "build_lists", ["bs_id"], :name => "index_build_lists_on_bs_id", :unique => true
add_index "build_lists", ["project_id"], :name => "index_build_lists_on_project_id"
create_table "categories", :force => true do |t|
t.string "name"
t.string "ancestry"
t.integer "projects_count", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "containers", :force => true do |t|
t.string "name", :null => false
t.integer "project_id", :null => false
@ -183,14 +191,17 @@ ActiveRecord::Schema.define(:version => 20111019173246) do
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
t.integer "category_id"
t.text "description"
end
add_index "projects", ["category_id"], :name => "index_projects_on_category_id"
create_table "relations", :force => true do |t|
t.integer "object_id"
t.string "object_type"
t.integer "target_id"
t.string "target_type"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -206,12 +217,6 @@ ActiveRecord::Schema.define(:version => 20111019173246) do
t.string "visibility", :default => "open"
end
create_table "rights", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "role_lines", :force => true do |t|
t.integer "role_id"
t.integer "relation_id"
@ -221,8 +226,6 @@ ActiveRecord::Schema.define(:version => 20111019173246) do
create_table "roles", :force => true do |t|
t.string "name"
t.string "to"
t.string "on"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -248,9 +251,9 @@ ActiveRecord::Schema.define(:version => 20111019173246) do
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "uname"
t.string "nickname"
t.text "ssh_key"
t.string "uname"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true

View File

@ -37,3 +37,137 @@ ARCHES = %w(i586 i686 x86_64 mips powerpc)
ARCHES.each do |arch|
Arch.find_or_create_by_name arch
end
CATEGORIES = {
:mandriva =>
%(Accessibility
Archiving/Backup
Archiving/Cd burning
Archiving/Compression
Archiving/Other
Books/Computer books
Books/Faqs
Books/Howtos
Books/Literature
Books/Other
Communications
Databases
Development/C
Development/C++
Development/Databases
Development/GNOME and GTK+
Development/Java
Development/KDE and Qt
Development/Kernel
Development/Other
Development/Perl
Development/PHP
Development/Python
Development/Ruby
Development/X11
Editors
Education
Emulators
File tools
Games/Adventure
Games/Arcade
Games/Boards
Games/Cards
Games/Other
Games/Puzzles
Games/Sports
Games/Strategy
Graphical desktop/Enlightenment
Graphical desktop/FVWM based
Graphical desktop/GNOME
Graphical desktop/Icewm
Graphical desktop/KDE
Graphical desktop/Other
Graphical desktop/Sawfish
Graphical desktop/WindowMaker
Graphical desktop/Xfce
Graphics
Monitoring
Networking/Chat
Networking/File transfer
Networking/Instant messaging
Networking/IRC
Networking/Mail
Networking/News
Networking/Other
Networking/Remote access
Networking/WWW
Office
Publishing
Sciences/Astronomy
Sciences/Biology
Sciences/Chemistry
Sciences/Computer science
Sciences/Geosciences
Sciences/Mathematics
Sciences/Other
Sciences/Physics
Shells
Sound
System/Base
System/Cluster
System/Configuration/Boot and Init
System/Configuration/Hardware
System/Configuration/Networking
System/Configuration/Other
System/Configuration/Packaging
System/Configuration/Printing
System/Fonts/Console
System/Fonts/True type
System/Fonts/Type1
System/Fonts/X11 bitmap
System/Internationalization
System/Kernel and hardware
System/Libraries
System/Printing
System/Servers
System/X11
Terminals
Text tools
Toys
Video),
:naulinux =>
%(Amusements/Games
Amusements/Graphics
Applications/Archiving
Applications/Communications
Applications/Databases
Applications/Editors
Applications/Emulators
Applications/Engineering
Applications/File
Applications/Internet
Applications/Multimedia
Applications/Productivity
Applications/Publishing
Applications/System
Applications/Text
Development/Debuggers
Development/Languages
Development/Libraries
Development/System
Development/Tools
Documentation
System Environment/Base
System Environment/Daemons
System Environment/Kernel
System Environment/Libraries
System Environment/Shells
User Interface/Desktops
User Interface/X
User Interface/X Hardware Support)
}
CATEGORIES.each do |platform_type, categories|
parent = Category.roots.find_or_create_by_name(platform_type)
categories.split("\n").each do |category|
Category.find_or_create_by_name(category) do |c|
c.parent = parent
end
end
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Category do
pending "add some examples to (or delete) #{__FILE__}"
end