diff --git a/app/controllers/flash_notifies_controller.rb b/app/controllers/admin/flash_notifies_controller.rb similarity index 78% rename from app/controllers/flash_notifies_controller.rb rename to app/controllers/admin/flash_notifies_controller.rb index c7d3915ef..5946427bf 100644 --- a/app/controllers/flash_notifies_controller.rb +++ b/app/controllers/admin/flash_notifies_controller.rb @@ -1,8 +1,4 @@ -class FlashNotifiesController < ApplicationController - before_filter :authenticate_user! - - load_and_authorize_resource - +class Admin::FlashNotifiesController < Admin::BaseController def index @flash_notifies = FlashNotify.paginate(:page => params[:page], :per_page => 20) end @@ -15,7 +11,7 @@ class FlashNotifiesController < ApplicationController @flash_notify = FlashNotify.new(params[:flash_notify]) if @flash_notify.save flash[:notice] = t("flash.flash_notify.saved") - redirect_to flash_notifies_path + redirect_to admin_flash_notifies_path else flash[:error] = t("flash.flash_notify.save_error") flash[:warning] = @flash_notify.errors.full_messages.join('. ') @@ -26,7 +22,7 @@ class FlashNotifiesController < ApplicationController def update if @flash_notify.update_attributes(params[:flash_notify]) flash[:notice] = t("flash.flash_notify.saved") - redirect_to flash_notifies_path + redirect_to admin_flash_notifies_path else flash[:error] = t("flash.flash_notify.save_error") flash[:warning] = @flash_notify.errors.full_messages.join('. ') @@ -37,10 +33,9 @@ class FlashNotifiesController < ApplicationController def destroy if @flash_notify.destroy flash[:notice] = t("flash.flash_notify.destroyed") - redirect_to flash_notifies_path else flash[:error] = t("flash.flash_notify.destroy_error") - redirect_to flash_notifies_path end + redirect_to admin_flash_notifies_path end end diff --git a/app/views/flash_notifies/_form.html.haml b/app/views/admin/flash_notifies/_form.html.haml similarity index 90% rename from app/views/flash_notifies/_form.html.haml rename to app/views/admin/flash_notifies/_form.html.haml index 73f0ec876..c609dd20b 100644 --- a/app/views/flash_notifies/_form.html.haml +++ b/app/views/admin/flash_notifies/_form.html.haml @@ -17,5 +17,5 @@ .button_block = submit_tag t("layout.save") %span.text_button_padding= t("layout.or") - = link_to t("layout.cancel"), flash_notifies_path, :class => "button" + = link_to t("layout.cancel"), admin_flash_notifies_path, :class => "button" diff --git a/app/views/admin/flash_notifies/edit.html.haml b/app/views/admin/flash_notifies/edit.html.haml new file mode 100644 index 000000000..89bed7609 --- /dev/null +++ b/app/views/admin/flash_notifies/edit.html.haml @@ -0,0 +1,4 @@ +%h3= t("layout.flash_notifies.edit_header") + += form_for @flash_notify, :url => admin_flash_notify_path(@flash_notify), :html => { :class => :form } do |f| + = render "form", :f => f diff --git a/app/views/flash_notifies/index.html.haml b/app/views/admin/flash_notifies/index.html.haml similarity index 60% rename from app/views/flash_notifies/index.html.haml rename to app/views/admin/flash_notifies/index.html.haml index 566938029..41a82be53 100644 --- a/app/views/flash_notifies/index.html.haml +++ b/app/views/admin/flash_notifies/index.html.haml @@ -1,4 +1,4 @@ -= link_to t("layout.flash_notifies.new"), new_flash_notify_path, :class => 'button' if can? :create, FlashNotify += link_to t("layout.flash_notifies.new"), new_admin_flash_notify_path, :class => 'button' if can? :create, FlashNotify %table#myTable.tablesorter.flash_notifys{:cellspacing => "0", :cellpadding => "0"} %thead @@ -14,8 +14,8 @@ %td= flash_notify.body_ru.truncate 18 %td= flash_notify.published %td - = link_to t("layout.flash_notifies.edit"), edit_flash_notify_path(flash_notify) - = link_to t("layout.flash_notifies.delete"), flash_notify_path(flash_notify), :method => :delete, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:delete, flash_notify) + = link_to t("layout.flash_notifies.edit"), edit_admin_flash_notify_path(flash_notify) + = link_to t("layout.flash_notifies.delete"), admin_flash_notify_path(flash_notify), :method => :delete, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:delete, flash_notify) = will_paginate @flash_notifies diff --git a/app/views/admin/flash_notifies/new.html.haml b/app/views/admin/flash_notifies/new.html.haml new file mode 100644 index 000000000..301a12bab --- /dev/null +++ b/app/views/admin/flash_notifies/new.html.haml @@ -0,0 +1,4 @@ +%h3= t("layout.flash_notifies.new_header") + += form_for @flash_notify, :url => admin_flash_notifies_path, :html => { :class => :form } do |f| + = render "form", :f => f diff --git a/app/views/flash_notifies/edit.html.haml b/app/views/flash_notifies/edit.html.haml deleted file mode 100644 index e545e4c6a..000000000 --- a/app/views/flash_notifies/edit.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h3= t("layout.flash_notifies.edit_header") - -= form_for @flash_notify, :url => flash_notify_path(@flash_notify), :html => { :class => :form } do |f| - = render "form", :f => f diff --git a/app/views/flash_notifies/new.html.haml b/app/views/flash_notifies/new.html.haml deleted file mode 100644 index 4b4bba0bf..000000000 --- a/app/views/flash_notifies/new.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h3= t("layout.flash_notifies.new_header") - -= form_for @flash_notify, :url => flash_notifies_path, :html => { :class => :form } do |f| - = render "form", :f => f diff --git a/app/views/layouts/_notifies.html.haml b/app/views/layouts/_notifies.html.haml index 46f5b8d00..d2c3f8b1b 100644 --- a/app/views/layouts/_notifies.html.haml +++ b/app/views/layouts/_notifies.html.haml @@ -1,11 +1,10 @@ - if current_user || APP_CONFIG['anonymous_access'] .flash_notify - - flash_notify = FlashNotify.published.first - - if flash_notify && flash_notify.should_show?(cookies[:flash_notify_hash]) + - if (flash_notify = FlashNotify.published.first) && flash_notify.should_show?(cookies[:flash_notify_hash]) .alert{:class => "alert-#{flash_notify.status}"} = flash_notify.body current_user.language - %a{:class=>"close", :'data-dismiss'=>"alert", :href=>"#", :id => 'close-alert'} × + %a.close#close-alert{:'data-dismiss'=>"alert", :href=>"#"} × - :javascript - var FLASH_HASH_ID = "#{flash_notify.hash_id}"; - var FLASH_EXPIRES_AT = "#{Date.today + 1.year}"; + :javascript + var FLASH_HASH_ID = "#{flash_notify.hash_id}"; + var FLASH_EXPIRES_AT = "#{Date.today + 1.year}"; diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index b12e73c29..5b6b58ac8 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -37,5 +37,6 @@ en: admins_menu: users: Users register_requests: Invites + flash_notifies: Notifies event_logs: Event log resque_server: Resque diff --git a/config/locales/menu.ru.yml b/config/locales/menu.ru.yml index 6850b6b00..e4a81ad6b 100644 --- a/config/locales/menu.ru.yml +++ b/config/locales/menu.ru.yml @@ -37,5 +37,6 @@ ru: admins_menu: users: Пользователи register_requests: Инвайты + flash_notifies: Оповещения event_logs: Лог событий resque_server: Resque diff --git a/config/routes.rb b/config/routes.rb index 6e7299f2d..9bedc15ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,8 +21,6 @@ Rosa::Application.routes.draw do root :to => 'activity_feeds#index' end - resources :flash_notifies - namespace :admin do resources :users do get :list, :on => :collection @@ -34,6 +32,7 @@ Rosa::Application.routes.draw do get :reject end end + resources :flash_notifies resources :event_logs, :only => :index constraints AdminAccess do mount Resque::Server => 'resque' diff --git a/db/schema.rb b/db/schema.rb index a23a418d6..88f4b829f 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 => 20120703101719) do +ActiveRecord::Schema.define(:version => 20120719045806) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do create_table "arches", :force => true do |t| t.string "name", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true @@ -63,8 +63,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.integer "user_id" t.string "provider" t.string "uid" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true @@ -75,8 +75,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.integer "level" t.integer "status" t.integer "build_list_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "version" end @@ -107,8 +107,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.integer "project_id" t.integer "arch_id" t.datetime "notified_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" @@ -137,8 +137,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "commentable_type" t.integer "user_id" t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.decimal "commentable_id", :precision => 50, :scale => 0 t.integer "project_id" end @@ -155,8 +155,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "controller" t.string "action" t.text "message" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end create_table "flash_notifies", :force => true do |t| @@ -170,8 +170,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do create_table "groups", :force => true do |t| t.integer "owner_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "uname" t.integer "own_projects_count", :default => 0, :null => false t.text "description" @@ -184,8 +184,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "title" t.text "body" t.string "status", :default => "open" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "user_id" t.datetime "closed_at" t.integer "closed_by" @@ -234,14 +234,14 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "description" t.string "name", :null => false t.integer "parent_platform_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "released", :default => false, :null => false t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type" + t.string "distrib_type", :null => false end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false @@ -250,8 +250,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.integer "platform_id" t.string "login" t.string "password" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "user_id" end @@ -267,8 +267,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do create_table "products", :force => true do |t| t.string "name", :null => false t.integer "platform_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "build_script" t.text "counter" t.text "ks" @@ -287,8 +287,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "name" t.string "version" t.datetime "file_mtime" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "platform_id" end @@ -297,25 +297,25 @@ ActiveRecord::Schema.define(:version => 20120703101719) do create_table "project_to_repositories", :force => true do |t| t.integer "project_id" t.integer "repository_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end create_table "projects", :force => true do |t| t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open" t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true - t.boolean "has_wiki", :default => false t.string "srpm_file_name" t.string "srpm_content_type" t.integer "srpm_file_size" t.datetime "srpm_updated_at" + t.boolean "has_wiki", :default => false t.string "default_branch", :default => "master" t.boolean "is_package", :default => true, :null => false t.integer "average_build_time", :default => 0, :null => false @@ -330,8 +330,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "token" t.boolean "approved", :default => false t.boolean "rejected", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "interest" t.text "more" end @@ -344,16 +344,16 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "actor_type" t.integer "target_id" t.string "target_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "role" end create_table "repositories", :force => true do |t| t.string "description", :null => false t.integer "platform_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "name", :null => false end @@ -364,8 +364,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.boolean "new_comment_reply", :default => true t.boolean "new_issue", :default => true t.boolean "issue_assign", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "new_comment_commit_owner", :default => true t.boolean "new_comment_commit_repo_owner", :default => true t.boolean "new_comment_commit_commentor", :default => true @@ -374,8 +374,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do create_table "subscribes", :force => true do |t| t.string "subscribeable_type" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "status", :default => true t.integer "project_id" t.decimal "subscribeable_id", :precision => 50, :scale => 0 @@ -385,21 +385,15 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "name" t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "password_salt", :default => "", :null => false t.string "reset_password_token" - t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "ssh_key" + t.datetime "created_at" + t.datetime "updated_at" t.string "uname" t.string "role" t.string "language", :default => "en" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.integer "own_projects_count", :default => 0, :null => false t.datetime "reset_password_sent_at" + t.integer "own_projects_count", :default => 0, :null => false t.text "professional_experience" t.string "site" t.string "company" @@ -408,11 +402,14 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", :default => 0 t.string "unlock_token" t.datetime "locked_at" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" t.string "authentication_token" - t.integer "build_priority", :default => 50 + t.integer "build_priority", :default => 50 end add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token" diff --git a/spec/controllers/flash_notifies_controller_spec.rb b/spec/controllers/admin/flash_notifies_controller_spec.rb similarity index 93% rename from spec/controllers/flash_notifies_controller_spec.rb rename to spec/controllers/admin/flash_notifies_controller_spec.rb index 169bbe8b5..ad7494fda 100644 --- a/spec/controllers/flash_notifies_controller_spec.rb +++ b/spec/controllers/admin/flash_notifies_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe FlashNotifiesController do +describe Admin::FlashNotifiesController do before(:each) do stub_symlink_methods @@ -68,7 +68,7 @@ describe FlashNotifiesController do it 'should be able to perform create action' do post :create, @create_params - response.should redirect_to(flash_notifies_path) + response.should redirect_to(admin_flash_notifies_path) end it 'should change objects count on create' do @@ -77,7 +77,7 @@ describe FlashNotifiesController do it 'should be able to perform destroy action' do delete :destroy, :id => @flash_notify - response.should redirect_to(flash_notifies_path) + response.should redirect_to(admin_flash_notifies_path) end it 'should change objects count on destroy' do @@ -86,7 +86,7 @@ describe FlashNotifiesController do it 'should be able to perform update action' do put :update, @update_params - response.should redirect_to(flash_notifies_path) + response.should redirect_to(admin_flash_notifies_path) end it 'should change flash notify body on update' do