From 990a46018cfb10e9afcaf9cabed9f781ffb44a62 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 25 Jan 2012 12:31:49 +0400 Subject: [PATCH 01/77] [refs #123] Add base logic for activity feed --- app/controllers/activity_feeds_controller.rb | 7 +++ app/controllers/stub_controller.rb | 24 ++++++++ app/helpers/activity_feeds_helper.rb | 2 + app/models/activity_feed.rb | 11 ++++ app/models/activity_feed_observer.rb | 55 +++++++++++++++++++ app/models/comment.rb | 39 ++++++++----- app/models/issue.rb | 26 ++++----- app/models/user.rb | 2 + .../partials/issue_assign_notification.haml | 7 +++ .../partials/new_comment_notification.haml | 9 +++ .../new_comment_reply_notification.haml | 9 +++ .../partials/new_issue_notification.haml | 7 +++ .../partials/new_user_notification.haml | 12 ++++ config/application.rb | 2 +- .../20120124065207_create_activity_feeds.rb | 14 +++++ db/schema.rb | 24 +++----- .../activity_feeds_controller_spec.rb | 5 ++ spec/factories/activity_feeds.rb | 6 ++ spec/helpers/activity_feeds_helper_spec.rb | 15 +++++ spec/models/activity_feed_observer_spec.rb | 5 ++ spec/models/activity_feed_spec.rb | 5 ++ 21 files changed, 243 insertions(+), 43 deletions(-) create mode 100644 app/controllers/activity_feeds_controller.rb create mode 100644 app/controllers/stub_controller.rb create mode 100644 app/helpers/activity_feeds_helper.rb create mode 100644 app/models/activity_feed.rb create mode 100644 app/models/activity_feed_observer.rb create mode 100644 app/views/activity_feeds/partials/issue_assign_notification.haml create mode 100644 app/views/activity_feeds/partials/new_comment_notification.haml create mode 100644 app/views/activity_feeds/partials/new_comment_reply_notification.haml create mode 100644 app/views/activity_feeds/partials/new_issue_notification.haml create mode 100644 app/views/activity_feeds/partials/new_user_notification.haml create mode 100644 db/migrate/20120124065207_create_activity_feeds.rb create mode 100644 spec/controllers/activity_feeds_controller_spec.rb create mode 100644 spec/factories/activity_feeds.rb create mode 100644 spec/helpers/activity_feeds_helper_spec.rb create mode 100644 spec/models/activity_feed_observer_spec.rb create mode 100644 spec/models/activity_feed_spec.rb diff --git a/app/controllers/activity_feeds_controller.rb b/app/controllers/activity_feeds_controller.rb new file mode 100644 index 000000000..3b9a173af --- /dev/null +++ b/app/controllers/activity_feeds_controller.rb @@ -0,0 +1,7 @@ +class ActivityFeedsController < ApplicationController + before_filter :authenticate_user! + + def index + @activity_feeds = current_user.activity_feeds + end +end diff --git a/app/controllers/stub_controller.rb b/app/controllers/stub_controller.rb new file mode 100644 index 000000000..67a69c51a --- /dev/null +++ b/app/controllers/stub_controller.rb @@ -0,0 +1,24 @@ +class StubController < AbstractController::Base + include AbstractController::Rendering + include AbstractController::Layouts + include AbstractController::Helpers + include AbstractController::Translation + include AbstractController::AssetPaths + include ActionController::UrlWriter + + # Uncomment if you want to use helpers + # defined in ApplicationHelper in your views + # helper ApplicationHelper + + # Make sure your controller can find views + self.view_paths = "app/views" + + # You can define custom helper methods to be used in views here + # helper_method :current_admin + # def current_admin; nil; end + + def partial_to_string(partial_name, locals) + render_to_string(partial_name, :locals => locals) + end + +end diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb new file mode 100644 index 000000000..54a624bad --- /dev/null +++ b/app/helpers/activity_feeds_helper.rb @@ -0,0 +1,2 @@ +module ActivityFeedsHelper +end diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb new file mode 100644 index 000000000..d636301e9 --- /dev/null +++ b/app/models/activity_feed.rb @@ -0,0 +1,11 @@ +class ActivityFeed < ActiveRecord::Base + belongs_to :user + + def render_body(partial_name, locals={}) + av = ActionView::Base.new(Rails::Configuration.new.view_path) + av.render( + :partial => 'app/views/activity_feeds/partials/' + partial_name + '.haml', + :locals => locals + ) + end +end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb new file mode 100644 index 000000000..22f16dfe3 --- /dev/null +++ b/app/models/activity_feed_observer.rb @@ -0,0 +1,55 @@ +class ActivityFeedObserver < ActiveRecord::Observer + observe :issue, :comment + + def after_create(record) + case record.class.to_s + when 'User' + ActivityFeed.create(:user => record, :body => render_body('new_user_notification')) + when 'Issue' + recipients = record.collect_recipient_ids + recipients.each do |recipient_id| + recipient = User.find(recipient_id) + UserMailer.delay.new_issue_notification(record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue + ActivityFeed.create(:user => record, :body => render_body('new_issue_notification', {:user => recipient, :issue => record})) + end + + UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify + ActivityFeed.create(:user => record.user, :body => render_body('issue_assign_notification', {:user => record.user, :issue => record})) + when 'Comment' + subscribes = record.commentable.subscribes + subscribes.each do |subscribe| + if record.user_id != subscribe.user_id + if record.reply? subscribe + UserMailer.delay.new_comment_reply_notification(record, subscribe.user) if record.can_notify_on_reply?(subscribe) + ActivityFeed.create(:user => record.user, :body => render_body('new_comment_reply_notification', {:user => subscribe.user, :comment => record})) + else + UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) + ActivityFeed.create(:user => record.user, :body => render_body('new_comment_notification', {:user => subscribe.user, :comment => record})) + end + end + end + end + end + + def after_update(record) + case record.class.to_s + when 'Issue' + UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify + ActivityFeed.create(:user => record.user, :body => render_body('issue_assign_notification', {:user => record.user, :issue => record})) + end + end + + def render_body(partial_name, locals={}) + #ac = ActionController::Base.new + #ac.render_to_string( + # 'app/views/activity_feeds/partials/' + partial_name + '.haml', + # :locals => locals + #) + + #ac = ActionView::Base.new([], locals) + #ac.render(:inline => 'app/views/activity_feeds/partials/' + partial_name + '.haml') + + StubController.new.partial_to_string('activity_feeds/partials/' + partial_name, locals) + end + +end diff --git a/app/models/comment.rb b/app/models/comment.rb index 8ba9c05d0..6b6f5a92a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -7,22 +7,35 @@ class Comment < ActiveRecord::Base # FIXME after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'" - after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'" + #after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'" + + def reply?(subscribe) + self.commentable.comments.exists?(:user_id => subscribe.user.id) + end + + def can_notify_on_reply?(subscribe) + User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify + end + + def can_notify_on_new_comment?(subscribe) + User.find(subscribe.user).notifier.new_comment && User.find(subscribe.user).notifier.can_notify + end protected - def deliver_new_comment_notification - subscribes = self.commentable.subscribes - subscribes.each do |subscribe| - if self.user_id != subscribe.user_id && User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify - if self.commentable.comments.exists?(:user_id => subscribe.user.id) - UserMailer.delay.new_comment_reply_notification(self, subscribe.user) - else - UserMailer.delay.new_comment_notification(self, subscribe.user) - end - end - end - end + #def deliver_new_comment_notification + # subscribes = self.commentable.subscribes + # subscribes.each do |subscribe| + # # TODO: new_comment and new_comment_reply - you need to check each variant, not only new_comment_reply... + # if self.user_id != subscribe.user_id && User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify + # if self.reply? subscribe + # UserMailer.delay.new_comment_reply_notification(self, subscribe.user) + # else + # UserMailer.delay.new_comment_notification(self, subscribe.user) + # end + # end + # end + #end def subscribe_on_reply self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id) diff --git a/app/models/issue.rb b/app/models/issue.rb index efeffbf13..0a0084c95 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -19,9 +19,9 @@ class Issue < ActiveRecord::Base after_create :set_serial_id after_create :subscribe_users - after_create :deliver_new_issue_notification - after_create :deliver_issue_assign_notification - after_update :deliver_issue_assign_notification + #after_create :deliver_new_issue_notification + #after_create :deliver_issue_assign_notification + #after_update :deliver_issue_assign_notification after_update :subscribe_issue_assigned_user def assign_uname @@ -45,17 +45,17 @@ class Issue < ActiveRecord::Base self.save! end - def deliver_new_issue_notification - recipients = collect_recipient_ids - recipients.each do |recipient_id| - recipient = User.find(recipient_id) - UserMailer.delay.new_issue_notification(self, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue - end - end + #def deliver_new_issue_notification + # recipients = collect_recipient_ids + # recipients.each do |recipient_id| + # recipient = User.find(recipient_id) + # UserMailer.delay.new_issue_notification(self, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue + # end + #end - def deliver_issue_assign_notification - UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id && self.user.notifier.issue_assign && self.user.notifier.can_notify - end + #def deliver_issue_assign_notification + # UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id && self.user.notifier.issue_assign && self.user.notifier.can_notify + #end def subscribe_users recipients = collect_recipient_ids diff --git a/app/models/user.rb b/app/models/user.rb index 16a399caa..5183b86b8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,6 +8,8 @@ class User < ActiveRecord::Base has_one :notifier, :class_name => 'Settings::Notifier' #:notifier + has_many :activity_feeds + has_many :authentications, :dependent => :destroy has_many :build_lists, :dependent => :destroy diff --git a/app/views/activity_feeds/partials/issue_assign_notification.haml b/app/views/activity_feeds/partials/issue_assign_notification.haml new file mode 100644 index 000000000..414f8e6c3 --- /dev/null +++ b/app/views/activity_feeds/partials/issue_assign_notification.haml @@ -0,0 +1,7 @@ +%p== Здравствуйте, #{user.name}. + + +%p Вам была назначена задача #{ link_to issue.title, [issue.project, issue] } + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/activity_feeds/partials/new_comment_notification.haml b/app/views/activity_feeds/partials/new_comment_notification.haml new file mode 100644 index 000000000..dd09ab701 --- /dev/null +++ b/app/views/activity_feeds/partials/new_comment_notification.haml @@ -0,0 +1,9 @@ +%p== Здравствуйте, #{user.name}. + + +%p К задаче #{ link_to comment.commentable.title, [comment.commentable.project, comment.commentable] } был добавлен новый комментарий. + +%p "#{ comment.body }" + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/activity_feeds/partials/new_comment_reply_notification.haml b/app/views/activity_feeds/partials/new_comment_reply_notification.haml new file mode 100644 index 000000000..9aa223deb --- /dev/null +++ b/app/views/activity_feeds/partials/new_comment_reply_notification.haml @@ -0,0 +1,9 @@ +%p== Здравствуйте, #{user.name}. + + +%p На Ваш комментарий в задаче #{ link_to comment.commentable.title, [comment.commentable.project, comment.commentable] } был дан ответ. + +%p "#{ comment.body }" + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/activity_feeds/partials/new_issue_notification.haml b/app/views/activity_feeds/partials/new_issue_notification.haml new file mode 100644 index 000000000..a5a139fd6 --- /dev/null +++ b/app/views/activity_feeds/partials/new_issue_notification.haml @@ -0,0 +1,7 @@ +%p== Здравствуйте, #{user.name}. + + +%p К проекту #{ link_to issue.project.name, project_path(issue.project) } была добавлена задача #{ link_to issue.title, [issue.project, issue] } + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/activity_feeds/partials/new_user_notification.haml b/app/views/activity_feeds/partials/new_user_notification.haml new file mode 100644 index 000000000..191e2ad5f --- /dev/null +++ b/app/views/activity_feeds/partials/new_user_notification.haml @@ -0,0 +1,12 @@ +%p== Здравствуйте, #{user.name}. + + +%p Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. + + +%p + ==Ваш email : #{user.email} + %br/ + ==Ваш пароль: #{user.password} + +%p== Команда поддержки «ROSA Build System» diff --git a/config/application.rb b/config/application.rb index 901d86784..c9d1d710a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,7 +24,7 @@ module Rosa # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. - config.active_record.observers = :event_log_observer + config.active_record.observers = :event_log_observer, :activity_feed_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. diff --git a/db/migrate/20120124065207_create_activity_feeds.rb b/db/migrate/20120124065207_create_activity_feeds.rb new file mode 100644 index 000000000..6321f4b58 --- /dev/null +++ b/db/migrate/20120124065207_create_activity_feeds.rb @@ -0,0 +1,14 @@ +class CreateActivityFeeds < ActiveRecord::Migration + def self.up + create_table :activity_feeds do |t| + t.integer :user_id, :null => false + t.text :body + + t.timestamps + end + end + + def self.down + drop_table :activity_feeds + end +end diff --git a/db/schema.rb b/db/schema.rb index 825f237ba..038fc0423 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,14 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120117110723) do +ActiveRecord::Schema.define(:version => 20120124065207) do + + create_table "activity_feeds", :force => true do |t| + t.integer "user_id", :null => false + t.text "body" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "arches", :force => true do |t| t.string "name", :null => false @@ -167,13 +174,6 @@ ActiveRecord::Schema.define(:version => 20120117110723) do add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true - create_table "permissions", :force => true do |t| - t.integer "right_id" - t.integer "role_id" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "platforms", :force => true do |t| t.string "description" t.string "name" @@ -270,14 +270,6 @@ ActiveRecord::Schema.define(:version => 20120117110723) do t.string "owner_type" end - create_table "rights", :force => true do |t| - t.string "name", :null => false - t.string "controller", :null => false - t.string "action", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "rpms", :force => true do |t| t.string "name", :null => false t.integer "arch_id", :null => false diff --git a/spec/controllers/activity_feeds_controller_spec.rb b/spec/controllers/activity_feeds_controller_spec.rb new file mode 100644 index 000000000..54ce3026a --- /dev/null +++ b/spec/controllers/activity_feeds_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ActivityFeedsController do + +end diff --git a/spec/factories/activity_feeds.rb b/spec/factories/activity_feeds.rb new file mode 100644 index 000000000..d0e1984cc --- /dev/null +++ b/spec/factories/activity_feeds.rb @@ -0,0 +1,6 @@ +# Read about factories at http://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :activity_feed do + end +end \ No newline at end of file diff --git a/spec/helpers/activity_feeds_helper_spec.rb b/spec/helpers/activity_feeds_helper_spec.rb new file mode 100644 index 000000000..623c526ec --- /dev/null +++ b/spec/helpers/activity_feeds_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the ActivityFeedsHelper. For example: +# +# describe ActivityFeedsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe ActivityFeedsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/activity_feed_observer_spec.rb b/spec/models/activity_feed_observer_spec.rb new file mode 100644 index 000000000..378ee2377 --- /dev/null +++ b/spec/models/activity_feed_observer_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ActivityFeedObserver do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/activity_feed_spec.rb b/spec/models/activity_feed_spec.rb new file mode 100644 index 000000000..c77e1d83a --- /dev/null +++ b/spec/models/activity_feed_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ActivityFeed do + pending "add some examples to (or delete) #{__FILE__}" +end From dd1493d67716208173c16d2106f6708ecc69047b Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 25 Jan 2012 17:05:39 +0400 Subject: [PATCH 02/77] [refs #123] Add activity feed page. Remove some unnessary code. Some logic fixes. --- app/models/activity_feed.rb | 8 -------- app/models/activity_feed_observer.rb | 20 +++++++------------- app/views/activity_feeds/index.html.haml | 21 +++++++++++++++++++++ config/locales/ru.yml | 3 +++ config/routes.rb | 5 ++++- 5 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 app/views/activity_feeds/index.html.haml diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb index d636301e9..0708e6df6 100644 --- a/app/models/activity_feed.rb +++ b/app/models/activity_feed.rb @@ -1,11 +1,3 @@ class ActivityFeed < ActiveRecord::Base belongs_to :user - - def render_body(partial_name, locals={}) - av = ActionView::Base.new(Rails::Configuration.new.view_path) - av.render( - :partial => 'app/views/activity_feeds/partials/' + partial_name + '.haml', - :locals => locals - ) - end end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 22f16dfe3..89eff315b 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -5,26 +5,28 @@ class ActivityFeedObserver < ActiveRecord::Observer case record.class.to_s when 'User' ActivityFeed.create(:user => record, :body => render_body('new_user_notification')) + when 'Issue' recipients = record.collect_recipient_ids recipients.each do |recipient_id| recipient = User.find(recipient_id) UserMailer.delay.new_issue_notification(record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue - ActivityFeed.create(:user => record, :body => render_body('new_issue_notification', {:user => recipient, :issue => record})) + ActivityFeed.create(:user => recipient, :body => render_body('new_issue_notification', {:user => recipient, :issue => record})) end UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify ActivityFeed.create(:user => record.user, :body => render_body('issue_assign_notification', {:user => record.user, :issue => record})) + when 'Comment' subscribes = record.commentable.subscribes subscribes.each do |subscribe| if record.user_id != subscribe.user_id if record.reply? subscribe UserMailer.delay.new_comment_reply_notification(record, subscribe.user) if record.can_notify_on_reply?(subscribe) - ActivityFeed.create(:user => record.user, :body => render_body('new_comment_reply_notification', {:user => subscribe.user, :comment => record})) + ActivityFeed.create(:user => subscribe.user, :body => render_body('new_comment_reply_notification', {:user => subscribe.user, :comment => record})) else UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) - ActivityFeed.create(:user => record.user, :body => render_body('new_comment_notification', {:user => subscribe.user, :comment => record})) + ActivityFeed.create(:user => subscribe.user, :body => render_body('new_comment_notification', {:user => subscribe.user, :comment => record})) end end end @@ -40,16 +42,8 @@ class ActivityFeedObserver < ActiveRecord::Observer end def render_body(partial_name, locals={}) - #ac = ActionController::Base.new - #ac.render_to_string( - # 'app/views/activity_feeds/partials/' + partial_name + '.haml', - # :locals => locals - #) - - #ac = ActionView::Base.new([], locals) - #ac.render(:inline => 'app/views/activity_feeds/partials/' + partial_name + '.haml') - - StubController.new.partial_to_string('activity_feeds/partials/' + partial_name, locals) + @@stub_controller ||= StubController.new + @@stub_controller.partial_to_string('activity_feeds/partials/' + partial_name, locals) end end diff --git a/app/views/activity_feeds/index.html.haml b/app/views/activity_feeds/index.html.haml new file mode 100644 index 000000000..85f1ba5c6 --- /dev/null +++ b/app/views/activity_feeds/index.html.haml @@ -0,0 +1,21 @@ +%a{ :name => "comments" } +.block#block-list + .content + %h2.title + = t("layout.activity_feed.header") + .inner + %ul.list + - @activity_feeds.each do |activity_feed| + %li + .left + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %br + = activity_feed.created_at + %br + %br + .item + = raw activity_feed.body + %br + %br + %br diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 469a1293a..6ba1c7ea6 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -46,6 +46,9 @@ ru: edit_header: Настройки оповещений processing: Обрабатывается... + activity_feed: + header: Лента активности + downloads: title: Статистика закачек пакетов message: Обновляется автоматически каждые 5 минут diff --git a/config/routes.rb b/config/routes.rb index bda7c96eb..327bc5543 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,8 @@ Rosa::Application.routes.draw do end end + resources :activity_feeds, :only => [:index] + resources :users, :groups do resources :platforms, :only => [:new, :create] @@ -167,6 +169,7 @@ Rosa::Application.routes.draw do match '/projects/:project_id/git/raw/:treeish/*path', :controller => "git/blobs", :action => :raw, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :raw match '/projects/:project_id/git/commit/raw/:commit_hash/*path', :controller => "git/blobs", :action => :raw, :as => :raw_commit - root :to => "platforms#index" + #root :to => "platforms#index" + root :to => "activity_feeds#index" match '/forbidden', :to => 'platforms#forbidden', :as => 'forbidden' end From 0eb0eb971393b9d1ef8d1e3a15320fb2faf566d6 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 26 Jan 2012 21:04:58 +0400 Subject: [PATCH 03/77] [refs #123] Activity Feed logic global refactoring. --- app/helpers/activity_feeds_helper.rb | 3 ++ app/models/activity_feed.rb | 6 +++ app/models/activity_feed_observer.rb | 40 ++++++++++++++----- app/views/activity_feeds/index.html.haml | 2 +- .../partials/issue_assign_notification.haml | 8 +--- .../partials/new_comment_notification.haml | 10 ++--- .../new_comment_reply_notification.haml | 10 ++--- .../partials/new_issue_notification.haml | 8 +--- .../partials/new_user_notification.haml | 10 ++--- config/locales/ru.yml | 20 ++++++++++ .../20120124065207_create_activity_feeds.rb | 3 +- db/schema.rb | 3 +- 12 files changed, 78 insertions(+), 45 deletions(-) diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb index 54a624bad..f3facbf94 100644 --- a/app/helpers/activity_feeds_helper.rb +++ b/app/helpers/activity_feeds_helper.rb @@ -1,2 +1,5 @@ module ActivityFeedsHelper + def render_activity_feed(activity_feed) + render :partial => activity_feed.partial, :locals => activity_feed.data + end end diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb index 0708e6df6..934ef56ea 100644 --- a/app/models/activity_feed.rb +++ b/app/models/activity_feed.rb @@ -1,3 +1,9 @@ class ActivityFeed < ActiveRecord::Base belongs_to :user + + serialize :data + + def partial + 'activity_feeds/partials/' + self.kind + end end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 89eff315b..eaf3c6772 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -4,18 +4,26 @@ class ActivityFeedObserver < ActiveRecord::Observer def after_create(record) case record.class.to_s when 'User' - ActivityFeed.create(:user => record, :body => render_body('new_user_notification')) + ActivityFeed.create(:user => record, :kind => 'new_user_notification', :date => {:user_name => record.name, :user_email => record.email, :password => user.password}) when 'Issue' recipients = record.collect_recipient_ids recipients.each do |recipient_id| recipient = User.find(recipient_id) UserMailer.delay.new_issue_notification(record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue - ActivityFeed.create(:user => recipient, :body => render_body('new_issue_notification', {:user => recipient, :issue => record})) + ActivityFeed.create( + :user => recipient, + :kind => 'new_issue_notification', + :data => {:user_name => recipient.name, :issue_id => record.id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} + ) end UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify - ActivityFeed.create(:user => record.user, :body => render_body('issue_assign_notification', {:user => record.user, :issue => record})) + ActivityFeed.create( + :user_name => record.user.name, + :kind => 'issue_assign_notification', + :data => {:user_name => record.user.name, :issue_id => record.id, :project_id => record.project.id, :issue_title => record.title} + ) when 'Comment' subscribes = record.commentable.subscribes @@ -23,10 +31,18 @@ class ActivityFeedObserver < ActiveRecord::Observer if record.user_id != subscribe.user_id if record.reply? subscribe UserMailer.delay.new_comment_reply_notification(record, subscribe.user) if record.can_notify_on_reply?(subscribe) - ActivityFeed.create(:user => subscribe.user, :body => render_body('new_comment_reply_notification', {:user => subscribe.user, :comment => record})) + ActivityFeed.create( + :user => subscribe.user, + :kind => 'new_comment_reply_notification', + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_id => record.commentable.id, :project_id => record.commentable.project.id} + ) else UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) - ActivityFeed.create(:user => subscribe.user, :body => render_body('new_comment_notification', {:user => subscribe.user, :comment => record})) + ActivityFeed.create( + :user => subscribe.user, + :kind => 'new_comment_notification', + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_id => record.commentable.id, :project_id => record.commentable.project.id} + ) end end end @@ -37,13 +53,17 @@ class ActivityFeedObserver < ActiveRecord::Observer case record.class.to_s when 'Issue' UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify - ActivityFeed.create(:user => record.user, :body => render_body('issue_assign_notification', {:user => record.user, :issue => record})) + ActivityFeed.create( + :user_name => record.user.name, + :kind => 'issue_assign_notification', + :data => {:user_name => record.user.name, :issue_id => record.id, :project_id => record.project.id, :issue_title => record.title} + ) end end - def render_body(partial_name, locals={}) - @@stub_controller ||= StubController.new - @@stub_controller.partial_to_string('activity_feeds/partials/' + partial_name, locals) - end + #def (partial_name, locals={}) + # @@stub_controller ||= StubController.new + # @@stub_controller.partial_to_string('activity_feeds/partials/' + partial_name, locals) + #end end diff --git a/app/views/activity_feeds/index.html.haml b/app/views/activity_feeds/index.html.haml index 85f1ba5c6..838d9a62a 100644 --- a/app/views/activity_feeds/index.html.haml +++ b/app/views/activity_feeds/index.html.haml @@ -15,7 +15,7 @@ %br %br .item - = raw activity_feed.body + = render_activity_feed(activity_feed) %br %br %br diff --git a/app/views/activity_feeds/partials/issue_assign_notification.haml b/app/views/activity_feeds/partials/issue_assign_notification.haml index 414f8e6c3..1dc74a671 100644 --- a/app/views/activity_feeds/partials/issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/issue_assign_notification.haml @@ -1,7 +1,3 @@ -%p== Здравствуйте, #{user.name}. +%p== #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) } - -%p Вам была назначена задача #{ link_to issue.title, [issue.project, issue] } - - -%p== Команда поддержки «ROSA Build System» +%p #{ t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } diff --git a/app/views/activity_feeds/partials/new_comment_notification.haml b/app/views/activity_feeds/partials/new_comment_notification.haml index dd09ab701..bbd60a77b 100644 --- a/app/views/activity_feeds/partials/new_comment_notification.haml +++ b/app/views/activity_feeds/partials/new_comment_notification.haml @@ -1,9 +1,5 @@ -%p== Здравствуйте, #{user.name}. +%p== #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } +%p #{ t("notifications.bodies.new_comment_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } -%p К задаче #{ link_to comment.commentable.title, [comment.commentable.project, comment.commentable] } был добавлен новый комментарий. - -%p "#{ comment.body }" - - -%p== Команда поддержки «ROSA Build System» +%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/new_comment_reply_notification.haml b/app/views/activity_feeds/partials/new_comment_reply_notification.haml index 9aa223deb..a0367f840 100644 --- a/app/views/activity_feeds/partials/new_comment_reply_notification.haml +++ b/app/views/activity_feeds/partials/new_comment_reply_notification.haml @@ -1,9 +1,5 @@ -%p== Здравствуйте, #{user.name}. +%p== #{ t("notifications.bodies.new_comment_reply_notification.title", :user_name => user_name) } +%p #{ t("notifications.bodies.new_comment_reply_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } -%p На Ваш комментарий в задаче #{ link_to comment.commentable.title, [comment.commentable.project, comment.commentable] } был дан ответ. - -%p "#{ comment.body }" - - -%p== Команда поддержки «ROSA Build System» +%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/new_issue_notification.haml b/app/views/activity_feeds/partials/new_issue_notification.haml index a5a139fd6..75d2269a7 100644 --- a/app/views/activity_feeds/partials/new_issue_notification.haml +++ b/app/views/activity_feeds/partials/new_issue_notification.haml @@ -1,7 +1,3 @@ -%p== Здравствуйте, #{user.name}. +%p== #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } - -%p К проекту #{ link_to issue.project.name, project_path(issue.project) } была добавлена задача #{ link_to issue.title, [issue.project, issue] } - - -%p== Команда поддержки «ROSA Build System» +%p #{ t("notifications.bodies.new_issue_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id]), :project_link => link_to(project_name, project_path(project_id)) } diff --git a/app/views/activity_feeds/partials/new_user_notification.haml b/app/views/activity_feeds/partials/new_user_notification.haml index 191e2ad5f..13339f00d 100644 --- a/app/views/activity_feeds/partials/new_user_notification.haml +++ b/app/views/activity_feeds/partials/new_user_notification.haml @@ -1,12 +1,10 @@ -%p== Здравствуйте, #{user.name}. +%p== #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } -%p Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. +%p #{ t("notifications.bodies.new_user_notification.content") } %p - ==Ваш email : #{user.email} + #{ t("notifications.bodies.new_user_notification.email"), :user_email => user_email } %br/ - ==Ваш пароль: #{user.password} - -%p== Команда поддержки «ROSA Build System» + #{ t("notifications.bodies.new_user_notification.password"), :user_password => user_email } diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 6ba1c7ea6..58ab6c0fa 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -692,6 +692,26 @@ ru: notifications: subjects: new_comment_notification: Новый комментарий к Вашей задаче + new_comment_reply_notification: Новый комментарий к Вашей задаче new_issue_notification: Новая задача добавлена к проекту new_user_notification: Регистрация на проекте «%{ project_name }» issue_assign_notification: Вам назначили задачу + + bodies: + new_comment_notification: + title: Здравствуйте, %{user_name}. + content: К задаче %{ issue_link } был добавлен новый комментарий. + new_comment_reply_notification: + title: Здравствуйте, %{user_name}. + content: На Ваш комментарий в задаче %{ issue_link } был дан ответ. + new_issue_notification: + title: Здравствуйте, %{user_name}. + content: К проекту %{ project_link } была добавлена задача %{ issue_link } + new_user_notification: + title: Здравствуйте, %{user_name}. + content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. + email: ==Ваш email : %{user_email} + password: ==Ваш пароль: %{user_password} + issue_assign_notification: + title: Здравствуйте, %{user_name}. + content: Вам была назначена задача %{ issue_link } diff --git a/db/migrate/20120124065207_create_activity_feeds.rb b/db/migrate/20120124065207_create_activity_feeds.rb index 6321f4b58..d5b13fc3a 100644 --- a/db/migrate/20120124065207_create_activity_feeds.rb +++ b/db/migrate/20120124065207_create_activity_feeds.rb @@ -2,7 +2,8 @@ class CreateActivityFeeds < ActiveRecord::Migration def self.up create_table :activity_feeds do |t| t.integer :user_id, :null => false - t.text :body + t.string :kind + t.text :data t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 038fc0423..c97d7408f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,7 +14,8 @@ ActiveRecord::Schema.define(:version => 20120124065207) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false - t.text "body" + t.string "kind" + t.text "data" t.datetime "created_at" t.datetime "updated_at" end From 72fd821bc8c2bc859bdc1a1741c98f3246bf9651 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 27 Jan 2012 16:06:04 +0400 Subject: [PATCH 04/77] [refs #123] Add fixes for activity feed --- app/models/activity_feed_observer.rb | 34 +++++++++++-------- app/models/issue.rb | 26 +++++++------- .../partials/_issue_assign_notification.haml | 3 ++ .../partials/_new_comment_notification.haml | 5 +++ .../_new_comment_reply_notification.haml | 5 +++ .../partials/_new_issue_notification.haml | 3 ++ .../partials/_new_user_notification.haml | 10 ++++++ .../partials/issue_assign_notification.haml | 3 -- .../partials/new_comment_notification.haml | 5 --- .../new_comment_reply_notification.haml | 5 --- .../partials/new_issue_notification.haml | 3 -- .../partials/new_user_notification.haml | 10 ------ config/locales/en.yml | 21 +++++++++++- config/locales/ru.yml | 12 +++---- 14 files changed, 84 insertions(+), 61 deletions(-) create mode 100644 app/views/activity_feeds/partials/_issue_assign_notification.haml create mode 100644 app/views/activity_feeds/partials/_new_comment_notification.haml create mode 100644 app/views/activity_feeds/partials/_new_comment_reply_notification.haml create mode 100644 app/views/activity_feeds/partials/_new_issue_notification.haml create mode 100644 app/views/activity_feeds/partials/_new_user_notification.haml delete mode 100644 app/views/activity_feeds/partials/issue_assign_notification.haml delete mode 100644 app/views/activity_feeds/partials/new_comment_notification.haml delete mode 100644 app/views/activity_feeds/partials/new_comment_reply_notification.haml delete mode 100644 app/views/activity_feeds/partials/new_issue_notification.haml delete mode 100644 app/views/activity_feeds/partials/new_user_notification.haml diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index eaf3c6772..94d975ff1 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -14,16 +14,18 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', - :data => {:user_name => recipient.name, :issue_id => record.id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} + :data => {:user_name => recipient.name, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} ) end - UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify - ActivityFeed.create( - :user_name => record.user.name, - :kind => 'issue_assign_notification', - :data => {:user_name => record.user.name, :issue_id => record.id, :project_id => record.project.id, :issue_title => record.title} - ) + if record.user_id_was != record.user_id + UserMailer.delay.issue_assign_notification(record, record.user) if record.user.notifier.issue_assign && record.user.notifier.can_notify + ActivityFeed.create( + :user => record.user, + :kind => 'issue_assign_notification', + :data => {:user_name => record.user.name, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title} + ) + end when 'Comment' subscribes = record.commentable.subscribes @@ -34,14 +36,14 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_reply_notification', - :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_id => record.commentable.id, :project_id => record.commentable.project.id} + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} ) else UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_notification', - :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_id => record.commentable.id, :project_id => record.commentable.project.id} + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} ) end end @@ -52,12 +54,14 @@ class ActivityFeedObserver < ActiveRecord::Observer def after_update(record) case record.class.to_s when 'Issue' - UserMailer.delay.issue_assign_notification(record, record.user) if record.user_id_was != record.user_id && record.user.notifier.issue_assign && record.user.notifier.can_notify - ActivityFeed.create( - :user_name => record.user.name, - :kind => 'issue_assign_notification', - :data => {:user_name => record.user.name, :issue_id => record.id, :project_id => record.project.id, :issue_title => record.title} - ) + if record.user_id_was != record.user_id + UserMailer.delay.issue_assign_notification(record, record.user) if record.user.notifier.issue_assign && record.user.notifier.can_notify + ActivityFeed.create( + :user => record.user, + :kind => 'issue_assign_notification', + :data => {:user_name => record.user.name, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title} + ) + end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 0a0084c95..8d1343595 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -38,6 +38,19 @@ class Issue < ActiveRecord::Base end end + def collect_recipient_ids + recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } + recipients = recipients | [self.user_id] if self.user_id + recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User' + + # filter by notification settings + recipients = recipients.select do |recipient| + User.find(recipient).notifier.new_issue && User.find(recipient).notifier.can_notify + end + + recipients + end + protected def set_serial_id @@ -65,19 +78,6 @@ class Issue < ActiveRecord::Base end end - def collect_recipient_ids - recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } - recipients = recipients | [self.user_id] if self.user_id - recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User' - - # filter by notification settings - recipients = recipients.select do |recipient| - User.find(recipient).notifier.new_issue && User.find(recipient).notifier.can_notify - end - - recipients - end - def subscribe_issue_assigned_user if self.user_id_was != self.user_id self.subscribes.where(:user_id => self.user_id_was).first.destroy unless self.user_id_was.blank? diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml new file mode 100644 index 000000000..f3ddea3b2 --- /dev/null +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -0,0 +1,3 @@ +%p== #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) } + +%p= raw t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))) diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_notification.haml new file mode 100644 index 000000000..23c15ef74 --- /dev/null +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -0,0 +1,5 @@ +%p== #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } + +%p= raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) + +%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/_new_comment_reply_notification.haml b/app/views/activity_feeds/partials/_new_comment_reply_notification.haml new file mode 100644 index 000000000..a9f040c38 --- /dev/null +++ b/app/views/activity_feeds/partials/_new_comment_reply_notification.haml @@ -0,0 +1,5 @@ +%p== #{ t("notifications.bodies.new_comment_reply_notification.title", :user_name => user_name) } + +%p= raw t("notifications.bodies.new_comment_reply_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) + +%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml new file mode 100644 index 000000000..6f1666c74 --- /dev/null +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -0,0 +1,3 @@ +%p== #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } + +%p= raw t("notifications.bodies.new_issue_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id)), :project_link => link_to(project_name, project_path(project_id))) diff --git a/app/views/activity_feeds/partials/_new_user_notification.haml b/app/views/activity_feeds/partials/_new_user_notification.haml new file mode 100644 index 000000000..b1ae04bd6 --- /dev/null +++ b/app/views/activity_feeds/partials/_new_user_notification.haml @@ -0,0 +1,10 @@ +%p== #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } + + +%p #{ t("notifications.bodies.new_user_notification.content") } + + +%p + #{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) } + %br/ + #{ t("notifications.bodies.new_user_notification.password", :user_password => user_email) } diff --git a/app/views/activity_feeds/partials/issue_assign_notification.haml b/app/views/activity_feeds/partials/issue_assign_notification.haml deleted file mode 100644 index 1dc74a671..000000000 --- a/app/views/activity_feeds/partials/issue_assign_notification.haml +++ /dev/null @@ -1,3 +0,0 @@ -%p== #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) } - -%p #{ t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } diff --git a/app/views/activity_feeds/partials/new_comment_notification.haml b/app/views/activity_feeds/partials/new_comment_notification.haml deleted file mode 100644 index bbd60a77b..000000000 --- a/app/views/activity_feeds/partials/new_comment_notification.haml +++ /dev/null @@ -1,5 +0,0 @@ -%p== #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } - -%p #{ t("notifications.bodies.new_comment_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } - -%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/new_comment_reply_notification.haml b/app/views/activity_feeds/partials/new_comment_reply_notification.haml deleted file mode 100644 index a0367f840..000000000 --- a/app/views/activity_feeds/partials/new_comment_reply_notification.haml +++ /dev/null @@ -1,5 +0,0 @@ -%p== #{ t("notifications.bodies.new_comment_reply_notification.title", :user_name => user_name) } - -%p #{ t("notifications.bodies.new_comment_reply_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id])) } - -%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/new_issue_notification.haml b/app/views/activity_feeds/partials/new_issue_notification.haml deleted file mode 100644 index 75d2269a7..000000000 --- a/app/views/activity_feeds/partials/new_issue_notification.haml +++ /dev/null @@ -1,3 +0,0 @@ -%p== #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } - -%p #{ t("notifications.bodies.new_issue_notification.content", :issue_link => link_to(issue_title, [project_id, issue_id]), :project_link => link_to(project_name, project_path(project_id)) } diff --git a/app/views/activity_feeds/partials/new_user_notification.haml b/app/views/activity_feeds/partials/new_user_notification.haml deleted file mode 100644 index 13339f00d..000000000 --- a/app/views/activity_feeds/partials/new_user_notification.haml +++ /dev/null @@ -1,10 +0,0 @@ -%p== #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } - - -%p #{ t("notifications.bodies.new_user_notification.content") } - - -%p - #{ t("notifications.bodies.new_user_notification.email"), :user_email => user_email } - %br/ - #{ t("notifications.bodies.new_user_notification.password"), :user_password => user_email } diff --git a/config/locales/en.yml b/config/locales/en.yml index cfeb90f79..a85a5be28 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -691,4 +691,23 @@ en: new_comment_notification: New comment to your task new_issue_notification: New task added to project new_user_notification: Registered on project «%{ project_name }» - issue_assign_notification: New task assigned \ No newline at end of file + issue_assign_notification: New task assigned + + bodies: + new_comment_notification: + title: Hello, %{user_name}. + content: To the issue %{issue_link} added a comment. + new_comment_reply_notification: + title: Hello, %{user_name}. + content: Your comment into issue %{issue_link} has been answered. + new_issue_notification: + title: Hello, %{user_name}. + content: To project %{project_link} has been added an issue %{issue_link} + new_user_notification: + title: Hello, %{user_name}. + content: You have been sign up to project «ROSA Build System» and now can sign in. + email: ==Your email %{user_email} + password: ==Your password %{user_password} + issue_assign_notification: + title: Hello, %{user_name}. + content: You have been assigned to issue %{issue_link} diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 58ab6c0fa..8fb21d916 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -700,18 +700,18 @@ ru: bodies: new_comment_notification: title: Здравствуйте, %{user_name}. - content: К задаче %{ issue_link } был добавлен новый комментарий. + content: К задаче %{issue_link} был добавлен новый комментарий. new_comment_reply_notification: title: Здравствуйте, %{user_name}. - content: На Ваш комментарий в задаче %{ issue_link } был дан ответ. + content: На Ваш комментарий в задаче %{issue_link} был дан ответ. new_issue_notification: title: Здравствуйте, %{user_name}. - content: К проекту %{ project_link } была добавлена задача %{ issue_link } + content: К проекту %{project_link} была добавлена задача %{issue_link} new_user_notification: title: Здравствуйте, %{user_name}. content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. - email: ==Ваш email : %{user_email} - password: ==Ваш пароль: %{user_password} + email: ==Ваш email %{user_email} + password: ==Ваш пароль %{user_password} issue_assign_notification: title: Здравствуйте, %{user_name}. - content: Вам была назначена задача %{ issue_link } + content: Вам была назначена задача %{issue_link} From e01fe571b4c8dccc6e7906f1ef23943994bb2913 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 27 Jan 2012 18:59:28 +0400 Subject: [PATCH 05/77] [refs #123] Add activity feed en translation fixes --- app/models/activity_feed_observer.rb | 8 ++++++-- config/locales/en.yml | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 94d975ff1..d500c2baa 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -1,10 +1,14 @@ class ActivityFeedObserver < ActiveRecord::Observer - observe :issue, :comment + observe :issue, :comment, :user def after_create(record) case record.class.to_s when 'User' - ActivityFeed.create(:user => record, :kind => 'new_user_notification', :date => {:user_name => record.name, :user_email => record.email, :password => user.password}) + ActivityFeed.create( + :user => record, + :kind => 'new_user_notification', + :date => {:user_name => record.name, :user_email => record.email, :password => user.password} + ) when 'Issue' recipients = record.collect_recipient_ids diff --git a/config/locales/en.yml b/config/locales/en.yml index a85a5be28..367014b0e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -46,6 +46,9 @@ en: edit_header: Notifier setting processing: working ... + activity_feed: + header: Activity Feed + downloads: title: Downloads statistic message: Automatically updated every 5 minutes From 9271c15a5f64c615ae348ec4151422e3cd64a7fb Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 10 Feb 2012 21:33:05 +0400 Subject: [PATCH 06/77] [refs #123] Add new commits support --- app/models/activity_feed_observer.rb | 25 +++++++++++++++++++ app/models/project.rb | 2 +- .../_git_delete_branch_notification.haml | 3 +++ .../partials/_git_new_push_notification.haml | 7 ++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/views/activity_feeds/partials/_git_delete_branch_notification.haml create mode 100644 app/views/activity_feeds/partials/_git_new_push_notification.haml diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index d500c2baa..ac404c168 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -52,6 +52,31 @@ class ActivityFeedObserver < ActiveRecord::Observer end end end + when 'GitHook' + change_type = record.change_type + branch_name = record.refname.match(/\/([\w\d]+)$/)[1] + #user_name = record. + + owner = record.owner + project = Project.find_by_name(record.repo) + + last_commits = project.git_repository.repo.log(branch_name, nil).first(3).collect do |commit| #:author => 'author' + [commit.sha, commit.message] + end + + if change_type == 'delete' + ActivityFeed.create( + :user => owner, + :kind => 'git_delete_branch_notification', + :data => {:user_id => owner.id, :user_name => owner.uname, :project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} + ) + else + ActivityFeed.create( + :user => owner,#record.user, + :kind => 'git_new_push_notification', + :data => {:user_id => owner.id, :user_name => owner.uname, :project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type} + ) + end end end diff --git a/app/models/project.rb b/app/models/project.rb index c15332d5e..4d548b39d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -164,7 +164,7 @@ class Project < ActiveRecord::Base def self.process_hook(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type) rec = GitHook.new(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type) - #ActivityFeedObserver.instance.after_create rec # for example + ActivityFeedObserver.instance.after_create rec end protected diff --git a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml new file mode 100644 index 000000000..22794adab --- /dev/null +++ b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml @@ -0,0 +1,3 @@ +%p== User #{ link_to user_name, user_path(user_id) } delete branch #{ branch_name } + +%p== Into project #{ link_to(project_name, project_path(project_id)) } diff --git a/app/views/activity_feeds/partials/_git_new_push_notification.haml b/app/views/activity_feeds/partials/_git_new_push_notification.haml new file mode 100644 index 000000000..cad03077f --- /dev/null +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -0,0 +1,7 @@ +%p== User #{ link_to user_name, user_path(user_id) } #{ change_type } branch #{ branch_name } +%p== Into project #{ link_to(project_name, project_path(project_id)) } + +- last_commits.each do |commit| + = link_to commit[0], commit_path(project_id, commit[0]) + = commit[1] + %br From 08ffd8c25d843d3edcc8106b6634dae465c1fbfd Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 14 Feb 2012 20:09:41 +0400 Subject: [PATCH 07/77] [refs #123] Add wiki to ActivityFeed --- app/controllers/activity_feeds_controller.rb | 2 +- app/controllers/wiki_controller.rb | 1 + app/models/activity_feed_observer.rb | 18 +++++++++++++++++ app/models/issue.rb | 20 ------------------- .../_wiki_new_commit_notification.haml | 2 ++ 5 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 app/views/activity_feeds/partials/_wiki_new_commit_notification.haml diff --git a/app/controllers/activity_feeds_controller.rb b/app/controllers/activity_feeds_controller.rb index 3b9a173af..b23311937 100644 --- a/app/controllers/activity_feeds_controller.rb +++ b/app/controllers/activity_feeds_controller.rb @@ -2,6 +2,6 @@ class ActivityFeedsController < ApplicationController before_filter :authenticate_user! def index - @activity_feeds = current_user.activity_feeds + @activity_feeds = current_user.activity_feeds.order('created_at DESC') end end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b334262e3..352e0c283 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -249,6 +249,7 @@ class WikiController < ApplicationController # @committer.after_commit do |committer, sha1| # here goes callback for notification # end + ActivityFeedObserver.instance.after_create(@committer) @committer end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index ac404c168..fff220e5f 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -77,6 +77,24 @@ class ActivityFeedObserver < ActiveRecord::Observer :data => {:user_id => owner.id, :user_name => owner.uname, :project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type} ) end + when 'Gollum::Committer' + actor = User.find_by_uname(record.actor.name) + project_name = record.wiki.path.match(/\/(\w+)\.wiki\.git$/)[1] + project = Project.find_by_name(project_name) + commit_sha = record.commit + #wiki_name = record.wiki.name + + # TODO: Move this logic into Gollum::Wiki + recipients = project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } + recipients = recipients | [project.owner_id] if project.owner_type == 'User' + + recipients.each do |recipient| + ActivityFeed.create( + :user => User.find(recipient),#record.user, + :kind => 'wiki_new_commit_notification', + :data => {:user_id => actor.id, :user_name => actor.name, :project_id => project.id, :project_name => project_name, :commit_sha => commit_sha} + ) + end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index c8d540735..dfe73c71b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -16,9 +16,6 @@ class Issue < ActiveRecord::Base after_create :set_serial_id after_create :subscribe_users - #after_create :deliver_new_issue_notification - #after_create :deliver_issue_assign_notification - #after_update :deliver_issue_assign_notification after_update :subscribe_issue_assigned_user def assign_uname @@ -40,11 +37,6 @@ class Issue < ActiveRecord::Base recipients = recipients | [self.user_id] if self.user_id recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User' - # filter by notification settings - recipients = recipients.select do |recipient| - User.find(recipient).notifier.new_issue && User.find(recipient).notifier.can_notify - end - recipients end @@ -55,18 +47,6 @@ class Issue < ActiveRecord::Base self.save! end - #def deliver_new_issue_notification - # recipients = collect_recipient_ids - # recipients.each do |recipient_id| - # recipient = User.find(recipient_id) - # UserMailer.delay.new_issue_notification(self, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue - # end - #end - - #def deliver_issue_assign_notification - # UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id && self.user.notifier.issue_assign && self.user.notifier.can_notify - #end - def subscribe_users recipients = collect_recipient_ids recipients.each do |recipient_id| diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml new file mode 100644 index 000000000..eb33be273 --- /dev/null +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -0,0 +1,2 @@ +%p== User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", compare_versions_project_wiki_index_path(project_id, commit_sha) } +%p== Into project #{ link_to(project_name, project_path(project_id)) } From 101fa63514f51ae19538e8631e2a7eda8673bdd9 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 14 Feb 2012 20:46:08 +0400 Subject: [PATCH 08/77] Small ActivityFeed refactoring --- app/controllers/wiki_controller.rb | 2 +- app/models/activity_feed_observer.rb | 26 +++++++++---------- app/models/project.rb | 6 +++++ .../_git_delete_branch_notification.haml | 2 +- .../partials/_git_new_push_notification.haml | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 352e0c283..4c1d8854c 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -249,7 +249,7 @@ class WikiController < ApplicationController # @committer.after_commit do |committer, sha1| # here goes callback for notification # end - ActivityFeedObserver.instance.after_create(@committer) + ActivityFeedObserver.instance.after_create(@committer).delay @committer end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index fff220e5f..d52726325 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -57,7 +57,7 @@ class ActivityFeedObserver < ActiveRecord::Observer branch_name = record.refname.match(/\/([\w\d]+)$/)[1] #user_name = record. - owner = record.owner + #owner = record.owner project = Project.find_by_name(record.repo) last_commits = project.git_repository.repo.log(branch_name, nil).first(3).collect do |commit| #:author => 'author' @@ -65,16 +65,18 @@ class ActivityFeedObserver < ActiveRecord::Observer end if change_type == 'delete' - ActivityFeed.create( - :user => owner, - :kind => 'git_delete_branch_notification', - :data => {:user_id => owner.id, :user_name => owner.uname, :project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} - ) + kind = 'git_delete_branch_notification' + options = {:project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} else + kind = 'git_new_push_notification' + options = {:project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type} + end + + project.owner_and_admin_ids.each do |recipient| ActivityFeed.create( - :user => owner,#record.user, - :kind => 'git_new_push_notification', - :data => {:user_id => owner.id, :user_name => owner.uname, :project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type} + :user => User.find(recipient), + :kind => kind, + :data => options ) end when 'Gollum::Committer' @@ -84,11 +86,7 @@ class ActivityFeedObserver < ActiveRecord::Observer commit_sha = record.commit #wiki_name = record.wiki.name - # TODO: Move this logic into Gollum::Wiki - recipients = project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } - recipients = recipients | [project.owner_id] if project.owner_type == 'User' - - recipients.each do |recipient| + project.owner_and_admin_ids.each do |recipient| ActivityFeed.create( :user => User.find(recipient),#record.user, :kind => 'wiki_new_commit_notification', diff --git a/app/models/project.rb b/app/models/project.rb index 4d548b39d..9238119fa 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -167,6 +167,12 @@ class Project < ActiveRecord::Base ActivityFeedObserver.instance.after_create rec end + def owner_and_admin_ids + recipients = self.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } + recipients = recipients | [self.owner_id] if self.owner_type == 'User' + recipients + end + protected def build_path(dir) diff --git a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml index 22794adab..10acc1d61 100644 --- a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml +++ b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml @@ -1,3 +1,3 @@ -%p== User #{ link_to user_name, user_path(user_id) } delete branch #{ branch_name } +%p== Branch #{ branch_name } has been deleted %p== Into project #{ link_to(project_name, project_path(project_id)) } diff --git a/app/views/activity_feeds/partials/_git_new_push_notification.haml b/app/views/activity_feeds/partials/_git_new_push_notification.haml index cad03077f..46a62e834 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,4 +1,4 @@ -%p== User #{ link_to user_name, user_path(user_id) } #{ change_type } branch #{ branch_name } +%p== Branch #{ branch_name } has been #{ change_type }d %p== Into project #{ link_to(project_name, project_path(project_id)) } - last_commits.each do |commit| From 28e2494e14e900fa1f3f6c652a33abcdef5ee10e Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 24 Feb 2012 15:26:50 +0400 Subject: [PATCH 09/77] [refs #123] Remove stubs controller --- app/controllers/stub_controller.rb | 24 ------------------------ app/models/activity_feed_observer.rb | 5 ----- 2 files changed, 29 deletions(-) delete mode 100644 app/controllers/stub_controller.rb diff --git a/app/controllers/stub_controller.rb b/app/controllers/stub_controller.rb deleted file mode 100644 index 67a69c51a..000000000 --- a/app/controllers/stub_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -class StubController < AbstractController::Base - include AbstractController::Rendering - include AbstractController::Layouts - include AbstractController::Helpers - include AbstractController::Translation - include AbstractController::AssetPaths - include ActionController::UrlWriter - - # Uncomment if you want to use helpers - # defined in ApplicationHelper in your views - # helper ApplicationHelper - - # Make sure your controller can find views - self.view_paths = "app/views" - - # You can define custom helper methods to be used in views here - # helper_method :current_admin - # def current_admin; nil; end - - def partial_to_string(partial_name, locals) - render_to_string(partial_name, :locals => locals) - end - -end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index d52726325..5c4b2a875 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -110,9 +110,4 @@ class ActivityFeedObserver < ActiveRecord::Observer end end - #def (partial_name, locals={}) - # @@stub_controller ||= StubController.new - # @@stub_controller.partial_to_string('activity_feeds/partials/' + partial_name, locals) - #end - end From 395fb812a6e69b343390320a054a2015ed8e74d1 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 24 Feb 2012 15:34:23 +0400 Subject: [PATCH 10/77] [refs #123] Move notifications locales into another file --- config/locales/en.yml | 33 --------------------------------- config/locales/ru.yml | 28 ---------------------------- 2 files changed, 61 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 0bb005ea5..0664293d0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1135,36 +1135,3 @@ en: platform: Platform counter: Downloads - notifications: - subjects: - new_comment_notification: New comment to your task - new_issue_notification: New task added to project - new_user_notification: Registered on project «%{ project_name }» - issue_assign_notification: New task assigned - - bodies: - new_comment_notification: - title: Hello, %{user_name}. - content: To the issue %{issue_link} added a comment. - new_comment_reply_notification: - title: Hello, %{user_name}. - content: Your comment into issue %{issue_link} has been answered. - new_issue_notification: - title: Hello, %{user_name}. - content: To project %{project_link} has been added an issue %{issue_link} - new_user_notification: - title: Hello, %{user_name}. - content: You have been sign up to project «ROSA Build System» and now can sign in. - email: ==Your email %{user_email} - password: ==Your password %{user_password} - issue_assign_notification: - title: Hello, %{user_name}. - content: You have been assigned to issue %{issue_link} - - download: - name: Name - version: Version - distro: Source - platform: Platform - counter: Downloads - diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 0f3cb2ddc..9be3f4015 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -793,31 +793,3 @@ ru: platform: Архитектура counter: Закачки - notifications: - subjects: - new_comment_notification: Новый комментарий к Вашей задаче - new_comment_reply_notification: Новый комментарий к Вашей задаче - new_issue_notification: Новая задача добавлена к проекту - new_user_notification: Регистрация на проекте «%{ project_name }» - issue_assign_notification: Вам назначили задачу - - bodies: - new_comment_notification: - title: Здравствуйте, %{user_name}. - content: К задаче %{issue_link} был добавлен новый комментарий. - new_comment_reply_notification: - title: Здравствуйте, %{user_name}. - content: На Ваш комментарий в задаче %{issue_link} был дан ответ. - new_issue_notification: - title: Здравствуйте, %{user_name}. - content: К проекту %{project_link} была добавлена задача %{issue_link} - new_user_notification: - title: Здравствуйте, %{user_name}. - content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. - email: ==Ваш email %{user_email} - password: ==Ваш пароль %{user_password} - issue_assign_notification: - title: Здравствуйте, %{user_name}. - content: Вам была назначена задача %{issue_link} - new_commit_comment_notification: Новый комментарий к коммиту - invite_approve_notification: Приглашение в ABF From 45905babd815572af835ff653e2dea7e8b71316a Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 24 Feb 2012 15:51:30 +0400 Subject: [PATCH 11/77] [refs #123] Add lost notification locales --- config/locales/notifications.en.yml | 34 +++++++++++++++++++++++++++++ config/locales/notifications.ru.yml | 29 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 config/locales/notifications.en.yml create mode 100644 config/locales/notifications.ru.yml diff --git a/config/locales/notifications.en.yml b/config/locales/notifications.en.yml new file mode 100644 index 000000000..93d15993b --- /dev/null +++ b/config/locales/notifications.en.yml @@ -0,0 +1,34 @@ +notifications: + subjects: + new_comment_notification: New comment to your task + new_issue_notification: New task added to project + new_user_notification: Registered on project «%{ project_name }» + issue_assign_notification: New task assigned + + bodies: + new_comment_notification: + title: Hello, %{user_name}. + content: To the issue %{issue_link} added a comment. + new_comment_reply_notification: + title: Hello, %{user_name}. + content: Your comment into issue %{issue_link} has been answered. + new_issue_notification: + title: Hello, %{user_name}. + content: To project %{project_link} has been added an issue %{issue_link} + new_user_notification: + title: Hello, %{user_name}. + content: You have been sign up to project «ROSA Build System» and now can sign in. + email: ==Your email %{user_email} + password: ==Your password %{user_password} + issue_assign_notification: + title: Hello, %{user_name}. + content: You have been assigned to issue %{issue_link} + + download: + name: Name + version: Version + distro: Source + platform: Platform + counter: Downloads + + diff --git a/config/locales/notifications.ru.yml b/config/locales/notifications.ru.yml new file mode 100644 index 000000000..f4ddbe462 --- /dev/null +++ b/config/locales/notifications.ru.yml @@ -0,0 +1,29 @@ +notifications: + subjects: + new_comment_notification: Новый комментарий к Вашей задаче + new_comment_reply_notification: Новый комментарий к Вашей задаче + new_issue_notification: Новая задача добавлена к проекту + new_user_notification: Регистрация на проекте «%{ project_name }» + issue_assign_notification: Вам назначили задачу + + bodies: + new_comment_notification: + title: Здравствуйте, %{user_name}. + content: К задаче %{issue_link} был добавлен новый комментарий. + new_comment_reply_notification: + title: Здравствуйте, %{user_name}. + content: На Ваш комментарий в задаче %{issue_link} был дан ответ. + new_issue_notification: + title: Здравствуйте, %{user_name}. + content: К проекту %{project_link} была добавлена задача %{issue_link} + new_user_notification: + title: Здравствуйте, %{user_name}. + content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. + email: ==Ваш email %{user_email} + password: ==Ваш пароль %{user_password} + issue_assign_notification: + title: Здравствуйте, %{user_name}. + content: Вам была назначена задача %{issue_link} + new_commit_comment_notification: Новый комментарий к коммиту + invite_approve_notification: Приглашение в ABF + From fd15a39f7a1c56c5e30c86a6cbd3e0a4e84a6261 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 14 Feb 2012 13:50:01 +0200 Subject: [PATCH 12/77] Fix cancan regsiter_requests specs. Temporary fix specs running bug through file rename. Refs #161 --- config/initializers/gollum.rb | 2 +- config/initializers/grit.rb | 2 +- db/schema.rb | 5 ++--- lib/{gollum.rb => gollum1.rb} | 0 lib/{grit.rb => grit1.rb} | 0 spec/factories/register_requests.rb | 13 ++++++++----- 6 files changed, 12 insertions(+), 10 deletions(-) rename lib/{gollum.rb => gollum1.rb} (100%) rename lib/{grit.rb => grit1.rb} (100%) diff --git a/config/initializers/gollum.rb b/config/initializers/gollum.rb index d5c28225a..143ec1535 100644 --- a/config/initializers/gollum.rb +++ b/config/initializers/gollum.rb @@ -1 +1 @@ -require './lib/gollum' +require './lib/gollum1' diff --git a/config/initializers/grit.rb b/config/initializers/grit.rb index 043d42d15..04420c3cb 100644 --- a/config/initializers/grit.rb +++ b/config/initializers/grit.rb @@ -1,3 +1,3 @@ # -*- encoding : utf-8 -*- -require './lib/grit' +require './lib/grit1' diff --git a/db/schema.rb b/db/schema.rb index bf68d3b7c..75b6b173f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -98,12 +98,12 @@ ActiveRecord::Schema.define(:version => 20120210141153) do end create_table "comments", :force => true do |t| + t.string "commentable_id" t.string "commentable_type" t.integer "user_id" t.text "body" t.datetime "created_at" t.datetime "updated_at" - t.decimal "commentable_id", :precision => 50, :scale => 0 end create_table "containers", :force => true do |t| @@ -125,7 +125,6 @@ ActiveRecord::Schema.define(:version => 20120210141153) do t.string "locked_by" t.datetime "created_at" t.datetime "updated_at" - t.string "queue" end add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" @@ -347,6 +346,7 @@ ActiveRecord::Schema.define(:version => 20120210141153) do t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" + t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" @@ -354,7 +354,6 @@ ActiveRecord::Schema.define(:version => 20120210141153) do t.string "uname" t.string "role" t.string "language", :default => "en" - t.datetime "reset_password_sent_at" t.integer "own_projects_count", :default => 0, :null => false end diff --git a/lib/gollum.rb b/lib/gollum1.rb similarity index 100% rename from lib/gollum.rb rename to lib/gollum1.rb diff --git a/lib/grit.rb b/lib/grit1.rb similarity index 100% rename from lib/grit.rb rename to lib/grit1.rb diff --git a/spec/factories/register_requests.rb b/spec/factories/register_requests.rb index 7fd9c1446..96cc52d02 100644 --- a/spec/factories/register_requests.rb +++ b/spec/factories/register_requests.rb @@ -2,9 +2,12 @@ FactoryGirl.define do factory :register_request do - name "MyString" - email "MyString" - token "MyString" - approved false - end + name "MyString" + email { Factory.next(:email) } + token "MyString" + interest "MyString" + more "MyText" + approved false + rejected false + end end From de9071ae4f623a3ee9707a21552a47f0f8aba401 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 14 Feb 2012 17:52:33 +0600 Subject: [PATCH 13/77] fix collaborator tests --- spec/controllers/collaborators_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/collaborators_controller_spec.rb b/spec/controllers/collaborators_controller_spec.rb index 3457d1aee..c7dcaa4b5 100644 --- a/spec/controllers/collaborators_controller_spec.rb +++ b/spec/controllers/collaborators_controller_spec.rb @@ -69,7 +69,7 @@ describe CollaboratorsController do @user.relations set_session_for(@user) @group = Factory(:group) - @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') end it_should_behave_like 'project admin user' From 1bc4efcdc4814b388b5db9288c730f140fbad951 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Tue, 14 Feb 2012 18:54:18 +0400 Subject: [PATCH 14/77] [issue #64] Fixed encodings bugs --- app/helpers/diff_helper.rb | 2 +- app/views/wiki/_diff_data.html.haml | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 0addc764b..646135d1e 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -8,7 +8,7 @@ module DiffHelper res += "" res += "" - res += diff_display.render(Git::Diff::InlineCallback.new) + res += diff_display.render(Git::Diff::InlineCallback.new).encode_to_default res += "" res += "
" diff --git a/app/views/wiki/_diff_data.html.haml b/app/views/wiki/_diff_data.html.haml index cd8fb1f9a..d4f405c30 100644 --- a/app/views/wiki/_diff_data.html.haml +++ b/app/views/wiki/_diff_data.html.haml @@ -1,8 +1,7 @@ .blob_header - .size= h(diff.deleted_file ? diff.a_path : diff.b_path) - - puts 'in view' - - puts diff.a_path - - puts diff.b_path + .size= h(diff.deleted_file ? diff.a_path : diff.b_path).encode_to_default + - puts diff.a_path.encode_to_default + - puts diff.b_path.encode_to_default .clear .diff_data.highlight From 43c896021ed57f422624dc056905ff71f86fe733 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Tue, 14 Feb 2012 18:54:44 +0400 Subject: [PATCH 15/77] [issue #64] Added possibility to diff and revert last commit --- app/controllers/wiki_controller.rb | 48 +++++++++++++++++++++--------- app/views/wiki/_compare.html.haml | 2 +- lib/gollum/wiki.rb | 10 +++++++ 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 4c1d8854c..51dc73dee 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -117,19 +117,37 @@ class WikiController < ApplicationController def compare_wiki if request.post? @versions = params[:versions] || [] - if @versions.size < 2 - redirect_to history_project_wiki_index_path(@project) - else - redirect_to compare_versions_project_wiki_index_path(@project, - sprintf('%s...%s', @versions.last, @versions.first)) + versions_string = case @versions.size + when 1 then @versions.first + when 2 then sprintf('%s...%s', @versions.last, @versions.first) + else begin + redirect_to history_project_wiki_index_path(@project) and return + end end + redirect_to compare_versions_project_wiki_index_path(@project, versions_string) +# if @versions.size < 2 +# redirect_to history_project_wiki_index_path(@project) +# else +# redirect_to compare_versions_project_wiki_index_path(@project, +# sprintf('%s...%s', @versions.last, @versions.first)) +# end elsif request.get? - @versions = params[:versions].split(/\.{2,3}/) - if @versions.size < 2 - redirect_to history_project_wiki_index_path(@project) - return + @versions = params[:versions].split(/\.{2,3}/) || [] + @diffs = case @versions.size + when 1 then @wiki.repo.commit_diff(@versions.first) + when 2 then @wiki.repo.diff(@versions.first, @versions.last) + else begin + redirect_to history_project_wiki_index_path(@project) + return + end end - @diffs = @wiki.repo.diff(@versions.first, @versions.last) + puts 'DIFFS' + puts @diffs.inspect +# if @versions.size < 2 +# redirect_to history_project_wiki_index_path(@project) +# return +# end +# @diffs = @wiki.repo.diff(@versions.first, @versions.last) render :compare else redirect_to project_wiki_path(@project, CGI.escape(@name)) @@ -141,8 +159,9 @@ class WikiController < ApplicationController @page = @wiki.page(@name) sha1 = params[:sha1] sha2 = params[:sha2] + sha2 = nil if params[:sha2] == 'prev' - if @wiki.revert_page(@page, sha1, sha2, {:committer => committer}).commit + if c = @wiki.revert_page(@page, sha1, sha2, {:committer => committer}) and c.commit flash[:notice] = t("flash.wiki.revert_success") redirect_to project_wiki_path(@project, CGI.escape(@name)) else @@ -162,14 +181,15 @@ class WikiController < ApplicationController def revert_wiki sha1 = params[:sha1] sha2 = params[:sha2] - if @wiki.revert_commit(sha1, sha2, {:committer => committer}).commit + sha2 = nil if sha2 == 'prev' + if c = @wiki.revert_commit(sha1, sha2, {:committer => committer}) and c.commit flash[:notice] = t("flash.wiki.revert_success") redirect_to project_wiki_index_path(@project) else sha2, sha1 = sha1, "#{sha1}^" if !sha2 @versions = [sha1, sha2] - diffs = @wiki.repo.diff(@versions.first, @versions.last) - @diffs = [diffs.first] + @diffs = @wiki.repo.diff(@versions.first, @versions.last) +# @diffs = [diffs.first] flash[:error] = t("flash.wiki.patch_does_not_apply") render :compare end diff --git a/app/views/wiki/_compare.html.haml b/app/views/wiki/_compare.html.haml index 0b58242e7..4796ba908 100644 --- a/app/views/wiki/_compare.html.haml +++ b/app/views/wiki/_compare.html.haml @@ -5,7 +5,7 @@ - if action_name != 'revert' %ul.actions %li.minibutton - = form_tag revert_path(@project, @versions[0][0..6], @versions[1][0..6], @name), + = form_tag revert_path(@project, @versions.first[0..6], (@versions.size == 1) ? 'prev' : @versions.last[0..6], @name), :name => "gollum-revert", :id => "gollum-revert-form" do = revert_button if can? :write, @project diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 14e8ae614..1c2b53d27 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -47,6 +47,8 @@ module Gollum multi_commit = false patch = full_reverse_diff_for(page, sha1, sha2) + puts 'patch' + puts patch committer = if obj = commit[:committer] multi_commit = true obj @@ -83,10 +85,18 @@ module Gollum end end + puts 'IN MY RELOADED FILE' + multi_commit ? committer : committer.commit end alias_method_chain :revert_page, :committer + def revert_commit_with_committer(sha1, sha2 = nil, commit = {}) + puts "i'm here" + revert_page_with_committer(nil, sha1, sha2, commit) + end + alias_method_chain :revert_commit, :committer + private def force_grit_encoding(str) From bab3a90155d1b93e7083beccebe60241afa6ce51 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 14 Feb 2012 20:15:52 +0200 Subject: [PATCH 16/77] Apply approved and rejected filters for register requests. Tune abilities. Link to user profile if user have already registered. Refs #174 --- app/controllers/register_requests_controller.rb | 2 +- app/models/ability.rb | 2 ++ app/views/register_requests/index.html.haml | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/register_requests_controller.rb b/app/controllers/register_requests_controller.rb index 74ddd6627..85c915a52 100644 --- a/app/controllers/register_requests_controller.rb +++ b/app/controllers/register_requests_controller.rb @@ -5,7 +5,7 @@ class RegisterRequestsController < ApplicationController before_filter :find_register_request, :only => [:approve, :reject] def index - @register_requests = @register_requests.unprocessed.paginate(:page => params[:page]) + @register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page]) end def new diff --git a/app/models/ability.rb b/app/models/ability.rb index 113b50dd1..2b58c1329 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,6 +17,8 @@ class Ability cannot :destroy, Subscribe cannot :create, Subscribe cannot :create, RegisterRequest + cannot :approve, RegisterRequest, :approved => true + cannot :reject, RegisterRequest, :rejected => true else # Shared rights between guests and registered users can :forbidden, Platform diff --git a/app/views/register_requests/index.html.haml b/app/views/register_requests/index.html.haml index a860887aa..9df74cd1b 100644 --- a/app/views/register_requests/index.html.haml +++ b/app/views/register_requests/index.html.haml @@ -5,6 +5,10 @@ %li= link_to t("layout.users.new"), new_user_path %li.active= link_to t("layout.users.register_requests"), register_requests_path .content + %div{:style => 'float: right; margin: 20px'} + = link_to t("layout.register_request.approved"), register_requests_path(:scope => :approved) + \| + = link_to t("layout.register_request.rejected"), register_requests_path(:scope => :rejected) %h2.title = t("layout.register_request.list_header") .inner @@ -23,7 +27,8 @@ %tr{:class => cycle("odd", "even")} %td= check_box_tag 'request_ids[]', request.id %td= request.name - %td= request.email + - @user = User.find_by_email(request.email) if request.approved + %td= link_to_if @user, request.email, @user %td= request.interest %td= request.more %td= request.created_at From e1f1e4aff4d71aa474b616d7f5e650e17e8979c2 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 15 Feb 2012 00:50:55 +0600 Subject: [PATCH 17/77] remove broken migration --- db/migrate/20120206194328_remove_orphan_platforms.rb | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 db/migrate/20120206194328_remove_orphan_platforms.rb diff --git a/db/migrate/20120206194328_remove_orphan_platforms.rb b/db/migrate/20120206194328_remove_orphan_platforms.rb deleted file mode 100644 index aa922710a..000000000 --- a/db/migrate/20120206194328_remove_orphan_platforms.rb +++ /dev/null @@ -1,8 +0,0 @@ -class RemoveOrphanPlatforms < ActiveRecord::Migration - def self.up - Platform.all.each {|x| x.destroy unless x.owner.present?} - end - - def self.down - end -end From 5986cd6ddef230aab582d57ad1487c86a0fd679f Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Wed, 15 Feb 2012 02:13:52 +0400 Subject: [PATCH 18/77] [issue #64] Removed debug methods and unnecessary comments. --- app/controllers/wiki_controller.rb | 17 ++--------------- lib/gollum/wiki.rb | 5 ----- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 51dc73dee..fd398d1aa 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -121,16 +121,11 @@ class WikiController < ApplicationController when 1 then @versions.first when 2 then sprintf('%s...%s', @versions.last, @versions.first) else begin - redirect_to history_project_wiki_index_path(@project) and return + redirect_to history_project_wiki_index_path(@project) + return end end redirect_to compare_versions_project_wiki_index_path(@project, versions_string) -# if @versions.size < 2 -# redirect_to history_project_wiki_index_path(@project) -# else -# redirect_to compare_versions_project_wiki_index_path(@project, -# sprintf('%s...%s', @versions.last, @versions.first)) -# end elsif request.get? @versions = params[:versions].split(/\.{2,3}/) || [] @diffs = case @versions.size @@ -141,13 +136,6 @@ class WikiController < ApplicationController return end end - puts 'DIFFS' - puts @diffs.inspect -# if @versions.size < 2 -# redirect_to history_project_wiki_index_path(@project) -# return -# end -# @diffs = @wiki.repo.diff(@versions.first, @versions.last) render :compare else redirect_to project_wiki_path(@project, CGI.escape(@name)) @@ -189,7 +177,6 @@ class WikiController < ApplicationController sha2, sha1 = sha1, "#{sha1}^" if !sha2 @versions = [sha1, sha2] @diffs = @wiki.repo.diff(@versions.first, @versions.last) -# @diffs = [diffs.first] flash[:error] = t("flash.wiki.patch_does_not_apply") render :compare end diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 1c2b53d27..70ef08e46 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -47,8 +47,6 @@ module Gollum multi_commit = false patch = full_reverse_diff_for(page, sha1, sha2) - puts 'patch' - puts patch committer = if obj = commit[:committer] multi_commit = true obj @@ -85,14 +83,11 @@ module Gollum end end - puts 'IN MY RELOADED FILE' - multi_commit ? committer : committer.commit end alias_method_chain :revert_page, :committer def revert_commit_with_committer(sha1, sha2 = nil, commit = {}) - puts "i'm here" revert_page_with_committer(nil, sha1, sha2, commit) end alias_method_chain :revert_commit, :committer From aedfc0df8c1aa68eb74489b76701099d0b71b5a3 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 15 Feb 2012 14:36:45 +0400 Subject: [PATCH 19/77] Change nginx log rotate period to 1 day --- config/locales/en.yml | 2 +- config/locales/ru.yml | 2 +- config/schedule.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 0664293d0..9e7871c1f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -59,7 +59,7 @@ en: downloads: title: Downloads statistic - message: Automatically updated every 5 minutes + message: Automatically updated every 24 hours refresh_btn: Refresh auto_build_lists: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 9be3f4015..3a9fcc2d8 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -63,7 +63,7 @@ ru: downloads: title: Статистика закачек пакетов - message: Обновляется автоматически каждые 5 минут + message: Обновляется автоматически каждые 24 часа refresh_btn: Обновить auto_build_lists: diff --git a/config/schedule.rb b/config/schedule.rb index f966ecc1d..f1d6faa22 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -7,7 +7,7 @@ # runner "Download.parse_and_remove_nginx_log" #end -every 5.minutes do +every 1.day, :at => '5:00' do #rake "sudo_test:projects" runner "Download.rotate_nginx_log" runner "Download.parse_and_remove_nginx_log" From 41861185c0874612b0c50dd6d1ee3ceacc06e190 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 15 Feb 2012 17:12:49 +0600 Subject: [PATCH 20/77] [refs #134] fixed git hook --- app/models/project.rb | 2 +- bin/post-receive-hook_dev | 15 ++++++++++++ bin/post-receive-hook_prod | 15 ++++++++++++ ...120131141651_write_git_hook_to_projects.rb | 13 ----------- lib/tasks/hook.rake | 23 +++++++++++++++++++ 5 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 bin/post-receive-hook_dev create mode 100644 bin/post-receive-hook_prod delete mode 100644 db/migrate/20120131141651_write_git_hook_to_projects.rb create mode 100644 lib/tasks/hook.rake diff --git a/app/models/project.rb b/app/models/project.rb index 9238119fa..56105d2e1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -219,7 +219,7 @@ class Project < ActiveRecord::Base def write_hook hook_file = File.join(path, 'hooks', 'post-receive') - FileUtils.cp(File.join(::Rails.root.to_s, 'lib', 'post-receive-hook'), hook_file) + FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook#{ENV['RAILS_ENV'] == 'production' ? '_prod' : '_dev'}"), hook_file) #File.chmod(0775, hook_file) # need? rescue Exception # FIXME end diff --git a/bin/post-receive-hook_dev b/bin/post-receive-hook_dev new file mode 100644 index 000000000..b577daa5b --- /dev/null +++ b/bin/post-receive-hook_dev @@ -0,0 +1,15 @@ +#!/bin/bash + +# This file was placed here by rosa-team. It makes sure that your pushed commits will be processed properly. + +pwd=`pwd` +reponame=`basename $pwd .git` +owner=`basename \`dirname $pwd\`` + +while read oldrev newrev ref +do + newrev_type=$(git cat-file -t $newrev 2> /dev/null) + oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) + + /bin/bash -l -c "cd /srv/rosa_build/current && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'" +done \ No newline at end of file diff --git a/bin/post-receive-hook_prod b/bin/post-receive-hook_prod new file mode 100644 index 000000000..6e9fb4bd8 --- /dev/null +++ b/bin/post-receive-hook_prod @@ -0,0 +1,15 @@ +#!/bin/bash + +# This file was placed here by rosa-team. It makes sure that your pushed commits will be processed properly. + +pwd=`pwd` +reponame=`basename $pwd .git` +owner=`basename \`dirname $pwd\`` + +while read oldrev newrev ref +do + newrev_type=$(git cat-file -t $newrev 2> /dev/null) + oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) + + /bin/bash -l -c "cd /srv/rosa_build/current && RAILS_ENV=production bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'" > /dev/null 2>&1 +done \ No newline at end of file diff --git a/db/migrate/20120131141651_write_git_hook_to_projects.rb b/db/migrate/20120131141651_write_git_hook_to_projects.rb deleted file mode 100644 index d8dded706..000000000 --- a/db/migrate/20120131141651_write_git_hook_to_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -class WriteGitHookToProjects < ActiveRecord::Migration - def self.up - origin_hook = File.join(::Rails.root.to_s, 'lib', 'post-receive-hook') - Project.all.each do |project| - hook_file = File.join(project.path, 'hooks', 'post-receive') - FileUtils.cp(origin_hook, hook_file) - end - end - - def self.down - Project.all.each { |project| FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive')} - end -end diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake new file mode 100644 index 000000000..9b4a0212b --- /dev/null +++ b/lib/tasks/hook.rake @@ -0,0 +1,23 @@ +namespace :hook do + desc "Inserting hook to all repos" + task :install => :environment do + origin_hook = File.join(::Rails.root.to_s, 'bin', "post-receive-hook#{ENV['RAILS_ENV'] == 'production' ? '_prod' : '_dev'}") + say "process.. #{origin_hook}" + count = 0 + Project.all.each do |project| + hook_file = File.join(project.path, 'hooks', 'post-receive') + FileUtils.cp(origin_hook, hook_file) + count = count + 1 + end + say "Done! Writing to #{count.to_s} repo(s)" + end + + desc "remove with git hook" + task :remove => :environment do + say "process.." + count = 0 + Project.all.each { |project| FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive'); count = count + 1} + say "Done! Removing from #{count.to_s} repo(s)" + end +end + From 4cdabd555c5ccbf70de580619abc7ca263e3cd10 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 15 Feb 2012 17:23:49 +0600 Subject: [PATCH 21/77] [refs #134] clean --- lib/post-receive-hook | 15 --------------- lib/tasks/hook.rake | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100755 lib/post-receive-hook diff --git a/lib/post-receive-hook b/lib/post-receive-hook deleted file mode 100755 index b577daa5b..000000000 --- a/lib/post-receive-hook +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# This file was placed here by rosa-team. It makes sure that your pushed commits will be processed properly. - -pwd=`pwd` -reponame=`basename $pwd .git` -owner=`basename \`dirname $pwd\`` - -while read oldrev newrev ref -do - newrev_type=$(git cat-file -t $newrev 2> /dev/null) - oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) - - /bin/bash -l -c "cd /srv/rosa_build/current && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'" -done \ No newline at end of file diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index 9b4a0212b..1eeae0774 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -12,7 +12,7 @@ namespace :hook do say "Done! Writing to #{count.to_s} repo(s)" end - desc "remove with git hook" + desc "remove git hook from all repos" task :remove => :environment do say "process.." count = 0 From 3b39738316017c7bad4f02142dc3e36f5d6be2f1 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 15 Feb 2012 19:06:25 +0600 Subject: [PATCH 22/77] [refs #134] rails root --- ...ive-hook_dev => post-receive-hook.partial} | 5 +---- bin/post-receive-hook_prod | 15 ------------- lib/tasks/hook.rake | 22 ++++++++++++++----- 3 files changed, 18 insertions(+), 24 deletions(-) rename bin/{post-receive-hook_dev => post-receive-hook.partial} (51%) delete mode 100644 bin/post-receive-hook_prod diff --git a/bin/post-receive-hook_dev b/bin/post-receive-hook.partial similarity index 51% rename from bin/post-receive-hook_dev rename to bin/post-receive-hook.partial index b577daa5b..b1e39a205 100644 --- a/bin/post-receive-hook_dev +++ b/bin/post-receive-hook.partial @@ -9,7 +9,4 @@ owner=`basename \`dirname $pwd\`` while read oldrev newrev ref do newrev_type=$(git cat-file -t $newrev 2> /dev/null) - oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) - - /bin/bash -l -c "cd /srv/rosa_build/current && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'" -done \ No newline at end of file + oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) \ No newline at end of file diff --git a/bin/post-receive-hook_prod b/bin/post-receive-hook_prod deleted file mode 100644 index 6e9fb4bd8..000000000 --- a/bin/post-receive-hook_prod +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# This file was placed here by rosa-team. It makes sure that your pushed commits will be processed properly. - -pwd=`pwd` -reponame=`basename $pwd .git` -owner=`basename \`dirname $pwd\`` - -while read oldrev newrev ref -do - newrev_type=$(git cat-file -t $newrev 2> /dev/null) - oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) - - /bin/bash -l -c "cd /srv/rosa_build/current && RAILS_ENV=production bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'" > /dev/null 2>&1 -done \ No newline at end of file diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index 1eeae0774..baf1e458a 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -1,15 +1,28 @@ namespace :hook do desc "Inserting hook to all repos" task :install => :environment do - origin_hook = File.join(::Rails.root.to_s, 'bin', "post-receive-hook#{ENV['RAILS_ENV'] == 'production' ? '_prod' : '_dev'}") - say "process.. #{origin_hook}" + is_production = ENV['RAILS_ENV'] == 'production' + say "Generate temporary file..." + hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") + FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) + File.open(hook, 'a') do |f| + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && \ + bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" + s << " > /dev/null 2>&1" if is_production + s << "\ndone\n" + f.write(s) + end + + say "Install process.." count = 0 Project.all.each do |project| hook_file = File.join(project.path, 'hooks', 'post-receive') - FileUtils.cp(origin_hook, hook_file) + FileUtils.cp(hook, hook_file) count = count + 1 end - say "Done! Writing to #{count.to_s} repo(s)" + say "Writing to #{count.to_s} repo(s)" + say "Removing temporary file" + FileUtils.rm_rf(hook) end desc "remove git hook from all repos" @@ -20,4 +33,3 @@ namespace :hook do say "Done! Removing from #{count.to_s} repo(s)" end end - From f7b496bb39d4df977b121814bb29d363c9604241 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Wed, 15 Feb 2012 20:30:56 +0400 Subject: [PATCH 23/77] Some fixes: * Changed default visibility to personal platforms to 'open' * Changed 'Erase' button to simple link in comments partial * Probably added domain name to links in mail notifications * Fixed protocol in repo links form 'http' to 'https' --- app/helpers/projects_helper.rb | 4 ++-- app/views/comments/_list.html.haml | 3 ++- app/views/user_mailer/issue_assign_notification.en.haml | 2 +- app/views/user_mailer/issue_assign_notification.ru.haml | 2 +- app/views/user_mailer/new_comment_notification.en.haml | 8 ++++---- app/views/user_mailer/new_comment_notification.ru.haml | 6 +++--- .../user_mailer/new_comment_reply_notification.en.haml | 4 ++-- app/views/user_mailer/new_issue_notification.en.haml | 2 +- app/views/user_mailer/new_issue_notification.ru.haml | 2 +- lib/modules/models/personal_repository.rb | 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 06c4de5b0..827e4cda0 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -2,9 +2,9 @@ module ProjectsHelper def git_repo_url(name) if current_user - "http://#{current_user.uname}@#{request.host_with_port}/#{name}.git" + "https://#{current_user.uname}@#{request.host_with_port}/#{name}.git" else - "http://#{request.host_with_port}/#{name}.git" + "https://#{request.host_with_port}/#{name}.git" end end end diff --git a/app/views/comments/_list.html.haml b/app/views/comments/_list.html.haml index 25e6e13ee..c2aa719bb 100644 --- a/app/views/comments/_list.html.haml +++ b/app/views/comments/_list.html.haml @@ -20,7 +20,8 @@ - edit_path = edit_project_commit_comment_path(project, commentable, comment) - delete_path = project_commit_comment_path(project, commentable, comment) = link_to t("layout.edit"), edit_path if can? :update, comment - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment + =# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment + = link_to t("layout.delete"), delete_path, :method => "delete", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment .block .content diff --git a/app/views/user_mailer/issue_assign_notification.en.haml b/app/views/user_mailer/issue_assign_notification.en.haml index 83c33e8ac..bc52f31d2 100644 --- a/app/views/user_mailer/issue_assign_notification.en.haml +++ b/app/views/user_mailer/issue_assign_notification.en.haml @@ -1,7 +1,7 @@ %p== Hello, #{@user.name}. -%p You have been assigned to issue #{ link_to @issue.title, [@issue.project, @issue] } +%p You have been assigned to issue #{ link_to @issue.title, project_issue_url(@issue.project, @issue) } %p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/issue_assign_notification.ru.haml b/app/views/user_mailer/issue_assign_notification.ru.haml index a6615d3eb..db96619f7 100644 --- a/app/views/user_mailer/issue_assign_notification.ru.haml +++ b/app/views/user_mailer/issue_assign_notification.ru.haml @@ -1,7 +1,7 @@ %p== Здравствуйте, #{@user.name}. -%p Вам была назначена задача #{ link_to @issue.title, [@issue.project, @issue] } +%p Вам была назначена задача #{ link_to @issue.title, project_issue_url(@issue.project, @issue) } %p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_notification.en.haml b/app/views/user_mailer/new_comment_notification.en.haml index 2c7fb66cb..99c1a4bfe 100644 --- a/app/views/user_mailer/new_comment_notification.en.haml +++ b/app/views/user_mailer/new_comment_notification.en.haml @@ -1,14 +1,14 @@ %p== Hello, #{@user.name}. - if @comment.commentable.class == Issue - - link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] + - link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) - object = 'issue' - elsif @comment.commentable.class == Grit::Commit - - link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id) + - link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id) - object = 'commit' -%p #{ link_to @comment.user.uname, user_path(@comment.user)} added new comment to #{object} #{link}. +%p #{ link_to @comment.user.uname, user_url(@comment.user)} added new comment to #{object} #{link}. %p "#{ @comment.body }" -%p== Support team «ROSA Build System» \ No newline at end of file +%p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_notification.ru.haml b/app/views/user_mailer/new_comment_notification.ru.haml index d1c0734dd..1dcab28a8 100644 --- a/app/views/user_mailer/new_comment_notification.ru.haml +++ b/app/views/user_mailer/new_comment_notification.ru.haml @@ -1,12 +1,12 @@ %p== Здравствуйте, #{@user.name}. - if @comment.commentable.class == Issue - - link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] + - link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) - object = 'задаче' - elsif @comment.commentable.class == Grit::Commit - - link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id) + - link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id) - object = 'коммиту' -%p #{ link_to @comment.user.uname, user_path(@comment.user)} добавил комментарий к #{object} #{link}. +%p #{ link_to @comment.user.uname, user_url(@comment.user)} добавил комментарий к #{object} #{link}. %p "#{ @comment.body }" diff --git a/app/views/user_mailer/new_comment_reply_notification.en.haml b/app/views/user_mailer/new_comment_reply_notification.en.haml index 9324062f2..b2838b2e0 100644 --- a/app/views/user_mailer/new_comment_reply_notification.en.haml +++ b/app/views/user_mailer/new_comment_reply_notification.en.haml @@ -1,7 +1,7 @@ %p== Hello, #{@user.name}. - -%p Your comment into issue #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } has been answered. +- #TODO hmm... this need to be refactored. +%p Your comment into issue #{ link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) } has been answered. %p "#{ @comment.body }" diff --git a/app/views/user_mailer/new_issue_notification.en.haml b/app/views/user_mailer/new_issue_notification.en.haml index f814fa617..7ddda0017 100644 --- a/app/views/user_mailer/new_issue_notification.en.haml +++ b/app/views/user_mailer/new_issue_notification.en.haml @@ -1,7 +1,7 @@ %p== Hello, #{@user.name}. -%p To project #{ link_to @issue.project.name, project_path(@issue.project) } has been added an issue #{ link_to @issue.title, [@issue.project, @issue] } +%p To project #{ link_to @issue.project.name, project_url(@issue.project) } has been added an issue #{ link_to @issue.title, project_issue_url(@issue.project, @issue) } %p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_issue_notification.ru.haml b/app/views/user_mailer/new_issue_notification.ru.haml index 3a2604cfb..4255c06c2 100644 --- a/app/views/user_mailer/new_issue_notification.ru.haml +++ b/app/views/user_mailer/new_issue_notification.ru.haml @@ -1,7 +1,7 @@ %p== Здравствуйте, #{@user.name}. -%p К проекту #{ link_to @issue.project.name, project_path(@issue.project) } была добавлена задача #{ link_to @issue.title, [@issue.project, @issue] } +%p К проекту #{ link_to @issue.project.name, project_url(@issue.project) } была добавлена задача #{ link_to @issue.title, project_issue_url(@issue.project, @issue) } %p== Команда поддержки «ROSA Build System» diff --git a/lib/modules/models/personal_repository.rb b/lib/modules/models/personal_repository.rb index 8ee4fd3d8..58f8f1805 100644 --- a/lib/modules/models/personal_repository.rb +++ b/lib/modules/models/personal_repository.rb @@ -16,7 +16,7 @@ module Modules pl.description = "#{self.uname}_personal" pl.platform_type = 'personal' pl.distrib_type = APP_CONFIG['distr_types'].first - pl.visibility = 'hidden' + pl.visibility = 'open' pl.save! rep = pl.repositories.build From 50ad3edab489aaaa189152d1ed9e212c25dd5648 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Wed, 15 Feb 2012 22:02:47 +0400 Subject: [PATCH 24/77] Fixed default host in mailer --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index fe08b9089..85f7a95ef 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -37,7 +37,7 @@ Rosa::Application.configure do # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false - config.action_mailer.default_url_options = { :host => 'rosa-build.rosalab.ru' } + config.action_mailer.default_url_options = { :host => 'abf.rosalinux.ru' } # Enable threaded mode # config.threadsafe! From a809a4c11612bef62a1732488da982094819f6fe Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 16 Feb 2012 21:08:08 +0600 Subject: [PATCH 25/77] [refs #134] fixed bug with new project --- app/models/project.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 56105d2e1..adc851079 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -218,9 +218,20 @@ class Project < ActiveRecord::Base end def write_hook + is_production = ENV['RAILS_ENV'] == 'production' + hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") + FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) + File.open(hook, 'a') do |f| + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" + s << " > /dev/null 2>&1" if is_production + s << "\ndone\n" + f.write(s) + end + hook_file = File.join(path, 'hooks', 'post-receive') - FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook#{ENV['RAILS_ENV'] == 'production' ? '_prod' : '_dev'}"), hook_file) - #File.chmod(0775, hook_file) # need? + FileUtils.cp(hook, hook_file) + FileUtils.rm_rf(hook) + rescue Exception # FIXME end end From 30f47a1748812823596b23281a6a5736d13ef781 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 16 Feb 2012 22:29:41 +0600 Subject: [PATCH 26/77] [refs #134] lost env! --- app/models/project.rb | 2 +- lib/tasks/hook.rake | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index adc851079..b26f2ee06 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -222,7 +222,7 @@ class Project < ActiveRecord::Base hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) File.open(hook, 'a') do |f| - s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index baf1e458a..67c5e8140 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -6,8 +6,7 @@ namespace :hook do hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) File.open(hook, 'a') do |f| - s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && \ - bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\"" s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) From 4daf50b34ee7eb0cdccdd4426ea2c0896a46726a Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 16 Feb 2012 20:23:33 +0200 Subject: [PATCH 27/77] Change blank repo message. Refs #196 --- config/locales/en.yml | 2 +- config/locales/ru.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 9e7871c1f..626fec74f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -513,7 +513,7 @@ en: list_header: Event log repositories: - empty: Empty repository + empty: "Repository is still empty. You need to wait some time if you have forked or imported" source: Source commits: Commits commit_diff_too_big: Sorry, commit too big! diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 3a9fcc2d8..3f4cb1f08 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -365,7 +365,7 @@ ru: git: repositories: - empty: Пустой репозиторий + empty: "Репозиторий пока пустой. Если форкнули или импортировали, необходимо немного подожать" source: Source commits: Commits commit_diff_too_big: Извините, коммит слишком большой! From f4f542811d70d89b8cc56485dbe38bfa7073d223 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Thu, 16 Feb 2012 23:08:54 +0400 Subject: [PATCH 28/77] [Refs#196] Update text message for empty text[ru] --- config/locales/ru.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 3f4cb1f08..1567e590a 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -365,7 +365,7 @@ ru: git: repositories: - empty: "Репозиторий пока пустой. Если форкнули или импортировали, необходимо немного подожать" + empty: "Репозиторий пуст. Если вы клонировали(Fork) проект или импортировали пакет, данные скоро появятся" source: Source commits: Commits commit_diff_too_big: Извините, коммит слишком большой! From e93d5c08b0304d519d90fd02a35d175bde48d2e1 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Thu, 16 Feb 2012 23:10:58 +0400 Subject: [PATCH 29/77] [Refs#196] Update text message for empty text[en] --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 626fec74f..368e2c04d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -513,7 +513,7 @@ en: list_header: Event log repositories: - empty: "Repository is still empty. You need to wait some time if you have forked or imported" + empty: "Repository is empty. You need to wait some time if you have forked project or imported package" source: Source commits: Commits commit_diff_too_big: Sorry, commit too big! From c972968338b5c9ba0dca4b3749d4a5c9c79b4731 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 17 Feb 2012 15:22:55 +0600 Subject: [PATCH 30/77] [refs #134] some hook task improvements --- lib/tasks/hook.rake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index 67c5e8140..d41bbafdb 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -14,7 +14,8 @@ namespace :hook do say "Install process.." count = 0 - Project.all.each do |project| + projects = ENV['project_id'] ? Project.where(:id => eval(ENV['project_id'])) : Project + projects.where('created_at >= ?', Time.now.ago(ENV['period'] ? eval(ENV['period']) : 100.years)).each do |project| hook_file = File.join(project.path, 'hooks', 'post-receive') FileUtils.cp(hook, hook_file) count = count + 1 @@ -28,7 +29,11 @@ namespace :hook do task :remove => :environment do say "process.." count = 0 - Project.all.each { |project| FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive'); count = count + 1} + projects = ENV['project_id'] ? Project.where(:id => eval(ENV['project_id'])) : Project + projects.where('created_at >= ?', Time.now.ago(ENV['period'] ? eval(ENV['period']) : 100.years)).each do |project| + FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive') + count = count + 1 + end say "Done! Removing from #{count.to_s} repo(s)" end end From 432b6ac27604257d2e48eec45e6c6e4b8736a335 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Fri, 17 Feb 2012 16:32:03 +0200 Subject: [PATCH 31/77] Refactor bluepill deploy recipies. Restart DJ through bluepill. Refs #196 --- config/deploy.rb | 3 ++- config/production.pill | 1 + lib/recipes/bluepill.rb | 49 +++++++++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index c67c374a3..3dc198504 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -62,8 +62,9 @@ namespace :deploy do end after "deploy:update_code", "deploy:symlink_all", "deploy:migrate" -after "deploy:restart","bluepill:stop", "delayed_job:restart", "deploy:cleanup", "bluepill:start" after "deploy:setup", "deploy:symlink_pids" +after "deploy:restart","bluepill:processes:restart_dj" # "bluepill:restart" +after "deploy:restart", "deploy:cleanup" require 'cape' namespace :rake_tasks do diff --git a/config/production.pill b/config/production.pill index ff49759fc..3199e382a 100644 --- a/config/production.pill +++ b/config/production.pill @@ -11,6 +11,7 @@ Bluepill.application(app_name) do |app| process.start_command = "/usr/bin/env RAILS_ENV=production script/delayed_job start" process.stop_command = "/usr/bin/env RAILS_ENV=production script/delayed_job stop" + process.restart_command = "/usr/bin/env RAILS_ENV=production script/delayed_job restart" process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'delayed_job.pid') end diff --git a/lib/recipes/bluepill.rb b/lib/recipes/bluepill.rb index a84ff7ecb..969728664 100644 --- a/lib/recipes/bluepill.rb +++ b/lib/recipes/bluepill.rb @@ -3,29 +3,46 @@ Capistrano::Configuration.instance(:must_exist).load do namespace :bluepill do set(:bluepill_binary) {"bundle exec bluepill --no-privileged"} - desc "Load bluepill configuration and start it" + namespace :processes do + desc "Start processes that bluepill is monitoring" + task :start, :roles => [:app] do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} start" + end + + desc "Stop processes that bluepill is monitoring" + task :stop, :roles => [:app], :on_error => :continue do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop" + end + + desc "Restart processes that bluepill is monitoring" + task :restart, :roles => [:app] do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart" + end + + desc "Prints bluepills monitored processes statuses" + task :status, :roles => [:app] do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status" + end + + desc "Restart DJ process" + task :restart_dj, :roles => [:app] do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job" + end + end + + desc "Start a bluepill process and load a config" task :start, :roles => [:app] do run "cd #{fetch :current_path} && #{try_sudo} APP_NAME=#{fetch :application} #{bluepill_binary} load config/production.pill" end - desc "Stop processes that bluepill is monitoring" - task :stop, :roles => [:app], :on_error => :continue do - run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop" - end - - task :restart, :roles => [:app] do - # run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart" - stop; quit; start - end - - desc "Stop processes that bluepill is monitoring and quit bluepill" - task :quit, :roles => [:app] do + desc "Quit bluepill" + task :stop, :roles => [:app] do run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} quit" end - desc "Prints bluepills monitored processes statuses" - task :status, :roles => [:app] do - run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status" + desc "Completely restart bluepill and monitored services" + task :restart, :roles => [:app] do + processes.stop; stop; start end end end From 5e58ec9e59430fa0d1479293403867b48ae9e994 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 21 Feb 2012 01:13:05 +0200 Subject: [PATCH 32/77] Delegate all repo abilities to platform. Remove repository owner and relations. Fix templates and specs. Refactor and code cleanup. Refs #205 --- .../personal_repositories_controller.rb | 2 +- app/controllers/repositories_controller.rb | 1 - app/models/ability.rb | 14 +++--- app/models/group.rb | 21 ++++---- app/models/relation.rb | 7 +-- app/models/repository.rb | 50 ++++++------------- app/models/user.rb | 15 +++--- .../projects_list.html.haml | 10 ---- .../personal_repositories/show.html.haml | 6 --- .../repositories/projects_list.html.haml | 5 -- app/views/repositories/show.html.haml | 5 -- ...0120220185458_remove_repositories_owner.rb | 12 +++++ db/schema.rb | 4 +- lib/modules/models/personal_repository.rb | 1 - .../collaborators_controller_spec.rb | 1 + spec/controllers/groups_controller_spec.rb | 1 + spec/controllers/members_controller_spec.rb | 1 + .../personal_repositories_controller_spec.rb | 5 +- .../repositories_controller_spec.rb | 6 +-- spec/factories/repository_factory.rb | 16 ++---- spec/models/cancan_spec.rb | 11 ++-- spec/models/comment_for_commit_spec.rb | 1 + spec/models/comment_spec.rb | 1 + spec/models/repository_spec.rb | 11 ++-- spec/models/subscribe_spec.rb | 1 + 25 files changed, 77 insertions(+), 131 deletions(-) create mode 100644 db/migrate/20120220185458_remove_repositories_owner.rb diff --git a/app/controllers/personal_repositories_controller.rb b/app/controllers/personal_repositories_controller.rb index c76c21623..122ed928a 100644 --- a/app/controllers/personal_repositories_controller.rb +++ b/app/controllers/personal_repositories_controller.rb @@ -12,7 +12,7 @@ class PersonalRepositoriesController < ApplicationController else @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 end - @user = @repository.owner + @user = @repository.platform.owner @urpmi_commands = @repository.platform.urpmi_list(request.host) end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 317683699..693be6034 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -42,7 +42,6 @@ class RepositoriesController < ApplicationController def create @repository = Repository.new(params[:repository]) @repository.platform_id = params[:platform_id] - @repository.owner = get_owner if @repository.save flash[:notice] = t('flash.repository.saved') redirect_to @repositories_path diff --git a/app/models/ability.rb b/app/models/ability.rb index 2b58c1329..8a6ac63a4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -66,18 +66,16 @@ class Ability can :read, Platform, :owner_type => 'User', :owner_id => user.id can :read, Platform, :owner_type => 'Group', :owner_id => user.group_ids can(:read, Platform, read_relations_for('platforms')) {|platform| local_reader? platform} - can(:update, Platform) {|platform| local_admin? platform} + can([:update, :build_all], Platform) {|platform| local_admin? platform} can([:freeze, :unfreeze, :destroy], Platform) {|platform| owner? platform} can :autocomplete_user_uname, Platform - # TODO delegate to platform? can :read, Repository, :platform => {:visibility => 'open'} - can :read, Repository, :owner_type => 'User', :owner_id => user.id - can :read, Repository, :owner_type => 'Group', :owner_id => user.group_ids - can(:read, Repository, read_relations_for('repositories')) {|repository| local_reader? repository} - can(:create, Repository) {|repository| local_admin? repository.platform} - can([:update, :add_project, :remove_project], Repository) {|repository| local_admin? repository} - can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository} + can :read, Repository, :platform => {:owner_type => 'User', :owner_id => user.id} + can :read, Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids} + can(:read, Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform} + can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform} + can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform} can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id} can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids} diff --git a/app/models/group.rb b/app/models/group.rb index c68147305..a7d96dcc7 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -2,16 +2,16 @@ class Group < ActiveRecord::Base belongs_to :owner, :class_name => 'User' - has_many :own_projects, :as => :owner, :class_name => 'Project' - + has_many :relations, :as => :object, :dependent => :destroy has_many :objects, :as => :target, :class_name => 'Relation' has_many :targets, :as => :object, :class_name => 'Relation' has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true - has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true, :dependent => :destroy - has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true - has_many :relations, :as => :object, :dependent => :destroy + has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true + + has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy + has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy validates :name, :owner, :presence => true validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } @@ -26,11 +26,12 @@ class Group < ActiveRecord::Base after_initialize lambda {|r| r.name ||= r.uname } # default include Modules::Models::PersonalRepository -# include Modules::Models::Owner + # include Modules::Models::Owner protected - def add_owner_to_members - Relation.create_with_role(self.owner, self, 'admin') -# members << self.owner if !members.exists?(:id => self.owner.id) - end + + def add_owner_to_members + Relation.create_with_role(self.owner, self, 'admin') + # members << self.owner if !members.exists?(:id => self.owner.id) + end end diff --git a/app/models/relation.rb b/app/models/relation.rb index 59c31d29d..6847b097b 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -22,7 +22,8 @@ class Relation < ActiveRecord::Base end protected - def add_default_role - self.role = ROLES.first if role.nil? || role.empty? - end + + def add_default_role + self.role = ROLES.first if role.nil? || role.empty? + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 379d3deac..f5c7d4c13 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,27 +1,19 @@ # -*- encoding : utf-8 -*- class Repository < ActiveRecord::Base belongs_to :platform - belongs_to :owner, :polymorphic => true has_many :projects, :through => :project_to_repositories #, :dependent => :destroy has_many :project_to_repositories, :validate => true, :dependent => :destroy - has_many :relations, :as => :target, :dependent => :destroy - has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy - has_many :members, :through => :objects, :source => :object, :source_type => 'User' - has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' - validates :description, :uniqueness => {:scope => :platform_id}, :presence => true validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ } - # validates :platform_id, :presence => true # if you uncomment this platform clone will not work scope :recent, order("name ASC") before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy - after_create :add_admin_relations - attr_accessible :description, :name #, :platform_id + attr_accessible :description, :name def full_clone(attrs) # owner clone.tap do |c| # dup @@ -31,8 +23,6 @@ class Repository < ActiveRecord::Base end end - include Modules::Models::Owner - class << self def build_stub(platform) rep = Repository.new @@ -43,31 +33,21 @@ class Repository < ActiveRecord::Base protected - def xml_rpc_create - result = BuildServer.create_repo name, platform.name - if result == BuildServer::SUCCESS - return true - else - raise "Failed to create repository #{name} inside platform #{platform.name} with code #{result}." - end + def xml_rpc_create + result = BuildServer.create_repo name, platform.name + if result == BuildServer::SUCCESS + return true + else + raise "Failed to create repository #{name} inside platform #{platform.name} with code #{result}." end + end - def xml_rpc_destroy - result = BuildServer.delete_repo name, platform.name - if result == BuildServer::SUCCESS - return true - else - raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}." - end - end - - def add_admin_relations - platform.relations.where(:role => 'admin').each do |rel| - if !relations.exists?(:role => 'admin', :object_type => rel.object_type, :object_id => rel.object_id) && rel.object != owner - r = relations.build(:role => 'admin', :object_type => rel.object_type) - r.object_id = rel.object_id - r.save - end - end + def xml_rpc_destroy + result = BuildServer.delete_repo name, platform.name + if result == BuildServer::SUCCESS + return true + else + raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}." end + end end diff --git a/app/models/user.rb b/app/models/user.rb index 25e8dab2f..aeb0729cd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,22 +13,19 @@ class User < ActiveRecord::Base has_many :authentications, :dependent => :destroy has_many :build_lists, :dependent => :destroy + has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy + has_many :comments, :dependent => :destroy has_many :relations, :as => :object, :dependent => :destroy has_many :targets, :as => :object, :class_name => 'Relation' - has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy - has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group' - has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy - has_many :own_repositories, :as => :owner, :class_name => 'Repository', :dependent => :destroy - - has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true + has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true - has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true - has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy - has_many :comments, :dependent => :destroy + has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy + has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy + has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy include Modules::Models::PersonalRepository diff --git a/app/views/personal_repositories/projects_list.html.haml b/app/views/personal_repositories/projects_list.html.haml index 4766fcb0b..2f3d8c3c0 100644 --- a/app/views/personal_repositories/projects_list.html.haml +++ b/app/views/personal_repositories/projects_list.html.haml @@ -20,21 +20,11 @@ = t("activerecord.attributes.repository.platform") \: = link_to @repository.platform.name, url_for(@repository.platform) - %p - %b - = t("activerecord.attributes.repository.owner") - \: - = link_to @repository.owner.name, url_for(@repository.owner) %p %b = t("activerecord.attributes.platform.visibility") \: = @repository.platform.visibility - %p - %b - = t("activerecord.attributes.repository.platform") - \: - = link_to @repository.platform.name, platform_path(@platform) .wat-cf = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") diff --git a/app/views/personal_repositories/show.html.haml b/app/views/personal_repositories/show.html.haml index f8f346094..c40d3a1d5 100644 --- a/app/views/personal_repositories/show.html.haml +++ b/app/views/personal_repositories/show.html.haml @@ -6,12 +6,6 @@ %li= link_to t("layout.personal_repositories.private_users"), platform_private_users_path(@repository.platform) if @repository.platform.hidden? .content .inner - %p - %b - = t("activerecord.attributes.repository.owner") - \: - = link_to @repository.owner.name, url_for(@repository.owner) - = render 'shared/urpmi_list', :urpmi_commands => @urpmi_commands .wat-cf =# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") diff --git a/app/views/repositories/projects_list.html.haml b/app/views/repositories/projects_list.html.haml index af5a9a1a9..d9ca336d8 100644 --- a/app/views/repositories/projects_list.html.haml +++ b/app/views/repositories/projects_list.html.haml @@ -21,11 +21,6 @@ = t("activerecord.attributes.repository.platform") \: = link_to @repository.platform.description, url_for(@repository.platform) - %p - %b - = t("activerecord.attributes.repository.owner") - \: - = link_to @repository.owner.uname, url_for(@repository.owner) .wat-cf = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml index 72ab6577a..7e23d2b0d 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/repositories/show.html.haml @@ -21,11 +21,6 @@ = t("activerecord.attributes.repository.platform") \: = link_to @repository.platform.description, url_for(@repository.platform) - %p - %b - = t("activerecord.attributes.repository.owner") - \: - = link_to @repository.owner.try(:name), url_for(@repository.owner) .wat-cf = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") if can? :destroy, @repository diff --git a/db/migrate/20120220185458_remove_repositories_owner.rb b/db/migrate/20120220185458_remove_repositories_owner.rb new file mode 100644 index 000000000..88c85a855 --- /dev/null +++ b/db/migrate/20120220185458_remove_repositories_owner.rb @@ -0,0 +1,12 @@ +class RemoveRepositoriesOwner < ActiveRecord::Migration + def self.up + remove_column :repositories, :owner_id + remove_column :repositories, :owner_type + Relation.delete_all(:target_type => 'Repository') + end + + def self.down + add_column :repositories, :owner_id, :integer + add_column :repositories, :owner_type, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 75b6b173f..e99351bdd 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 => 20120210141153) do +ActiveRecord::Schema.define(:version => 20120220185458) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -302,8 +302,6 @@ ActiveRecord::Schema.define(:version => 20120210141153) do t.datetime "created_at" t.datetime "updated_at" t.string "name", :null => false - t.integer "owner_id" - t.string "owner_type" end create_table "rpms", :force => true do |t| diff --git a/lib/modules/models/personal_repository.rb b/lib/modules/models/personal_repository.rb index 58f8f1805..5b903ecae 100644 --- a/lib/modules/models/personal_repository.rb +++ b/lib/modules/models/personal_repository.rb @@ -20,7 +20,6 @@ module Modules pl.save! rep = pl.repositories.build - rep.owner = pl.owner rep.name = 'main' rep.description = 'main' rep.save! diff --git a/spec/controllers/collaborators_controller_spec.rb b/spec/controllers/collaborators_controller_spec.rb index c7dcaa4b5..858bd3c05 100644 --- a/spec/controllers/collaborators_controller_spec.rb +++ b/spec/controllers/collaborators_controller_spec.rb @@ -37,6 +37,7 @@ end describe CollaboratorsController do before(:each) do + stub_rsync_methods @project = Factory(:project) @another_user = Factory(:user) @update_params = {:user => {:read => {@another_user.id => '1'}}} diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 2ccf820b3..4238babf8 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe GroupsController do before(:each) do + stub_rsync_methods @group = Factory(:group) @another_user = Factory(:user) @create_params = {:group => {:name => 'grp1', :uname => 'un_grp1'}} diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb index 512bbc73c..ab8ab5fbe 100644 --- a/spec/controllers/members_controller_spec.rb +++ b/spec/controllers/members_controller_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe MembersController do before(:each) do + stub_rsync_methods @group = Factory(:group) @user = @group.owner set_session_for @user diff --git a/spec/controllers/personal_repositories_controller_spec.rb b/spec/controllers/personal_repositories_controller_spec.rb index 50ff6f03f..6e020d61e 100644 --- a/spec/controllers/personal_repositories_controller_spec.rb +++ b/spec/controllers/personal_repositories_controller_spec.rb @@ -92,9 +92,6 @@ describe PersonalRepositoriesController do @project.update_attribute(:owner, @user) - @repository.update_attribute(:owner, @user) - @repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') - @repository.platform.update_attribute(:owner, @user) @repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') end @@ -108,7 +105,7 @@ describe PersonalRepositoriesController do before(:each) do @user = Factory(:user) set_session_for(@user) - @repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') + @repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') end it_should_behave_like 'personal repository viewer' diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb index 935de2e40..422fb5128 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/repositories_controller_spec.rb @@ -79,8 +79,8 @@ describe RepositoriesController do before(:each) do @user = Factory(:user) set_session_for(@user) - @repository.update_attribute(:owner, @user) - @repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + @repository.platform.update_attribute(:owner, @user) + @repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') end it_should_behave_like 'repository user with owner rights' @@ -90,7 +90,7 @@ describe RepositoriesController do before(:each) do @user = Factory(:user) set_session_for(@user) - @repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') + @repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') end it_should_behave_like 'repository user with reader rights' diff --git a/spec/factories/repository_factory.rb b/spec/factories/repository_factory.rb index 2188bc17e..4af755b28 100644 --- a/spec/factories/repository_factory.rb +++ b/spec/factories/repository_factory.rb @@ -3,18 +3,12 @@ Factory.define(:repository) do |p| p.description { Factory.next(:string) } p.name { Factory.next(:unixname) } p.association :platform, :factory => :platform - p.association :owner, :factory => :user end -Factory.define(:personal_repository, :class => Repository) do |p| - p.description { Factory.next(:string) } - p.name { Factory.next(:unixname) } - p.association :platform, :factory => :platform - p.association :owner, :factory => :user - - p.after_create { |rep| - rep.platform.platform_type = 'personal' - rep.platform.visibility = 'hidden' - rep.platform.save! +Factory.define(:personal_repository, :parent => :repository) do |p| + p.after_create {|r| + r.platform.platform_type = 'personal' + r.platform.visibility = 'hidden' + r.platform.save! } end diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index 597d5dd38..248a502d6 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -278,24 +278,19 @@ describe CanCan do context 'with owner rights' do before(:each) do - @repository.update_attribute(:owner, @user) + @repository.platform.update_attribute(:owner, @user) end - [:read, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action| + [:read, :create, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action| it "should be able to #{action} repository" do @ability.should be_able_to(action, @repository) end end - - it do - @repository.platform.update_attribute(:owner, @user) - @ability.should be_able_to(:create, @repository) - end end context 'with read rights' do before(:each) do - @repository.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader') + @repository.platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader') end it "should be able to read repository" do diff --git a/spec/models/comment_for_commit_spec.rb b/spec/models/comment_for_commit_spec.rb index 6f693d03e..446131e5e 100644 --- a/spec/models/comment_for_commit_spec.rb +++ b/spec/models/comment_for_commit_spec.rb @@ -21,6 +21,7 @@ def set_comments_data_for_commit end describe Comment do + before { stub_rsync_methods } context 'for global admin user' do before(:each) do @user = Factory(:admin) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index b44f85684..d692beb19 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -15,6 +15,7 @@ def set_commentable_data end describe Comment do + before { stub_rsync_methods } context 'for global admin user' do before(:each) do @user = Factory(:admin) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 9056e45c7..c742a5671 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -10,14 +10,9 @@ describe Repository do @params = {:name => 'tst_platform', :description => 'test platform'} end - it 'it should increase Relations.count by 1' do - rep = Repository.new(@params) - rep.platform = @platform - rep.owner = @platform.owner - rep.save! - Relation.by_object(rep.owner).by_target(rep).count.should eql(1) -# (@platform.owner.repositories.where(:platform_id => @platform.id).count == 1).should be_true + it 'it should increase Repository.count by 1' do + rep = Repository.create(@params) {|r| r.platform = @platform} + @platform.repositories.count.should eql(1) end end - #pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/subscribe_spec.rb b/spec/models/subscribe_spec.rb index eff91b9a8..40ccddd3c 100644 --- a/spec/models/subscribe_spec.rb +++ b/spec/models/subscribe_spec.rb @@ -12,6 +12,7 @@ def set_testable_data end describe Subscribe do + before { stub_rsync_methods } context 'for global admin user' do before(:each) do @user = Factory(:admin) From 600df031f5c53428528bffdb97d3304a7199ddc1 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 21 Feb 2012 23:27:11 +0200 Subject: [PATCH 33/77] Refactor platform clone controller and routes. Refactor and fix clone process for platform, repository, product. Place XML RPC clone request to DJ. Refs #207 --- app/controllers/platforms_controller.rb | 26 +++++++++++++------------ app/models/platform.rb | 12 +++++------- app/models/product.rb | 6 +++--- app/models/repository.rb | 6 +++--- app/views/platforms/clone.html.haml | 2 +- config/routes.rb | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 060fe99e0..06eb87c45 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -109,19 +109,21 @@ class PlatformsController < ApplicationController end def clone - if request.post? - @cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], - :owner_id => current_user.id, :owner_type => current_user.class.to_s) - if @cloned.persisted? - flash[:notice] = I18n.t("flash.platform.clone_success") - redirect_to @cloned - else - flash[:error] = @cloned.errors.full_messages.join('. ') - end + @cloned = Platform.new + @cloned.name = @platform.name + "_clone" + @cloned.description = @platform.description + "_clone" + end + + def make_clone + @cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], + :owner_id => current_user.id, :owner_type => current_user.class.to_s) + if @cloned.persisted? # valid? + flash[:notice] = I18n.t("flash.platform.clone_success") + redirect_to @cloned else - @cloned = Platform.new - @cloned.name = @platform.name + "_clone" - @cloned.description = @platform.description + "_clone" + raise @cloned.repositories.first.inspect + flash[:error] = @cloned.errors.full_messages.join('. ') + render 'clone' end end diff --git a/app/models/platform.rb b/app/models/platform.rb index e7b552ba2..773aa3111 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -98,23 +98,21 @@ class Platform < ActiveRecord::Base platform_type == 'personal' end - def full_clone(attrs) # :description, :name, :owner + def full_clone(attrs = {}) # :description, :name, :owner clone.tap do |c| - c.attributes = attrs + c.attributes = attrs # do not set protected c.updated_at = nil; c.created_at = nil # :id = nil c.parent = self - new_attrs = {:platform_id => nil} - c.repositories = repositories.map{|r| r.full_clone(new_attrs.merge(:owner_id => attrs[:owner_id], :owner_type => attrs[:owner_type]))} - c.products = products.map{|p| p.full_clone(new_attrs)} + c.repositories = repositories.map(&:full_clone) + c.products = products.map(&:full_clone) end end - # TODO * make it Delayed Job * def make_clone(attrs) p = full_clone(attrs) begin Thread.current[:skip] = true - p.save and xml_rpc_clone(attrs[:name]) + p.save and self.delay.xml_rpc_clone(attrs[:name]) ensure Thread.current[:skip] = false end diff --git a/app/models/product.rb b/app/models/product.rb index 94e355d20..14cd10549 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -59,10 +59,10 @@ class Product < ActiveRecord::Base EOF end - def full_clone(attrs) # owner + def full_clone(attrs = {}) clone.tap do |c| # dup - c.attributes = attrs - c.updated_at = nil; c.created_at = nil # :id = nil + c.attributes = attrs # do not set protected + c.platform_id = nil; c.updated_at = nil; c.created_at = nil # :id = nil end end diff --git a/app/models/repository.rb b/app/models/repository.rb index f5c7d4c13..79e49a345 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -15,10 +15,10 @@ class Repository < ActiveRecord::Base attr_accessible :description, :name - def full_clone(attrs) # owner + def full_clone(attrs = {}) clone.tap do |c| # dup - c.attributes = attrs - c.updated_at = nil; c.created_at = nil # :id = nil + c.attributes = attrs # do not set protected + c.platform_id = nil; c.updated_at = nil; c.created_at = nil # :id = nil c.projects = projects end end diff --git a/app/views/platforms/clone.html.haml b/app/views/platforms/clone.html.haml index 045e2956a..01eb9b7be 100644 --- a/app/views/platforms/clone.html.haml +++ b/app/views/platforms/clone.html.haml @@ -8,7 +8,7 @@ %h2.title = t("layout.platforms.clone_header") .inner - = form_for @cloned, :url => clone_platform_path(@platform), :html => { :class => :form } do |f| + = form_for @cloned, :url => make_clone_platform_path(@platform), :html => { :class => :form } do |f| .group = f.label :name, :class => :label = f.text_field :name, :class => 'text_field' diff --git a/config/routes.rb b/config/routes.rb index e8c872689..b3ef45c46 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -71,7 +71,7 @@ Rosa::Application.routes.draw do post 'freeze' post 'unfreeze' get 'clone' - post 'clone' + post 'make_clone' post 'build_all' end From 7c273c022b82133e49c535fbd490a3f2aecdd088 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 21 Feb 2012 23:43:06 +0200 Subject: [PATCH 34/77] Remove raise. Refs #207 --- app/controllers/platforms_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 06eb87c45..5e6a467f3 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -121,7 +121,6 @@ class PlatformsController < ApplicationController flash[:notice] = I18n.t("flash.platform.clone_success") redirect_to @cloned else - raise @cloned.repositories.first.inspect flash[:error] = @cloned.errors.full_messages.join('. ') render 'clone' end From 069c226110a102f0185b9d4a8e3299ed2b0e0ae2 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 22 Feb 2012 14:35:40 +0200 Subject: [PATCH 35/77] Place platform destroy to background. Redo clone process to 2 phases - base_clone and relations_clone. Place relations clone and XML RPC to background. Remove unneeded validations. Refactor xml_rpc_clone. Refs #207 --- app/controllers/platforms_controller.rb | 7 +++-- app/models/platform.rb | 38 +++++++++++++++---------- app/models/project.rb | 2 +- app/models/repository.rb | 8 +++--- lib/ext/core/object.rb | 10 +++++++ 5 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 lib/ext/core/object.rb diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 5e6a467f3..c357b526a 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -115,9 +115,10 @@ class PlatformsController < ApplicationController end def make_clone - @cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], + @cloned = @platform.base_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], :owner_id => current_user.id, :owner_type => current_user.class.to_s) - if @cloned.persisted? # valid? + if with_skip{@cloned.save} + @cloned.delay.clone_complete flash[:notice] = I18n.t("flash.platform.clone_success") redirect_to @cloned else @@ -127,7 +128,7 @@ class PlatformsController < ApplicationController end def destroy - @platform.destroy if @platform + @platform.delay.destroy if @platform flash[:notice] = t("flash.platform.destroyed") redirect_to root_path diff --git a/app/models/platform.rb b/app/models/platform.rb index 773aa3111..305addb84 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -14,7 +14,7 @@ class Platform < ActiveRecord::Base has_many :members, :through => :objects, :source => :object, :source_type => 'User' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' - validates :description, :presence => true, :uniqueness => true + validates :description, :presence => true validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} @@ -98,25 +98,33 @@ class Platform < ActiveRecord::Base platform_type == 'personal' end - def full_clone(attrs = {}) # :description, :name, :owner + def base_clone(attrs = {}) # :description, :name, :owner clone.tap do |c| c.attributes = attrs # do not set protected c.updated_at = nil; c.created_at = nil # :id = nil c.parent = self - c.repositories = repositories.map(&:full_clone) - c.products = products.map(&:full_clone) end end - def make_clone(attrs) - p = full_clone(attrs) - begin - Thread.current[:skip] = true - p.save and self.delay.xml_rpc_clone(attrs[:name]) - ensure - Thread.current[:skip] = false + # def full_clone(attrs = {}) # :description, :name, :owner + # clone.tap do |c| + # c.attributes = attrs # do not set protected + # c.updated_at = nil; c.created_at = nil # :id = nil + # c.parent = self + # c.repositories = repositories.map(&:full_clone) + # c.products = products.map(&:full_clone) + # end + # end + + def clone_relations(from = parent) + self.repositories = from.repositories.map(&:full_clone) + self.products = from.products.map(&:full_clone) + end + + def clone_complete + with_skip do + clone_relations and xml_rpc_clone end - p end def name @@ -179,12 +187,12 @@ class Platform < ActiveRecord::Base end end - def xml_rpc_clone(new_name) - result = BuildServer.clone_platform new_name, self.name, APP_CONFIG['root_path'] + '/platforms' + def xml_rpc_clone(old_name = parent.name, new_name = name) + result = BuildServer.clone_platform new_name, old_name, APP_CONFIG['root_path'] + '/platforms' if result == BuildServer::SUCCESS return true else - raise "Failed to clone platform #{name} with code #{result}. Path: #{build_path(name)} to platform #{new_name}" + raise "Failed to clone platform #{old_name} with code #{result}. Path: #{build_path(old_name)} to platform #{new_name}" end end diff --git a/app/models/project.rb b/app/models/project.rb index b26f2ee06..d7e20f02d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -18,7 +18,7 @@ class Project < ActiveRecord::Base has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User' has_many :groups, :through => :relations, :source => :object, :source_type => 'Group' - validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ } + 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?} diff --git a/app/models/repository.rb b/app/models/repository.rb index 79e49a345..45b1e116d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,11 +2,11 @@ class Repository < ActiveRecord::Base belongs_to :platform - has_many :projects, :through => :project_to_repositories #, :dependent => :destroy - has_many :project_to_repositories, :validate => true, :dependent => :destroy + has_many :project_to_repositories, :dependent => :destroy, :validate => true + has_many :projects, :through => :project_to_repositories - validates :description, :uniqueness => {:scope => :platform_id}, :presence => true - validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ } + validates :description, :presence => true + validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /^[a-z0-9_\-]+$/} scope :recent, order("name ASC") diff --git a/lib/ext/core/object.rb b/lib/ext/core/object.rb new file mode 100644 index 000000000..d2856a51c --- /dev/null +++ b/lib/ext/core/object.rb @@ -0,0 +1,10 @@ +class Object + def with_skip + begin + Thread.current[:skip] = true + yield + ensure + Thread.current[:skip] = false + end + end +end From 9015b971aa765a3bf32d3f0c1f6b8256f28da80d Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 22 Feb 2012 22:24:29 +0200 Subject: [PATCH 36/77] Redo clone logic. Split clone process for repositories. Optimize and refactor. Refs #207 --- app/controllers/platforms_controller.rb | 6 ++---- app/models/platform.rb | 20 +++++--------------- app/models/product.rb | 5 +++-- app/models/repository.rb | 20 ++++++++++++++++---- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index c357b526a..3b0151bd6 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -115,10 +115,8 @@ class PlatformsController < ApplicationController end def make_clone - @cloned = @platform.base_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], - :owner_id => current_user.id, :owner_type => current_user.class.to_s) - if with_skip{@cloned.save} - @cloned.delay.clone_complete + @cloned = @platform.full_clone params[:platform].merge(:owner => current_user) + if @cloned.persisted? flash[:notice] = I18n.t("flash.platform.clone_success") redirect_to @cloned else diff --git a/app/models/platform.rb b/app/models/platform.rb index 305addb84..3b7551703 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -100,30 +100,20 @@ class Platform < ActiveRecord::Base def base_clone(attrs = {}) # :description, :name, :owner clone.tap do |c| - c.attributes = attrs # do not set protected + c.attributes = attrs # attrs.each {|k,v| c.send("#{k}=", v)} c.updated_at = nil; c.created_at = nil # :id = nil c.parent = self end end - # def full_clone(attrs = {}) # :description, :name, :owner - # clone.tap do |c| - # c.attributes = attrs # do not set protected - # c.updated_at = nil; c.created_at = nil # :id = nil - # c.parent = self - # c.repositories = repositories.map(&:full_clone) - # c.products = products.map(&:full_clone) - # end - # end - def clone_relations(from = parent) - self.repositories = from.repositories.map(&:full_clone) + self.repositories = from.repositories.map{|r| r.full_clone(:platform_id => id)} self.products = from.products.map(&:full_clone) end - def clone_complete - with_skip do - clone_relations and xml_rpc_clone + def full_clone(attrs = {}) + base_clone(attrs).tap do |c| + with_skip {c.save} and c.clone_relations(self) and c.delay.xml_rpc_clone end end diff --git a/app/models/product.rb b/app/models/product.rb index 14cd10549..536b3dbbf 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -61,8 +61,9 @@ class Product < ActiveRecord::Base def full_clone(attrs = {}) clone.tap do |c| # dup - c.attributes = attrs # do not set protected - c.platform_id = nil; c.updated_at = nil; c.created_at = nil # :id = nil + c.platform_id = nil + attrs.each {|k,v| c.send("#{k}=", v)} + c.updated_at = nil; c.created_at = nil # :id = nil end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 45b1e116d..50b57cb4a 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -15,11 +15,23 @@ class Repository < ActiveRecord::Base attr_accessible :description, :name - def full_clone(attrs = {}) + def base_clone(attrs = {}) clone.tap do |c| # dup - c.attributes = attrs # do not set protected - c.platform_id = nil; c.updated_at = nil; c.created_at = nil # :id = nil - c.projects = projects + c.platform_id = nil + attrs.each {|k,v| c.send("#{k}=", v)} + c.updated_at = nil; c.created_at = nil # :id = nil + end + end + + def clone_relations(from) + with_skip do + from.projects.find_each {|p| self.projects << p} + end + end + + def full_clone(attrs = {}) + base_clone(attrs).tap do |c| + with_skip {c.save} and c.delay.clone_relations(self) end end From 07093c0d1d8ee02a9c3d582f85e357d110306aeb Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 00:57:43 +0200 Subject: [PATCH 37/77] Create directory for platform before clone. Fix created directory permissions. Increase timeout during XML RPC clone. Switch off cascade XML RPC requests during platform destroy. Refs #207 --- app/models/platform.rb | 11 ++++++++++- app/models/project_to_repository.rb | 2 +- app/models/repository.rb | 2 +- lib/build_server.rb | 4 +++- lib/modules/models/rsync_stub.rb | 4 ++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index 3b7551703..713283b5c 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -18,6 +18,7 @@ class Platform < ActiveRecord::Base validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} + before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy # before_update :check_freezing @@ -131,9 +132,13 @@ class Platform < ActiveRecord::Base end end + def create_directory + system("sudo mkdir -p -m 0777 #{path}") + end + def mount_directory_for_rsync # umount_directory_for_rsync # TODO ignore errors - system("sudo mkdir -p #{mount_path}") + system("sudo mkdir -p -m 0777 #{mount_path}") system("sudo mount --bind #{path} #{mount_path}") Arch.all.each do |arch| str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n" @@ -153,6 +158,10 @@ class Platform < ActiveRecord::Base end end + def destroy + with_skip {super} # avoid cascade XML RPC requests + end + protected def build_path(dir) diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index 7bf5adba5..611bb0bbe 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -6,7 +6,7 @@ class ProjectToRepository < ActiveRecord::Base delegate :path, :to => :project after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]} - after_destroy lambda { project.xml_rpc_destroy(repository) } + after_destroy lambda { project.xml_rpc_destroy(repository) }, :unless => lambda {Thread.current[:skip]} # after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? } validate :one_project_in_platform_repositories diff --git a/app/models/repository.rb b/app/models/repository.rb index 50b57cb4a..7684ee005 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -11,7 +11,7 @@ class Repository < ActiveRecord::Base scope :recent, order("name ASC") before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} - before_destroy :xml_rpc_destroy + before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]} attr_accessible :description, :name diff --git a/lib/build_server.rb b/lib/build_server.rb index feb066b19..2bf6cfc9a 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -49,10 +49,12 @@ class BuildServer end def self.clone_repo new_name, old_name, new_platform_name + tmp = self.client.timeout # TODO remove this when core will be ready + self.client.timeout = 30.minutes self.client.call('clone_repo', new_name, old_name, new_platform_name) + self.client.timeout = tmp end - def self.publish_container container_id self.client.call('publish_container', container_id) end diff --git a/lib/modules/models/rsync_stub.rb b/lib/modules/models/rsync_stub.rb index bbf101d76..7865c232f 100644 --- a/lib/modules/models/rsync_stub.rb +++ b/lib/modules/models/rsync_stub.rb @@ -5,6 +5,10 @@ module Modules extend ActiveSupport::Concern included do + def create_directory + true + end + def mount_directory_for_rsync true end From c3d5ea790f0377e68897ffb3a09452db8fe0188e Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 17:17:02 +0200 Subject: [PATCH 38/77] Rescue and ignore timeout error during long XML RPC. Apply add_branch script. Refs #207 --- lib/build_server.rb | 16 +++++++++------- lib/tasks/add_branch.rake | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 lib/tasks/add_branch.rake diff --git a/lib/build_server.rb b/lib/build_server.rb index 2bf6cfc9a..9aa2be76e 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -28,33 +28,35 @@ class BuildServer self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type) end - def self.delete_platform name self.client.call('delete_platform', name) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end - def self.clone_platform new_name, old_name, new_root_folder self.client.call('clone_platform', new_name, old_name, new_root_folder) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end - def self.create_repo name, platform_name self.client.call('create_repository', name, platform_name) end - def self.delete_repo name, platform_name self.client.call('delete_repository', name, platform_name) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end def self.clone_repo new_name, old_name, new_platform_name - tmp = self.client.timeout # TODO remove this when core will be ready - self.client.timeout = 30.minutes self.client.call('clone_repo', new_name, old_name, new_platform_name) - self.client.timeout = tmp + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end + def self.publish_container container_id self.client.call('publish_container', container_id) end diff --git a/lib/tasks/add_branch.rake b/lib/tasks/add_branch.rake new file mode 100644 index 000000000..1a7b96bd5 --- /dev/null +++ b/lib/tasks/add_branch.rake @@ -0,0 +1,22 @@ +require 'highline/import' + +desc "Add branch for platform projects" +task :add_branch => :environment do + src_branch = ENV['SRC_BRANCH'] || 'import_mandriva2011' + dst_branch = ENV['DST_BRANCH'] || 'rosa2012lts' + + say "START add branch #{dst_branch} from #{src_branch}" + Platform.find_by_name(dst_branch).repositories.each do |r| + say "=== Process #{r.name} repo" + r.projects.find_each do |p| + say "===== Process #{p.name} project" + tmp_path = Rails.root.join('tmp', p.name) + system("git clone #{p.path} #{tmp_path}") + system("cd #{tmp_path} && git checkout remotes/origin/#{src_branch}") or system("cd #{tmp_path} && git checkout master") + system("cd #{tmp_path} && git checkout -b #{dst_branch}") + system("cd #{tmp_path} && git push origin HEAD") + FileUtils.rm_rf tmp_path + end + end + say 'DONE' +end From 15f78e30a0d09cfb6d0dbb1fde86bdcc18dfc544 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 20:32:56 +0200 Subject: [PATCH 39/77] Redo platform build_all with sleep and errors rescue. Refs #207 --- app/controllers/platforms_controller.rb | 6 +----- app/models/platform.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 3b0151bd6..01cbc0eec 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -8,11 +8,7 @@ class PlatformsController < ApplicationController autocomplete :user, :uname def build_all - @platform.repositories.each do |repository| - repository.projects.each do |project| - project.delay.build_for(@platform, current_user) - end - end + @platform.delay.build_all(current_user) redirect_to(platform_path(@platform), :notice => t("flash.platform.build_all_success")) end diff --git a/app/models/platform.rb b/app/models/platform.rb index 713283b5c..76756ee3e 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -158,6 +158,21 @@ class Platform < ActiveRecord::Base end end + def build_all(user) + repositories.each do |r| + r.projects.find_in_batches(:batch_size => 5) do |group| + sleep 1 + group.each do |p| + begin + p.build_for(self, user) + rescue RuntimeError, Exception + p.delay.build_for(self, user) + end + end + end + end + end + def destroy with_skip {super} # avoid cascade XML RPC requests end From 165a8dd6f4694131e41a687369ea6c00653ff903 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 21:06:28 +0200 Subject: [PATCH 40/77] Build only main repo. Refs #207 --- app/models/platform.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index 76756ee3e..6a109fa2d 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -159,15 +159,13 @@ class Platform < ActiveRecord::Base end def build_all(user) - repositories.each do |r| - r.projects.find_in_batches(:batch_size => 5) do |group| - sleep 1 - group.each do |p| - begin - p.build_for(self, user) - rescue RuntimeError, Exception - p.delay.build_for(self, user) - end + repositories.find_by_name('main').projects.find_in_batches(:batch_size => 5) do |group| + sleep 1 + group.each do |p| + begin + p.build_for(self, user) + rescue RuntimeError, Exception + p.delay.build_for(self, user) end end end From 51e2c85b0a475625d37bde529c2534c505acc9a1 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 22:20:44 +0200 Subject: [PATCH 41/77] Fix build_for settings. Refs #207 --- app/models/project.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index d7e20f02d..08e487864 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,14 +61,13 @@ class Project < ActiveRecord::Base end end - def build_for(platform, user) + def build_for(platform, user) build_lists.create do |bl| bl.pl = platform bl.bpl = platform - bl.update_type = 'recommended' + bl.update_type = 'newpackage' bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild - # FIXME: Need to set "latest_#{platform.name}" - bl.project_version = "latest_import_mandriva2011" + bl.project_version = "latest_#{platform.name}" # "latest_import_mandriva2011" bl.build_requires = false # already set as db default bl.user = user bl.auto_publish = true # already set as db default From 63c89edfda7379f3330b5419c09cc45830e47a0e Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Fri, 24 Feb 2012 17:49:47 +0400 Subject: [PATCH 42/77] Isolated localization for activity feed --- config/locales/activity_feed.en.yml | 31 ++++++++++++++++++++++++++ config/locales/activity_feed.ru.yml | 34 +++++++++++++++++++++++++++++ config/locales/en.yml | 4 ---- config/locales/notifications.en.yml | 34 ----------------------------- config/locales/notifications.ru.yml | 29 ------------------------ config/locales/ru.yml | 3 --- 6 files changed, 65 insertions(+), 70 deletions(-) create mode 100644 config/locales/activity_feed.en.yml create mode 100644 config/locales/activity_feed.ru.yml delete mode 100644 config/locales/notifications.en.yml delete mode 100644 config/locales/notifications.ru.yml diff --git a/config/locales/activity_feed.en.yml b/config/locales/activity_feed.en.yml new file mode 100644 index 000000000..cc3307d17 --- /dev/null +++ b/config/locales/activity_feed.en.yml @@ -0,0 +1,31 @@ +en: + + layout: + activity_feed: + header: Activity Feed + + notifications: + subjects: + new_comment_notification: New comment to your task + new_issue_notification: New task added to project + new_user_notification: Registered on project «%{ project_name }» + issue_assign_notification: New task assigned + + bodies: + new_comment_notification: + title: Hello, %{user_name}. + content: To the issue %{issue_link} added a comment. + new_comment_reply_notification: + title: Hello, %{user_name}. + content: Your comment into issue %{issue_link} has been answered. + new_issue_notification: + title: Hello, %{user_name}. + content: To project %{project_link} has been added an issue %{issue_link} + new_user_notification: + title: Hello, %{user_name}. + content: You have been sign up to project «ROSA Build System» and now can sign in. + email: ==Your email %{user_email} + password: ==Your password %{user_password} + issue_assign_notification: + title: Hello, %{user_name}. + content: You have been assigned to issue %{issue_link} diff --git a/config/locales/activity_feed.ru.yml b/config/locales/activity_feed.ru.yml new file mode 100644 index 000000000..2ac9486cc --- /dev/null +++ b/config/locales/activity_feed.ru.yml @@ -0,0 +1,34 @@ +ru: + + layout: + activity_feed: + header: Лента активности + + notifications: + subjects: + new_comment_notification: Новый комментарий к Вашей задаче + new_comment_reply_notification: Новый комментарий к Вашей задаче + new_issue_notification: Новая задача добавлена к проекту + new_user_notification: Регистрация на проекте «%{ project_name }» + issue_assign_notification: Вам назначили задачу + + bodies: + new_comment_notification: + title: Здравствуйте, %{user_name}. + content: К задаче %{issue_link} был добавлен новый комментарий. + new_comment_reply_notification: + title: Здравствуйте, %{user_name}. + content: На Ваш комментарий в задаче %{issue_link} был дан ответ. + new_issue_notification: + title: Здравствуйте, %{user_name}. + content: К проекту %{project_link} была добавлена задача %{issue_link} + new_user_notification: + title: Здравствуйте, %{user_name}. + content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. + email: ==Ваш email %{user_email} + password: ==Ваш пароль %{user_password} + issue_assign_notification: + title: Здравствуйте, %{user_name}. + content: Вам была назначена задача %{issue_link} + new_commit_comment_notification: Новый комментарий к коммиту + invite_approve_notification: Приглашение в ABF \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 368e2c04d..fda62af7e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -381,9 +381,6 @@ en: unlock: Do not receive unlock instructions? sign_in_through: Sign in by %{provider} - activity_feed: - header: Activity Feed - downloads: title: Downloads statistic message: Automatically updated every 5 minutes @@ -1134,4 +1131,3 @@ en: distro: Source platform: Platform counter: Downloads - diff --git a/config/locales/notifications.en.yml b/config/locales/notifications.en.yml deleted file mode 100644 index 93d15993b..000000000 --- a/config/locales/notifications.en.yml +++ /dev/null @@ -1,34 +0,0 @@ -notifications: - subjects: - new_comment_notification: New comment to your task - new_issue_notification: New task added to project - new_user_notification: Registered on project «%{ project_name }» - issue_assign_notification: New task assigned - - bodies: - new_comment_notification: - title: Hello, %{user_name}. - content: To the issue %{issue_link} added a comment. - new_comment_reply_notification: - title: Hello, %{user_name}. - content: Your comment into issue %{issue_link} has been answered. - new_issue_notification: - title: Hello, %{user_name}. - content: To project %{project_link} has been added an issue %{issue_link} - new_user_notification: - title: Hello, %{user_name}. - content: You have been sign up to project «ROSA Build System» and now can sign in. - email: ==Your email %{user_email} - password: ==Your password %{user_password} - issue_assign_notification: - title: Hello, %{user_name}. - content: You have been assigned to issue %{issue_link} - - download: - name: Name - version: Version - distro: Source - platform: Platform - counter: Downloads - - diff --git a/config/locales/notifications.ru.yml b/config/locales/notifications.ru.yml deleted file mode 100644 index f4ddbe462..000000000 --- a/config/locales/notifications.ru.yml +++ /dev/null @@ -1,29 +0,0 @@ -notifications: - subjects: - new_comment_notification: Новый комментарий к Вашей задаче - new_comment_reply_notification: Новый комментарий к Вашей задаче - new_issue_notification: Новая задача добавлена к проекту - new_user_notification: Регистрация на проекте «%{ project_name }» - issue_assign_notification: Вам назначили задачу - - bodies: - new_comment_notification: - title: Здравствуйте, %{user_name}. - content: К задаче %{issue_link} был добавлен новый комментарий. - new_comment_reply_notification: - title: Здравствуйте, %{user_name}. - content: На Ваш комментарий в задаче %{issue_link} был дан ответ. - new_issue_notification: - title: Здравствуйте, %{user_name}. - content: К проекту %{project_link} была добавлена задача %{issue_link} - new_user_notification: - title: Здравствуйте, %{user_name}. - content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. - email: ==Ваш email %{user_email} - password: ==Ваш пароль %{user_password} - issue_assign_notification: - title: Здравствуйте, %{user_name}. - content: Вам была назначена задача %{issue_link} - new_commit_comment_notification: Новый комментарий к коммиту - invite_approve_notification: Приглашение в ABF - diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 1567e590a..6a73ff386 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -58,9 +58,6 @@ ru: unlock: Не получили инструкции по разблокировке? sign_in_through: Войти через %{provider} - activity_feed: - header: Лента активности - downloads: title: Статистика закачек пакетов message: Обновляется автоматически каждые 24 часа From 3685eafe575e2f0d5752c422cb4323b2925e1a75 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Fri, 24 Feb 2012 17:50:35 +0400 Subject: [PATCH 43/77] Remove unused code [Refs #207] --- app/models/comment.rb | 15 --------------- config/routes.rb | 1 - 2 files changed, 16 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index bd84e8f68..e6a72f83e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -8,7 +8,6 @@ class Comment < ActiveRecord::Base # FIXME after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'" - #after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'" after_create :invoke_helper, :if => "commentable_type == 'Grit::Commit'" after_create :subscribe_users after_create {|comment| Subscribe.new_comment_notification(comment)} @@ -35,20 +34,6 @@ class Comment < ActiveRecord::Base protected - #def deliver_new_comment_notification - # subscribes = self.commentable.subscribes - # subscribes.each do |subscribe| - # # TODO: new_comment and new_comment_reply - you need to check each variant, not only new_comment_reply... - # if self.user_id != subscribe.user_id && User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify - # if self.reply? subscribe - # UserMailer.delay.new_comment_reply_notification(self, subscribe.user) - # else - # UserMailer.delay.new_comment_notification(self, subscribe.user) - # end - # end - # end - #end - def subscribe_on_reply self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id) end diff --git a/config/routes.rb b/config/routes.rb index b3ef45c46..1daa1fe29 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -211,7 +211,6 @@ Rosa::Application.routes.draw do match '/projects/:project_id/git/raw/:treeish/*path', :controller => "git/blobs", :action => :raw, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :raw match '/projects/:project_id/git/commit/raw/:commit_hash/*path', :controller => "git/blobs", :action => :raw, :as => :raw_commit - #root :to => "platforms#index" root :to => "activity_feeds#index" match '/forbidden', :to => 'platforms#forbidden', :as => 'forbidden' end From 3c8f1c062bdcb71a74ec02e4fd4e938fe2912659 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Fri, 24 Feb 2012 20:33:00 +0400 Subject: [PATCH 44/77] Fix ActivityFeed for user, remove info about password [Refs #207] --- app/models/activity_feed_observer.rb | 4 +++- .../activity_feeds/partials/_new_user_notification.haml | 7 +------ app/views/user_mailer/new_user_notification.en.haml | 2 -- app/views/user_mailer/new_user_notification.ru.haml | 2 -- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 5c4b2a875..b4e5fb348 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -7,7 +7,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => record, :kind => 'new_user_notification', - :date => {:user_name => record.name, :user_email => record.email, :password => user.password} + :data => {:user_name => record.name, :user_email => record.email} ) when 'Issue' @@ -52,6 +52,7 @@ class ActivityFeedObserver < ActiveRecord::Observer end end end + when 'GitHook' change_type = record.change_type branch_name = record.refname.match(/\/([\w\d]+)$/)[1] @@ -79,6 +80,7 @@ class ActivityFeedObserver < ActiveRecord::Observer :data => options ) end + when 'Gollum::Committer' actor = User.find_by_uname(record.actor.name) project_name = record.wiki.path.match(/\/(\w+)\.wiki\.git$/)[1] diff --git a/app/views/activity_feeds/partials/_new_user_notification.haml b/app/views/activity_feeds/partials/_new_user_notification.haml index b1ae04bd6..98d4796e9 100644 --- a/app/views/activity_feeds/partials/_new_user_notification.haml +++ b/app/views/activity_feeds/partials/_new_user_notification.haml @@ -1,10 +1,5 @@ %p== #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } - %p #{ t("notifications.bodies.new_user_notification.content") } - -%p - #{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) } - %br/ - #{ t("notifications.bodies.new_user_notification.password", :user_password => user_email) } +%p #{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) } \ No newline at end of file diff --git a/app/views/user_mailer/new_user_notification.en.haml b/app/views/user_mailer/new_user_notification.en.haml index d1a0722bf..c0f05d467 100644 --- a/app/views/user_mailer/new_user_notification.en.haml +++ b/app/views/user_mailer/new_user_notification.en.haml @@ -6,7 +6,5 @@ %p ==Your email : #{@user.email} - %br/ - ==Your password: #{@user.password} %p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_user_notification.ru.haml b/app/views/user_mailer/new_user_notification.ru.haml index f3c6d1ec7..acae98cba 100644 --- a/app/views/user_mailer/new_user_notification.ru.haml +++ b/app/views/user_mailer/new_user_notification.ru.haml @@ -6,7 +6,5 @@ %p ==Ваш email : #{@user.email} - %br/ - ==Ваш пароль: #{@user.password} %p== Команда поддержки «ROSA Build System» From dde81b55544c40a31af6f6be448b748abae8f118 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sat, 25 Feb 2012 00:25:35 +0600 Subject: [PATCH 45/77] [refs #123] fix activity feed for commit comments; remove reply notification --- app/models/activity_feed_observer.rb | 30 +++++++++++-------- app/models/comment.rb | 5 ---- app/models/subscribe.rb | 23 -------------- .../_new_comment_reply_notification.haml | 5 ---- .../_new_commit_comment_notification.haml | 5 ++++ .../new_comment_reply_notification.en.haml | 9 ------ config/locales/activity_feed.en.yml | 7 ++--- config/locales/activity_feed.ru.yml | 9 ++---- config/locales/en.yml | 1 - 9 files changed, 29 insertions(+), 65 deletions(-) delete mode 100644 app/views/activity_feeds/partials/_new_comment_reply_notification.haml create mode 100644 app/views/activity_feeds/partials/_new_commit_comment_notification.haml delete mode 100644 app/views/user_mailer/new_comment_reply_notification.en.haml diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index b4e5fb348..6092ddea3 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -32,25 +32,31 @@ class ActivityFeedObserver < ActiveRecord::Observer end when 'Comment' - subscribes = record.commentable.subscribes - subscribes.each do |subscribe| - if record.user_id != subscribe.user_id - if record.reply? subscribe - UserMailer.delay.new_comment_reply_notification(record, subscribe.user) if record.can_notify_on_reply?(subscribe) - ActivityFeed.create( - :user => subscribe.user, - :kind => 'new_comment_reply_notification', - :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} - ) - else + if record.commentable.class == Issue + subscribes = record.commentable.subscribes.finder_hack + subscribes.each do |subscribe| + if record.user_id != subscribe.user_id UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_notification', - :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, + :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} ) end end + elsif record.commentable.class == Grit::Commit + subscribes = Subscribe.comment_subscribes(record).where(:status => true) + subscribes.each do |subscribe| + next if record.own_comment?(subscribe.user) + UserMailer.delay.new_comment_notification(record, subscribe.user) if subscribe.user.notifier.can_notify + ActivityFeed.create( + :user => subscribe.user, + :kind => 'new_comment_commit_notification', + :data => {:user_name => subscribe.user.name, :comment_body => record.body, :commit_message => record.commentable.message.encode_to_default, + :commit_id => record.commentable.id, :project_id => record.project.id} + ) + end end when 'GitHook' diff --git a/app/models/comment.rb b/app/models/comment.rb index e6a72f83e..0cde4b217 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -10,7 +10,6 @@ class Comment < ActiveRecord::Base after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'" after_create :invoke_helper, :if => "commentable_type == 'Grit::Commit'" after_create :subscribe_users - after_create {|comment| Subscribe.new_comment_notification(comment)} def helper class_eval "def commentable; project.git_repository.commit('#{commentable_id}'); end" if commentable_type == 'Grit::Commit' @@ -20,10 +19,6 @@ class Comment < ActiveRecord::Base user_id == user.id end - def reply?(subscribe) - self.commentable.comments.exists?(:user_id => subscribe.user.id) - end - def can_notify_on_reply?(subscribe) User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify end diff --git a/app/models/subscribe.rb b/app/models/subscribe.rb index a8fd5cc31..9779af5a3 100644 --- a/app/models/subscribe.rb +++ b/app/models/subscribe.rb @@ -14,27 +14,6 @@ class Subscribe < ActiveRecord::Base Subscribe.where(:subscribeable_id => comment.commentable.id, :subscribeable_type => comment.commentable.class.name, :project_id => comment.project) end - def self.new_comment_notification(comment) - commentable_class = comment.commentable.class - Subscribe.new_comment_issue_notification(comment) if commentable_class == Issue - Subscribe.new_comment_commit_notification(comment) if commentable_class == Grit::Commit - end - - def self.new_comment_issue_notification(comment) - comment.commentable.subscribes.finder_hack.each do |subscribe| - next if comment.own_comment?(subscribe.user) || !subscribe.user.notifier.can_notify - UserMailer.delay.new_comment_notification(comment, subscribe.user) if subscribe.user.notifier.new_comment_reply - end - end - - def self.new_comment_commit_notification(comment) - subscribes = Subscribe.comment_subscribes(comment).where(:status => true) - subscribes.each do |subscribe| - next if comment.own_comment?(subscribe.user) || !subscribe.user.notifier.can_notify - UserMailer.delay.new_comment_notification(comment, subscribe.user) - end - end - def self.subscribed_to_commit?(project, user, commit) subscribe = user.subscribes.where(:subscribeable_id => commit.id, :subscribeable_type => commit.class.name, :project_id => project.id).first return subscribe.subscribed? if subscribe # return status if already subscribe present @@ -44,12 +23,10 @@ class Subscribe < ActiveRecord::Base (user.committer?(commit) && user.notifier.new_comment_commit_owner) end - def self.subscribe_to_commit(options) Subscribe.set_subscribe_to_commit(options, true) end - def self.unsubscribe_from_commit(options) Subscribe.set_subscribe_to_commit(options, false) end diff --git a/app/views/activity_feeds/partials/_new_comment_reply_notification.haml b/app/views/activity_feeds/partials/_new_comment_reply_notification.haml deleted file mode 100644 index a9f040c38..000000000 --- a/app/views/activity_feeds/partials/_new_comment_reply_notification.haml +++ /dev/null @@ -1,5 +0,0 @@ -%p== #{ t("notifications.bodies.new_comment_reply_notification.title", :user_name => user_name) } - -%p= raw t("notifications.bodies.new_comment_reply_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) - -%p "#{ comment_body }" diff --git a/app/views/activity_feeds/partials/_new_commit_comment_notification.haml b/app/views/activity_feeds/partials/_new_commit_comment_notification.haml new file mode 100644 index 000000000..32826e333 --- /dev/null +++ b/app/views/activity_feeds/partials/_new_commit_comment_notification.haml @@ -0,0 +1,5 @@ +%p== #{ t("notifications.bodies.new_commit_comment_notification.title", :user_name => user_name) } + +%p= raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))}) + +%p "#{ comment_body }" diff --git a/app/views/user_mailer/new_comment_reply_notification.en.haml b/app/views/user_mailer/new_comment_reply_notification.en.haml deleted file mode 100644 index b2838b2e0..000000000 --- a/app/views/user_mailer/new_comment_reply_notification.en.haml +++ /dev/null @@ -1,9 +0,0 @@ -%p== Hello, #{@user.name}. - -- #TODO hmm... this need to be refactored. -%p Your comment into issue #{ link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) } has been answered. - -%p "#{ @comment.body }" - - -%p== Support team «ROSA Build System» diff --git a/config/locales/activity_feed.en.yml b/config/locales/activity_feed.en.yml index cc3307d17..0794427a7 100644 --- a/config/locales/activity_feed.en.yml +++ b/config/locales/activity_feed.en.yml @@ -6,7 +6,8 @@ en: notifications: subjects: - new_comment_notification: New comment to your task + new_comment_notification: New comment to task + new_commit_comment_notification: New comment to commit new_issue_notification: New task added to project new_user_notification: Registered on project «%{ project_name }» issue_assign_notification: New task assigned @@ -15,9 +16,7 @@ en: new_comment_notification: title: Hello, %{user_name}. content: To the issue %{issue_link} added a comment. - new_comment_reply_notification: - title: Hello, %{user_name}. - content: Your comment into issue %{issue_link} has been answered. + commit_content: To the commit %{commit_link} added a comment. new_issue_notification: title: Hello, %{user_name}. content: To project %{project_link} has been added an issue %{issue_link} diff --git a/config/locales/activity_feed.ru.yml b/config/locales/activity_feed.ru.yml index 2ac9486cc..256a8d7bb 100644 --- a/config/locales/activity_feed.ru.yml +++ b/config/locales/activity_feed.ru.yml @@ -6,8 +6,8 @@ ru: notifications: subjects: - new_comment_notification: Новый комментарий к Вашей задаче - new_comment_reply_notification: Новый комментарий к Вашей задаче + new_comment_notification: Новый комментарий к задаче + new_commit_comment_notification: Новый комментарий к коммиту new_issue_notification: Новая задача добавлена к проекту new_user_notification: Регистрация на проекте «%{ project_name }» issue_assign_notification: Вам назначили задачу @@ -16,9 +16,7 @@ ru: new_comment_notification: title: Здравствуйте, %{user_name}. content: К задаче %{issue_link} был добавлен новый комментарий. - new_comment_reply_notification: - title: Здравствуйте, %{user_name}. - content: На Ваш комментарий в задаче %{issue_link} был дан ответ. + commit_content: К коммиту %{commit_link} был добавлен новый комментарий. new_issue_notification: title: Здравствуйте, %{user_name}. content: К проекту %{project_link} была добавлена задача %{issue_link} @@ -30,5 +28,4 @@ ru: issue_assign_notification: title: Здравствуйте, %{user_name}. content: Вам была назначена задача %{issue_link} - new_commit_comment_notification: Новый комментарий к коммиту invite_approve_notification: Приглашение в ABF \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index fda62af7e..d4c08478c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -949,7 +949,6 @@ en: new_issue_notification: New task added to project new_user_notification: Registered on project «%{ project_name }» issue_assign_notification: New task assigned - new_commit_comment_notification: New comment to commit invite_approve_notification: Invitation to ABF project: From 952082f7a00868d090340721cde0c563c4c2941c Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 13:15:12 +0400 Subject: [PATCH 46/77] [Fix #235] Remove wrong clone_platform_product_path url --- app/views/platforms/show.html.haml | 2 +- app/views/products/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index baf917e62..8f8755070 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -113,7 +113,7 @@ = link_to t("layout.edit"), edit_platform_product_path(@platform, product) if can? :update, product | = link_to t("layout.delete"), platform_product_path(@platform, product), :method => :delete, :confirm => t("layout.products.confirm_delete") if can? :destroy, product - = (product.can_clone? ? "| #{link_to t("layout.products.clone"), clone_platform_product_path(@platform, product)}" : "").html_safe + =# (product.can_clone? ? "| #{link_to t("layout.products.clone"), clone_platform_product_path(@platform, product)}" : "").html_safe .actions-bar.wat-cf .actions - content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/products/show.html.haml b/app/views/products/show.html.haml index f9c3f5bea..0dc7ae13c 100644 --- a/app/views/products/show.html.haml +++ b/app/views/products/show.html.haml @@ -31,7 +31,7 @@ - if can? :destroy, @product = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_product_path(@platform, @product), :method => "delete", :class => "button", :confirm => t("layout.products.confirm_delete") - if @product.can_clone? - = link_to t("layout.products.clone"), clone_platform_product_path(@platform, @product), :class => "button" + =# link_to t("layout.products.clone"), clone_platform_product_path(@platform, @product), :class => "button" - if can?(:create, @product => ProductBuildList) = link_to t("layout.products.build"), platform_product_product_build_lists_path(@platform, @product), :class => "button", :method => 'post', :confirm => t("layout.confirm") From 97c9eab3beca09085353090db307f19838c9f9ce Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 13:41:42 +0400 Subject: [PATCH 47/77] [Fix #236] Add application/octet-stream content type for tar.bz2 product attachment --- app/models/product.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 536b3dbbf..e52a700f0 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -10,7 +10,7 @@ class Product < ActiveRecord::Base has_attached_file :tar - validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip", "application/x-bzip2", "application/x-tar"], :message => I18n.t('layout.invalid_content_type') + validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip", "application/x-bzip2", "application/x-tar", "application/octet-stream"], :message => I18n.t('layout.invalid_content_type') validates :name, :presence => true, :uniqueness => {:scope => :platform_id} scope :recent, order("name ASC") From 062b5c71b119a90799383f932c1bc81d3ef8e46a Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 15:13:56 +0400 Subject: [PATCH 48/77] [Refs #221] Fix right for platform local admin --- app/views/product_build_lists/_product_build_list.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/product_build_lists/_product_build_list.html.haml b/app/views/product_build_lists/_product_build_list.html.haml index 38a70580e..91fb1c373 100644 --- a/app/views/product_build_lists/_product_build_list.html.haml +++ b/app/views/product_build_lists/_product_build_list.html.haml @@ -3,5 +3,5 @@ %td= link_to product_build_list.product.name, [product_build_list.product.platform, product_build_list.product] %td= link_to nil, product_build_list.container_path %td= product_build_list.human_status - %td= link_to t("layout.product_build_lists.delete"), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => "delete", :confirm => t("layout.confirm") if can? :delete, product_build_list + %td= link_to t("layout.product_build_lists.delete"), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => "delete", :confirm => t("layout.confirm") if can? :destroy, product_build_list %td= product_build_list.notified_at \ No newline at end of file From 02cbec8d86b07857fcf1ebbfbda29f9e5ec2c4bb Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 15:15:49 +0400 Subject: [PATCH 49/77] [Refs #221] Add xml-rpc call for iso container destroy --- app/models/product_build_list.rb | 14 ++++++++++++-- lib/product_builder.rb | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index f9078f19d..cae1b3bba 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -14,6 +14,7 @@ class ProductBuildList < ActiveRecord::Base attr_accessor :base_url after_create :xml_rpc_create + after_destroy :xml_delete_iso_container def container_path "/downloads/#{product.platform.name}/product/#{id}/" @@ -34,8 +35,17 @@ class ProductBuildList < ActiveRecord::Base if result == ProductBuilder::SUCCESS return true else - # return false - raise "Failed to create product_build_list #{id} inside platform #{product.platform.name} tar url #{tar_url} with code #{result}." + raise "Failed to create product_build_list #{id} inside platform #{platform.name} tar url #{tar_url} with code #{result}." + end + end + + def xml_delete_iso_container + result = ProductBuilder.delete_iso_container platform.name, id + if result == ProductBuilder::SUCCESS + return true + else + raise "Failed to destroy product_build_list #{id} inside platform #{platform.name} with code #{result}." end end + end diff --git a/lib/product_builder.rb b/lib/product_builder.rb index dfcac41df..65d2b5530 100644 --- a/lib/product_builder.rb +++ b/lib/product_builder.rb @@ -14,4 +14,8 @@ class ProductBuilder call('create_product', pbl.id.to_s, pbl.product.platform.name, pbl.product.ks, pbl.product.menu, pbl.product.build_script, pbl.product.counter, [], pbl.product.tar.exists? ? "#{pbl.base_url}#{pbl.product.tar.url}" : '') end + + def self.delete_iso_container(plname, id): + self.client(pbl.product.platform.distrib_type).call('delete_iso_container', plname, id) + end end From 6e15ee3e96a5f59be3adf57d6bd2ca4281813318 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 15:47:05 +0400 Subject: [PATCH 50/77] [Refs #221] Fix syntax error --- lib/product_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/product_builder.rb b/lib/product_builder.rb index 65d2b5530..c774de089 100644 --- a/lib/product_builder.rb +++ b/lib/product_builder.rb @@ -15,7 +15,7 @@ class ProductBuilder pbl.product.counter, [], pbl.product.tar.exists? ? "#{pbl.base_url}#{pbl.product.tar.url}" : '') end - def self.delete_iso_container(plname, id): + def self.delete_iso_container(plname, id) self.client(pbl.product.platform.distrib_type).call('delete_iso_container', plname, id) end end From b20c533e6b7ae4ae71238004a7d20a424d769f82 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 16:00:02 +0400 Subject: [PATCH 51/77] [Refs #221] Fix xml-rpc call --- app/models/product_build_list.rb | 2 +- lib/product_builder.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index cae1b3bba..24ee0afab 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -40,7 +40,7 @@ class ProductBuildList < ActiveRecord::Base end def xml_delete_iso_container - result = ProductBuilder.delete_iso_container platform.name, id + result = ProductBuilder.delete_iso_container self if result == ProductBuilder::SUCCESS return true else diff --git a/lib/product_builder.rb b/lib/product_builder.rb index c774de089..a845f2dda 100644 --- a/lib/product_builder.rb +++ b/lib/product_builder.rb @@ -15,7 +15,7 @@ class ProductBuilder pbl.product.counter, [], pbl.product.tar.exists? ? "#{pbl.base_url}#{pbl.product.tar.url}" : '') end - def self.delete_iso_container(plname, id) - self.client(pbl.product.platform.distrib_type).call('delete_iso_container', plname, id) + def self.delete_iso_container pbl # product_build_list + self.client(pbl.product.platform.distrib_type).call('delete_iso_container', pbl.product.platform.name, pbl.id.to_s) end end From 05eac4918ffd8f7fc2613ad4ed18d26c773b0e8c Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 29 Feb 2012 19:10:01 +0400 Subject: [PATCH 52/77] Fix NoMethodError: undefined method `default_order' for ActiveRecord::Relation --- app/controllers/categories_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 3dae0ee00..f7ed16b9d 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -19,10 +19,10 @@ class CategoriesController < ApplicationController 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').default_order + having('count(projects.id) > 0').group('categories.id, categories.name, categories.ancestry, projects_count') render 'index2' else - @categories = Category.default_order.paginate(:page => params[:page]) + @categories = Category.paginate(:page => params[:page]) end end From 12d8f5e7b8f9ea347ee25c96472c43bc0442ec6b Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 29 Feb 2012 21:12:06 +0400 Subject: [PATCH 53/77] [refs #232] Add new design to some group pages --- app/controllers/groups_controller.rb | 11 +- app/views/groups/index.html.haml | 71 +++++--- app/views/groups/show.html.haml | 162 ++++++++++-------- app/views/projects/_form.html.haml | 4 +- config/locales/en.yml | 3 + config/locales/ru.yml | 7 +- ...0120229163054_add_description_to_groups.rb | 5 + db/schema.rb | 26 ++- 8 files changed, 170 insertions(+), 119 deletions(-) create mode 100644 db/migrate/20120229163054_add_description_to_groups.rb diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 0ff9ec811..f72e11897 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -12,11 +12,12 @@ class GroupsController < ApplicationController def index puts parent.inspect - @groups = if parent? and !parent.nil? - parent.groups - else - Group - end.accessible_by(current_ability) + #@groups = #if parent? and !parent.nil? + # parent.groups + #else + # Group + #end.accessible_by(current_ability) + @groups = current_user.groups#accessible_by(current_ability) @groups = if params[:query] @groups.where(["name LIKE ?", "%#{params[:query]}%"]) diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index ab8e9eab0..1a2ef07bb 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,30 +1,45 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.groups.list"), users_path - %li= link_to t("layout.groups.new"), new_group_path - .content - %h2.title - = t("layout.groups.list_header") - .inner - %table.table - %tr - %th.first ID - %th= t("activerecord.attributes.group.name") - %th= t("activerecord.attributes.group.owner") - %th.last   - - @groups.each do |group| - %tr{:class => cycle("odd", "even")} - %td - = group.id - %td - = link_to group.name, group_path(group) - %td - = link_to group.owner.name, user_path(group.owner) - %td.last - = raw [(link_to t("layout.edit"), edit_group_path(group) if can? :update, group), - (link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete") if can? :destroy, group)].compact.join(' | ') - .actions-bar.wat-cf - .actions= will_paginate @groups, :param_name => :group_page += link_to t("layout.groups.new"), new_group_path, :class => "button" +%table#myTable.tablesorter.group-list{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th.th1= t("layout.groups.group") + %th.th2= t("layout.groups.description") + %th= t("layout.groups.leave_group") + %tbody + - @groups.each do |group| + %tr#Row1 + %td= link_to group.name, group_path(group) + %td.td2= group.description + %td.td5 + = link_to image_tag('x.png'), '#' unless group.owner_id == current_user.id + +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first.active= link_to t("layout.groups.list"), users_path +-# %li= link_to t("layout.groups.new"), new_group_path +-# .content +-# %h2.title +-# = t("layout.groups.list_header") +-# .inner +-# %table.table +-# %tr +-# %th.first ID +-# %th= t("activerecord.attributes.group.name") +-# %th= t("activerecord.attributes.group.owner") +-# %th.last   +-# - @groups.each do |group| +-# %tr{:class => cycle("odd", "even")} +-# %td +-# = group.id +-# %td +-# = link_to group.name, group_path(group) +-# %td +-# = link_to group.owner.name, user_path(group.owner) +-# %td.last +-# = raw [(link_to t("layout.edit"), edit_group_path(group) if can? :update, group), +-# (link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete") if can? :destroy, group)].compact.join(' | ') +-# .actions-bar.wat-cf +-# .actions= will_paginate @groups, :param_name => :group_page -# content_for :sidebar, render('sidebar') diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 728defa97..975816ac4 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,78 +1,88 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to t("layout.groups.list"), groups_path - %li= link_to t("layout.groups.new"), new_group_path - %li.active= link_to t("layout.groups.show"), group_path - .content - .inner - %p - %b - Id - \: - = @group.id - %p - %b - = t("activerecord.attributes.group.name") - \: - = @group.name - %p - %b - = t("activerecord.attributes.group.owner") - \: - = link_to @group.owner.name, user_path(@group.owner) - %p - %b - = t("activerecord.attributes.group.created_at") - \: - = @group.created_at - .wat-cf - = link_to image_tag("code.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_group_path(@group), :class => "button" - = link_to image_tag("x.png", :alt => t("layout.delete")) + " " + t("layout.delete"), group_path(@group), :method => "delete", :class => "button", :confirm => t("layout.groups.confirm_delete") - -.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.platforms.list"), platforms_path - %li= link_to t("layout.platforms.new"), new_group_platform_path(@group) - .content - %h2.title - = t("layout.platforms.list_header") - .inner - = render :partial => 'shared/search_form' - = render :partial => 'platforms/list', :object => @platforms - .actions-bar.wat-cf - .actions - = will_paginate @platforms, :param_name => :platform_page +.all.verybigpadding + %h3= @group.name + %h4= t("activerecord.attributes.group.description") + ":" + %p= @group.description + %h4= t("layout.groups.projects_list") + ":" + %p + - @group.projects.each do |project| + = link_to project.name, project + %br -#.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.repositories.list"), repositories_path - %li= link_to t("layout.repositories.new"), new_group_repository_path(@group) - .content - %h2.title - = t("layout.repositories.list_header") - .inner - = render :partial => 'shared/search_form' - = render :partial => 'repositories/list', :object => @repositories - .actions-bar.wat-cf - .actions - = will_paginate @repositories, :param_name => :repository_page - -.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.projects.list"), projects_path - %li= link_to t("layout.projects.new"), new_group_project_path(@group) - .content - %h2.title - = t("layout.projects.list_header") - .inner - = render :partial => 'shared/search_form' - = render :partial => 'projects/list', :object => @projects - .actions-bar.wat-cf - .actions - = will_paginate @projects, :param_name => :project_page - -- content_for :sidebar, render('sidebar') +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first= link_to t("layout.groups.list"), groups_path +-# %li= link_to t("layout.groups.new"), new_group_path +-# %li.active= link_to t("layout.groups.show"), group_path +-# .content +-# .inner +-# %p +-# %b +-# Id +-# \: +-# = @group.id +-# %p +-# %b +-# = t("activerecord.attributes.group.name") +-# \: +-# = @group.name +-# %p +-# %b +-# = t("activerecord.attributes.group.owner") +-# \: +-# = link_to @group.owner.name, user_path(@group.owner) +-# %p +-# %b +-# = t("activerecord.attributes.group.created_at") +-# \: +-# = @group.created_at +-# .wat-cf +-# = link_to image_tag("code.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_group_path(@group), :class => "button" +-# = link_to image_tag("x.png", :alt => t("layout.delete")) + " " + t("layout.delete"), group_path(@group), :method => "delete", :class => "button", :confirm => t("layout.groups.confirm_delete") +-# +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first.active= link_to t("layout.platforms.list"), platforms_path +-# %li= link_to t("layout.platforms.new"), new_group_platform_path(@group) +-# .content +-# %h2.title +-# = t("layout.platforms.list_header") +-# .inner +-# = render :partial => 'shared/search_form' +-# = render :partial => 'platforms/list', :object => @platforms +-# .actions-bar.wat-cf +-# .actions +-# = will_paginate @platforms, :param_name => :platform_page +-# +-#-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first.active= link_to t("layout.repositories.list"), repositories_path +-# %li= link_to t("layout.repositories.new"), new_group_repository_path(@group) +-# .content +-# %h2.title +-# = t("layout.repositories.list_header") +-# .inner +-# = render :partial => 'shared/search_form' +-# = render :partial => 'repositories/list', :object => @repositories +-# .actions-bar.wat-cf +-# .actions +-# = will_paginate @repositories, :param_name => :repository_page +-# +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first.active= link_to t("layout.projects.list"), projects_path +-# %li= link_to t("layout.projects.new"), new_group_project_path(@group) +-# .content +-# %h2.title +-# = t("layout.projects.list_header") +-# .inner +-# = render :partial => 'shared/search_form' +-# = render :partial => 'projects/list', :object => @projects +-# .actions-bar.wat-cf +-# .actions +-# = will_paginate @projects, :param_name => :project_page +-# +-#- content_for :sidebar, render('sidebar') diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 80aab60ae..036ca3244 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -15,9 +15,9 @@ = f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label .rightlist = label_tag t("activerecord.attributes.project.who_owns.me") - = radio_button_tag :who_owns, 'me'#, {}.merge( (@who_owns == :me ? {:checked => 'checked'} : {}) ) + = radio_button_tag :who_owns, 'me', :html => {:class => 'niceRadio'}#, {}.merge( (@who_owns == :me ? {:checked => 'checked'} : {}) ) = label_tag t("activerecord.attributes.project.who_owns.group") - = radio_button_tag :who_owns, 'group'#, {}.merge( (@who_owns == :group ? {:checked => 'checked'} : {}) ) + = radio_button_tag :who_owns, 'group', :class => 'niceRadio'#, {}.merge( (@who_owns == :group ? {:checked => 'checked'} : {}) ) -# TODO: Make our own select_box helper with new design, blackjack and bitches! = select_tag :owner_id, options_for_select( Group.can_own_project(current_user) ) .both diff --git a/config/locales/en.yml b/config/locales/en.yml index 730535734..973ec7bd4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -296,6 +296,9 @@ en: own_projects: My projects part_projects: Participate projects filter_header: Filter + group: Group + description: Descripton + leave_group: Leave group git: upload: Upload diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e330ca07b..1ae5bae7c 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -271,7 +271,7 @@ ru: groups: list: Список - new: Создать + new: Создать группу edit: Редактировать members: Участники new_header: Новая группа @@ -281,6 +281,10 @@ ru: back_to_the_list: ⇐ К списку групп confirm_delete: Вы уверены, что хотите удалить эту группу? edit_members: Изменить список участников + group: Группа + description: Описание + leave_group: Покинуть группу + projects_list: Список проектов users: list: Список @@ -677,6 +681,7 @@ ru: owner: Владелец created_at: Создана updated_at: Обновлена + description: Описание user: name: Имя diff --git a/db/migrate/20120229163054_add_description_to_groups.rb b/db/migrate/20120229163054_add_description_to_groups.rb new file mode 100644 index 000000000..16662758f --- /dev/null +++ b/db/migrate/20120229163054_add_description_to_groups.rb @@ -0,0 +1,5 @@ +class AddDescriptionToGroups < ActiveRecord::Migration + def change + add_column :groups, :description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 5f32738b7..1739e2c5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120224122738) do +ActiveRecord::Schema.define(:version => 20120229163054) do + + create_table "activity_feeds", :force => true do |t| + t.integer "user_id", :null => false + t.string "kind" + t.text "data" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "arches", :force => true do |t| t.string "name", :null => false @@ -155,6 +163,7 @@ ActiveRecord::Schema.define(:version => 20120224122738) do t.datetime "updated_at" t.string "uname" t.integer "own_projects_count", :default => 0, :null => false + t.text "description" end create_table "issues", :force => true do |t| @@ -263,22 +272,20 @@ ActiveRecord::Schema.define(:version => 20120224122738) 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| t.string "name" t.string "email" t.string "token" t.boolean "approved", :default => false t.boolean "rejected", :default => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "interest" t.text "more" end add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false + add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false create_table "relations", :force => true do |t| t.integer "object_id" @@ -337,8 +344,8 @@ ActiveRecord::Schema.define(:version => 20120224122738) 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" t.datetime "updated_at" @@ -346,9 +353,14 @@ ActiveRecord::Schema.define(:version => 20120224122738) do 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" end + add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true add_index "users", ["uname"], :name => "index_users_on_uname", :unique => true From 157f9a1a68f5d7c22b14346c87fff17a525a036f Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 1 Mar 2012 16:28:38 +0400 Subject: [PATCH 54/77] [refs #232] Add sidebar and group edit page --- app/views/groups/_form.html.haml | 35 ++++++++++------ app/views/groups/_sidebar.html.haml | 62 ++++++++++++++++++++++------- app/views/groups/edit.html.haml | 40 ++++++++++++++----- config/locales/en.yml | 3 ++ config/locales/ru.yml | 2 + 5 files changed, 105 insertions(+), 37 deletions(-) diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml index 37c8848f3..7f0dcf7af 100644 --- a/app/views/groups/_form.html.haml +++ b/app/views/groups/_form.html.haml @@ -1,13 +1,24 @@ -.group - = f.label :name, t("activerecord.attributes.group.name"), :class => :label - = f.text_field :name, :class => 'text_field' -.group - = f.label :uname, t("activerecord.attributes.group.uname"), :class => :label - = f.text_field :uname, :class => 'text_field', :disabled => f.object.try(:persisted?) +.leftlist + = f.label :description, t("activerecord.attributes.group.description"), :class => :label +.rightlist + = f.text_area :description +.both +.leftlist + \  +.rightlist + = submit_tag t("layout.save") +.both -.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"), users_path, :class => "text_button_padding link_button" +-#.group +-# = f.label :name, t("activerecord.attributes.group.name"), :class => :label +-# = f.text_field :name, :class => 'text_field' +-#.group +-# = f.label :uname, t("activerecord.attributes.group.uname"), :class => :label +-# = f.text_field :uname, :class => 'text_field', :disabled => f.object.try(:persisted?) +-# +-#.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"), users_path, :class => "text_button_padding link_button" diff --git a/app/views/groups/_sidebar.html.haml b/app/views/groups/_sidebar.html.haml index 6ee1d6923..820d1f643 100644 --- a/app/views/groups/_sidebar.html.haml +++ b/app/views/groups/_sidebar.html.haml @@ -1,15 +1,49 @@ -.block.notice - %h3= t("layout.groups.members") - .content - %p - %ul - - @group.members.each do |user| +.admin-preferences +- act = action_name.to_sym +- contr = controller_name.to_sym + +%aside + .admin-preferences + %ul + - if can? :edit, @project + %li{:class => (act == :edit && contr == :groups) ? 'active' : ''} + = link_to t("layout.groups.edit"), edit_group_path(@group) + - if can? :manage_members, @group %li - - if can? :read, user - = link_to user.name, user_path(user) - - else - = user.name - - if (@group.owner == user) - = '(' + t("layout.owner") + ')' - %br - = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) if can? :manage_members, @group + = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) + +-#.block.notice +-# %h3= t("layout.groups.members") +-# .content +-# %p +-# %ul +-# - @group.members.each do |user| +-# %li +-# - if can? :read, user +-# = link_to user.name, user_path(user) +-# - else +-# = user.name +-# - if (@group.owner == user) +-# = '(' + t("layout.owner") + ')' +-# %br +-# = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) if can? :manage_members, @group + %ul + %li.active + %a{:href => "#"} Основное + %li + %a{:href => "#"} Участники +-#.block.notice +-# %h3= t("layout.groups.members") +-# .content +-# %p +-# %ul +-# - @group.members.each do |user| +-# %li +-# - if can? :read, user +-# = link_to user.name, user_path(user) +-# - else +-# = user.name +-# - if (@group.owner == user) +-# = '(' + t("layout.owner") + ')' +-# %br +-# = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) if can? :manage_members, @group diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index c11eb70cc..d9c170f51 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -1,13 +1,31 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to t("layout.groups.list"), groups_path - %li= link_to t("layout.groups.new"), new_group_path - %li.active= link_to t("layout.groups.edit"), edit_group_path - .content - %h2.title= t("layout.groups.edit_header") - .inner - = form_for @group, :url => group_path(@group), :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} += form_for @group, :html => { :class => :form, :multipart => true } do |f| + = render :partial => "form", :locals => {:f => f} + +.hr +.groups-profile + = image_tag('code.png') +.groups-profile + = link_to t("layout.groups.public_profile"), @group +.both +.hr +.leftside + = t("layout.groups.delete_warning") +.rightside + = link_to t("layout.delete"), group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group +.both - content_for :sidebar, render('sidebar') + +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first= link_to t("layout.groups.list"), groups_path +-# %li= link_to t("layout.groups.new"), new_group_path +-# %li.active= link_to t("layout.groups.edit"), edit_group_path +-# .content +-# %h2.title= t("layout.groups.edit_header") +-# .inner +-# = form_for @group, :url => group_path(@group), :html => { :class => :form } do |f| +-# = render :partial => "form", :locals => {:f => f} +-# +-#- content_for :sidebar, render('sidebar') diff --git a/config/locales/en.yml b/config/locales/en.yml index 973ec7bd4..affbcbe9a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -299,6 +299,9 @@ en: group: Group description: Descripton leave_group: Leave group + projects_list: Projects list + public_profile: Public profile + delete_warning: Attention! Deleted group can not be restored! git: upload: Upload diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 1ae5bae7c..56224a7d9 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -285,6 +285,8 @@ ru: description: Описание leave_group: Покинуть группу projects_list: Список проектов + public_profile: Публичный профиль + delete_warning: Внимание! Удаленная группа восстановлению не подлежит. users: list: Список From f4a50b509cf1b18fd4cdc9eeccd8916b4a44e18f Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 1 Mar 2012 16:37:54 +0400 Subject: [PATCH 55/77] [refs #232] Add edit btn to group public page --- app/views/groups/show.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 975816ac4..442854cf3 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -7,6 +7,8 @@ - @group.projects.each do |project| = link_to project.name, project %br + %br + = link_to t("layout.edit"), edit_group_path(@group), :class => 'button' if can? :edit, @group -#.block -# .secondary-navigation From 71748ebddc890399cd885cc16b9a8a2789c3089d Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 1 Mar 2012 17:19:58 +0400 Subject: [PATCH 56/77] [refs #232] Add design to group new page --- app/views/groups/_form.html.haml | 11 ++++++++++- app/views/groups/new.html.haml | 27 +++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml index 7f0dcf7af..27e098be9 100644 --- a/app/views/groups/_form.html.haml +++ b/app/views/groups/_form.html.haml @@ -1,8 +1,17 @@ +- act = controller.action_name.to_sym +- if [:new, :create].include? act + .leftlist + = f.label :name, t("activerecord.attributes.group.name"), :class => :label + .rightlist.nomargin + = f.text_field :name + .both +%br .leftlist = f.label :description, t("activerecord.attributes.group.description"), :class => :label -.rightlist +.rightlist.nomargin = f.text_area :description .both +%br .leftlist \  .rightlist diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml index 02f2bca5d..91ec1bf95 100644 --- a/app/views/groups/new.html.haml +++ b/app/views/groups/new.html.haml @@ -1,12 +1,19 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to t("layout.groups.list"), groups_path - %li.active= link_to t("layout.groups.new"), new_group_path - .content - %h2.title= t("layout.groups.new_header") - .inner - = form_for @group, :url => groups_path, :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} +%h3.bpadding10= t("layout.groups.new_header") += form_for @group, :url => groups_path do |f| + = render :partial => "form", :locals => {:f => f} + +:javascript + $('article .all').addClass('bigpadding'); + +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first= link_to t("layout.groups.list"), groups_path +-# %li.active= link_to t("layout.groups.new"), new_group_path +-# .content +-# %h2.title= t("layout.groups.new_header") +-# .inner +-# = form_for @group, :url => groups_path, :html => { :class => :form } do |f| +-# = render :partial => "form", :locals => {:f => f} -# content_for :sidebar, render('sidebar') From fc3d4c0b6d335022961177ad718ade0bd521fd21 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 1 Mar 2012 18:23:26 +0400 Subject: [PATCH 57/77] [refs #232] Add group members edit page design --- app/controllers/members_controller.rb | 2 +- app/views/groups/_sidebar.html.haml | 2 +- app/views/members/edit.html.haml | 142 ++++++++++++++++++-------- config/routes.rb | 1 + 4 files changed, 101 insertions(+), 46 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 8d22c69f3..62cb2e46a 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -65,7 +65,7 @@ class MembersController < ApplicationController redirect_to parent_path end - def destroy + def remove end def add diff --git a/app/views/groups/_sidebar.html.haml b/app/views/groups/_sidebar.html.haml index 820d1f643..3a84d8935 100644 --- a/app/views/groups/_sidebar.html.haml +++ b/app/views/groups/_sidebar.html.haml @@ -9,7 +9,7 @@ %li{:class => (act == :edit && contr == :groups) ? 'active' : ''} = link_to t("layout.groups.edit"), edit_group_path(@group) - if can? :manage_members, @group - %li + %li{:class => (act == :edit && contr == :members) ? 'active' : ''} = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) -#.block.notice diff --git a/app/views/members/edit.html.haml b/app/views/members/edit.html.haml index 2a6b01a91..55ac93a3e 100644 --- a/app/views/members/edit.html.haml +++ b/app/views/members/edit.html.haml @@ -1,46 +1,100 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to t("layout.members.back_to_group"), parent_path - %li.active= link_to t("layout.members.edit"), edit_group_members_path(@group) - .content - .inner - = form_tag group_members_path(parent) do - %h2.title= t("layout.users.list_header") - %table.table - %tr - %th.first ID - %th= t("activerecord.attributes.user.name") - %th= t("activerecord.attributes.user.roles") - %th= t("activerecord.attributes.user.uname") - - #TODO: Replace this Chelyabinsk add/remove collaborators method by more human method - - @users.each do |user| - %tr{:class => cycle("odd", "even")} - %td - = user.id - %td - = link_to user.name, user_path(user) - %td - - Relation::ROLES.each do |role| - = check_box_tag "#{ role }[#{user.id}]", '1', ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"} - = label_tag "#{ role }[#{user.id}]", t("layout.members.roles.#{ role }") - %td - = user.uname - .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"), group_path(parent), :class => "text_button_padding link_button" += form_tag group_members_path(@group), :id => 'members_form', :delete_url => remove_group_members_path(@group) do + = hidden_field_tag "_method", "post" + %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th + \  + %th + = t("layout.collaborators.members") + %th{:colspan => "3"} + = t("layout.collaborators.roles") + %tbody + - @users.each do |user| + %tr#admin-table-members-row1 + %td + %span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)", :style => "background-position: 0px 0px; "} + = check_box_tag "user_remove[#{user.id}][]" + %td + .img + = image_tag(gravatar_url(user.email)) + .forimg= link_to user.name, user_path(user) + - Relation::ROLES.each_with_index do |role, i| + %td + .radio + = radio_button_tag "user[#{user.id}]", role, ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio' + -# f.radio_button "group[#{role}][#{group.id}]", '1', ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil) + -#%span.niceRadio.radioChecked + -# %input#myradio1{:checked => "checked", :name => "myradio", :tabindex => "1", :type => "radio", :value => "on"}/ + .forradio= t("layout.collaborators.role_names.#{ role }") + = link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button' + .both +.hr.top - = form_tag add_group_members_path(parent) do - .group - %h2.title= t("layout.members.add_member") - = label_tag "", t("layout.members.input_username") - = autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path - %br - .group.navform.wat-cf - %button.button{:type => "submit"} - = image_tag("choose.png", :alt => t("layout.add")) - = t("layout.add") += form_tag add_group_members_path(parent) do + .admin-search + = autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path#, :id_element => '#member_id_field' + .admin-role + .lineForm + = select_tag 'role', options_for_collaborators_roles_select + .both + -#.admin-search + -# = label_tag "group_uname", t("layout.collaborators.input_groupname") + -# = autocomplete_field_tag 'group_id', params[:group_id], autocomplete_group_uname_groups_path, :id_element => '#group_id_field' + =# hidden_field_tag 'member_id', nil, :id => 'member_id_field' + =# hidden_field_tag 'group_id', nil, :id => 'group_id_field' + %br + = submit_tag t("layout.add"), :class => 'button' +.hr.bottom +.both += link_to_function t("layout.save"), "saveAdminMember();", :class => 'button' + +- content_for :sidebar, render('groups/sidebar') + +-#.block +-# .secondary-navigation +-# %ul.wat-cf +-# %li.first= link_to t("layout.members.back_to_group"), parent_path +-# %li.active= link_to t("layout.members.edit"), edit_group_members_path(@group) +-# .content +-# .inner +-# = form_tag group_members_path(parent) do +-# %h2.title= t("layout.users.list_header") +-# %table.table +-# %tr +-# %th.first ID +-# %th= t("activerecord.attributes.user.name") +-# %th= t("activerecord.attributes.user.roles") +-# %th= t("activerecord.attributes.user.uname") +-# - #TODO: Replace this Chelyabinsk add/remove collaborators method by more human method +-# - @users.each do |user| +-# %tr{:class => cycle("odd", "even")} +-# %td +-# = user.id +-# %td +-# = link_to user.name, user_path(user) +-# %td +-# - Relation::ROLES.each do |role| +-# = check_box_tag "#{ role }[#{user.id}]", '1', ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"} +-# = label_tag "#{ role }[#{user.id}]", t("layout.members.roles.#{ role }") +-# %td +-# = user.uname +-# .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"), group_path(parent), :class => "text_button_padding link_button" +-# +-# = form_tag add_group_members_path(parent) do +-# .group +-# %h2.title= t("layout.members.add_member") +-# = label_tag "", t("layout.members.input_username") +-# = autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path +-# %br +-# .group.navform.wat-cf +-# %button.button{:type => "submit"} +-# = image_tag("choose.png", :alt => t("layout.add")) +-# = t("layout.add") +-# diff --git a/config/routes.rb b/config/routes.rb index b19755d07..7783d1ba0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -164,6 +164,7 @@ Rosa::Application.routes.draw do get :edit post :add post :update + delete :remove end member do post :update From eb689b7f18a99e7312e21d3c9f5d1e2fe74e4c7b Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 1 Mar 2012 19:41:40 +0400 Subject: [PATCH 58/77] [refs #232] Add new design and logic refactor for group members action --- app/controllers/members_controller.rb | 59 ++++++++++++++------------- app/views/groups/index.html.haml | 2 +- app/views/members/edit.html.haml | 59 +-------------------------- config/routes.rb | 1 + 4 files changed, 35 insertions(+), 86 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 62cb2e46a..b0fd1166c 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -29,50 +29,53 @@ class MembersController < ApplicationController end def update - all_user_ids = [] - Relation::ROLES.each { |r| - all_user_ids = all_user_ids | params[r.to_sym].keys if params[r.to_sym] - } + params['user'].keys.each { |user_id| + role = params['user'][user_id] - # Remove relations - users_for_removing = parent.members.select do |u| - !all_user_ids.map{|k| k.to_i}.include? u.id and parent.owner != u - end - users_for_removing.each do |u| - Relation.by_object(u).by_target(parent).each {|r| r.destroy} - end - - # Create relations - Relation::ROLES.each { |r| - #users_for_creating = users_for_creating params[:user].keys.map{|p| p.to_i} - @project.collaborators.map(&:id) - params[r.to_sym].keys.each { |u| - if relation = parent.objects.find_by_object_id_and_object_type(u, 'User') - relation.update_attribute(:role, r) - else - relation = parent.objects.build(:object_id => u, :object_type => 'User', :role => r) - puts relation.inspect - puts r - relation.save! - end - } if params[r.to_sym] - } + if relation = parent.objects.find_by_object_id_and_object_type(user_id, 'User') + relation.update_attribute(:role, role) + else + relation = parent.objects.build(:object_id => user_id, :object_type => 'User', :role => role) + relation.save! + end + } if params['user'] if parent.save flash[:notice] = t("flash.members.successfully_changed") else flash[:error] = t("flash.members.error_in_changing") end - redirect_to parent_path + + redirect_to edit_group_members_path(parent) end def remove + if params[:id] + u = User.find(params[:id]) + Relation.by_object(u).by_target(parent)[0].destroy + + redirect_to groups_path + else + all_user_ids = [] + + params['user_remove'].keys.each { |user_id| + all_user_ids << user_id if params['user_remove'][user_id] == ["1"] + } if params['user_remove'] + + all_user_ids.each do |user_id| + u = User.find(user_id) + Relation.by_object(u).by_target(parent).each {|r| r.destroy} + end + + redirect_to edit_group_members_path(parent) + end end def add if params['user_id'] and !params['user_id'].empty? @user = User.find_by_uname(params['user_id']) unless parent.objects.exists? :object_id => @user.id, :object_type => 'User' - relation = parent.objects.build(:object_id => @user.id, :object_type => 'User', :role => 'reader') + relation = parent.objects.build(:object_id => @user.id, :object_type => 'User', :role => params[:role]) if relation.save flash[:notice] = t("flash.members.successfully_added") else diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 1a2ef07bb..2ee1168fb 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -11,7 +11,7 @@ %td= link_to group.name, group_path(group) %td.td2= group.description %td.td5 - = link_to image_tag('x.png'), '#' unless group.owner_id == current_user.id + = link_to image_tag('x.png'), remove_group_member_path(group, current_user), :method => :delete unless group.owner_id == current_user.id -#.block -# .secondary-navigation diff --git a/app/views/members/edit.html.haml b/app/views/members/edit.html.haml index 55ac93a3e..05525eab8 100644 --- a/app/views/members/edit.html.haml +++ b/app/views/members/edit.html.haml @@ -11,9 +11,9 @@ = t("layout.collaborators.roles") %tbody - @users.each do |user| - %tr#admin-table-members-row1 + %tr %td - %span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)", :style => "background-position: 0px 0px; "} + %span#niceCheckbox1.niceCheck-main = check_box_tag "user_remove[#{user.id}][]" %td .img @@ -23,9 +23,6 @@ %td .radio = radio_button_tag "user[#{user.id}]", role, ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio' - -# f.radio_button "group[#{role}][#{group.id}]", '1', ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil) - -#%span.niceRadio.radioChecked - -# %input#myradio1{:checked => "checked", :name => "myradio", :tabindex => "1", :type => "radio", :value => "on"}/ .forradio= t("layout.collaborators.role_names.#{ role }") = link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button' .both @@ -38,11 +35,6 @@ .lineForm = select_tag 'role', options_for_collaborators_roles_select .both - -#.admin-search - -# = label_tag "group_uname", t("layout.collaborators.input_groupname") - -# = autocomplete_field_tag 'group_id', params[:group_id], autocomplete_group_uname_groups_path, :id_element => '#group_id_field' - =# hidden_field_tag 'member_id', nil, :id => 'member_id_field' - =# hidden_field_tag 'group_id', nil, :id => 'group_id_field' %br = submit_tag t("layout.add"), :class => 'button' @@ -51,50 +43,3 @@ = link_to_function t("layout.save"), "saveAdminMember();", :class => 'button' - content_for :sidebar, render('groups/sidebar') - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first= link_to t("layout.members.back_to_group"), parent_path --# %li.active= link_to t("layout.members.edit"), edit_group_members_path(@group) --# .content --# .inner --# = form_tag group_members_path(parent) do --# %h2.title= t("layout.users.list_header") --# %table.table --# %tr --# %th.first ID --# %th= t("activerecord.attributes.user.name") --# %th= t("activerecord.attributes.user.roles") --# %th= t("activerecord.attributes.user.uname") --# - #TODO: Replace this Chelyabinsk add/remove collaborators method by more human method --# - @users.each do |user| --# %tr{:class => cycle("odd", "even")} --# %td --# = user.id --# %td --# = link_to user.name, user_path(user) --# %td --# - Relation::ROLES.each do |role| --# = check_box_tag "#{ role }[#{user.id}]", '1', ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"} --# = label_tag "#{ role }[#{user.id}]", t("layout.members.roles.#{ role }") --# %td --# = user.uname --# .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"), group_path(parent), :class => "text_button_padding link_button" --# --# = form_tag add_group_members_path(parent) do --# .group --# %h2.title= t("layout.members.add_member") --# = label_tag "", t("layout.members.input_username") --# = autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path --# %br --# .group.navform.wat-cf --# %button.button{:type => "submit"} --# = image_tag("choose.png", :alt => t("layout.add")) --# = t("layout.add") --# diff --git a/config/routes.rb b/config/routes.rb index 7783d1ba0..877a6cb00 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,6 +168,7 @@ Rosa::Application.routes.draw do end member do post :update + delete :remove end end end From d376b55a57b7c1d25fe694ef2c21f85734caf921 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 2 Mar 2012 12:47:16 +0400 Subject: [PATCH 59/77] [refs #232] Move groups locales to another files. Remove unsused commented code. On small sidebar fix --- app/controllers/members_controller.rb | 1 + app/views/groups/_form.html.haml | 14 ----- app/views/groups/_sidebar.html.haml | 36 ------------ app/views/groups/edit.html.haml | 14 ----- app/views/groups/index.html.haml | 31 ----------- app/views/groups/new.html.haml | 13 ----- app/views/groups/show.html.haml | 79 --------------------------- config/locales/en.yml | 34 ------------ config/locales/groups.en.yml | 38 +++++++++++++ config/locales/groups.ru.yml | 54 ++++++++++++++++++ config/locales/ru.yml | 47 ---------------- 11 files changed, 93 insertions(+), 268 deletions(-) create mode 100644 config/locales/groups.en.yml create mode 100644 config/locales/groups.ru.yml diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index b0fd1166c..9d9f8ce1f 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -23,6 +23,7 @@ class MembersController < ApplicationController @user = User.find params[:id] render :edit_rights and return end + @group = parent end def create diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml index 27e098be9..f81005f2d 100644 --- a/app/views/groups/_form.html.haml +++ b/app/views/groups/_form.html.haml @@ -17,17 +17,3 @@ .rightlist = submit_tag t("layout.save") .both - --#.group --# = f.label :name, t("activerecord.attributes.group.name"), :class => :label --# = f.text_field :name, :class => 'text_field' --#.group --# = f.label :uname, t("activerecord.attributes.group.uname"), :class => :label --# = f.text_field :uname, :class => 'text_field', :disabled => f.object.try(:persisted?) --# --#.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"), users_path, :class => "text_button_padding link_button" diff --git a/app/views/groups/_sidebar.html.haml b/app/views/groups/_sidebar.html.haml index 3a84d8935..24c862edf 100644 --- a/app/views/groups/_sidebar.html.haml +++ b/app/views/groups/_sidebar.html.haml @@ -11,39 +11,3 @@ - if can? :manage_members, @group %li{:class => (act == :edit && contr == :members) ? 'active' : ''} = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) - --#.block.notice --# %h3= t("layout.groups.members") --# .content --# %p --# %ul --# - @group.members.each do |user| --# %li --# - if can? :read, user --# = link_to user.name, user_path(user) --# - else --# = user.name --# - if (@group.owner == user) --# = '(' + t("layout.owner") + ')' --# %br --# = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) if can? :manage_members, @group - %ul - %li.active - %a{:href => "#"} Основное - %li - %a{:href => "#"} Участники --#.block.notice --# %h3= t("layout.groups.members") --# .content --# %p --# %ul --# - @group.members.each do |user| --# %li --# - if can? :read, user --# = link_to user.name, user_path(user) --# - else --# = user.name --# - if (@group.owner == user) --# = '(' + t("layout.owner") + ')' --# %br --# = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) if can? :manage_members, @group diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index d9c170f51..bfce72fe0 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -15,17 +15,3 @@ .both - content_for :sidebar, render('sidebar') - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first= link_to t("layout.groups.list"), groups_path --# %li= link_to t("layout.groups.new"), new_group_path --# %li.active= link_to t("layout.groups.edit"), edit_group_path --# .content --# %h2.title= t("layout.groups.edit_header") --# .inner --# = form_for @group, :url => group_path(@group), :html => { :class => :form } do |f| --# = render :partial => "form", :locals => {:f => f} --# --#- content_for :sidebar, render('sidebar') diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 2ee1168fb..57bd85913 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -12,34 +12,3 @@ %td.td2= group.description %td.td5 = link_to image_tag('x.png'), remove_group_member_path(group, current_user), :method => :delete unless group.owner_id == current_user.id - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first.active= link_to t("layout.groups.list"), users_path --# %li= link_to t("layout.groups.new"), new_group_path --# .content --# %h2.title --# = t("layout.groups.list_header") --# .inner --# %table.table --# %tr --# %th.first ID --# %th= t("activerecord.attributes.group.name") --# %th= t("activerecord.attributes.group.owner") --# %th.last   --# - @groups.each do |group| --# %tr{:class => cycle("odd", "even")} --# %td --# = group.id --# %td --# = link_to group.name, group_path(group) --# %td --# = link_to group.owner.name, user_path(group.owner) --# %td.last --# = raw [(link_to t("layout.edit"), edit_group_path(group) if can? :update, group), --# (link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete") if can? :destroy, group)].compact.join(' | ') --# .actions-bar.wat-cf --# .actions= will_paginate @groups, :param_name => :group_page - --# content_for :sidebar, render('sidebar') diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml index 91ec1bf95..2eea090f7 100644 --- a/app/views/groups/new.html.haml +++ b/app/views/groups/new.html.haml @@ -4,16 +4,3 @@ :javascript $('article .all').addClass('bigpadding'); - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first= link_to t("layout.groups.list"), groups_path --# %li.active= link_to t("layout.groups.new"), new_group_path --# .content --# %h2.title= t("layout.groups.new_header") --# .inner --# = form_for @group, :url => groups_path, :html => { :class => :form } do |f| --# = render :partial => "form", :locals => {:f => f} - --# content_for :sidebar, render('sidebar') diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 442854cf3..574ddda07 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -9,82 +9,3 @@ %br %br = link_to t("layout.edit"), edit_group_path(@group), :class => 'button' if can? :edit, @group - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first= link_to t("layout.groups.list"), groups_path --# %li= link_to t("layout.groups.new"), new_group_path --# %li.active= link_to t("layout.groups.show"), group_path --# .content --# .inner --# %p --# %b --# Id --# \: --# = @group.id --# %p --# %b --# = t("activerecord.attributes.group.name") --# \: --# = @group.name --# %p --# %b --# = t("activerecord.attributes.group.owner") --# \: --# = link_to @group.owner.name, user_path(@group.owner) --# %p --# %b --# = t("activerecord.attributes.group.created_at") --# \: --# = @group.created_at --# .wat-cf --# = link_to image_tag("code.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_group_path(@group), :class => "button" --# = link_to image_tag("x.png", :alt => t("layout.delete")) + " " + t("layout.delete"), group_path(@group), :method => "delete", :class => "button", :confirm => t("layout.groups.confirm_delete") --# --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first.active= link_to t("layout.platforms.list"), platforms_path --# %li= link_to t("layout.platforms.new"), new_group_platform_path(@group) --# .content --# %h2.title --# = t("layout.platforms.list_header") --# .inner --# = render :partial => 'shared/search_form' --# = render :partial => 'platforms/list', :object => @platforms --# .actions-bar.wat-cf --# .actions --# = will_paginate @platforms, :param_name => :platform_page --# --#-#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first.active= link_to t("layout.repositories.list"), repositories_path --# %li= link_to t("layout.repositories.new"), new_group_repository_path(@group) --# .content --# %h2.title --# = t("layout.repositories.list_header") --# .inner --# = render :partial => 'shared/search_form' --# = render :partial => 'repositories/list', :object => @repositories --# .actions-bar.wat-cf --# .actions --# = will_paginate @repositories, :param_name => :repository_page --# --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first.active= link_to t("layout.projects.list"), projects_path --# %li= link_to t("layout.projects.new"), new_group_project_path(@group) --# .content --# %h2.title --# = t("layout.projects.list_header") --# .inner --# = render :partial => 'shared/search_form' --# = render :partial => 'projects/list', :object => @projects --# .actions-bar.wat-cf --# .actions --# = will_paginate @projects, :param_name => :project_page --# --#- content_for :sidebar, render('sidebar') diff --git a/config/locales/en.yml b/config/locales/en.yml index affbcbe9a..6632d522b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -262,26 +262,6 @@ en: writer: Writer admin: Admin - members: - back_to_group: Back to group - edit: Edit list - roles: Roles - add_member: Add member - input_username: Username - - groups: - list: List - new: Create - edit: Edit - members: Members - new_header: New group - edit_header: Edit - list_header: Groups - show: Group - back_to_the_list: ⇐ List of groups - confirm_delete: Are you sure to remove this group? - edit_members: Edit members - users: list: List new: Create @@ -531,13 +511,6 @@ en: successfully_added: Member %s successfully added error_in_adding: Member %s adding error - members: - successfully_changed: Members list successfully changed - error_in_changing: Members list changing error - successfully_added: Member successfully added - error_in_adding: Member adding error - already_added: User already added - auto_build_list: success: Automated build success! failed: Automated build failed! @@ -815,13 +788,6 @@ en: use_default: By default use_default_for_owner: Default by owner - group: - name: Name - uname: Nickname - owner: Owner - created_at: Created - updated_at: Updated - user: name: User login: Nickname or Email diff --git a/config/locales/groups.en.yml b/config/locales/groups.en.yml new file mode 100644 index 000000000..b80db4833 --- /dev/null +++ b/config/locales/groups.en.yml @@ -0,0 +1,38 @@ +en: + layout: + groups: + list: List + new: Create + edit: Edit + members: Members + new_header: New group + edit_header: Edit + list_header: Groups + show: Group + back_to_the_list: ⇐ List of groups + confirm_delete: Are you sure to remove this group? + edit_members: Edit members + + members: + back_to_group: Back to group + edit: Edit list + roles: Roles + add_member: Add member + input_username: Username + + flash: + members: + successfully_changed: Members list successfully changed + error_in_changing: Members list changing error + successfully_added: Member successfully added + error_in_adding: Member adding error + already_added: User already added + + activerecord: + attributes: + group: + name: Name + uname: Nickname + owner: Owner + created_at: Created + updated_at: Updated diff --git a/config/locales/groups.ru.yml b/config/locales/groups.ru.yml new file mode 100644 index 000000000..00b9f12bb --- /dev/null +++ b/config/locales/groups.ru.yml @@ -0,0 +1,54 @@ +ru: + layout: + groups: + list: Список + new: Создать группу + edit: Редактировать + members: Участники + new_header: Новая группа + edit_header: Редактировать + list_header: Группы + show: Группа + back_to_the_list: ⇐ К списку групп + confirm_delete: Вы уверены, что хотите удалить эту группу? + edit_members: Изменить список участников + group: Группа + description: Описание + leave_group: Покинуть группу + projects_list: Список проектов + public_profile: Публичный профиль + delete_warning: Внимание! Удаленная группа восстановлению не подлежит. + + members: + back_to_group: Вернуться к группе + edit: Редактировать список + roles: Роли + add_member: Добавить участника + input_username: Псевдоним пользователя + + + flash: + group: + saved: Группа успешно сохранена + save_error: Не удалось сохранить группу + destroyed: Группа успешно удалена + user_uname_exists: Пользователь с таким именем уже зарегестрирован + + members: + successfully_changed: Список участников успешно изменен + error_in_changing: Ошибка изменения списка участников + successfully_added: Участник успешно добавлен + error_in_adding: Ошибка при добавлении участника + already_added: Пользователь уже добавлен + + + + activerecord: + attributes: + group: + name: Название + uname: Псевдоним + owner: Владелец + created_at: Создана + updated_at: Обновлена + description: Описание diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 56224a7d9..273736972 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -262,32 +262,6 @@ ru: writer: Писатель admin: Админ - members: - back_to_group: Вернуться к группе - edit: Редактировать список - roles: Роли - add_member: Добавить участника - input_username: Псевдоним пользователя - - groups: - list: Список - new: Создать группу - edit: Редактировать - members: Участники - new_header: Новая группа - edit_header: Редактировать - list_header: Группы - show: Группа - back_to_the_list: ⇐ К списку групп - confirm_delete: Вы уверены, что хотите удалить эту группу? - edit_members: Изменить список участников - group: Группа - description: Описание - leave_group: Покинуть группу - projects_list: Список проектов - public_profile: Публичный профиль - delete_warning: Внимание! Удаленная группа восстановлению не подлежит. - users: list: Список new: Создать @@ -403,13 +377,6 @@ ru: successfully_added: Участник %s успешно добавлен error_in_adding: Ошибка при добавлении участника %s - members: - successfully_changed: Список участников успешно изменен - error_in_changing: Ошибка изменения списка участников - successfully_added: Участник успешно добавлен - error_in_adding: Ошибка при добавлении участника - already_added: Пользователь уже добавлен - auto_build_list: success: Сборка проекта автоматизорована! failed: Не удалось автоматизировать сборку! @@ -444,12 +411,6 @@ ru: save_error: Не удалось сохранить данные о пользователе destroyed: Учетная запись успешно удалена - group: - saved: Группа успешно сохранена - save_error: Не удалось сохранить группу - destroyed: Группа успешно удалена - user_uname_exists: Пользователь с таким именем уже зарегестрирован - repository: saved: Репозиторий успешно добавлен save_error: Не удалось добавить репозиторий @@ -677,14 +638,6 @@ ru: use_default: По умолчанию use_default_for_owner: По умолчанию для владельца - group: - name: Название - uname: Псевдоним - owner: Владелец - created_at: Создана - updated_at: Обновлена - description: Описание - user: name: Имя login: Псевдоним или Email From 3369953b4c4581a52da204a0e49ac83346c5fb71 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 2 Mar 2012 13:46:16 +0400 Subject: [PATCH 60/77] [refs #232] Remove unused commented code from groups controller --- app/controllers/groups_controller.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index f72e11897..9dad1d7b0 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -11,12 +11,6 @@ class GroupsController < ApplicationController autocomplete :group, :uname def index - puts parent.inspect - #@groups = #if parent? and !parent.nil? - # parent.groups - #else - # Group - #end.accessible_by(current_ability) @groups = current_user.groups#accessible_by(current_ability) @groups = if params[:query] From 8677fa749369eb9dc6134d98b3dba0ca9dc024c5 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 2 Mar 2012 14:39:48 +0400 Subject: [PATCH 61/77] [refs #232] Remove name field --- app/controllers/groups_controller.rb | 2 +- app/models/group.rb | 8 ++++++-- app/views/groups/_form.html.haml | 4 ++-- db/migrate/20120302102734_remove_name_from_groups.rb | 9 +++++++++ db/schema.rb | 6 +++--- 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20120302102734_remove_name_from_groups.rb diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 9dad1d7b0..74f3a0803 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -41,7 +41,7 @@ class GroupsController < ApplicationController current_user end - if @group.save + if @group.save! flash[:notice] = t('flash.group.saved') redirect_to group_path(@group) else diff --git a/app/models/group.rb b/app/models/group.rb index 4e08229c9..1ef70ed0a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -13,14 +13,14 @@ class Group < ActiveRecord::Base has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy - validates :name, :owner, :presence => true + validates :owner, :presence => true validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? } scope :by_owner, lambda { |owner| where(:owner_id => owner.id) } scope :by_admin, lambda { |admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User') } - attr_readonly :uname, :own_projects_count + attr_readonly :own_projects_count delegate :ssh_key, :email, :to => :owner @@ -33,6 +33,10 @@ class Group < ActiveRecord::Base (by_owner(user) | by_admin(user)).collect { |el| [el.name, el.id] } end + def name + uname + end + protected def add_owner_to_members diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml index f81005f2d..62463254f 100644 --- a/app/views/groups/_form.html.haml +++ b/app/views/groups/_form.html.haml @@ -1,9 +1,9 @@ - act = controller.action_name.to_sym - if [:new, :create].include? act .leftlist - = f.label :name, t("activerecord.attributes.group.name"), :class => :label + = f.label :uname, t("activerecord.attributes.group.uname"), :class => :label .rightlist.nomargin - = f.text_field :name + = f.text_field :uname .both %br .leftlist diff --git a/db/migrate/20120302102734_remove_name_from_groups.rb b/db/migrate/20120302102734_remove_name_from_groups.rb new file mode 100644 index 000000000..f7f33ae48 --- /dev/null +++ b/db/migrate/20120302102734_remove_name_from_groups.rb @@ -0,0 +1,9 @@ +class RemoveNameFromGroups < ActiveRecord::Migration + def up + remove_column :groups, :name + end + + def down + add_column :groups, :name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f89af4329..bd359a27b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120229182356) do +ActiveRecord::Schema.define(:version => 20120302102734) do + create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false t.string "kind" @@ -156,7 +157,6 @@ ActiveRecord::Schema.define(:version => 20120229182356) do end create_table "groups", :force => true do |t| - t.string "name" t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" @@ -284,11 +284,11 @@ ActiveRecord::Schema.define(:version => 20120229182356) do 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_rpm", :default => true end From 7164dd580ea04a9006316595550b9746f86c7cbc Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 18:27:38 +0600 Subject: [PATCH 62/77] [refs #230] fix error messages + some refactoring --- app/assets/images/error-arrow.png | Bin 0 -> 3200 bytes app/assets/javascripts/login.js | 72 +-- app/assets/stylesheets/devise/login.scss | 326 ++++++++++++++ .../stylesheets/devise/registration.scss | 416 ++++++++++-------- app/assets/stylesheets/login.scss | 277 +----------- app/helpers/devise_helper.rb | 21 + app/views/devise/passwords/edit.html.haml | 14 +- app/views/devise/registrations/new.html.haml | 37 +- app/views/devise/sessions/new.html.haml | 11 +- app/views/layouts/sessions.html.haml | 2 +- config/locales/devise.en.yml | 6 +- config/locales/devise.ru.yml | 6 +- 12 files changed, 632 insertions(+), 556 deletions(-) create mode 100644 app/assets/images/error-arrow.png create mode 100644 app/assets/stylesheets/devise/login.scss create mode 100644 app/helpers/devise_helper.rb diff --git a/app/assets/images/error-arrow.png b/app/assets/images/error-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..3e2e9734f4512236948850180cf9262bfab47dc9 GIT binary patch literal 3200 zcmV-`41e>9P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00052Nkl5DGRA<2 z007L4ETOd)02F}2WHLEY$Prp=0zd%dY&Lrw$MGk}aq223BGNRy7sv63LZR>ifW)T6 zEC`K8qo7i$ymK7q6@WW-p4t}a^?H7@**tSy_ne6C-juIyK>$FsTCJUKw|nY&UWbUH z+a4!-nwu&BKmZWS131O)hNH4VBAfe>$Dk*X#8) mGk?vE*=Vg++fCE-^w$6^2l!#ld1e6s0000 \ +
\ +
#{error}
\ + ".html_safe + end + end +end diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 84463652a..df4f48751 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -11,23 +11,19 @@ %h1= title t('devise.passwords.edit') %br .content - -password_error = nil - - if resource.errors.present? - - resource.errors.each do |attr, array| - -password_error = array if attr == :password + - password_error, reset_password_token_error = getDeviseErrors(:password, :reset_password_token) = form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, :class => "form" }) do |f| = f.hidden_field :reset_password_token .left.first=t('activerecord.attributes.user.password') .right.first - = f.text_field :password, :id => 'pass', :class => "registartion-input #{password_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};" + = f.text_field :password, :id => 'password', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}" .both .left=t('activerecord.attributes.user.password_confirm') .right - = f.text_field :password_confirmation, :id => 'pass2', :class => "registartion-input #{password_error ? "registartion-input-error" : ''}", :onClick => "this.className='registartion-input-focus';disError(this);", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};buttonCheck();", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};", :onkeydown => "buttonCheck();" + = f.text_field :password_confirmation, :id => 'password2', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}" .both %br =f.submit t("devise.passwords.edit_button"), :class => 'button', :id => 'btnLogin' - - if password_error - #hint.error.reset{:style => 'display: block;'} - %p=password_error + =showDeviseHintError(:password, password_error, 'reset') + diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 957a05c01..19bebe4d4 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -3,51 +3,36 @@ %header .logo / Page - - uname_error = name_error = email_error = password_error = password_confirm_error = nil - - if resource.errors.present? # Trash - - resource.errors.each do |attr, array| - -uname_error = array if attr == :uname - -name_error = array if attr == :name - -email_error = array if attr == :email - -password_error = array if attr == :password - -password_confirm_error = array if attr == :password_confirmation - + - uname_error, name_error, email_error, password_error = getDeviseErrors(:uname, :name, :email, :password) %article = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f| = hidden_field_tag :invitation_token, @invitation_token .left.first=t('activerecord.attributes.user.uname') .right.first - = f.text_field :uname, :id => 'login', :class => "registartion-input #{uname_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};" + = f.text_field :uname, :id => 'login', :class => "registartion-input #{uname_error ? 'registartion-input-error' : ''}" .both .left=t('activerecord.attributes.user.name') .right - = f.text_field :name, :id => 'name', :class => "registartion-input #{name_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};" + = f.text_field :name, :id => 'name', :class => "registartion-input #{name_error ? 'registartion-input-error' : ''}" .both .left=t('activerecord.attributes.user.email') .right - = f.text_field :email, :id => 'email', :readonly => 'readonly', :class => "registartion-input #{email_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};" + = f.text_field :email, :id => 'email', :readonly => 'readonly', :class => "registartion-input #{email_error ? 'registartion-input-error' : ''}" .both .left=t('activerecord.attributes.user.password') .right - = f.text_field :password, :id => 'pass', :class => "registartion-input #{password_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};" + = f.text_field :password, :id => 'password', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}" .both .left=t('activerecord.attributes.user.password_confirm') .right - = f.text_field :password_confirmation, :id => 'pass2', :class => "registartion-input #{password_confirm_error ? "registartion-input-error" : ''}", :onClick => "this.className='registartion-input-focus';disError(this);", :onblur => "if(this.value==''){this.value='';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};buttonCheck();", :onfocus => "if(this.value==''){this.value='';this.className='registartion-input-focus';};", :onkeydown => "buttonCheck();" + = f.text_field :password_confirmation, :id => 'password2', :class => "registartion-input #{password_error ? 'registartion-input-error' : ''}" .both .in =f.submit t("layout.devise.shared_links.sign_up"), :class => 'button', :id => 'btnLogin' .both - -if uname_error - .error.login#hintLogin - %p=uname_error - -if name_error - .error.name#hintName - %p=name_error - -if email_error - .error.email#hintEmail - %p=email_error - -if password_error - .error.password#hintPassword - %p=password_error \ No newline at end of file + =showDeviseHintError(:login, uname_error) + =showDeviseHintError(:name, name_error) + =showDeviseHintError(:email, email_error) + =showDeviseHintError(:password, password_error) + diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 985798573..1dd5e6e24 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -13,9 +13,9 @@ =hidden_field_tag :password_default, password = form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "form login" }) do |f| %h1= title t("layout.sessions.sign_in_header") - = f.text_field :login, :class => "registartion-input #{is_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='#{login}';this.className='registartion-input';} else{this.className='registartion-input-no-focus';};buttonCheck();", :onfocus => "if(this.value=='#{login}'){this.value='';this.className='registartion-input-focus';};", :onkeydown => "buttonCheck();", :type => "text", :value => login + = f.text_field :login, :class => "registartion-input #{is_error ? "registartion-input-error" : ''}", :value => login %br/ - = f.password_field :password, :class => "registartion-input #{is_error ? "registartion-input-error" : ''}", :onblur => "if(this.value==''){this.value='#{password}';this.className='registartion-input';}else{this.className='registartion-input-no-focus';};buttonCheck();", :onfocus => "if(this.value=='#{password}'){this.value='';this.className='registartion-input-focus';};", :onkeydown => "buttonCheck();", :type => "password", :value => password + = f.password_field :password, :class => "registartion-input #{is_error ? "registartion-input-error" : ''}", :value => password %br/ .registration .remember @@ -23,12 +23,11 @@ %span#niceCheckbox1.niceCheck{:onclick => "changeCheck(this)"} = f.check_box :remember_me .text=t('devise.sessions.remember_me') - .in=f.submit t('layout.devise.shared_links.sign_in'), :class => 'button disabled', :id => 'btnLogin' + .in=f.submit t('layout.devise.shared_links.sign_in'), :class => 'button', :id => 'btnLogin' %div{:style => "clear: both;"} .hr .both - #hint.error{:style => is_error ? 'display: block;' : ''} - %p=t('devise.failure.invalid') .forgot .password - %p= link_to t("layout.devise.shared_links.forgot_password"), new_password_path(resource_name) \ No newline at end of file + %p= link_to t("layout.devise.shared_links.forgot_password"), new_password_path(resource_name) + =showDeviseHintError(:login_error, is_error ? t('devise.failure.invalid') : false) diff --git a/app/views/layouts/sessions.html.haml b/app/views/layouts/sessions.html.haml index 6bf94f40e..a3fe71e85 100644 --- a/app/views/layouts/sessions.html.haml +++ b/app/views/layouts/sessions.html.haml @@ -5,10 +5,10 @@ = display_meta_tags :site => APP_CONFIG['project_name'] - if controller_name == 'sessions' && action_name == 'new' = stylesheet_link_tag "login" - = javascript_include_tag "login" - elsif ['registrations', 'passwords'].include?(controller_name) && ['new', 'create', 'edit', 'update'].include?(action_name) = stylesheet_link_tag "reg_session" = csrf_meta_tag + = javascript_include_tag "login" %body -# render :partial => "layouts/flashes" diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 46d859830..4a0155bc3 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -9,11 +9,6 @@ en: one: "1 error prohibited this %{resource} from being saved:" other: "%{count} errors prohibited this %{resource} from being saved:" - activerecord: - errors: - messages: - confirmation: "passwords doesn't match" - devise: failure: already_authenticated: 'You are already signed in.' @@ -38,6 +33,7 @@ en: forgot: 'Forgot password' send: 'Send' edit_button: 'Change' + new_password: 'New password' confirmations: send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' diff --git a/config/locales/devise.ru.yml b/config/locales/devise.ru.yml index 06261d0e4..b25fd5976 100644 --- a/config/locales/devise.ru.yml +++ b/config/locales/devise.ru.yml @@ -11,11 +11,6 @@ ru: many: "%{resource}: сохранение не удалось из-за %{count} ошибок" other: "%{resource}: сохранение не удалось из-за %{count} ошибки" - activerecord: - errors: - messages: - confirmation: "пароли не совпадают" - devise: failure: already_authenticated: 'Вы уже вошли в систему.' @@ -40,6 +35,7 @@ ru: forgot: 'Забыли пароль' send: 'Послать' edit_button: 'Изменить' + new_password: 'Новый пароль' confirmations: send_instructions: "В течение нескольких минут вы получите e-mail с инструкциями по подтверждению вашей учётной записи." send_paranoid_instructions: 'Если Ваш e-mail существует, то в течение нескольких минут вы получите e-mail с инструкциями по подтверждению вашей учётной записи.' From 50fc094bce2a67b6eb21fd48feafa87f7dcb0694 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 21:32:00 +0600 Subject: [PATCH 63/77] [refs #228] fuuuuu... --- app/assets/javascripts/login.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/login.js b/app/assets/javascripts/login.js index d8a00f4a7..74dbb2e36 100644 --- a/app/assets/javascripts/login.js +++ b/app/assets/javascripts/login.js @@ -15,8 +15,8 @@ $(document).ready(function() { $(this).addClass('registartion-input-focus').removeClass('registartion-input-error'); }).live('blur', function() { var id = $(this).attr('id'); - if(id == 'user_login') { $(this).val(login_default)} - else if(id == 'user_password') {$(this).val(pass_default)} + if(id == 'user_login' && $(this).val() == '') { $(this).val(login_default)} + else if(id == 'user_password' && $(this).val() == '') { $(this).val(pass_default)} $(this).addClass('registartion-input-no-focus').removeClass('registartion-input-focus'); }); From 7b37846a54f251a395e9e97739ecb3a9efe2bd77 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 2 Mar 2012 19:50:17 +0400 Subject: [PATCH 64/77] [issue #195] Fixed line numbering with files contains <> --- app/assets/stylesheets/design/custom.scss | 2 +- app/views/git/blobs/_show.html.haml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 51240598b..2b0f028c4 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -299,7 +299,7 @@ table.tablesorter tbody td a .issue_title { #output.formatted { width: auto; font-family: "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace; - padding: 10px 5px; + padding: 10px 5px 0px; margin-left: 45px; } diff --git a/app/views/git/blobs/_show.html.haml b/app/views/git/blobs/_show.html.haml index cb3363e7c..aba2703b4 100644 --- a/app/views/git/blobs/_show.html.haml +++ b/app/views/git/blobs/_show.html.haml @@ -38,7 +38,7 @@ %pre#code =#{render_blob(@blob)} :preserve - #{@blob.data.encode_to_default.html_safe} + #{h(@blob.data.encode_to_default).html_safe} .both - when :binary %table.table.blob @@ -51,6 +51,6 @@
:javascript $(document).ready(function() { - //CodeMirror.runMode(document.getElementById("code").innerHTML, "#{@blob.mime_type}", - // document.getElementById("output")); + var text = $('#code').innerHTML.replace(/&/gi, '&'); + CodeMirror.runMode(text, "#{@blob.mime_type}", document.getElementById("output")); }); From b3750f8644516094666a64d735c7517b9e0033a6 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 2 Mar 2012 20:48:19 +0400 Subject: [PATCH 65/77] [issue #195] Fixed branch selector. --- app/controllers/git/blobs_controller.rb | 2 +- app/helpers/git_helper.rb | 8 +++++--- app/presenters/comment_presenter.rb | 3 --- app/views/projects/_branch_select.html.haml | 2 +- config/locales/layout/projects.en.yml | 1 + config/locales/layout/projects.ru.yml | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/git/blobs_controller.rb b/app/controllers/git/blobs_controller.rb index 33bafb823..a355a17c3 100644 --- a/app/controllers/git/blobs_controller.rb +++ b/app/controllers/git/blobs_controller.rb @@ -6,7 +6,7 @@ class Git::BlobsController < Git::BaseController before_filter :set_path_blob def show - redirect_to project_repo_path(@project) and return unless @blob.present? + redirect_to project_path(@project) and return unless @blob.present? if params[:raw] image_url = Rails.root.to_s + "/" + @path diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index 45b8cd030..7ea91820f 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -74,18 +74,20 @@ module GitHelper # TODO This is very dirty hack. Maybe need to be changed. def branch_selector_options(project) - tmp = params + tmp = params.dup unless tmp['treeish'].present? tmp.merge!('project_id' => project.id, 'treeish' => project.default_branch).delete('id') end + tmp.delete('treeish') if tmp['commit_hash'].present? res = {} current = url_for(tmp).split('?', 2).first + tmp['commit_hash'] = truncate(tmp['commit_hash'], :length => 20) if tmp['commit_hash'] res = project.branches.inject(res) do |h, branch| - h[branch.name] = url_for(tmp.merge('treeish' => branch.name)).split('?', 2).first + h[truncate(branch.name, :length => 20)] = url_for(tmp.merge('treeish' => branch.name)).split('?', 2).first h end - res.merge!(tmp['treeish'] => current) + res.merge!(tmp['commit_hash'] || tmp['treeish'] => current) options_for_select(res.sort, current).html_safe end diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb index 9200d774d..44db9899d 100644 --- a/app/presenters/comment_presenter.rb +++ b/app/presenters/comment_presenter.rb @@ -30,9 +30,6 @@ class CommentPresenter < ApplicationPresenter def buttons project = options[:project] commentable = options[:commentable] - puts "PROJECT = " + project.inspect - puts "COMMENTABLE = " + commentable.inspect - puts "COMMENT = " + comment.inspect (ep, dp) = if commentable.class == Issue [edit_project_issue_comment_path(project, commentable, comment), project_issue_comment_path(project, commentable, comment)] diff --git a/app/views/projects/_branch_select.html.haml b/app/views/projects/_branch_select.html.haml index 78d8f6a33..1386e6023 100644 --- a/app/views/projects/_branch_select.html.haml +++ b/app/views/projects/_branch_select.html.haml @@ -3,7 +3,7 @@ :class => 'sel80', :id => 'branch_selector' %form{ :action => '', :method => :get, :id => 'branch_changer', :'data-action' => "#{controller_name}"} .fork - %p= t('layout.projects.current_branch')+':' + %p= t("layout.projects.#{params[:commit_hash].present? ? 'current_commit' : 'current_branch'}")+':' .both :javascript diff --git a/config/locales/layout/projects.en.yml b/config/locales/layout/projects.en.yml index 64673fae7..39894940e 100644 --- a/config/locales/layout/projects.en.yml +++ b/config/locales/layout/projects.en.yml @@ -11,4 +11,5 @@ en: author: Author current_branch: Current branch + current_commit: Current commit files_in_project: Files in diff --git a/config/locales/layout/projects.ru.yml b/config/locales/layout/projects.ru.yml index ff40b9cae..1b4ccaee0 100644 --- a/config/locales/layout/projects.ru.yml +++ b/config/locales/layout/projects.ru.yml @@ -10,5 +10,6 @@ ru: message: Сообщение author: Автор - current_branch: Текущий бранч + current_branch: Текущая ветка + current_commit: Текущий коммит files_in_project: Файлы в From 41c0d1e856602d66531f73f2f9efc1f0ea0d37a0 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 22:52:15 +0600 Subject: [PATCH 66/77] [refs #194] fix security and tests --- app/controllers/issues_controller.rb | 6 +++--- spec/controllers/issues_controller_spec.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 2d3f13cf5..e6956c7bc 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -4,7 +4,7 @@ class IssuesController < ApplicationController before_filter :authenticate_user! load_and_authorize_resource :project, :except => NON_RESTFUL_ACTION - load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy] + load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy, :new, :create] before_filter :load_and_authorize_label, :only => NON_RESTFUL_ACTION layout 'application' @@ -67,8 +67,8 @@ class IssuesController < ApplicationController status = 200 if @issue.save render action, :status => (status || 500), :layout => false else - @issue.title = params[:issue][:title] - @issue.body = params[:issue][:body] + @issue.title = params[:issue][:title] if params[:issue][:title] + @issue.body = params[:issue][:body] if params[:issue][:body] status = 200 if @issue.save render :nothing => true, :status => (status || 500), :layout => false end diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb index 907bf98fa..eb2579ae6 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/issues_controller_spec.rb @@ -27,7 +27,7 @@ end shared_examples_for 'user with issue update rights' do it 'should be able to perform update action' do put :update, {:id => @issue.serial_id}.merge(@update_params) - response.should redirect_to([@project, @issue]) + response.code.should eq('200') end it 'should update issue title' do From c7b412c0e0b93f439e16c02bc2c3961ad605416f Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 23:38:00 +0600 Subject: [PATCH 67/77] [refs #194] some refactoring --- app/controllers/issues_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e6956c7bc..0f47c0679 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -3,15 +3,13 @@ class IssuesController < ApplicationController NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label, :search_collaborators] before_filter :authenticate_user! - load_and_authorize_resource :project, :except => NON_RESTFUL_ACTION + load_resource :project load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy, :new, :create] before_filter :load_and_authorize_label, :only => NON_RESTFUL_ACTION layout 'application' def index(status = 200) - logger.debug "!!!!!!!!!!!!!!!!!!" - logger.debug "request format is #{request.format}" @is_assigned_to_me = params[:filter] == 'to_me' @status = params[:status] == 'closed' ? 'closed' : 'open' @labels = params[:labels] || [] @@ -112,7 +110,6 @@ class IssuesController < ApplicationController private def load_and_authorize_label - @project = Project.find(params[:project_id]) @label = Label.find(params[:label_id]) if params[:label_id] authorize! :write, @project end From dfa361f5c3ee58edde63d4661a9e8751dd3bbd2e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 23:45:20 +0600 Subject: [PATCH 68/77] [refs #194] fix triggering change event for niceRadio buttons --- app/assets/javascripts/design/radio.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/design/radio.js b/app/assets/javascripts/design/radio.js index 31650da65..179027de2 100644 --- a/app/assets/javascripts/design/radio.js +++ b/app/assets/javascripts/design/radio.js @@ -76,7 +76,8 @@ function changeRadioStart(el) { } el.next().bind("mousedown", function(e) { - changeRadio($(this)) + changeRadio($(this)); + $(this).find("input:radio").change(); }); if($.browser.msie) { el.next().find("input").eq(0).bind("click", function(e) { From 319fcdad86bcc321da73706b3acdd993b6a756ec Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sat, 3 Mar 2012 00:21:46 +0600 Subject: [PATCH 69/77] [refs #194] refactoring --- app/controllers/issues_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 0f47c0679..6476d5e93 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -65,9 +65,7 @@ class IssuesController < ApplicationController status = 200 if @issue.save render action, :status => (status || 500), :layout => false else - @issue.title = params[:issue][:title] if params[:issue][:title] - @issue.body = params[:issue][:body] if params[:issue][:body] - status = 200 if @issue.save + status = 200 if @issue.update_attributes(params[:issue]) render :nothing => true, :status => (status || 500), :layout => false end end From 7cd3e40efc1c98840bad14a89bdeb14e0042c0c9 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sat, 3 Mar 2012 01:23:45 +0600 Subject: [PATCH 70/77] [refs #194] fix accessible list --- app/controllers/issues_controller.rb | 5 ++--- app/models/issue.rb | 2 +- app/views/issues/_index_sidebar.html.haml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 6476d5e93..71812a6df 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -34,17 +34,16 @@ class IssuesController < ApplicationController end def new - @issue = Issue.new(:project => @project) + @issue = @project.issues.new end def create @user_id = params[:user_id] @user_uname = params[:user_uname] - @issue = Issue.new(params[:issue]) + @issue = @project.issues.new(params[:issue]) @issue.creator_id = current_user.id @issue.user_id = @user_id - @issue.project_id = @project.id if @issue.save @issue.subscribe_creator(current_user.id) diff --git a/app/models/issue.rb b/app/models/issue.rb index d38095d86..dcb65ed79 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -23,7 +23,7 @@ class Issue < ActiveRecord::Base after_update :deliver_issue_assign_notification after_update :subscribe_issue_assigned_user - attr_accessible :labelings_attributes, :title, :body, :project, :project_id, :closed_at, :closed_by + attr_accessible :labelings_attributes, :title, :body accepts_nested_attributes_for :labelings, :allow_destroy => true scope :opened, where(:status => 'open', :closed_by => nil, :closed_at => nil) diff --git a/app/views/issues/_index_sidebar.html.haml b/app/views/issues/_index_sidebar.html.haml index 8f0401ccc..8a34ff263 100644 --- a/app/views/issues/_index_sidebar.html.haml +++ b/app/views/issues/_index_sidebar.html.haml @@ -16,5 +16,5 @@ =tracker_search_field(:search_issue, t('layout.issues.search')) .bordered.nopadding %h3.bmargin10=t('layout.issues.new') - = link_to t("layout.add"), new_project_issue_path(@project), :class => 'button' if can? :new, Issue.new(:project_id => @project.id) + = link_to t("layout.add"), new_project_issue_path(@project), :class => 'button' if can? :new, @project.issues.new =render :partial => 'labels' From 9ee3942702aff09d11b9f36eb78d1bc0b81fa587 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Sat, 3 Mar 2012 03:25:20 +0400 Subject: [PATCH 71/77] [issue #195] Fixed bug with project creating --- app/views/projects/new.html.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index f723a1960..b540d8a8d 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -1,5 +1,3 @@ -= render :partial => 'projects/submenu' - %h3.bpadding10 = t("layout.projects.new_header") From 7e5e3ca609e3c3cb40b197fe9b5b9c1265ad0000 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Sat, 3 Mar 2012 04:24:57 +0400 Subject: [PATCH 72/77] [issue #195] Fixed another creating bug... I feel like a slipper-man... --- app/views/projects/_form.html.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index fe9d5a284..0c0c1fb58 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -15,12 +15,16 @@ = f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label .rightlist = label_tag t("activerecord.attributes.project.who_owns.me") - - if Group.can_own_project(User.find(6)).count > 0 - = radio_button_tag :who_owns, 'me'#, {}.merge( (@who_owns == :me ? {:checked => 'checked'} : {}) ) + - if Group.can_own_project(current_user).count > 0 + = radio_button_tag :who_owns, 'me', @who_owns == :me #{}.merge( (@who_owns == :me) ? {:checked => 'checked'} : {} ) + - puts @who_owns.inspect + - puts @who_owns == :group = label_tag t("activerecord.attributes.project.who_owns.group") - = radio_button_tag :who_owns, 'group'#, {}.merge( (@who_owns == :group ? {:checked => 'checked'} : {}) ) + = radio_button_tag :who_owns, 'group', @who_owns == :group #{}.merge( (@who_owns == :group) ? {:checked => 'checked'} : {} ) -# TODO: Make our own select_box helper with new design, blackjack and bitches! = select_tag :owner_id, options_for_select( Group.can_own_project(current_user) ) + - else + = hidden_field_tag :who_owns, :me .both -#- if [:new, :create].include? act -# .leftlist From 159fbe65dc497a393adc1654ea3a7070647834be Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 3 Mar 2012 02:19:31 +0200 Subject: [PATCH 73/77] Re-add compass. Add flash messages design. Refactor and fix bugs after merge. Remove duplicates, sync and separate locales . Fix some specs. Refs #263 --- Gemfile | 3 +- Gemfile.lock | 9 +- app/assets/stylesheets/design/common.scss | 20 +- app/controllers/comments_controller.rb | 2 +- app/controllers/groups_controller.rb | 2 +- app/mailers/user_mailer.rb | 2 +- app/models/activity_feed_observer.rb | 2 +- app/views/layouts/_flashes.html.haml | 3 +- .../new_comment_notification.en.haml | 2 +- .../new_comment_notification.ru.haml | 2 +- config/application.rb | 3 - config/deploy.rb | 6 +- config/locales/layout/comments.en.yml | 7 - config/locales/layout/comments.ru.yml | 7 - config/locales/layout/projects.en.yml | 15 - config/locales/layout/projects.ru.yml | 15 - .../locales/{ => models}/activity_feed.en.yml | 4 +- .../locales/{ => models}/activity_feed.ru.yml | 4 +- config/locales/{ => models}/build_list.en.yml | 0 config/locales/{ => models}/build_list.ru.yml | 0 config/locales/models/comment.en.yml | 22 ++ config/locales/models/comment.ru.yml | 22 ++ config/locales/{ => models}/event_log.en.yml | 17 + config/locales/{ => models}/event_log.ru.yml | 17 + .../{groups.en.yml => models/group.en.yml} | 15 + .../{groups.ru.yml => models/group.ru.yml} | 5 +- .../{issues.en.yml => models/issue.en.yml} | 0 .../{issues.ru.yml => models/issue.ru.yml} | 0 config/locales/models/platform.en.yml | 66 ++++ config/locales/models/platform.ru.yml | 66 ++++ config/locales/models/product.en.yml | 55 ++++ config/locales/models/product.ru.yml | 55 ++++ config/locales/models/project.en.yml | 77 +++++ config/locales/models/project.ru.yml | 77 +++++ config/locales/models/repository.en.yml | 45 +++ config/locales/models/repository.ru.yml | 45 +++ config/locales/models/user.en.yml | 41 +++ config/locales/models/user.ru.yml | 41 +++ config/locales/ru.yml | 297 +----------------- config/locales/wiki.en.yml | 10 + config/locales/wiki.ru.yml | 10 + db/schema.rb | 134 ++++---- script/delayed_job | 2 +- spec/controllers/groups_controller_spec.rb | 4 +- spec/factories/group_factory.rb | 2 +- 45 files changed, 791 insertions(+), 442 deletions(-) delete mode 100644 config/locales/layout/comments.en.yml delete mode 100644 config/locales/layout/comments.ru.yml delete mode 100644 config/locales/layout/projects.en.yml delete mode 100644 config/locales/layout/projects.ru.yml rename config/locales/{ => models}/activity_feed.en.yml (90%) rename config/locales/{ => models}/activity_feed.ru.yml (94%) rename config/locales/{ => models}/build_list.en.yml (100%) rename config/locales/{ => models}/build_list.ru.yml (100%) create mode 100644 config/locales/models/comment.en.yml create mode 100644 config/locales/models/comment.ru.yml rename config/locales/{ => models}/event_log.en.yml (85%) rename config/locales/{ => models}/event_log.ru.yml (84%) rename config/locales/{groups.en.yml => models/group.en.yml} (67%) rename config/locales/{groups.ru.yml => models/group.ru.yml} (98%) rename config/locales/{issues.en.yml => models/issue.en.yml} (100%) rename config/locales/{issues.ru.yml => models/issue.ru.yml} (100%) create mode 100644 config/locales/models/platform.en.yml create mode 100644 config/locales/models/platform.ru.yml create mode 100644 config/locales/models/product.en.yml create mode 100644 config/locales/models/product.ru.yml create mode 100644 config/locales/models/project.en.yml create mode 100644 config/locales/models/project.ru.yml create mode 100644 config/locales/models/repository.en.yml create mode 100644 config/locales/models/repository.ru.yml create mode 100644 config/locales/models/user.en.yml create mode 100644 config/locales/models/user.ru.yml diff --git a/Gemfile b/Gemfile index 7fd1a784b..9b638d81b 100644 --- a/Gemfile +++ b/Gemfile @@ -43,8 +43,9 @@ gem 'jquery-rails', '~> 2.0.1' group :assets do gem 'sass-rails', '~> 3.2.4' gem 'coffee-rails', '~> 3.2.2' + gem 'compass-rails', '~> 1.0.0.rc.3' + gem 'compass_twitter_bootstrap', '~> 2.0.1.2' gem 'uglifier', '~> 1.2.1' - gem 'compass', '~> 0.12.rc.1' # :git => 'git://github.com/chriseppstein/compass.git', :branch => 'rails31' gem 'therubyracer', '~> 0.9.10' end diff --git a/Gemfile.lock b/Gemfile.lock index e8ae4e140..fe06f3d6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,6 +93,10 @@ GEM chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) + compass-rails (1.0.0.rc.3) + compass (~> 0.12.rc.0) + compass_twitter_bootstrap (2.0.1.2) + compass creole (0.4.2) daemons (1.1.6) delayed_job (3.0.1) @@ -111,7 +115,7 @@ GEM execjs (1.3.0) multi_json (~> 1.0) expression_parser (0.9.0) - factory_girl (2.6.0) + factory_girl (2.6.1) activesupport (>= 2.3.9) factory_girl_rails (1.7.0) factory_girl (~> 2.6.0) @@ -307,7 +311,8 @@ DEPENDENCIES capistrano-ext capistrano_colors coffee-rails (~> 3.2.2) - compass (~> 0.12.rc.1) + compass-rails (~> 1.0.0.rc.3) + compass_twitter_bootstrap (~> 2.0.1.2) creole daemons (= 1.1.6) delayed_job_active_record (~> 0.3.2) diff --git a/app/assets/stylesheets/design/common.scss b/app/assets/stylesheets/design/common.scss index c0b24ccf6..b3bc37c8c 100644 --- a/app/assets/stylesheets/design/common.scss +++ b/app/assets/stylesheets/design/common.scss @@ -1,17 +1,31 @@ -@import 'compass/utilities/tables'; +//@import "compass"; +//@import "compass_twitter_bootstrap"; +//@import "compass_twitter_bootstrap_responsive"; +@import 'compass/utilities/tables'; table.info { width: 100%; border-spacing: 0; td {padding: 5px;} } - table.columns2 { @include inner-table-borders; th.first, td.first {width: 30%;} } - table.columns3 { @include alternating-rows-and-columns(#eee, #ccc, #000); th.first, td.first, th.last, td.last {width: 30%;} } + +@import 'blueprint/interaction'; +.flash { + .notice { + @include success; + } + .warning { + @include notice; + } + .error, .alert { + @include error; + } +} diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d802e9a0d..9953154da 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -75,7 +75,7 @@ class CommentsController < ApplicationController def find_comment @comment = Comment.find(params[:id]) - if @comment.commentable_type == 'Grit::Commit' + if @comment.commit_comment? @comment.project = @project @comment.helper end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 74f3a0803..9dad1d7b0 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -41,7 +41,7 @@ class GroupsController < ApplicationController current_user end - if @group.save! + if @group.save flash[:notice] = t('flash.group.saved') redirect_to group_path(@group) else diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 6609ac427..82b8be5b8 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -13,7 +13,7 @@ class UserMailer < ActionMailer::Base def new_comment_notification(comment, user) @user = user @comment = comment - mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format| + mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format| format.html end end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 6092ddea3..d6dad75b0 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -45,7 +45,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ) end end - elsif record.commentable.class == Grit::Commit + elsif record.commit_comment? subscribes = Subscribe.comment_subscribes(record).where(:status => true) subscribes.each do |subscribe| next if record.own_comment?(subscribe.user) diff --git a/app/views/layouts/_flashes.html.haml b/app/views/layouts/_flashes.html.haml index 7a6e9681f..a135909b8 100644 --- a/app/views/layouts/_flashes.html.haml +++ b/app/views/layouts/_flashes.html.haml @@ -1,4 +1,3 @@ .flash - flash.each do |type, message| - .message{:class => type} - %p= message \ No newline at end of file + .message{:class => type}= message \ No newline at end of file diff --git a/app/views/user_mailer/new_comment_notification.en.haml b/app/views/user_mailer/new_comment_notification.en.haml index 99c1a4bfe..5a20af6f6 100644 --- a/app/views/user_mailer/new_comment_notification.en.haml +++ b/app/views/user_mailer/new_comment_notification.en.haml @@ -3,7 +3,7 @@ - if @comment.commentable.class == Issue - link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) - object = 'issue' -- elsif @comment.commentable.class == Grit::Commit +- elsif @comment.commit_comment? - link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id) - object = 'commit' %p #{ link_to @comment.user.uname, user_url(@comment.user)} added new comment to #{object} #{link}. diff --git a/app/views/user_mailer/new_comment_notification.ru.haml b/app/views/user_mailer/new_comment_notification.ru.haml index 1dcab28a8..a4bd0fd6d 100644 --- a/app/views/user_mailer/new_comment_notification.ru.haml +++ b/app/views/user_mailer/new_comment_notification.ru.haml @@ -3,7 +3,7 @@ - if @comment.commentable.class == Issue - link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) - object = 'задаче' -- elsif @comment.commentable.class == Grit::Commit +- elsif @comment.commit_comment? - link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id) - object = 'коммиту' %p #{ link_to @comment.user.uname, user_url(@comment.user)} добавил комментарий к #{object} #{link}. diff --git a/config/application.rb b/config/application.rb index 86b7679c0..6a3448bfc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -55,8 +55,5 @@ module Rosa # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - - # Compass - config.sass.load_paths << Compass::Frameworks['compass'].stylesheets_directory if config.respond_to?(:sass) end end diff --git a/config/deploy.rb b/config/deploy.rb index 61d73d225..ac2b9ba34 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -69,9 +69,9 @@ after "deploy:setup", "deploy:symlink_pids" # after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart" # DJ -after "deploy:stop", "delayed_job:stop" -after "deploy:start", "delayed_job:start" -after "deploy:restart", "delayed_job:restart" +# after "deploy:stop", "delayed_job:stop" +# after "deploy:start", "delayed_job:start" +# after "deploy:restart", "delayed_job:restart" after "deploy:restart", "deploy:cleanup" diff --git a/config/locales/layout/comments.en.yml b/config/locales/layout/comments.en.yml deleted file mode 100644 index b309be256..000000000 --- a/config/locales/layout/comments.en.yml +++ /dev/null @@ -1,7 +0,0 @@ -en: - layout: - comments: - has_commented: "adds a note" - notifications_are: "Notifications for new comments are" - comments_header: "Comments" - back: 'Back' diff --git a/config/locales/layout/comments.ru.yml b/config/locales/layout/comments.ru.yml deleted file mode 100644 index 4a8723d17..000000000 --- a/config/locales/layout/comments.ru.yml +++ /dev/null @@ -1,7 +0,0 @@ -ru: - layout: - comments: - has_commented: "оставил комментарий" - notifications_are: "Уведомления о последующих комментариях" - comments_header: "Комментарии" - back: 'Назад' diff --git a/config/locales/layout/projects.en.yml b/config/locales/layout/projects.en.yml deleted file mode 100644 index 39894940e..000000000 --- a/config/locales/layout/projects.en.yml +++ /dev/null @@ -1,15 +0,0 @@ -en: - layout: - projects: - diff_show_header: "%{files} with %{additions} and %{deletions}." - about_subheader: "About project" - last_commit: "Last commit" - - filename: File - age: Modification date - message: Message - author: Author - - current_branch: Current branch - current_commit: Current commit - files_in_project: Files in diff --git a/config/locales/layout/projects.ru.yml b/config/locales/layout/projects.ru.yml deleted file mode 100644 index 1b4ccaee0..000000000 --- a/config/locales/layout/projects.ru.yml +++ /dev/null @@ -1,15 +0,0 @@ -ru: - layout: - projects: - diff_show_header: "%{files} с %{additions} и %{deletions}." - about_subheader: "О проекте" - last_commit: "Последний коммит" - - filename: Файл - age: Дата модификации - message: Сообщение - author: Автор - - current_branch: Текущая ветка - current_commit: Текущий коммит - files_in_project: Файлы в diff --git a/config/locales/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml similarity index 90% rename from config/locales/activity_feed.en.yml rename to config/locales/models/activity_feed.en.yml index 0794427a7..0839059c2 100644 --- a/config/locales/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -1,16 +1,16 @@ en: - layout: activity_feed: header: Activity Feed notifications: subjects: - new_comment_notification: New comment to task + new_comment_notification: New comment to your task new_commit_comment_notification: New comment to commit new_issue_notification: New task added to project new_user_notification: Registered on project «%{ project_name }» issue_assign_notification: New task assigned + invite_approve_notification: Invitation to ABF bodies: new_comment_notification: diff --git a/config/locales/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml similarity index 94% rename from config/locales/activity_feed.ru.yml rename to config/locales/models/activity_feed.ru.yml index 256a8d7bb..04b065970 100644 --- a/config/locales/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -1,16 +1,16 @@ ru: - layout: activity_feed: header: Лента активности notifications: subjects: - new_comment_notification: Новый комментарий к задаче + new_comment_notification: Новый комментарий к Вашей задаче new_commit_comment_notification: Новый комментарий к коммиту new_issue_notification: Новая задача добавлена к проекту new_user_notification: Регистрация на проекте «%{ project_name }» issue_assign_notification: Вам назначили задачу + invite_approve_notification: Приглашение в ABF bodies: new_comment_notification: diff --git a/config/locales/build_list.en.yml b/config/locales/models/build_list.en.yml similarity index 100% rename from config/locales/build_list.en.yml rename to config/locales/models/build_list.en.yml diff --git a/config/locales/build_list.ru.yml b/config/locales/models/build_list.ru.yml similarity index 100% rename from config/locales/build_list.ru.yml rename to config/locales/models/build_list.ru.yml diff --git a/config/locales/models/comment.en.yml b/config/locales/models/comment.en.yml new file mode 100644 index 000000000..d5486283c --- /dev/null +++ b/config/locales/models/comment.en.yml @@ -0,0 +1,22 @@ +en: + layout: + comments: + confirm_delete: Are you sure to delete the comment? + new_header: New comment + edit_header: Editing a comment + has_commented: "adds a note" + notifications_are: "Notifications for new comments are" + comments_header: "Comments" + back: 'Back' + + flash: + comment: + saved: Comment saved + save_error: Comment saves error + destroyed: Comment deleted + + activerecord: + attributes: + comment: + body: Content + user: Author diff --git a/config/locales/models/comment.ru.yml b/config/locales/models/comment.ru.yml new file mode 100644 index 000000000..ff9e15dd3 --- /dev/null +++ b/config/locales/models/comment.ru.yml @@ -0,0 +1,22 @@ +ru: + layout: + comments: + confirm_delete: Вы уверены, что хотите удалить комментарий? + new_header: Новый комментарий + edit_header: Редактирование комментария + has_commented: "оставил комментарий" + notifications_are: "Уведомления о последующих комментариях" + comments_header: "Комментарии" + back: 'Назад' + + flash: + comment: + saved: Комментарий успешно сохранен + save_error: Ошибка сохранения комментария + destroyed: Комментарий удален + + activerecord: + attributes: + comment: + body: Содержание + user: Автор diff --git a/config/locales/event_log.en.yml b/config/locales/models/event_log.en.yml similarity index 85% rename from config/locales/event_log.en.yml rename to config/locales/models/event_log.en.yml index e7584a599..ac04b8aa2 100644 --- a/config/locales/event_log.en.yml +++ b/config/locales/models/event_log.en.yml @@ -48,3 +48,20 @@ en: versions_list: version list status: the status of the assembly project_build: build package + + layout: + event_logs: + list: List + list_header: Event log + + activerecord: + models: + event_log: Event log + attributes: + event_log: + kind: Event type + created_at: Event date and time + user: User + ip: User IP + protocol: Access protocol + description: Description diff --git a/config/locales/event_log.ru.yml b/config/locales/models/event_log.ru.yml similarity index 84% rename from config/locales/event_log.ru.yml rename to config/locales/models/event_log.ru.yml index 4ff644004..68a1d390a 100644 --- a/config/locales/event_log.ru.yml +++ b/config/locales/models/event_log.ru.yml @@ -48,3 +48,20 @@ ru: versions_list: список версий status: статус сборки project_build: сборка пакета + + layout: + event_logs: + list: Список + list_header: Лог событий + + activerecord: + models: + event_log: Лог событий + attributes: + event_log: + kind: Тип события + created_at: Дата и время события + user: Пользователь + ip: IP пользователя + protocol: Протокол доступа + description: Описание события diff --git a/config/locales/groups.en.yml b/config/locales/models/group.en.yml similarity index 67% rename from config/locales/groups.en.yml rename to config/locales/models/group.en.yml index b80db4833..139645c8f 100644 --- a/config/locales/groups.en.yml +++ b/config/locales/models/group.en.yml @@ -12,6 +12,12 @@ en: back_to_the_list: ⇐ List of groups confirm_delete: Are you sure to remove this group? edit_members: Edit members + group: Group + description: Descripton + leave_group: Leave group + projects_list: Projects list + public_profile: Public profile + delete_warning: Attention! Deleted group can not be restored! members: back_to_group: Back to group @@ -21,6 +27,12 @@ en: input_username: Username flash: + group: + saved: Group saved + save_error: Group saves error + destroyed: Group deleted + user_uname_exists: User already exists + members: successfully_changed: Members list successfully changed error_in_changing: Members list changing error @@ -29,6 +41,8 @@ en: already_added: User already added activerecord: + models: + group: Group attributes: group: name: Name @@ -36,3 +50,4 @@ en: owner: Owner created_at: Created updated_at: Updated + description: Description diff --git a/config/locales/groups.ru.yml b/config/locales/models/group.ru.yml similarity index 98% rename from config/locales/groups.ru.yml rename to config/locales/models/group.ru.yml index 00b9f12bb..231f95c53 100644 --- a/config/locales/groups.ru.yml +++ b/config/locales/models/group.ru.yml @@ -26,7 +26,6 @@ ru: add_member: Добавить участника input_username: Псевдоним пользователя - flash: group: saved: Группа успешно сохранена @@ -41,9 +40,9 @@ ru: error_in_adding: Ошибка при добавлении участника already_added: Пользователь уже добавлен - - activerecord: + models: + group: Группа attributes: group: name: Название diff --git a/config/locales/issues.en.yml b/config/locales/models/issue.en.yml similarity index 100% rename from config/locales/issues.en.yml rename to config/locales/models/issue.en.yml diff --git a/config/locales/issues.ru.yml b/config/locales/models/issue.ru.yml similarity index 100% rename from config/locales/issues.ru.yml rename to config/locales/models/issue.ru.yml diff --git a/config/locales/models/platform.en.yml b/config/locales/models/platform.en.yml new file mode 100644 index 000000000..4025ff4b8 --- /dev/null +++ b/config/locales/models/platform.en.yml @@ -0,0 +1,66 @@ +en: + layout: + platforms: + admin_id: Owner + build_all: Build all + list: List + new: Create + edit: Edit + new_header: New platform + edit_header: Edit + list_header: Platforms + list_header_main: General + list_header_personal: Personal + list_header_all: All + clone_header: Platform clone + show: Platform + projects: Projects + products: Products + location: Location + repositories: Repositories + back_to_the_list: ⇐To platform list + freeze: Freeze + unfreeze: Unfeeze + confirm_freeze: Are you sure to freeze this platform? + confirm_freeze: Are you sure to clone this platform? + confirm_unfreeze: Are you sure to defrost this platform? + released_suffix: (released) + confirm_delete: Are you sure to delete this platform? + current_platform_header: Current platform + owner: Owner + visibility: Visibility + platform_type: Platform type + distrib_type: Distribution kit type + private_users: Access data + confirm_clone: To clone? + clone: To clone + + flash: + platform: + saved: Platform saved + save_error: Platform saves error + freezed: Platform freezed + freeze_error: Platform freezing error, try again + unfreezed: Platform unfreezed + unfreeze_error: Platform unfreezing error, try again + destroyed: Platform deleted + build_all_success: All project build in progress + clone_success: Cloned successfully + + activerecord: + models: + platform: Platform + attributes: + platform: + name: Name + description: Description + parent_platform_id: Parent platform + parent: Parent platform + released: Released + created_at: Created + updated_at: Updated + distrib_type: Source type + visibility: Status + visibility_types: + open: Open + hidden: Hidden diff --git a/config/locales/models/platform.ru.yml b/config/locales/models/platform.ru.yml new file mode 100644 index 000000000..3aecfc0a9 --- /dev/null +++ b/config/locales/models/platform.ru.yml @@ -0,0 +1,66 @@ +ru: + layout: + platforms: + admin_id: Владелец + build_all: Собрать все + list: Список + new: Создать + edit: Редактировать + new_header: Новая платформа + edit_header: Редактировать + list_header: Платформы + list_header_main: Основные + list_header_personal: Персональные + list_header_all: Все + clone_header: Клонирование платформы + show: Платформа + projects: Проекты + products: Продукты + location: Расположение + repositories: Репозитории + back_to_the_list: ⇐ К списку платформ + freeze: Заморозить + unfreeze: Разморозить + confirm_freeze: Вы уверены, что хотите заморозить эту платформу? + confirm_freeze: Вы уверены, что хотите клонировать эту платформу? + confirm_unfreeze: Вы уверены, что хотите разморозить эту платформу? + released_suffix: (выпущена) + confirm_delete: Вы уверены, что хотите удалить эту платформу? + current_platform_header: Текущая платформа + owner: Владелец + visibility: Видимость + platform_type: Тип платформы + distrib_type: Тип дистрибутива + private_users: Данные для доступа + confirm_clone: Клонировать? + clone: Клонировать + + flash: + platform: + saved: Платформа успешно добавлена + save_error: Не удалось создать платформу + freezed: Платформа успешно заморожена + freeze_error: Не удалось заморозить платформу, попробуйте еще раз + unfreezed: Платформа успешно разморожена + unfreeze_error: Не удалось разморозить платформу, попробуйте еще раз + destroyed: Платформа успешно удалена + build_all_success: Все проекты успешно отправлены на сборку + clone_success: Клонирование успешно + + activerecord: + models: + platform: Платформа + attributes: + platform: + name: Название + description: Описание + parent_platform_id: Родительская платформа + parent: Родительская платформа + released: Released + created_at: Создана + updated_at: Обновлена + distrib_type: Тип дистрибутива + visibility: Статус + visibility_types: + open: Открытый + hidden: Закрытый diff --git a/config/locales/models/product.en.yml b/config/locales/models/product.en.yml new file mode 100644 index 000000000..5670d6618 --- /dev/null +++ b/config/locales/models/product.en.yml @@ -0,0 +1,55 @@ +en: + layout: + products: + list: List + new: New product + list_header: Products + clone: Clone + build: Build + new_header: New product + edit_header: Product editing + confirm_delete: Are you sure to delete this product? + + cron_tab_generator: + show: Show cron tab the generator + hide: Hide cron tab the generator + choose: Choose + every_minute: Every minute + every_hour: Every hour + every_day: Every day + every_month: Every month + every_weekday: Every weekdays + minutes: Minutes + hours: Hours + days: Days + months: Months + weekdays: weekdays + + flash: + product: + saved: Product saved + save_error: Product saves error + build_started: Product build started + destroyed: Product deleted + build_list_delete: Product build list deleted + + activerecord: + models: + product: Product + attributes: + product: + name: Name + platform_id: Platform + build_status: Build status + build_path: ISO path + created_at: Created + updated_at: Updated + ks: Content .ks.template + counter: Content .counter + build_script: Content build + menu: Content .menu.xml + tar: Tar.bz2 file + is_template: Template + system_wide: System + cron_tab: Cront tab + use_cron: Cron usage diff --git a/config/locales/models/product.ru.yml b/config/locales/models/product.ru.yml new file mode 100644 index 000000000..d53a389d9 --- /dev/null +++ b/config/locales/models/product.ru.yml @@ -0,0 +1,55 @@ +ru: + layout: + products: + list: Список + new: Новый продукт + list_header: Продукты + clone: Клонировать + build: Собрать + new_header: Новый продукт + edit_header: Редактирование продукта + confirm_delete: Вы уверены, что хотите удалить этот продукт? + + cron_tab_generator: + show: Показать cron tab генератор + hide: Спрятать cron tab генератор + choose: Выберите + every_minute: Каждую минуту + every_hour: Каждый час + every_day: Каждый день + every_month: Каждый месяц + every_weekday: Каждый день недели + minutes: Минуты + hours: Часы + days: Дни + months: Месяцы + weekdays: Дни недели + + flash: + product: + saved: Продукт успешно сохранен + save_error: Не удалось сохранить изменения + build_started: Запущена сборка продукта + destroyed: Продукт удален + build_list_delete: Сборочный лист продукта удален + + activerecord: + models: + product: Продукт + attributes: + product: + name: Название + platform_id: Платформа + build_status: Статус последней сборки + build_path: Путь к iso + created_at: Создан + updated_at: Обновлен + ks: Содержимое .ks.template + counter: Содержимое .counter + build_script: Содержимое build + menu: Содержимое .menu.xml + tar: Tar.bz2 файл + is_template: Шаблон + system_wide: Общесистемный + cron_tab: Cront tab + use_cron: Использовать крон diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml new file mode 100644 index 000000000..add8be4fe --- /dev/null +++ b/config/locales/models/project.en.yml @@ -0,0 +1,77 @@ +en: + layout: + projects: + add: Add + edit: Edit + list: List + list_header: Projects + edit_header: Edit the project + show: Project + build: Build + new_build: New build %{project_name} + confirm_delete: Are you sure to delete this project? + new: New project + new_header: New project + new_header: New project + location: Location + git_repo_location: Path to git repo + current_project_header: Current project + current_build_lists: Current builds + build_button: Start build + add_collaborators: Add collaborators + members: Members + collaborators: Collaborators + groups: Groups + edit_collaborators: Edit collaborators + issues: Issues + wiki: Wiki + delete_warning: Attention! Deleted project can not be restored! + sections: Sections + has_issue_description: Issues adds lightweight issue tracking tightly integrated with your repository. Add issues to milestones, label issues, and close & reference issues from commit messages. + has_wiki_description: Wikis are the simplest way to let others contribute content. Any user can create and edit pages to use for documentation, examples, support or anything you wish. + + diff_show_header: "%{files} with %{additions} and %{deletions}." + about_subheader: "About project" + last_commit: "Last commit" + + filename: File + age: Modification date + message: Message + author: Author + + current_branch: Current branch + current_commit: Current commit + files_in_project: Files in + + flash: + project: + saved: Project saved + save_error: Project saves error + save_warning_ssh_key: Owner of the project must specify in profile a SSH key + destroyed: Project deleted + forked: Project forked + fork_error: Project fork error + + activerecord: + models: + project: Project + attributes: + project: + category_id: Category + name: Name + description: Descripton + owner: Owner + visibility: Visibility + visibility_types: + open: Open + hidden: Hidden + repository_id: Repository + repository: Repository + created_at: Created + updated_at: Updated + has_issues: Tracker on + has_wiki: Wiki on + srpm: Import code from src.rpm + who_owns: + me: I + group: Group diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml new file mode 100644 index 000000000..0cdefa439 --- /dev/null +++ b/config/locales/models/project.ru.yml @@ -0,0 +1,77 @@ +ru: + layout: + projects: + add: Добавить + edit: Редактировать + list: Список + list_header: Проекты + edit_header: Редактировать проект + show: Проект + build: Собрать + new_build: Новая сборка %{project_name} + confirm_delete: Вы уверены, что хотите удалить этот проект? + new: Новый проект + new_header: Новый проект + new_header: Новый проект + location: Расположение + git_repo_location: Путь к git-репозиторию + current_project_header: Текущий проект + current_build_lists: Текущие сборки + build_button: Начать сборку + add_collaborators: Добавить коллабораторов + members: Участники + collaborators: Коллабораторы + groups: Группы + edit_collaborators: Изменить список участников + issues: Задачи + wiki: Wiki + delete_warning: Внимание! Удаленный проект восстановлению не подлежит. + sections: Разделы + has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта. + has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость. + + diff_show_header: "%{files} с %{additions} и %{deletions}." + about_subheader: "О проекте" + last_commit: "Последний коммит" + + filename: Файл + age: Дата модификации + message: Сообщение + author: Автор + + current_branch: Текущая ветка + current_commit: Текущий коммит + files_in_project: Файлы в + + flash: + project: + saved: Проект успешно сохранен + save_error: Не удалось сохранить проект + save_warning_ssh_key: Владельцу проекта необходимо указать в профиле свой SSH ключ + destroyed: Проект успешно удален + forked: Проект успешно форкнут + fork_error: Ошибка форка + + activerecord: + models: + project: Проект + attributes: + project: + category_id: Категория + name: Название + description: Описание + owner: Владелец + visibility: Видимость + visibilities: + open: Публичная + hidden: Приватная + repository_id: Репозиторий + repository: Репозиторий + created_at: Создан + updated_at: Обновлен + has_issues: Включить трэкер + has_wiki: Включить Wiki + srpm: Импортировать код из src.rpm + who_owns: + me: Я + group: Группа diff --git a/config/locales/models/repository.en.yml b/config/locales/models/repository.en.yml new file mode 100644 index 000000000..ccfa02b8d --- /dev/null +++ b/config/locales/models/repository.en.yml @@ -0,0 +1,45 @@ +en: + layout: + repositories: + list: List + list_header: Repositories + new: New repository + new_header: New repository + show: Repository + location: Location + projects: Projects + new_header: New repository + back_to_the_list: ⇐ List of repositories + confirm_delete: Are you sure to delete this repository? + current_repository_header: Current repository + + personal_repositories: + settings_header: Settings + change_visibility_from_hidden: Replace the status to "Opened" + change_visibility_from_open: Replace the status to "Private" + settings: Settings + show: My repository + private_users: Private repository users + + flash: + repository: + saved: Repository added + save_error: Repository adding error + destroyed: Repository deleted + project_added: Project added on repository + project_not_added: Project adding error. In this repository already is a project with such name. First remove the old project + project_removed: Project deleted + project_not_removed: Project deleting failed + + activerecord: + models: + repository: Repository + attributes: + repository: + name: Name + description: Description + platform_id: Platform + platform: Platform + created_at: Created + updated_at: Updated + owner: Owner diff --git a/config/locales/models/repository.ru.yml b/config/locales/models/repository.ru.yml new file mode 100644 index 000000000..87bca736f --- /dev/null +++ b/config/locales/models/repository.ru.yml @@ -0,0 +1,45 @@ +ru: + layout: + repositories: + list: Список + list_header: Репозитории + new: Новый репозиторий + new_header: Новый репозиторий + show: Репозиторий + location: Расположение + projects: Проекты + new_header: Новый репозиторий + back_to_the_list: ⇐ К списку репозиториев + confirm_delete: Вы уверены, что хотите удалить этот репозиторий? + current_repository_header: Текущий репозиторий + + personal_repositories: + settings_header: Настройки + change_visibility_from_hidden: Сменить статус на "Открытый" + change_visibility_from_open: Сменить статус на "Приватный" + settings: Настройки + show: Мой репозиторий + private_users: Пользователи приватного репозитория + + flash: + repository: + saved: Репозиторий успешно добавлен + save_error: Не удалось добавить репозиторий + destroyed: Репозиторий успешно удален + project_added: Проект добавлен к репозиторию + project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект + project_removed: Проект удален из репозитория + project_not_removed: Не удалось удалить проект из репозитория + + activerecord: + models: + repository: Репозиторий + attributes: + repository: + name: Название + description: Описание + platform_id: Платформа + platform: Платформа + created_at: Создан + updated_at: Обновлен + owner: Владелец diff --git a/config/locales/models/user.en.yml b/config/locales/models/user.en.yml new file mode 100644 index 000000000..f7583331f --- /dev/null +++ b/config/locales/models/user.en.yml @@ -0,0 +1,41 @@ +en: + layout: + users: + list: List + new: Create + edit: Edit + new_header: New user + edit_header: Edit + list_header: Users + groups: Groups + show: User + back_to_the_list: ⇐ List of users + confirm_delete: Are you sure to remove this user? + own_projects: My projects + part_projects: Participate projects + filter_header: Filter + + flash: + user: + saved: User saved + save_error: User data saves error + destroyed: User account deleted + + activerecord: + models: + user: User + attributes: + user: + name: User + login: Nickname or Email + email: Email + uname: Nickname + ssh_key: SSH key + current_password: Current password + role: Role + created_at: Created + updated_at: Updated + role: System role + language: Language + password: Password + password_confirm: Confirmation diff --git a/config/locales/models/user.ru.yml b/config/locales/models/user.ru.yml new file mode 100644 index 000000000..50c44c434 --- /dev/null +++ b/config/locales/models/user.ru.yml @@ -0,0 +1,41 @@ +ru: + layout: + users: + list: Список + new: Создать + edit: Редактировать + new_header: Новый пользователь + edit_header: Редактировать + list_header: Пользователи + groups: Группы + show: Пользователь + back_to_the_list: ⇐ К списку пользователей + confirm_delete: Вы уверены, что хотите удалить этого пользователя? + own_projects: Мои проекты + part_projects: Участвую в проектах + filter_header: Фильтр + + flash: + user: + saved: Пользователь успешно сохранен + save_error: Не удалось сохранить данные о пользователе + destroyed: Учетная запись успешно удалена + + activerecord: + models: + user: Пользователь + attributes: + user: + name: Имя + login: Псевдоним или Email + email: Email + uname: Никнейм + ssh_key: SSH ключ + current_password: Текущий пароль + role: Роль + created_at: Создан + updated_at: Обновлен + role: Роль в системе + language: Язык + password: Пароль + password_confirm: Повторите пароль diff --git a/config/locales/ru.yml b/config/locales/ru.yml index bccb71891..0563af77c 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -23,6 +23,7 @@ ru: show: Просмотр cancel: Отмена create: Создать + update: Обновить delete: Удалить save: Сохранить search: Искать @@ -37,7 +38,6 @@ ru: false_: Нет publish: Опубликовать add: Добавить - update: Обновить upload: Загрузить not_access: Нет доступа! owner: Владелец @@ -50,7 +50,7 @@ ru: edit_header: Настройки оповещений processing: Обрабатывается... invalid_content_type: имеет неверный тип - + devise: shared_links: sign_in: Войти @@ -109,126 +109,6 @@ ru: edit_header: Редактировать категорию confirm_delete: Вы уверены, что хотите удалить эту категорию? - comments: - confirm_delete: Вы уверены, что хотите удалить комментарий? - new_header: Новый комментарий - edit_header: Редактирование комментария - - platforms: - admin_id: Владелец - build_all: Собрать все - list: Список - new: Создать - edit: Редактировать - new_header: Новая платформа - edit_header: Редактировать - list_header: Платформы - list_header_main: Основные - list_header_personal: Персональные - list_header_all: Все - clone_header: Клонирование платформы - show: Платформа - projects: Проекты - products: Продукты - location: Расположение - repositories: Репозитории - back_to_the_list: ⇐ К списку платформ - freeze: Заморозить - unfreeze: Разморозить - confirm_freeze: Вы уверены, что хотите заморозить эту платформу? - confirm_freeze: Вы уверены, что хотите клонировать эту платформу? - confirm_unfreeze: Вы уверены, что хотите разморозить эту платформу? - released_suffix: (выпущена) - confirm_delete: Вы уверены, что хотите удалить эту платформу? - current_platform_header: Текущая платформа - owner: Владелец - visibility: Видимость - platform_type: Тип платформы - distrib_type: Тип дистрибутива - private_users: Данные для доступа - confirm_clone: Клонировать? - clone: Клонировать - - event_logs: - list: Список - list_header: Лог событий - - repositories: - list: Список - list_header: Репозитории - new: Новый репозиторий - new_header: Новый репозиторий - show: Репозиторий - location: Расположение - projects: Проекты - new_header: Новый репозиторий - back_to_the_list: ⇐ К списку репозиториев - confirm_delete: Вы уверены, что хотите удалить этот репозиторий? - current_repository_header: Текущий репозиторий - - personal_repositories: - settings_header: Настройки - change_visibility_from_hidden: Сменить статус на "Открытый" - change_visibility_from_open: Сменить статус на "Приватный" - settings: Настройки - show: Мой репозиторий - private_users: Пользователи приватного репозитория - - products: - list: Список - new: Новый продукт - list_header: Продукты - clone: Клонировать - build: Собрать - new_header: Новый продукт - edit_header: Редактирование продукта - confirm_delete: Вы уверены, что хотите удалить этот продукт? - - cron_tab_generator: - show: Показать cron tab генератор - hide: Спрятать cron tab генератор - choose: Выберите - every_minute: Каждую минуту - every_hour: Каждый час - every_day: Каждый день - every_month: Каждый месяц - every_weekday: Каждый день недели - minutes: Минуты - hours: Часы - days: Дни - months: Месяцы - weekdays: Дни недели - - projects: - add: Добавить - edit: Редактировать - list: Список - list_header: Проекты - edit_header: Редактировать проект - show: Проект - build: Собрать - new_build: Новая сборка %{project_name} - confirm_delete: Вы уверены, что хотите удалить этот проект? - new: Новый проект - new_header: Новый проект - new_header: Новый проект - location: Расположение - git_repo_location: Путь к git-репозиторию - current_project_header: Текущий проект - current_build_lists: Текущие сборки - build_button: Начать сборку - add_collaborators: Добавить коллабораторов - members: Участники - collaborators: Коллабораторы - groups: Группы - edit_collaborators: Изменить список участников - issues: Задачи - wiki: Wiki - delete_warning: Внимание! Удаленный проект восстановлению не подлежит. - sections: Разделы - has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта. - has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость. - collaborators: back_to_proj: Вернуться к проекту edit: Редактировать список @@ -246,21 +126,6 @@ ru: writer: Писатель admin: Админ - users: - list: Список - new: Создать - edit: Редактировать - new_header: Новый пользователь - edit_header: Редактировать - list_header: Пользователи - groups: Группы - show: Пользователь - back_to_the_list: ⇐ К списку пользователей - confirm_delete: Вы уверены, что хотите удалить этого пользователя? - own_projects: Мои проекты - part_projects: Участвую в проектах - filter_header: Фильтр - git: repositories: empty: "Репозиторий пуст. Если вы клонировали(Fork) проект или импортировали пакет, данные скоро появятся" @@ -318,60 +183,6 @@ ru: save_error: Не удалось сохранить категорию destroyed: Категория успешно удалена - comment: - saved: Комментарий успешно сохранен - save_error: Ошибка сохранения комментария - destroyed: Комментарий удален - - project: - saved: Проект успешно сохранен - save_error: Не удалось сохранить проект - save_warning_ssh_key: Владельцу проекта необходимо указать в профиле свой SSH ключ - destroyed: Проект успешно удален - forked: Проект успешно форкнут - fork_error: Ошибка форка - - user: - saved: Пользователь успешно сохранен - save_error: Не удалось сохранить данные о пользователе - destroyed: Учетная запись успешно удалена - - repository: - saved: Репозиторий успешно добавлен - save_error: Не удалось добавить репозиторий - destroyed: Репозиторий успешно удален - project_added: Проект добавлен к репозиторию - project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект - project_removed: Проект удален из репозитория - project_not_removed: Не удалось удалить проект из репозитория - - product: - saved: Продукт успешно сохранен - save_error: Не удалось сохранить изменения - build_started: Запущена сборка продукта - destroyed: Продукт удален - build_list_delete: Сборочный лист продукта удален - - platform: - saved: Платформа успешно добавлена - save_error: Не удалось создать платформу - freezed: Платформа успешно заморожена - freeze_error: Не удалось заморозить платформу, попробуйте еще раз - unfreezed: Платформа успешно разморожена - unfreeze_error: Не удалось разморозить платформу, попробуйте еще раз - destroyed: Платформа успешно удалена - build_all_success: Все проекты успешно отправлены на сборку - clone_success: Клонирование успешно - - wiki: - ref_not_exist: Версия не существует - successfully_updated: Страница '%{name}' успешно обновлена - duplicate_page: Страница '%{name}' уже существует - page_successfully_removed: Страница успешно удалена - page_not_found: Страница '%{name}' не найдена. - revert_success: Изменения успешно откачены - patch_does_not_apply: Не удалось откатить изменения - blob: successfully_updated: Файл '%{name}' успешно обновлен updating_error: Ошибка обновления файла '%{name}' @@ -394,22 +205,13 @@ ru: models: category: Категория - repository: Репозиторий arch: Arch container: Container - platform: Платформа - group: Группа - event_log: Лог событий - project: Проект rpm: RPM - user: Пользователь private_user: Приватный пользователь - product: Продукт product_build_list: Сборочный лист продукта download: Статистика auto_build_list: Автоматическая пересборка пакетов - settings: - notifier: Настройки оповещений attributes: settings: @@ -433,10 +235,6 @@ ru: arch_id: Архитектура arch: Архитектура - comment: - body: Содержание - user: Автор - private_user: login: Логин password: Пароль @@ -445,32 +243,6 @@ ru: parent_id: Родитель name: Название - repository: - name: Название - description: Описание - platform_id: Платформа - platform: Платформа - created_at: Создан - updated_at: Обновлен - owner: Владелец - - product: - name: Название - platform_id: Платформа - build_status: Статус последней сборки - build_path: Путь к iso - created_at: Создан - updated_at: Обновлен - ks: Содержимое .ks.template - counter: Содержимое .counter - build_script: Содержимое build - menu: Содержимое .menu.xml - tar: Tar.bz2 файл - is_template: Шаблон - system_wide: Общесистемный - cron_tab: Cront tab - use_cron: Использовать крон - arch: name: Название created_at: Создана @@ -485,48 +257,6 @@ ru: created_at: Создан updated_at: Обновлен - platform: - name: Название - description: Описание - parent_platform_id: Родительская платформа - parent: Родительская платформа - released: Released - created_at: Создана - updated_at: Обновлена - distrib_type: Тип дистрибутива - visibility: Статус - visibility_types: - open: Открытый - hidden: Закрытый - - event_log: - kind: Тип события - created_at: Дата и время события - user: Пользователь - ip: IP пользователя - protocol: Протокол доступа - description: Описание события - - project: - category_id: Категория - name: Название - description: Описание - owner: Владелец - visibility: Видимость - visibilities: - open: Публичная - hidden: Приватная - repository_id: Репозиторий - repository: Репозиторий - created_at: Создан - updated_at: Обновлен - has_issues: Включить трэкер - has_wiki: Включить Wiki - srpm: Импортировать код из src.rpm - who_owns: - me: Я - group: Группа - rpm: name: Название arch_id: Arch @@ -536,28 +266,6 @@ ru: created_at: Создан updated_at: Обновлен - role: - name: Название - on: Ведомый - to: Ведущий - use_default: По умолчанию - use_default_for_owner: По умолчанию для владельца - - user: - name: Имя - login: Псевдоним или Email - email: Email - uname: Никнейм - ssh_key: SSH ключ - current_password: Текущий пароль - role: Роль - created_at: Создан - updated_at: Обновлен - role: Роль в системе - language: Язык - password: Пароль - password_confirm: Повторите пароль - product_build_list: id: Id product: Продукт @@ -571,4 +279,3 @@ ru: distro: Дистрибутив platform: Архитектура counter: Закачки - diff --git a/config/locales/wiki.en.yml b/config/locales/wiki.en.yml index 24f5a9511..994ba84f3 100644 --- a/config/locales/wiki.en.yml +++ b/config/locales/wiki.en.yml @@ -63,3 +63,13 @@ en: # Welcome to **Wiki** # Edit this page and create new ones. + + flash: + wiki: + ref_not_exist: No such version + successfully_updated: Page '%{name}' successfully updated + duplicate_page: Page '%{name}' already exists + page_successfully_removed: Page successfully removed + page_not_found: Page '%{name}' not found + revert_success: Changes successfully reverted + patch_does_not_apply: Patch does not apply diff --git a/config/locales/wiki.ru.yml b/config/locales/wiki.ru.yml index df50dd5e7..7b7f81ab6 100644 --- a/config/locales/wiki.ru.yml +++ b/config/locales/wiki.ru.yml @@ -63,3 +63,13 @@ ru: # Добро пожаловать в **Wiki** # Отредактируйте эту страницу и создайте новые. + + flash: + wiki: + ref_not_exist: Версия не существует + successfully_updated: Страница '%{name}' успешно обновлена + duplicate_page: Страница '%{name}' уже существует + page_successfully_removed: Страница успешно удалена + page_not_found: Страница '%{name}' не найдена. + revert_success: Изменения успешно откачены + patch_does_not_apply: Не удалось откатить изменения diff --git a/db/schema.rb b/db/schema.rb index 30578adab..164a98f94 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,22 +17,14 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "user_id", :null => false t.string "kind" t.text "data" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "activity_feeds", :force => true do |t| - t.integer "user_id", :null => false - t.string "kind" - t.text "data" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "arches", :force => true do |t| t.string "name", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true @@ -41,8 +33,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "user_id" t.string "provider" t.string "uid" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true @@ -53,8 +45,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "arch_id" t.integer "pl_id" t.integer "bpl_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "build_list_items", :force => true do |t| @@ -62,8 +54,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "level" t.integer "status" t.integer "build_list_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "version" end @@ -77,8 +69,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "project_id" t.integer "arch_id" t.datetime "notified_at" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" @@ -101,16 +93,16 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "name" t.string "ancestry" t.integer "projects_count", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "comments", :force => true do |t| t.string "commentable_type" t.integer "user_id" t.text "body" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.decimal "commentable_id", :precision => 50, :scale => 0 end @@ -118,8 +110,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "name", :null => false t.integer "project_id", :null => false t.integer "owner_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "delayed_jobs", :force => true do |t| @@ -131,8 +123,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.datetime "locked_at" t.datetime "failed_at" t.string "locked_by" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "queue" end @@ -144,8 +136,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "distro" t.string "platform" t.integer "counter", :default => 0 - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "event_logs", :force => true do |t| @@ -160,14 +152,14 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "controller" t.string "action" t.text "message" - t.datetime "created_at" - t.datetime "updated_at" + 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" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "uname" t.integer "own_projects_count", :default => 0, :null => false t.text "description" @@ -180,8 +172,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "title" t.text "body" t.string "status", :default => "open" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "creator_id" t.datetime "closed_at" t.integer "closed_by" @@ -212,8 +204,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "description" t.string "name" t.integer "parent_platform_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "released", :default => false t.integer "owner_id" t.string "owner_type" @@ -226,8 +218,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "platform_id" t.string "login" t.string "password" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "user_id" end @@ -235,8 +227,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "product_id" t.integer "status", :default => 2, :null => false t.datetime "notified_at" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id" @@ -246,8 +238,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.integer "platform_id", :null => false t.integer "build_status", :default => 2, :null => false t.string "build_path" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "build_script" t.text "counter" t.text "ks" @@ -267,8 +259,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "name" t.string "version" t.datetime "file_mtime" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "platform_id" end @@ -277,14 +269,14 @@ ActiveRecord::Schema.define(:version => 20120302102734) do create_table "project_to_repositories", :force => true do |t| t.integer "project_id" t.integer "repository_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "projects", :force => true do |t| t.string "name" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open" @@ -301,6 +293,9 @@ ActiveRecord::Schema.define(:version => 20120302102734) 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| t.string "name" t.string "email" @@ -321,16 +316,16 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "object_type" t.integer "target_id" t.string "target_type" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false 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" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "name", :null => false end @@ -338,8 +333,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.string "name", :null => false t.integer "arch_id", :null => false t.integer "project_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "rpms", ["project_id", "arch_id"], :name => "index_rpms_on_project_id_and_arch_id" @@ -352,8 +347,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do t.boolean "new_comment_reply", :default => true t.boolean "new_issue", :default => true t.boolean "issue_assign", :default => true - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false 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 @@ -362,8 +357,8 @@ ActiveRecord::Schema.define(:version => 20120302102734) do create_table "subscribes", :force => true do |t| t.string "subscribeable_type" t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "status", :default => true t.integer "project_id" t.decimal "subscribeable_id", :precision => 50, :scale => 0 @@ -371,25 +366,20 @@ ActiveRecord::Schema.define(:version => 20120302102734) do create_table "users", :force => true do |t| 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 "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" + t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "ssh_key" 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.string "language", :default => "en" + t.integer "own_projects_count", :default => 0, :null => false end - add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true add_index "users", ["uname"], :name => "index_users_on_uname", :unique => true diff --git a/script/delayed_job b/script/delayed_job index da53fc1ff..526e4170f 100755 --- a/script/delayed_job +++ b/script/delayed_job @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -ENV['RAILS_ENV'] ||= "production" +# ENV['RAILS_ENV'] ||= "production" require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) require 'delayed/command' Delayed::Command.new(ARGV).daemonize diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 4238babf8..04b71c40d 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -6,8 +6,8 @@ describe GroupsController do stub_rsync_methods @group = Factory(:group) @another_user = Factory(:user) - @create_params = {:group => {:name => 'grp1', :uname => 'un_grp1'}} - @update_params = {:group => {:name => 'grp2'}} + @create_params = {:group => {:description => 'grp1', :uname => 'un_grp1'}} + @update_params = {:group => {:description => 'grp2'}} end context 'for guest' do diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb index b6b592409..57dee6213 100644 --- a/spec/factories/group_factory.rb +++ b/spec/factories/group_factory.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- Factory.define(:group) do |g| - g.name { Factory.next(:string) } g.uname { Factory.next(:uname) } + g.description 'Description' g.association :owner, :factory => :user end From 13f0d8223d23bdf6c3c1494174fe4d0546ef6a6c Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 3 Mar 2012 02:42:10 +0200 Subject: [PATCH 74/77] Remove compass-bootstrap. Take back DJ fix. Refs #263 --- Gemfile | 1 - Gemfile.lock | 3 --- app/assets/stylesheets/design/common.scss | 4 ---- script/delayed_job | 2 +- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 9b638d81b..b947d6b69 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,6 @@ group :assets do gem 'sass-rails', '~> 3.2.4' gem 'coffee-rails', '~> 3.2.2' gem 'compass-rails', '~> 1.0.0.rc.3' - gem 'compass_twitter_bootstrap', '~> 2.0.1.2' gem 'uglifier', '~> 1.2.1' gem 'therubyracer', '~> 0.9.10' end diff --git a/Gemfile.lock b/Gemfile.lock index fe06f3d6b..dc37fd324 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,8 +95,6 @@ GEM sass (~> 3.1) compass-rails (1.0.0.rc.3) compass (~> 0.12.rc.0) - compass_twitter_bootstrap (2.0.1.2) - compass creole (0.4.2) daemons (1.1.6) delayed_job (3.0.1) @@ -312,7 +310,6 @@ DEPENDENCIES capistrano_colors coffee-rails (~> 3.2.2) compass-rails (~> 1.0.0.rc.3) - compass_twitter_bootstrap (~> 2.0.1.2) creole daemons (= 1.1.6) delayed_job_active_record (~> 0.3.2) diff --git a/app/assets/stylesheets/design/common.scss b/app/assets/stylesheets/design/common.scss index b3bc37c8c..991c793d9 100644 --- a/app/assets/stylesheets/design/common.scss +++ b/app/assets/stylesheets/design/common.scss @@ -1,7 +1,3 @@ -//@import "compass"; -//@import "compass_twitter_bootstrap"; -//@import "compass_twitter_bootstrap_responsive"; - @import 'compass/utilities/tables'; table.info { width: 100%; diff --git a/script/delayed_job b/script/delayed_job index 526e4170f..da53fc1ff 100755 --- a/script/delayed_job +++ b/script/delayed_job @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -# ENV['RAILS_ENV'] ||= "production" +ENV['RAILS_ENV'] ||= "production" require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) require 'delayed/command' Delayed::Command.new(ARGV).daemonize From a0f0c24f88d646728e8232809985c0c68b431a79 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 3 Mar 2012 03:05:19 +0200 Subject: [PATCH 75/77] Fix flash messages. Add styles. Refs #263 --- app/assets/stylesheets/design/custom.scss | 2 ++ app/controllers/groups_controller.rb | 2 +- app/controllers/projects_controller.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 2b0f028c4..75a786165 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -283,6 +283,8 @@ div.comment div.comment-right { float: right; } +div.comment textarea { resize: none } + #repo-wrapper div.file div.data .formatted { overflow-x: auto; overflow-y: none; diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 9dad1d7b0..09b12a4eb 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -46,7 +46,7 @@ class GroupsController < ApplicationController redirect_to group_path(@group) else flash[:error] = t('flash.group.save_error') - flash[:warning] = @group.errors[:base] + flash[:warning] = @group.errors.full_messages.join('. ') render :action => :new end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ecc700762..738bdf950 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -52,7 +52,7 @@ class ProjectsController < ApplicationController redirect_to @project else flash[:error] = t('flash.project.save_error') - flash[:warning] = @project.errors[:base] + flash[:warning] = @project.errors.full_messages.join('. ') render :action => :new end end From ce633f5838d528901ed38ed98120063bcac61c8f Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 3 Mar 2012 03:34:24 +0200 Subject: [PATCH 76/77] Fix group owner. Refs #232 --- app/controllers/groups_controller.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 09b12a4eb..c1effe3dd 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -35,11 +35,7 @@ class GroupsController < ApplicationController def create @group = Group.new params[:group] - @group.owner = if parent? and parent.is_a? User - parent - else - current_user - end + @group.owner = current_user if @group.save flash[:notice] = t('flash.group.saved') From 0c194f5b507cd2b539ce1247b7cfdc7871430657 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 3 Mar 2012 03:54:56 +0200 Subject: [PATCH 77/77] Fix DJ deploy callbacks. Remove capistrano-ext. Refs #263 --- Gemfile | 1 - Gemfile.lock | 3 --- config/deploy.rb | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index b947d6b69..af5c5b47a 100644 --- a/Gemfile +++ b/Gemfile @@ -62,7 +62,6 @@ group :development do # deploy gem 'whenever', :require => false gem 'capistrano', :require => false - gem 'capistrano-ext', :require => false gem 'cape', :require => false gem 'capistrano_colors', :require => false end diff --git a/Gemfile.lock b/Gemfile.lock index dc37fd324..a5090aea5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,8 +76,6 @@ GEM net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) - capistrano-ext (1.2.1) - capistrano (>= 1.0.0) capistrano_colors (0.5.5) chronic (0.6.7) chunky_png (1.2.5) @@ -306,7 +304,6 @@ DEPENDENCIES cancan (~> 1.6.7) cape capistrano - capistrano-ext capistrano_colors coffee-rails (~> 3.2.2) compass-rails (~> 1.0.0.rc.3) diff --git a/config/deploy.rb b/config/deploy.rb index ac2b9ba34..d6b03af8a 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -69,8 +69,8 @@ after "deploy:setup", "deploy:symlink_pids" # after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart" # DJ -# after "deploy:stop", "delayed_job:stop" -# after "deploy:start", "delayed_job:start" +after "deploy:stop", "delayed_job:stop" +after "deploy:start", "delayed_job:start" # after "deploy:restart", "delayed_job:restart" after "deploy:restart", "deploy:cleanup"