From 15a86c2ecd94474a5995d5b99f032651d9da3c66 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 23 Jul 2012 18:25:37 +0400 Subject: [PATCH 1/6] [refs #576] Add flash notifies --- .../javascripts/extra/flash_notifies.js | 19 +++ app/assets/stylesheets/design/custom.scss | 60 ++++++++ app/controllers/flash_notifies_controller.rb | 46 ++++++ app/models/flash_notify.rb | 24 ++++ app/views/flash_notifies/_form.html.haml | 21 +++ app/views/flash_notifies/edit.html.haml | 4 + app/views/flash_notifies/index.html.haml | 21 +++ app/views/flash_notifies/new.html.haml | 4 + app/views/layouts/_notifies.html.haml | 12 ++ app/views/layouts/application.html.haml | 1 + config/locales/models/flash_notify.en.yml | 28 ++++ config/locales/models/flash_notify.ru.yml | 28 ++++ config/routes.rb | 2 + .../20120719045806_create_flash_notifies.rb | 11 ++ db/schema.rb | 9 ++ .../flash_notifies_controller_spec.rb | 132 ++++++++++++++++++ spec/factories/flash_notify.rb | 10 ++ spec/models/flash_notify_spec.rb | 5 + vendor/assets/javascripts/bootstrap-alert.js | 90 ++++++++++++ vendor/assets/javascripts/vendor.js | 1 + 20 files changed, 528 insertions(+) create mode 100644 app/assets/javascripts/extra/flash_notifies.js create mode 100644 app/controllers/flash_notifies_controller.rb create mode 100644 app/models/flash_notify.rb create mode 100644 app/views/flash_notifies/_form.html.haml create mode 100644 app/views/flash_notifies/edit.html.haml create mode 100644 app/views/flash_notifies/index.html.haml create mode 100644 app/views/flash_notifies/new.html.haml create mode 100644 app/views/layouts/_notifies.html.haml create mode 100644 config/locales/models/flash_notify.en.yml create mode 100644 config/locales/models/flash_notify.ru.yml create mode 100644 db/migrate/20120719045806_create_flash_notifies.rb create mode 100644 spec/controllers/flash_notifies_controller_spec.rb create mode 100644 spec/factories/flash_notify.rb create mode 100644 spec/models/flash_notify_spec.rb create mode 100644 vendor/assets/javascripts/bootstrap-alert.js diff --git a/app/assets/javascripts/extra/flash_notifies.js b/app/assets/javascripts/extra/flash_notifies.js new file mode 100644 index 000000000..4002c4873 --- /dev/null +++ b/app/assets/javascripts/extra/flash_notifies.js @@ -0,0 +1,19 @@ +function setCookie (name, value, expires, path, domain, secure) { + document.cookie = name + "=" + escape(value) + + ((expires) ? "; expires=" + expires : "") + + ((path) ? "; path=" + path : "") + + ((domain) ? "; domain=" + domain : "") + + ((secure) ? "; secure" : ""); +} + +$(document).ready(function() { + if ($(".alert").size()) { + $(".alert").alert() + } + + $('#close-alert').click(function () { + setCookie("flash_notify_id", FLASH_NOTIFY_ID, FLASH_EXPIRES_AT); + setCookie("flash_notify_hash", FLASH_HASH_ID, FLASH_EXPIRES_AT); + }); +}); + diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index ccf97e3d0..193800920 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1172,3 +1172,63 @@ table.tablesorter tr td.no_results { text-align: center; } /* end */ + +/* Flash Notifies */ + +.flash_notify { + .alert-success { + color: #468847; + background-color: #DFF0D8; + border-color: #D6E9C6; + } + + .alert { + padding: 8px 35px 8px 14px; + margin-bottom: 18px; + color: #C09853; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + background-color: #FCF8E3; + border: 1px solid #FBEED5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + } + + .alert-danger, .alert-error { + color: #B94A48; + background-color: #F2DEDE; + border-color: #EED3D7; + } + + .alert-info { + color: #3A87AD; + background-color: #D9EDF7; + border-color: #BCE8F1; + } + + .alert .close { + position: relative; + top: -2px; + right: -21px; + line-height: 18px; + } + + button.close { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + } + + .close { + float: right; + font-size: 20px; + font-weight: bold; + line-height: 18px; + color: black; + text-shadow: 0 1px 0 white; + opacity: 0.2; + filter: alpha(opacity=20); + } +} diff --git a/app/controllers/flash_notifies_controller.rb b/app/controllers/flash_notifies_controller.rb new file mode 100644 index 000000000..c7d3915ef --- /dev/null +++ b/app/controllers/flash_notifies_controller.rb @@ -0,0 +1,46 @@ +class FlashNotifiesController < ApplicationController + before_filter :authenticate_user! + + load_and_authorize_resource + + def index + @flash_notifies = FlashNotify.paginate(:page => params[:page], :per_page => 20) + end + + def new + @flash_notify = FlashNotify.new(:published => true) + end + + def create + @flash_notify = FlashNotify.new(params[:flash_notify]) + if @flash_notify.save + flash[:notice] = t("flash.flash_notify.saved") + redirect_to flash_notifies_path + else + flash[:error] = t("flash.flash_notify.save_error") + flash[:warning] = @flash_notify.errors.full_messages.join('. ') + render :new + end + end + + def update + if @flash_notify.update_attributes(params[:flash_notify]) + flash[:notice] = t("flash.flash_notify.saved") + redirect_to flash_notifies_path + else + flash[:error] = t("flash.flash_notify.save_error") + flash[:warning] = @flash_notify.errors.full_messages.join('. ') + render :edit + end + end + + 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 + end +end diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb new file mode 100644 index 000000000..884e13096 --- /dev/null +++ b/app/models/flash_notify.rb @@ -0,0 +1,24 @@ +require 'digest/md5' + +class FlashNotify < ActiveRecord::Base + # attr_accessible :title, :body + + STATUSES = %w[error success info] + + validates :status, :inclusion => {:in => STATUSES} + validates :body_ru, :body_en, :status, :presence => true + + scope :published, where(:published => true) + + def hash_id + @digest ||= Digest::MD5.hexdigest("#{self.id}-#{self.updated_at}") + end + + def body(language) + read_attribute("body_#{language}") + end + + def should_show?(cookie_id, cookie_hash_id) + cookie_id.to_i == id && cookie_hash_id == hash_id ? false : true + end +end diff --git a/app/views/flash_notifies/_form.html.haml b/app/views/flash_notifies/_form.html.haml new file mode 100644 index 000000000..73f0ec876 --- /dev/null +++ b/app/views/flash_notifies/_form.html.haml @@ -0,0 +1,21 @@ +.leftlist= f.label :body_ru, t("activerecord.attributes.flash_notify.body_ru"), :class => :label +.rightlist= f.text_area :body_ru, :class => 'text_field' +.both + +.leftlist= f.label :body_en, t("activerecord.attributes.flash_notify.body_en"), :class => :label +.rightlist= f.text_area :body_en, :class => 'text_field' +.both + +.leftlist= f.label :status, t("activerecord.attributes.flash_notify.status"), :class => :label +.rightlist= f.select :status, FlashNotify::STATUSES +.both + +.leftlist= f.label :published, t("activerecord.attributes.flash_notify.published"), :class => :label +.rightlist= f.check_box :published +.both + +.button_block + = submit_tag t("layout.save") + %span.text_button_padding= t("layout.or") + = link_to t("layout.cancel"), flash_notifies_path, :class => "button" + diff --git a/app/views/flash_notifies/edit.html.haml b/app/views/flash_notifies/edit.html.haml new file mode 100644 index 000000000..2dc979eaa --- /dev/null +++ b/app/views/flash_notifies/edit.html.haml @@ -0,0 +1,4 @@ +%h3= t("layout.flash_notifies.edit_header") + += form_for @flash_notify, :url => flash_notifies_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/flash_notifies/index.html.haml new file mode 100644 index 000000000..4b42da4a5 --- /dev/null +++ b/app/views/flash_notifies/index.html.haml @@ -0,0 +1,21 @@ += link_to t("layout.flash_notifies.new"), new_flash_notify_path, :class => 'button' if can? :create, FlashNotify + +%table#myTable.tablesorter.flash_notifys{:cellspacing => "0", :cellpadding => "0"} + %thead + %tr + %th.th1= t("activerecord.attributes.flash_notify.body_en") + %th.th2= t("activerecord.attributes.flash_notify.body_ru") + %th.th3= t("activerecord.attributes.flash_notify.published") + %th.th3= t("layout.flash_notifies.actions") + %tbody + - @flash_notifies.each do |flash_notify| + %tr{:class => cycle("odd", "even")} + %td= flash_notify.body_en.slice(0..15) + "..." + %td= flash_notify.body_ru.slice(0..15) + "..." + %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) + += will_paginate @flash_notifies + diff --git a/app/views/flash_notifies/new.html.haml b/app/views/flash_notifies/new.html.haml new file mode 100644 index 000000000..4b4bba0bf --- /dev/null +++ b/app/views/flash_notifies/new.html.haml @@ -0,0 +1,4 @@ +%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 new file mode 100644 index 000000000..766485dcd --- /dev/null +++ b/app/views/layouts/_notifies.html.haml @@ -0,0 +1,12 @@ +- if current_user || APP_CONFIG['anonymous_access'] + .flash_notify + - flash_notify = FlashNotify.published.first + - if flash_notify && flash_notify.should_show?(cookies[:flash_notify_id], 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'} × + +:javascript + var FLASH_NOTIFY_ID = "#{flash_notify.id}"; + var FLASH_HASH_ID = "#{flash_notify.hash_id}"; + var FLASH_EXPIRES_AT = "#{Date.today + 1.year}"; diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 642d9b82e..ce5659724 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -47,6 +47,7 @@ = yield :feed_tabs .both = render "layouts/flashes" + = render "layouts/notifies" %article - if content_for?(:sidebar) %aside= yield :sidebar diff --git a/config/locales/models/flash_notify.en.yml b/config/locales/models/flash_notify.en.yml new file mode 100644 index 000000000..50f5ac06c --- /dev/null +++ b/config/locales/models/flash_notify.en.yml @@ -0,0 +1,28 @@ +en: + layout: + flash_notifies: + list_header: Notifies + new: New notify + new_header: New notify + actions: Actions + edit: Edit + edit_header: Edit notify + delete: Delete + + flash: + flash_notify: + saved: Notify added + save_error: Unable to add notify + destroyed: Notify deleted + + activerecord: + models: + flash_notify: Notify + attributes: + flash_notify: + body_ru: Body Ru + body_en: Body En + published: Published + status: Status + created_at: Created + updated_at: Updated diff --git a/config/locales/models/flash_notify.ru.yml b/config/locales/models/flash_notify.ru.yml new file mode 100644 index 000000000..b2be708c1 --- /dev/null +++ b/config/locales/models/flash_notify.ru.yml @@ -0,0 +1,28 @@ +ru: + layout: + flash_notifies: + list_header: Оповещения + new: Новое оповещение + new_header: Новое оповещение + actions: Действия + edit: Редактирование + edit_header: Редактировать оповещение + delete: Удалить + + flash: + flash_notify: + saved: Оповещение сохранено + save_error: Не получилось сохранить оповещение + destroyed: Оповещение удалено + + activerecord: + models: + flash_notify: Оповещение + attributes: + flash_notify: + body_ru: Текст Ru + body_en: Текст En + published: Опубликовано + status: Статус + created_at: Создано + updated_at: Обновлено diff --git a/config/routes.rb b/config/routes.rb index 62c3029d3..6e7299f2d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,8 @@ Rosa::Application.routes.draw do root :to => 'activity_feeds#index' end + resources :flash_notifies + namespace :admin do resources :users do get :list, :on => :collection diff --git a/db/migrate/20120719045806_create_flash_notifies.rb b/db/migrate/20120719045806_create_flash_notifies.rb new file mode 100644 index 000000000..2a9f16a29 --- /dev/null +++ b/db/migrate/20120719045806_create_flash_notifies.rb @@ -0,0 +1,11 @@ +class CreateFlashNotifies < ActiveRecord::Migration + def change + create_table :flash_notifies do |t| + t.text :body_ru, :null => false + t.text :body_en, :null => false + t.string :status, :null => false + t.boolean :published, :null => false, :default => true + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5200f5c01..a23a418d6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -159,6 +159,15 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.datetime "updated_at", :null => false end + create_table "flash_notifies", :force => true do |t| + t.text "body_ru", :null => false + t.text "body_en", :null => false + t.string "status", :null => false + t.boolean "published", :default => true, :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "groups", :force => true do |t| t.integer "owner_id" t.datetime "created_at", :null => false diff --git a/spec/controllers/flash_notifies_controller_spec.rb b/spec/controllers/flash_notifies_controller_spec.rb new file mode 100644 index 000000000..b00301fbd --- /dev/null +++ b/spec/controllers/flash_notifies_controller_spec.rb @@ -0,0 +1,132 @@ +require 'spec_helper' + +describe FlashNotifiesController do + before(:each) do + stub_symlink_methods + + @user = FactoryGirl.create(:user) + @create_params = { + :flash_notify => { + :body_ru => "Hello! I`m ru body", + :body_en => "Hello! I`m en body", + :status => "error", + :published => true + } + } + + @flash_notify = FactoryGirl.create(:flash_notify) + @flash_notify2 = FactoryGirl.create(:flash_notify) + + @update_params = { + :id => @flash_notify, + :flash_notify => { + :body_ru => "updated!" + } + } + end + + context 'for guest' do + [:index, :create, :update, :edit, :new, :destroy].each do |action| + it "should not be able to perform #{ action } action" do + get action, :id => @flash_notify + response.should redirect_to(new_user_session_path) + end + end + + it 'should not change objects count on create' do + lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(0) + end + + it 'should not change objects count on destroy' do + lambda { delete :destroy, :id => @flash_notify }.should change{ FlashNotify.count }.by(0) + end + + it 'should not change flash notify body on update' do + put :update, @update_params + @flash_notify.reload.body_ru.should_not == "updated!" + end + end + + context 'for global admin' do + before(:each) do + @admin = FactoryGirl.create(:admin) + @user = FactoryGirl.create(:user) + set_session_for(@admin) + end + + it 'should be able to perform index action' do + get :index + response.should render_template(:index) + end + + it 'should load 2 flash notifies objects on index' do + get :index + assigns[:flash_notifies].count.should == 2 + end + + it 'should be able to perform new action' do + get :new + response.should render_template(:new) + end + + it 'should be able to perform edit action' do + get :edit + response.should render_template(:edit) + end + + it 'should be able to perform create action' do + post :create, @create_params + response.should redirect_to(flash_notifies_path) + end + + it 'should change objects count on create' do + lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(1) + end + + it 'should be able to perform destroy action' do + delete :destroy, :id => @flash_notify + response.should redirect_to(flash_notifies_path) + end + + it 'should change objects count on destroy' do + lambda { delete :destroy, :id => @flash_notify }.should change{ FlashNotify.count }.by(-1) + end + + it 'should be able to perform update action' do + put :update, @update_params + response.should redirect_to(flash_notifies_path) + end + + it 'should change flash notify body on update' do + put :update, @update_params + @flash_notify.reload.body_ru.should == "updated!" + end + end + + context 'for simple user' do + before(:each) do + @user = FactoryGirl.create(:user) + set_session_for(@user) + end + + [:index, :create, :update, :edit, :new, :destroy].each do |action| + it "should not be able to perform #{ action } action" do + get action, :id => @flash_notify + response.should redirect_to(forbidden_path) + end + end + + it 'should not change objects count on create' do + lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(0) + end + + it 'should not change objects count on destroy' do + lambda { delete :destroy, :id => @flash_notify }.should change{ FlashNotify.count }.by(0) + end + + it 'should not change flash notify body on update' do + put :update, @update_params + @flash_notify.reload.body_ru.should_not == "updated!" + end + end +end diff --git a/spec/factories/flash_notify.rb b/spec/factories/flash_notify.rb new file mode 100644 index 000000000..b3f239540 --- /dev/null +++ b/spec/factories/flash_notify.rb @@ -0,0 +1,10 @@ +# -*- encoding : utf-8 -*- +FactoryGirl.define do + factory :flash_notify do + body_ru { FactoryGirl.generate(:string) } + body_en { FactoryGirl.generate(:string) } + status "error" + published true + end +end + diff --git a/spec/models/flash_notify_spec.rb b/spec/models/flash_notify_spec.rb new file mode 100644 index 000000000..8501d64a4 --- /dev/null +++ b/spec/models/flash_notify_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe FlashNotify do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/vendor/assets/javascripts/bootstrap-alert.js b/vendor/assets/javascripts/bootstrap-alert.js new file mode 100644 index 000000000..57890a9a2 --- /dev/null +++ b/vendor/assets/javascripts/bootstrap-alert.js @@ -0,0 +1,90 @@ +/* ========================================================== + * bootstrap-alert.js v2.0.4 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* ALERT CLASS DEFINITION + * ====================== */ + + var dismiss = '[data-dismiss="alert"]' + , Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + , selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + + e && e.preventDefault() + + $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) + + $parent.trigger(e = $.Event('close')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent + .trigger('closed') + .remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent.on($.support.transition.end, removeElement) : + removeElement() + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + /* ALERT DATA-API + * ============== */ + + $(function () { + $('body').on('click.alert.data-api', dismiss, Alert.prototype.close) + }) + +}(window.jQuery); \ No newline at end of file diff --git a/vendor/assets/javascripts/vendor.js b/vendor/assets/javascripts/vendor.js index 9d833de06..a4d1ebcfb 100644 --- a/vendor/assets/javascripts/vendor.js +++ b/vendor/assets/javascripts/vendor.js @@ -12,6 +12,7 @@ //= require bootstrap-dropdown // require bootstrap-tooltip // require bootstrap-popover +//= require bootstrap-alert //= require chosen.jquery // require html5shiv // require_tree . From 3d19a4f23eea92a19c8bba3c1340f66991792b0e Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 24 Jul 2012 13:19:22 +0400 Subject: [PATCH 2/6] [refs #576] Optimize tests, views and model --- app/models/flash_notify.rb | 2 +- app/views/flash_notifies/edit.html.haml | 2 +- app/views/flash_notifies/index.html.haml | 4 ++-- .../flash_notifies_controller_spec.rb | 18 +++++------------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb index 884e13096..5cc407173 100644 --- a/app/models/flash_notify.rb +++ b/app/models/flash_notify.rb @@ -19,6 +19,6 @@ class FlashNotify < ActiveRecord::Base end def should_show?(cookie_id, cookie_hash_id) - cookie_id.to_i == id && cookie_hash_id == hash_id ? false : true + !(cookie_id.to_i == id && cookie_hash_id == hash_id) end end diff --git a/app/views/flash_notifies/edit.html.haml b/app/views/flash_notifies/edit.html.haml index 2dc979eaa..e545e4c6a 100644 --- a/app/views/flash_notifies/edit.html.haml +++ b/app/views/flash_notifies/edit.html.haml @@ -1,4 +1,4 @@ %h3= t("layout.flash_notifies.edit_header") -= form_for @flash_notify, :url => flash_notifies_path(@flash_notify), :html => { :class => :form } do |f| += 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/index.html.haml b/app/views/flash_notifies/index.html.haml index 4b42da4a5..566938029 100644 --- a/app/views/flash_notifies/index.html.haml +++ b/app/views/flash_notifies/index.html.haml @@ -10,8 +10,8 @@ %tbody - @flash_notifies.each do |flash_notify| %tr{:class => cycle("odd", "even")} - %td= flash_notify.body_en.slice(0..15) + "..." - %td= flash_notify.body_ru.slice(0..15) + "..." + %td= flash_notify.body_en.truncate 18 + %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) diff --git a/spec/controllers/flash_notifies_controller_spec.rb b/spec/controllers/flash_notifies_controller_spec.rb index b00301fbd..169bbe8b5 100644 --- a/spec/controllers/flash_notifies_controller_spec.rb +++ b/spec/controllers/flash_notifies_controller_spec.rb @@ -54,24 +54,16 @@ describe FlashNotifiesController do set_session_for(@admin) end - it 'should be able to perform index action' do - get :index - response.should render_template(:index) - end - it 'should load 2 flash notifies objects on index' do get :index assigns[:flash_notifies].count.should == 2 end - it 'should be able to perform new action' do - get :new - response.should render_template(:new) - end - - it 'should be able to perform edit action' do - get :edit - response.should render_template(:edit) + [:index, :new, :edit].each do |action| + it "should be able to perform #{action} action" do + get action, :id => @flash_notify + response.should render_template(action) + end end it 'should be able to perform create action' do From c0036a1bb5594ff5ca09ddcfc71be62c355137f4 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 25 Jul 2012 16:41:06 +0400 Subject: [PATCH 3/6] [refs #576] Fix should_show? method and template offsets --- app/assets/javascripts/extra/flash_notifies.js | 1 - app/models/flash_notify.rb | 4 ++-- app/views/layouts/_notifies.html.haml | 9 ++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/extra/flash_notifies.js b/app/assets/javascripts/extra/flash_notifies.js index 4002c4873..52c9fbf53 100644 --- a/app/assets/javascripts/extra/flash_notifies.js +++ b/app/assets/javascripts/extra/flash_notifies.js @@ -12,7 +12,6 @@ $(document).ready(function() { } $('#close-alert').click(function () { - setCookie("flash_notify_id", FLASH_NOTIFY_ID, FLASH_EXPIRES_AT); setCookie("flash_notify_hash", FLASH_HASH_ID, FLASH_EXPIRES_AT); }); }); diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb index 5cc407173..601b197b2 100644 --- a/app/models/flash_notify.rb +++ b/app/models/flash_notify.rb @@ -18,7 +18,7 @@ class FlashNotify < ActiveRecord::Base read_attribute("body_#{language}") end - def should_show?(cookie_id, cookie_hash_id) - !(cookie_id.to_i == id && cookie_hash_id == hash_id) + def should_show?(cookie_hash_id) + cookie_hash_id != hash_id && published end end diff --git a/app/views/layouts/_notifies.html.haml b/app/views/layouts/_notifies.html.haml index 766485dcd..46f5b8d00 100644 --- a/app/views/layouts/_notifies.html.haml +++ b/app/views/layouts/_notifies.html.haml @@ -1,12 +1,11 @@ - if current_user || APP_CONFIG['anonymous_access'] .flash_notify - flash_notify = FlashNotify.published.first - - if flash_notify && flash_notify.should_show?(cookies[:flash_notify_id], cookies[:flash_notify_hash]) + - if flash_notify && 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'} × -:javascript - var FLASH_NOTIFY_ID = "#{flash_notify.id}"; - 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}"; From e09a9467e2251021c4f545fafdc0351dc1697724 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 25 Jul 2012 21:05:25 +0300 Subject: [PATCH 4/6] Fix flash notifies display bug. Add admin section link. Move controller to admin namspace. Refactor and fix notifies controller. Refs #576 --- .../{ => admin}/flash_notifies_controller.rb | 13 +-- .../flash_notifies/_form.html.haml | 2 +- app/views/admin/flash_notifies/edit.html.haml | 4 + .../flash_notifies/index.html.haml | 6 +- app/views/admin/flash_notifies/new.html.haml | 4 + app/views/flash_notifies/edit.html.haml | 4 - app/views/flash_notifies/new.html.haml | 4 - app/views/layouts/_notifies.html.haml | 11 +- config/locales/menu.en.yml | 1 + config/locales/menu.ru.yml | 1 + config/routes.rb | 3 +- db/schema.rb | 101 +++++++++--------- .../flash_notifies_controller_spec.rb | 8 +- 13 files changed, 77 insertions(+), 85 deletions(-) rename app/controllers/{ => admin}/flash_notifies_controller.rb (78%) rename app/views/{ => admin}/flash_notifies/_form.html.haml (90%) create mode 100644 app/views/admin/flash_notifies/edit.html.haml rename app/views/{ => admin}/flash_notifies/index.html.haml (60%) create mode 100644 app/views/admin/flash_notifies/new.html.haml delete mode 100644 app/views/flash_notifies/edit.html.haml delete mode 100644 app/views/flash_notifies/new.html.haml rename spec/controllers/{ => admin}/flash_notifies_controller_spec.rb (93%) 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 From 1362ee87c58d92059505f9868079825f47d1a1ff Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 25 Jul 2012 21:14:22 +0300 Subject: [PATCH 5/6] Add submenu for notifies section. Refs #576 --- app/views/admin/flash_notifies/edit.html.haml | 2 ++ app/views/admin/flash_notifies/index.html.haml | 1 + app/views/admin/flash_notifies/new.html.haml | 2 ++ 3 files changed, 5 insertions(+) diff --git a/app/views/admin/flash_notifies/edit.html.haml b/app/views/admin/flash_notifies/edit.html.haml index 89bed7609..a1f10e1cd 100644 --- a/app/views/admin/flash_notifies/edit.html.haml +++ b/app/views/admin/flash_notifies/edit.html.haml @@ -2,3 +2,5 @@ = form_for @flash_notify, :url => admin_flash_notify_path(@flash_notify), :html => { :class => :form } do |f| = render "form", :f => f + += render 'submenu' diff --git a/app/views/admin/flash_notifies/index.html.haml b/app/views/admin/flash_notifies/index.html.haml index 41a82be53..9578d1a0e 100644 --- a/app/views/admin/flash_notifies/index.html.haml +++ b/app/views/admin/flash_notifies/index.html.haml @@ -19,3 +19,4 @@ = will_paginate @flash_notifies += render 'submenu' diff --git a/app/views/admin/flash_notifies/new.html.haml b/app/views/admin/flash_notifies/new.html.haml index 301a12bab..0177e384e 100644 --- a/app/views/admin/flash_notifies/new.html.haml +++ b/app/views/admin/flash_notifies/new.html.haml @@ -2,3 +2,5 @@ = form_for @flash_notify, :url => admin_flash_notifies_path, :html => { :class => :form } do |f| = render "form", :f => f + += render 'submenu' From e3ee41294dd74974c19e91e9c96f48ede3eb1bf9 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 25 Jul 2012 21:21:52 +0300 Subject: [PATCH 6/6] Use current locale for message body display. Refs #576 --- app/views/layouts/_notifies.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_notifies.html.haml b/app/views/layouts/_notifies.html.haml index d2c3f8b1b..82ca70300 100644 --- a/app/views/layouts/_notifies.html.haml +++ b/app/views/layouts/_notifies.html.haml @@ -2,7 +2,7 @@ .flash_notify - 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 + = flash_notify.body I18n.locale %a.close#close-alert{:'data-dismiss'=>"alert", :href=>"#"} × :javascript