diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb deleted file mode 100644 index f7ed16b9d..000000000 --- a/app/controllers/categories_controller.rb +++ /dev/null @@ -1,78 +0,0 @@ -# -*- encoding : utf-8 -*- -class CategoriesController < ApplicationController - before_filter :authenticate_user! - before_filter :find_category, :only => [:show, :edit, :update, :destroy] - before_filter :find_platform, :only => [:show, :index] - - load_and_authorize_resource - - def platforms - @all_platforms = Platform.all - @all_platforms_count = Platform.joins(:repositories => :projects).group('platforms.id').count - @personal_platforms = Platform.personal - @personal_platforms_count = Platform.personal.joins(:repositories => :projects).group('platforms.id').count - @main_platforms = Platform.main - @main_platforms_count = Platform.main.joins(:repositories => :projects).group('platforms.id').count - end - - def index - if @platform - @categories = Category.select('categories.id, categories.name, categories.ancestry, count(projects.id) projects_count'). - joins(:projects => :repositories).where('repositories.platform_id = ?', @platform.id). - having('count(projects.id) > 0').group('categories.id, categories.name, categories.ancestry, projects_count') - render 'index2' - else - @categories = Category.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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1052213cc..ec035d7bc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- module ApplicationHelper def choose_title - title = if ['categories', 'personal_repositories', 'downloads'].include?(controller.controller_name) + title = if ['personal_repositories', 'downloads'].include?(controller.controller_name) APP_CONFIG['repo_project_name'] else APP_CONFIG['project_name'] diff --git a/app/models/category.rb b/app/models/category.rb deleted file mode 100644 index a7cb4d328..000000000 --- a/app/models/category.rb +++ /dev/null @@ -1,10 +0,0 @@ -# -*- encoding : utf-8 -*- -class Category < ActiveRecord::Base - has_many :projects, :dependent => :nullify - - validates :name, :presence => true - - default_scope order('categories.name') - - has_ancestry -end diff --git a/app/models/project.rb b/app/models/project.rb index 83b246f69..8f52595aa 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -3,7 +3,6 @@ class Project < ActiveRecord::Base VISIBILITIES = ['open', 'hidden'] MAX_OWN_PROJECTS = 32000 - belongs_to :category, :counter_cache => true belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count has_many :issues, :dependent => :destroy @@ -21,7 +20,7 @@ class Project < ActiveRecord::Base validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/} validates :owner, :presence => true validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS } - # validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?} + validates_attachment_size :srpm, :less_than => 500.megabytes validates_attachment_content_type :srpm, :content_type => ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], :message => I18n.t('layout.invalid_content_type') diff --git a/app/views/categories/_category.html.haml b/app/views/categories/_category.html.haml deleted file mode 100644 index 013dc5310..000000000 --- a/app/views/categories/_category.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%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") \ No newline at end of file diff --git a/app/views/categories/_form.html.haml b/app/views/categories/_form.html.haml deleted file mode 100644 index dc652871c..000000000 --- a/app/views/categories/_form.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -= 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("choose.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" diff --git a/app/views/categories/_sidebar.html.haml b/app/views/categories/_sidebar.html.haml deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/categories/edit.html.haml b/app/views/categories/edit.html.haml deleted file mode 100644 index c279e42ac..000000000 --- a/app/views/categories/edit.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -.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') diff --git a/app/views/categories/index.html.haml b/app/views/categories/index.html.haml deleted file mode 100644 index 52700aad1..000000000 --- a/app/views/categories/index.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -.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   - = render @categories - .actions-bar.wat-cf - .actions= will_paginate @categories diff --git a/app/views/categories/index2.html.haml b/app/views/categories/index2.html.haml deleted file mode 100644 index 97e74afed..000000000 --- a/app/views/categories/index2.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -.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= category.projects_count \ No newline at end of file diff --git a/app/views/categories/new.html.haml b/app/views/categories/new.html.haml deleted file mode 100644 index a7c6611db..000000000 --- a/app/views/categories/new.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -.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" diff --git a/app/views/categories/platforms.html.haml b/app/views/categories/platforms.html.haml deleted file mode 100644 index a93767620..000000000 --- a/app/views/categories/platforms.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -.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") - %br - .inner - %h3.title= t("layout.platforms.list_header_main") - %table.table - - @main_platforms.each do |platform| - %tr{:class => cycle("odd", "even")} - %td= link_to platform.name, platform_categories_path(platform) - %td.last= @main_platforms_count[platform.id].to_i - %br - .inner - %h3.title= t("layout.platforms.list_header_personal") - %table.table - - @personal_platforms.each do |platform| - %tr{:class => cycle("odd", "even")} - %td= link_to platform.name, platform_categories_path(platform) - %td.last= @personal_platforms_count[platform.id].to_i - %br - .inner - %h3.title= t("layout.platforms.list_header_all") - %table.table - - @all_platforms.each do |platform| - %tr{:class => cycle("odd", "even")} - %td= link_to platform.name, platform_categories_path(platform) - %td.last= @all_platforms_count[platform.id].to_i diff --git a/app/views/categories/show.html.haml b/app/views/categories/show.html.haml deleted file mode 100644 index 0ee654296..000000000 --- a/app/views/categories/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -.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 diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 5642020ee..4a4ffa06f 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -21,10 +21,7 @@ - else = hidden_field_tag :who_owns, :me .both --#- if [:new, :create].include? act --# .leftlist= f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label --# .rightlist= f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true --# .both + .leftlist= f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label .rightlist =# f.select :visibility, Project::VISIBILITIES diff --git a/config/locales/en.yml b/config/locales/en.yml index 3b4bc3759..e2b649312 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -93,16 +93,6 @@ en: regenerate_btn: Regenerate warning_message: Warning - Old data set as invalid when new data obtaining - categories: - list: List - new: Create - edit: Edit - platforms: By platform - list_header: Catalogue - new_header: New category - edit_header: Edit category - confirm_delete: Are you sure to delete this category? - collaborators: back_to_proj: Back to project edit: Edit list @@ -166,11 +156,6 @@ en: successfully_added: Member %s successfully added error_in_adding: Member %s adding error - category: - saved: Category saved - save_error: Category saves error - destroyed: Category deleted - blob: successfully_updated: File '%{name}' successfully updated updating_error: Error updating file '%{name}' @@ -192,7 +177,6 @@ en: can_have_less_or_equal: You cannot have more than %{count} projects. models: - category: Category arch: Arch container: Container rpm: RPM @@ -216,10 +200,6 @@ en: login: Login password: Password - category: - parent_id: Parent - name: Name - arch: name: Name created_at: Created diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index f9aeb6885..458463829 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -3,7 +3,6 @@ en: repositories: Repositories personal_repository: My repository products: Products - categories: Catalogue downloads: Statistics top_menu: platforms: Platforms diff --git a/config/locales/menu.ru.yml b/config/locales/menu.ru.yml index 858689f6c..a7d0682d8 100644 --- a/config/locales/menu.ru.yml +++ b/config/locales/menu.ru.yml @@ -1,6 +1,5 @@ ru: menu: - categories: Каталог products: Продукты repositories: Репозитории personal_repository: Мой репозиторий diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index ebfe1c0e0..e79e66abd 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -60,7 +60,6 @@ en: project: Project attributes: project: - category_id: Category name: Name description: Descripton owner: Owner diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 194a8a0b3..acda92170 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -60,7 +60,6 @@ ru: project: Проект attributes: project: - category_id: Категория name: Название description: Описание owner: Владелец diff --git a/config/locales/ru.yml b/config/locales/ru.yml index a8c9d7614..ca0c366c3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -93,16 +93,6 @@ ru: regenerate_btn: Перегенерировать warning_message: Примечание - При получении новых данных старые становятся недействительными - categories: - list: Список - new: Создать - edit: Редактировать - platforms: По платформам - list_header: Каталог - new_header: Новая категория - edit_header: Редактировать категорию - confirm_delete: Вы уверены, что хотите удалить эту категорию? - collaborators: back_to_proj: Вернуться к проекту edit: Редактировать список @@ -166,11 +156,6 @@ ru: successfully_added: Участник %s успешно добавлен error_in_adding: Ошибка при добавлении участника %s - category: - saved: Категория успешно сохранена - save_error: Не удалось сохранить категорию - destroyed: Категория успешно удалена - blob: successfully_updated: Файл '%{name}' успешно обновлен updating_error: Ошибка обновления файла '%{name}' @@ -192,7 +177,6 @@ ru: can_have_less_or_equal: Нельзя иметь больше, чем %{count} проектов. models: - category: Категория arch: Arch container: Container rpm: RPM @@ -217,10 +201,6 @@ ru: login: Логин password: Пароль - category: - parent_id: Родитель - name: Название - arch: name: Название created_at: Создана diff --git a/config/routes.rb b/config/routes.rb index 20dc90673..ea4f010fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,10 +44,6 @@ Rosa::Application.routes.draw do match 'statistics/refresh' => 'downloads#refresh', :as => :downloads_refresh match 'statistics/test_sudo' => 'downloads#test_sudo', :as => :test_sudo_downloads - resources :categories do - get :platforms, :on => :collection - end - match '/private/:platform_name/*file_path' => 'privates#show' match 'build_lists/publish_build', :to => "build_lists#publish_build" @@ -101,8 +97,6 @@ Rosa::Application.routes.draw do end resources :repositories - - resources :categories, :only => [:index, :show] end resources :projects, :except => [:show] do @@ -198,8 +192,6 @@ Rosa::Application.routes.draw do resources :search, :only => [:index] - match '/catalogs', :to => 'categories#platforms', :as => :catalogs - match 'product_status', :to => 'product_build_lists#status_build' # Tree diff --git a/db/migrate/20120329182602_delete_categories.rb b/db/migrate/20120329182602_delete_categories.rb new file mode 100644 index 000000000..7b2c9b985 --- /dev/null +++ b/db/migrate/20120329182602_delete_categories.rb @@ -0,0 +1,17 @@ +class DeleteCategories < ActiveRecord::Migration + def self.up + remove_column :projects, :category_id + drop_table :categories + end + + def self.down + 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 + add_column :projects, :category_id, :integer + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 5596d9be6..d1166777e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120329181830) do +ActiveRecord::Schema.define(:version => 20120329182602) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -81,14 +81,6 @@ ActiveRecord::Schema.define(:version => 20120329181830) 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 "comments", :force => true do |t| t.string "commentable_type" t.integer "user_id" @@ -273,7 +265,6 @@ ActiveRecord::Schema.define(:version => 20120329181830) do t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open" - t.integer "category_id" t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true @@ -286,7 +277,6 @@ ActiveRecord::Schema.define(:version => 20120329181830) do t.boolean "is_rpm", :default => true end - add_index "projects", ["category_id"], :name => "index_projects_on_category_id" add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false create_table "register_requests", :force => true do |t| diff --git a/db/seeds.rb b/db/seeds.rb index 8e6b2314d..bb47f49f9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,137 +3,3 @@ ARCHES = %w(i386 i586 x86_64) 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