From c17630408861774a71b04ed16737f707db290bf4 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 5 Mar 2012 13:11:50 +0400 Subject: [PATCH 01/41] Add first version of new design to activity feed. Add new scope to BuildList model. Fix one moment into observer. --- app/helpers/activity_feeds_helper.rb | 2 +- app/models/activity_feed_observer.rb | 6 +-- app/models/build_list.rb | 1 + app/views/activity_feeds/_sidebar.html.haml | 47 +++++++++++++++++++ app/views/activity_feeds/index.html.haml | 27 +++-------- .../_git_delete_branch_notification.haml | 16 +++++-- .../partials/_git_new_push_notification.haml | 24 +++++++--- .../partials/_issue_assign_notification.haml | 16 +++++-- .../partials/_new_comment_notification.haml | 21 +++++++-- .../_new_commit_comment_notification.haml | 21 +++++++-- .../partials/_new_issue_notification.haml | 16 +++++-- .../partials/_new_user_notification.haml | 20 ++++++-- .../_wiki_new_commit_notification.haml | 19 +++++++- config/locales/models/activity_feed.en.yml | 5 ++ config/locales/models/activity_feed.ru.yml | 11 +++-- 15 files changed, 192 insertions(+), 60 deletions(-) create mode 100644 app/views/activity_feeds/_sidebar.html.haml diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb index f3facbf94..8880830d7 100644 --- a/app/helpers/activity_feeds_helper.rb +++ b/app/helpers/activity_feeds_helper.rb @@ -1,5 +1,5 @@ module ActivityFeedsHelper def render_activity_feed(activity_feed) - render :partial => activity_feed.partial, :locals => activity_feed.data + render :partial => activity_feed.partial, :locals => activity_feed.data.merge(:activity_feed => activity_feed) end end diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index d6dad75b0..0c7f21dbc 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -18,7 +18,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', - :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} + :data => {:user_name => record.user.name, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} ) end @@ -58,7 +58,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ) end end - + when 'GitHook' change_type = record.change_type branch_name = record.refname.match(/\/([\w\d]+)$/)[1] @@ -86,7 +86,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/models/build_list.rb b/app/models/build_list.rb index 6fdedf10e..4b585a73b 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -62,6 +62,7 @@ class BuildList < ActiveRecord::Base where(["status in (?) OR (status in (?) AND notified_at >= ?)", [WAITING_FOR_RESPONSE, BUILD_PENDING, BuildServer::BUILD_STARTED], outdatable_statuses, Time.now - 2.days]) } scope :for_status, lambda {|status| where(:status => status) } + scope :for_user, lambda { |user| where(:user_id => user.id) } scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) } scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) } scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) } diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/activity_feeds/_sidebar.html.haml new file mode 100644 index 000000000..49cee5b82 --- /dev/null +++ b/app/views/activity_feeds/_sidebar.html.haml @@ -0,0 +1,47 @@ +.bordered + = link_to t("layout.activity_feed.new_project"), new_project_path, :class => 'button' + %h3= t("layout.activity_feed.my_last_projects") + %table + %tbody + - current_user.projects.each do |project| + %tr + %td + - if project.public? + = image_tag("unlock.png") + - else + = image_tag("lock.png") + %td + = link_to "#{project.owner.uname}/#{project.name}", project_path(project) + %tr + %td + \  + %td + = link_to t("layout.activity_feed.all_my_projects"), projects_path +.block + %h3= t("layout.activity_feed.my_builds_by_day") + %table{:cellpadding => "0", :cellspacing => "0"} + %tbody + %tr + %td.first + = link_to t("layout.build_lists.statuses.#{:build_published}"), build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED}) + %td= BuildList.for_status(BuildList::BUILD_PUBLISHED).for_user(current_user).count + %tr + %td.first + = link_to t("layout.build_lists.statuses.#{:success}"), build_lists_path(:filter => {:status => BuildServer::SUCCESS}) + %td= BuildList.for_status(BuildServer::SUCCESS).for_user(current_user).count + %tr + %td.first + = link_to t("layout.build_lists.statuses.#{:build_started}"), build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED}) + %td= BuildList.for_status(BuildServer::BUILD_STARTED).for_user(current_user).count + %tr + %td.first + = link_to t("layout.build_lists.statuses.#{:build_pending}"), build_lists_path(:filter => {:status => BuildList::BUILD_PENDING}) + %td= BuildList.for_status(BuildList::BUILD_PENDING).for_user(current_user).count + %tr + %td.first + = link_to t("layout.build_lists.statuses.#{:build_error}"), build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR}) + %td= BuildList.for_status(BuildServer::BUILD_ERROR).for_user(current_user).count + %tr + %td.first + = link_to t("layout.activity_feed.all_my_builds"), build_lists_path + %td   diff --git a/app/views/activity_feeds/index.html.haml b/app/views/activity_feeds/index.html.haml index 838d9a62a..4ea9e88fa 100644 --- a/app/views/activity_feeds/index.html.haml +++ b/app/views/activity_feeds/index.html.haml @@ -1,21 +1,6 @@ -%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 - = render_activity_feed(activity_feed) - %br - %br - %br +%h3.fix= t("layout.activity_feed.header") +- @activity_feeds.each do |activity_feed| + .activity + = render_activity_feed(activity_feed) + +- content_for :sidebar, render('sidebar') 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 10acc1d61..b9d99b35f 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,13 @@ -%p== Branch #{ branch_name } has been deleted - -%p== Into project #{ link_to(project_name, project_path(project_id)) } +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject Branch #{ branch_name } has been deleted + .both +.fulltext + 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 46a62e834..a39159ef6 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,7 +1,19 @@ -%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| - = link_to commit[0], commit_path(project_id, commit[0]) - = commit[1] +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject Branch #{ branch_name } has been #{ change_type }d + .both +.fulltext + Into project #{ link_to(project_name, project_path(project_id)) } %br + %br + - last_commits.each do |commit| + = link_to commit[0], commit_path(project_id, commit[0]) + = commit[1] + %br diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml index f3ddea3b2..b4df281fd 100644 --- a/app/views/activity_feeds/partials/_issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -1,3 +1,13 @@ -%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))) +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) } + .both +.fulltext + = 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 index 23c15ef74..57ce1ff34 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -1,5 +1,16 @@ -%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 }" +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } + .both +.fulltext + = raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) + %br + %br + "#{ 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 index 32826e333..82f012c70 100644 --- a/app/views/activity_feeds/partials/_new_commit_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_commit_comment_notification.haml @@ -1,5 +1,16 @@ -%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 }" +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject #{ t("notifications.bodies.new_commit_comment_notification.title", :user_name => user_name) } + .both +.fulltext + = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))}) + %br + %br + "#{ 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 6f1666c74..f2af553bd 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -1,3 +1,13 @@ -%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))) +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } + .both +.fulltext + = 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 index 98d4796e9..b65b2a477 100644 --- a/app/views/activity_feeds/partials/_new_user_notification.haml +++ b/app/views/activity_feeds/partials/_new_user_notification.haml @@ -1,5 +1,15 @@ -%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) } \ No newline at end of file +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } + .both +.fulltext + #{ t("notifications.bodies.new_user_notification.content") } + %br + #{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) } diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index eb33be273..76db7f9ad 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -1,2 +1,17 @@ -%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)) } +.top + .image + = image_tag(gravatar_url(activity_feed.user.email, 30)) + .text + %span.name + = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + %br + %span.date= activity_feed.created_at + %br + %span.subject + -#TODO: Fix wiki compare routes. + -# 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) } + .both +.fulltext + -#TODO: Fix wiki compare routes. + -#%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) } + Into project #{ link_to(project_name, project_path(project_id)) } diff --git a/config/locales/models/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml index 0839059c2..273c3c1ce 100644 --- a/config/locales/models/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -2,6 +2,11 @@ en: layout: activity_feed: header: Activity Feed + my_last_projects: My last projects + all_my_projects: All my projects + all_my_builds: All my builds + my_builds_by_day: My buils for last 24 hours + new_project: Create project notifications: subjects: diff --git a/config/locales/models/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml index 04b065970..fd040d964 100644 --- a/config/locales/models/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -1,7 +1,12 @@ ru: layout: - activity_feed: - header: Лента активности + activity_feed: + header: Лента активности + my_last_projects: Мои последние проекты + all_my_projects: Все мои проекты + all_my_builds: Все мои сборки + my_builds_by_day: Мои сборки за 24 часа + new_project: Создать проект notifications: subjects: @@ -28,4 +33,4 @@ ru: issue_assign_notification: title: Здравствуйте, %{user_name}. content: Вам была назначена задача %{issue_link} - invite_approve_notification: Приглашение в ABF \ No newline at end of file + invite_approve_notification: Приглашение в ABF From 9558a1d65f307b1c26f47762a33a736a9366546a Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 5 Mar 2012 20:36:58 +0400 Subject: [PATCH 02/41] [refs #265] Fix wiki history link --- .../partials/_wiki_new_commit_notification.haml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 76db7f9ad..471056bad 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -8,10 +8,7 @@ %span.date= activity_feed.created_at %br %span.subject - -#TODO: Fix wiki compare routes. - -# 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) } + User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", history_project_wiki_index_path(project_id) } .both .fulltext - -#TODO: Fix wiki compare routes. - -#%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) } Into project #{ link_to(project_name, project_path(project_id)) } From 9214f79d914fca0d0418be1acf27326a8c5318cf Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 5 Mar 2012 20:48:59 +0400 Subject: [PATCH 03/41] [refs #265] Fix one more wiki compare route --- config/routes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index b79b1131c..3535be950 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,7 +114,8 @@ Rosa::Application.routes.draw do match ':ref' => 'wiki#show', :as => :versioned, :via => :get post :compare - match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get + #match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get + match 'compare/:versions' => 'wiki#compare', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get end end resources :issues, :except => :edit do From de0f7c83c8fc1372f834dd1dba1a96b7578de040 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Mar 2012 14:37:04 +0600 Subject: [PATCH 04/41] [refs #265] fix hook and add execute bit for it --- app/models/project.rb | 3 ++- lib/tasks/hook.rake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 72b3f57fe..52ea9a7c7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -262,10 +262,11 @@ 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} && #{is_production ? 'RAILS_ENV=production' : ''} 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) + f.chmod(0775) end hook_file = File.join(path, 'hooks', 'post-receive') diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index d41bbafdb..42b629791 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -6,10 +6,11 @@ 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} && #{is_production ? 'RAILS_ENV=production' : ''} 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) + f.chmod(0775) end say "Install process.." From 4f995ca548146878c55f6d2cac8f2bd14c8eb5ff Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Mar 2012 15:39:23 +0600 Subject: [PATCH 05/41] [refs #265] hook mode 775 -> 755 --- app/models/project.rb | 2 +- lib/tasks/hook.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 52ea9a7c7..8e5e6269e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -266,7 +266,7 @@ class Project < ActiveRecord::Base s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) - f.chmod(0775) + f.chmod(0755) end hook_file = File.join(path, 'hooks', 'post-receive') diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index 42b629791..aa4636739 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -10,7 +10,7 @@ namespace :hook do s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) - f.chmod(0775) + f.chmod(0755) end say "Install process.." From f54d889f74aed593dbdbcd72e31b1e2d44bcf4e7 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 6 Mar 2012 18:04:05 +0400 Subject: [PATCH 06/41] [refs #265] Fix activity partials messages and locales. Fix observer. --- app/models/activity_feed_observer.rb | 18 ++++++++------- app/models/user.rb | 2 +- .../_git_delete_branch_notification.haml | 4 ++-- .../partials/_git_new_push_notification.haml | 4 ++-- .../partials/_issue_assign_notification.haml | 4 ++-- .../partials/_new_comment_notification.haml | 4 ++-- .../_new_commit_comment_notification.haml | 4 ++-- .../partials/_new_issue_notification.haml | 4 ++-- .../_wiki_new_commit_notification.haml | 9 ++++---- config/locales/models/activity_feed.en.yml | 15 ++++++++----- config/locales/models/activity_feed.ru.yml | 22 ++++++++++--------- 11 files changed, 48 insertions(+), 42 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 0c7f21dbc..ff191ef64 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -18,7 +18,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', - :data => {:user_name => record.user.name, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} + :data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} ) end @@ -27,7 +27,7 @@ class ActivityFeedObserver < ActiveRecord::Observer 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} + :data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title} ) end @@ -40,7 +40,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_notification', - :data => {:user_name => subscribe.user.name, :comment_body => record.body, :issue_title => record.commentable.title, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id} ) end @@ -53,7 +53,7 @@ class ActivityFeedObserver < ActiveRecord::Observer 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, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :comment_body => record.body, :commit_message => record.commentable.message.encode_to_default, :commit_id => record.commentable.id, :project_id => record.project.id} ) end @@ -67,13 +67,15 @@ class ActivityFeedObserver < ActiveRecord::Observer #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' + last_commits = project.git_repository.repo.log(branch_name, nil).first(3) + first_commiter = User.find_by_email(last_commits[0].author.email) if last_commits.size > 0 + last_commits = last_commits.collect do |commit| #:author => 'author' [commit.sha, commit.message] end if change_type == 'delete' kind = 'git_delete_branch_notification' - options = {:project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} + options = {:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email, :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} @@ -98,7 +100,7 @@ class ActivityFeedObserver < ActiveRecord::Observer 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} + :data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id, :project_name => project_name, :commit_sha => commit_sha} ) end end @@ -112,7 +114,7 @@ class ActivityFeedObserver < ActiveRecord::Observer 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} + :data => {:user_name => record.user.name, :user_email => record.user.email, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title} ) end end diff --git a/app/models/user.rb b/app/models/user.rb index 44deb7fd1..841dd1c37 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,7 +31,7 @@ class User < ActiveRecord::Base validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } validate { errors.add(:uname, :taken) if Group.where('uname LIKE ?', uname).present? } - validates :ssh_key, :uniqueness => true, :allow_blank => true + #validates :ssh_key, :uniqueness => true, :allow_blank => true validates :role, :inclusion => {:in => ROLES}, :allow_blank => true validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true 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 b9d99b35f..fa193e2cb 100644 --- a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml +++ b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml @@ -1,9 +1,9 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + =# image_tag(gravatar_url(activity_feed.user.email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + =# link_to activity_feed.user.uname, user_path(activity_feed.user.uname) %br %span.date= activity_feed.created_at %br 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 a39159ef6..9f7de7eeb 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,9 +1,9 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(gravatar_url(user_email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + = link_to user_name, user_path(user_id) %br %span.date= activity_feed.created_at %br diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml index b4df281fd..4bd61663d 100644 --- a/app/views/activity_feeds/partials/_issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -7,7 +7,7 @@ %br %span.date= activity_feed.created_at %br - %span.subject #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) } + %span.subject= raw t("notifications.bodies.issue_assign_notification.title", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))) .both .fulltext - = raw t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))) + =# 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 index 57ce1ff34..cf44cb4a5 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -1,9 +1,9 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(gravatar_url(user_email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + = link_to user_name, user_path(user_id) %br %span.date= activity_feed.created_at %br diff --git a/app/views/activity_feeds/partials/_new_commit_comment_notification.haml b/app/views/activity_feeds/partials/_new_commit_comment_notification.haml index 82f012c70..583a75e1e 100644 --- a/app/views/activity_feeds/partials/_new_commit_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_commit_comment_notification.haml @@ -1,9 +1,9 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(gravatar_url(user_email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + = link_to user_name, user_path(user_id) %br %span.date= activity_feed.created_at %br diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml index f2af553bd..2e718a019 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -1,9 +1,9 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(gravatar_url(user_email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + = link_to user_name, user_path(user_id) %br %span.date= activity_feed.created_at %br diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 471056bad..4a85dd81c 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -1,14 +1,13 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(gravatar_url(user_email, 30)) .text %span.name - = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) + = link_to user_name, user_path(user_id) %br %span.date= activity_feed.created_at %br - %span.subject - User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", history_project_wiki_index_path(project_id) } + %span.subject #{ t("notifications.bodies.wiki_new_commit_notification.title", :user_name => user_name) } .both .fulltext - Into project #{ link_to(project_name, project_path(project_id)) } + = raw t("notifications.bodies.wiki_new_commit_notification.content", {:history_link => link_to("wiki", history_project_wiki_index_path(project_id)), :project_link => link_to(project_name, project_path(project_id)) }) diff --git a/config/locales/models/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml index 273c3c1ce..ee50f9f0c 100644 --- a/config/locales/models/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -19,17 +19,20 @@ en: bodies: new_comment_notification: - title: Hello, %{user_name}. - content: To the issue %{issue_link} added a comment. + title: User %{user_name} has been added a new comment. + content: Issue %{issue_link} 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} + title: User %{user_name} has been added an issue. + content: Project %{project_link}. 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} + title: You have been assigned to issue %{issue_link} + wiki_new_commit_notification: + title: User has been updated wiki + content: This %{history_link} has been changed into project %{project_link} + invite_approve_notification: Invite to ABF diff --git a/config/locales/models/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml index fd040d964..9f97b53c7 100644 --- a/config/locales/models/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -18,19 +18,21 @@ ru: invite_approve_notification: Приглашение в ABF bodies: - new_comment_notification: - title: Здравствуйте, %{user_name}. - content: К задаче %{issue_link} был добавлен новый комментарий. + new_comment_notification: + title: Пользователь %{user_name} добавил новый комментарий + content: Задача %{issue_link} commit_content: К коммиту %{commit_link} был добавлен новый комментарий. - new_issue_notification: - title: Здравствуйте, %{user_name}. - content: К проекту %{project_link} была добавлена задача %{issue_link} - new_user_notification: + 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} + issue_assign_notification: + title: Вам была назначена задача %{issue_link} + wiki_new_commit_notification: + title: Пользователь обновил wiki + content: Изменил %{history_link} в проекте %{project_link} invite_approve_notification: Приглашение в ABF From 7e53a6c511ebab7aaf660903de489cf323615de2 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 6 Mar 2012 18:57:05 +0400 Subject: [PATCH 07/41] [refs #265] Fix git push and delete branch partials and logic --- app/models/activity_feed_observer.rb | 5 ++-- .../_git_delete_branch_notification.haml | 12 +++------ .../partials/_git_new_push_notification.haml | 27 ++++++++++++------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index ff191ef64..81372b994 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -68,17 +68,18 @@ class ActivityFeedObserver < ActiveRecord::Observer project = Project.find_by_name(record.repo) last_commits = project.git_repository.repo.log(branch_name, nil).first(3) - first_commiter = User.find_by_email(last_commits[0].author.email) if last_commits.size > 0 + first_commiter = User.find_by_email(last_commits[0].author.email) unless last_commits.blank? last_commits = last_commits.collect do |commit| #:author => 'author' [commit.sha, commit.message] end if change_type == 'delete' kind = 'git_delete_branch_notification' - options = {:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email, :project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} + 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} + options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email}) if first_commiter end project.owner_and_admin_ids.each do |recipient| 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 fa193e2cb..47907b719 100644 --- a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml +++ b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml @@ -1,13 +1,7 @@ .top - .image - =# image_tag(gravatar_url(activity_feed.user.email, 30)) - .text - %span.name - =# link_to activity_feed.user.uname, user_path(activity_feed.user.uname) - %br - %span.date= activity_feed.created_at - %br - %span.subject Branch #{ branch_name } has been deleted + %span.date= activity_feed.created_at + %br + %span.subject Branch #{ branch_name } has been deleted .both .fulltext 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 9f7de7eeb..0e70af5fc 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,15 +1,22 @@ -.top - .image - = image_tag(gravatar_url(user_email, 30)) - .text - %span.name - = link_to user_name, user_path(user_id) - %br - %span.date= activity_feed.created_at +- if defined? user_email + .top + .image + = image_tag(gravatar_url(user_email, 30)) + .text + %span.name + = link_to user_name, user_path(user_id) %br - %span.subject Branch #{ branch_name } has been #{ change_type }d - .both + %span.date= activity_feed.created_at + %br + %span.subject Branch #{ branch_name } has been #{ change_type }d + .both .fulltext + - unless defined? user_email + %span.date= activity_feed.created_at + %br + Branch #{ branch_name } has been #{ change_type }d + %br + %br Into project #{ link_to(project_name, project_path(project_id)) } %br %br From 872132d8a6d083a7947ab6f97f8d88ce8f4751dc Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 00:20:14 +0600 Subject: [PATCH 08/41] [refs #265] fix find owner and project --- app/models/activity_feed_observer.rb | 12 ++++-------- app/models/git_hook.rb | 5 +++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 81372b994..22d7ee954 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -62,12 +62,8 @@ class ActivityFeedObserver < ActiveRecord::Observer 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) + last_commits = record.project.git_repository.repo.log(branch_name, nil).first(3) first_commiter = User.find_by_email(last_commits[0].author.email) unless last_commits.blank? last_commits = last_commits.collect do |commit| #:author => 'author' [commit.sha, commit.message] @@ -75,14 +71,14 @@ class ActivityFeedObserver < ActiveRecord::Observer if change_type == 'delete' kind = 'git_delete_branch_notification' - options = {:project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type} + options = {:project_id => record.project.id, :project_name => record.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} + options = {:project_id => record.project.id, :project_name => record.project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type} options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email}) if first_commiter end - project.owner_and_admin_ids.each do |recipient| + record.project.owner_and_admin_ids.each do |recipient| ActivityFeed.create( :user => User.find(recipient), :kind => kind, diff --git a/app/models/git_hook.rb b/app/models/git_hook.rb index 1e45ee672..2f39d9cbf 100644 --- a/app/models/git_hook.rb +++ b/app/models/git_hook.rb @@ -5,8 +5,9 @@ class GitHook def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type) @repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type - @owner = User.find_by_uname owner_uname - @project = @owner.projects.where(:name => repo).first + if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first + @project = @owner.projects.where(:name => repo).first + end @change_type = git_change_type git_revision_types commit_type From 0f823bd9f3ab1877abf3a529521c22c4bcc09be8 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 02:51:51 +0600 Subject: [PATCH 09/41] [refs #265] fix security & commit to comments --- app/controllers/comments_controller.rb | 43 +++++++++----------------- app/models/ability.rb | 3 +- app/models/comment.rb | 9 ++---- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9953154da..35fb65746 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,12 +1,11 @@ # -*- encoding : utf-8 -*- class CommentsController < ApplicationController before_filter :authenticate_user! - before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy] - #before_filter :find_project, :only => [:index, :edit] - before_filter :find_comment, :only => [:edit, :update, :destroy] - authorize_resource :only => [:show, :edit, :update, :destroy] - authorize_resource :project, :only => [:index] + load_resource :project + before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy] + before_filter :find_comment, :only => [:edit, :update, :destroy] + authorize_resource def index @comments = @commentable.comments @@ -14,8 +13,11 @@ class CommentsController < ApplicationController def create @comment = @commentable.comments.build(params[:comment]) if @commentable.class == Issue - @comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id.hex, :commentable_type => @commentable.class.name, :project => @project)) if @commentable.class == Grit::Commit - @comment.user = current_user + if @commentable.class == Grit::Commit + @comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id.hex, :commentable_type => @commentable.class.name)) + @comment.project = @project + end + @comment.user_id = current_user.id if @comment.save flash[:notice] = I18n.t("flash.comment.saved") redirect_to commentable_path @@ -54,23 +56,12 @@ class CommentsController < ApplicationController private - def find_commentable - #params.each do |name, value| - # if name =~ /(.+)_id$/ - # return $1.classify.constantize.find(value) - # end - #end - #nil - if params[:issue_id].present? - return Issue.find_by_serial_id_and_project_id(params[:issue_id], params[:project_id]) - elsif params[:commit_id].present? - return @project.git_repository.commit(params[:commit_id]) - end - end - def set_commentable - find_project - @commentable = find_commentable + @commentable = if params[:issue_id].present? + @project.issues.find_by_serial_id params[:issue_id] + elsif params[:commit_id].present? + @project.git_repository.commit params[:commit_id] + end end def find_comment @@ -81,12 +72,6 @@ class CommentsController < ApplicationController end end - def find_project - @project = Project.find(params[:project_id]) - end - - protected - def commentable_path @commentable.class == Issue ? [@project, @commentable] : commit_path(@project, @commentable.id) end diff --git a/app/models/ability.rb b/app/models/ability.rb index eaf71d097..1b142f347 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -103,8 +103,7 @@ class Ability can(:create, Comment) {|comment| can? :read, comment.project || comment.commentable.project} can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.project || comment.commentable.project)} - #cannot :manage, Comment, :commentable => {:project => {:has_issues => false}} # switch off issues - cannot(:manage, Comment) {|comment| comment.commentable_type == 'Issue' && !comment.commentable.project.has_issues} # switch off issues + cannot :manage, Comment, :commentable_type => 'Issue', :commentable => {:project => {:has_issues => false}} # switch off issues cannot :manage, RegisterRequest end diff --git a/app/models/comment.rb b/app/models/comment.rb index 85382f129..21b2e8d78 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -8,11 +8,12 @@ class Comment < ActiveRecord::Base default_scope order('created_at') - # FIXME after_create :subscribe_on_reply, :unless => lambda {|c| c.commit_comment?} - after_create :invoke_helper, :if => lambda {|c| c.commit_comment?} + after_create :helper, :if => lambda {|c| c.commit_comment?} after_create :subscribe_users + attr_accessible :body, :commentable_id, :commentable_type + def helper class_eval { def commentable; project.git_repository.commit(commentable_id.to_s(16)); end } if commit_comment? end @@ -35,10 +36,6 @@ class Comment < ActiveRecord::Base self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id) end - def invoke_helper - self.helper - end - def subscribe_users if self.commentable.class == Issue self.commentable.subscribes.create(:user => self.user) if !self.commentable.subscribes.exists?(:user_id => self.user.id) From 13ba125dc073140b030f508f370746e573f3761a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 03:49:29 +0600 Subject: [PATCH 10/41] [refs #265] add project_id to comment & fix email notification --- app/controllers/comments_controller.rb | 2 +- app/mailers/user_mailer.rb | 1 + app/models/ability.rb | 2 +- app/models/comment.rb | 2 +- .../20120306212914_add_project_to_comment.rb | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20120306212914_add_project_to_comment.rb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 35fb65746..ce54bab7e 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -3,7 +3,7 @@ class CommentsController < ApplicationController before_filter :authenticate_user! load_resource :project - before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy] + before_filter :set_commentable before_filter :find_comment, :only => [:edit, :update, :destroy] authorize_resource diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 82b8be5b8..d3c150d88 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -13,6 +13,7 @@ class UserMailer < ActionMailer::Base def new_comment_notification(comment, user) @user = user @comment = comment + @comment.helper mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format| format.html end diff --git a/app/models/ability.rb b/app/models/ability.rb index 1b142f347..2b16560fa 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -101,7 +101,7 @@ class Ability can([:update, :destroy], Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)} cannot :manage, Issue, :project => {:has_issues => false} # switch off issues - can(:create, Comment) {|comment| can? :read, comment.project || comment.commentable.project} + can(:create, Comment) {|comment| can? :read, comment.project} can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.project || comment.commentable.project)} cannot :manage, Comment, :commentable_type => 'Issue', :commentable => {:project => {:has_issues => false}} # switch off issues cannot :manage, RegisterRequest diff --git a/app/models/comment.rb b/app/models/comment.rb index 21b2e8d78..e4c4e3c2a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true belongs_to :user - attr_accessor :project + belongs_to :project validates :body, :user_id, :commentable_id, :commentable_type, :presence => true diff --git a/db/migrate/20120306212914_add_project_to_comment.rb b/db/migrate/20120306212914_add_project_to_comment.rb new file mode 100644 index 000000000..4ae6f4b64 --- /dev/null +++ b/db/migrate/20120306212914_add_project_to_comment.rb @@ -0,0 +1,14 @@ +class AddProjectToComment < ActiveRecord::Migration + def up + add_column :comments, :project_id, :integer + Subscribe.reset_column_information + Comment.where(:commentable_type => 'Grit::Commit').destroy_all + Comment.where(:commentable_type => 'Issue').each do |comment| + comment.update_attribute(:project_id, comment.commentable.project) + end + end + + def down + remove_column :comments, :project_id + end +end From 4b173932e568a3cdad711a14e2960f7ba674a09b Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 16:44:42 +0600 Subject: [PATCH 11/41] [refs #194] fix managing issue executor --- app/assets/javascripts/extra/tracker.js | 5 +++-- app/views/issues/_manage_sidebar.html.haml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index 735f9998f..4950086fe 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -171,7 +171,7 @@ $(document).ready(function() { var clone = $(this).clone(); form_new.find('#flag-span').fadeOut(0); form_new.find('#issue_labels').append(clone); - var labels = $('#active_labels'); + var labels = $('.current_labels'); labels.find('#'+$(this).attr('id')).remove(); labels.append(clone); }); @@ -243,7 +243,7 @@ $(document).ready(function() { $('.button.manage_executor').live('click', function() { $('form#search_user, .button.update_executor').fadeIn(0); - $('.current_executor .people').addClass('remove_executor selected'); + $('.current_executor .people').addClass('remove_executor selected').removeClass('nopointer'); $(this).fadeOut(0); }); @@ -259,6 +259,7 @@ $(document).ready(function() { url: form.attr("action"), data: form.serialize(), success: function(data){ + $('.current_executor .people').removeClass('remove_executor selected').addClass('nopointer'); $('form#search_user, .button.update_executor').fadeOut(0); $('.button.manage_executor').fadeIn(0); $('#manage_issue_users_list').html(''); diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/issues/_manage_sidebar.html.haml index f417de58b..2968931c8 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/issues/_manage_sidebar.html.haml @@ -16,7 +16,7 @@ =form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_executor issue'} do |f| .current_executor - if @issue.user - #user-0.people + #user-0.people.nopointer .avatar=image_tag avatar_url(@issue.user), :alt => 'avatar' .name="#{@issue.user.uname} (#{@issue.user.name})" =hidden_field_tag "user-0", @issue.user.id, :name => 'issue[user_id]' From 9a6beef2da311bbaa8873031ce3c187d5cff0c17 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 16:50:45 +0600 Subject: [PATCH 12/41] [refs #194] fix issue managing labels --- app/assets/javascripts/extra/tracker.js | 2 ++ app/views/issues/_manage_sidebar.html.haml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index 4950086fe..a4fea6060 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -249,6 +249,7 @@ $(document).ready(function() { $('.button.manage_labels').live('click', function() { $('form#search_labels, .button.update_labels').fadeIn(0); + $('.current_labels .label').addClass('remove_label selected').removeClass('nopointer'); $(this).fadeOut(0); }); @@ -278,6 +279,7 @@ $(document).ready(function() { url: form.attr("action"), data: form.serialize(), success: function(data){ + $('.current_labels .label').removeClass('remove_label selected').addClass('nopointer'); $('form#search_labels, .button.update_labels').fadeOut(0); $('.button.manage_labels').fadeIn(0); $('#manage_issue_labels_list').html(''); diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/issues/_manage_sidebar.html.haml index 2968931c8..89c8f140d 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/issues/_manage_sidebar.html.haml @@ -41,7 +41,7 @@ =form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_labels issue'} do |f| .current_labels - (@issue.labels || []).each do |label| - .label.selected{:id => "flag#{label.id}"} + .label.nopointer{:id => "flag#{label.id}"} .flag{:style => "display:none; background: ##{label.color}"} .labeltext.selected{:style => "background: ##{label.color}"}=label.name =hidden_field_tag "label-#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]" From c657efc338e18e678d29f295b88a6d537bf957e7 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 19:36:17 +0600 Subject: [PATCH 13/41] [refs #194] show all project labels without searching --- app/assets/javascripts/extra/tracker.js | 11 +++--- app/controllers/issues_controller.rb | 7 +--- app/models/label.rb | 1 + app/views/issues/_manage_sidebar.html.haml | 43 ++++++++++------------ app/views/issues/_search_labels.html.haml | 6 --- config/routes.rb | 1 - 6 files changed, 28 insertions(+), 41 deletions(-) delete mode 100644 app/views/issues/_search_labels.html.haml diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index a4fea6060..3ece43803 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -171,14 +171,13 @@ $(document).ready(function() { var clone = $(this).clone(); form_new.find('#flag-span').fadeOut(0); form_new.find('#issue_labels').append(clone); - var labels = $('.current_labels'); - labels.find('#'+$(this).attr('id')).remove(); - labels.append(clone); + var labels = $('.manage_labels'); + labels.append($(this).find('#'+$(this).attr('id'))); }); $('.remove_label.label.selected').live('click', function() { var id = $(this).attr('id'); - $('.current_labels, #active_labels').find('#'+id+'.label.selected.remove_label').remove(); + $('.manage_labels, #active_labels').find('#'+id+'.label.selected.remove_label').remove(); var form = $('.form.issue'); if(form.find('.remove_label.label.selected').length == 1) { form.find('#flag-span').fadeIn(0); @@ -189,6 +188,7 @@ $(document).ready(function() { label.removeClass('selected').addClass('add_label').removeClass('remove_label'); label.find('.labeltext.selected').attr('style', '').removeClass('selected'); label.find('.flag').fadeIn(0); + $('.manage_labels').find('#'+$(this).attr('id')).remove(); }); $('.issue_status.switch_issue_status').live('click', function () { @@ -249,7 +249,8 @@ $(document).ready(function() { $('.button.manage_labels').live('click', function() { $('form#search_labels, .button.update_labels').fadeIn(0); - $('.current_labels .label').addClass('remove_label selected').removeClass('nopointer'); + $('.current_labels .label .labeltext.selected').parent().addClass('remove_label selected').removeClass('nopointer'); + $('.current_labels .label .labeltext:not(.selected)').parent().addClass('add_label').removeClass('nopointer'); $(this).fadeOut(0); }); diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 16e7acebe..63e8e1e6b 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -68,7 +68,7 @@ class IssuesController < ApplicationController status = 200 if @issue.update_attributes(params[:issue]) render :nothing => true, :status => (status || 500), :layout => false else - render :nothing => true, :status => 200, :layout => false + render :nothing => true, :status => 200, :layout => false end end @@ -102,11 +102,6 @@ class IssuesController < ApplicationController render 'issues/_search_collaborators', :layout => false end - def search_labels - @labels = @project.labels.where("labels.name ILIKE ?", "%#{params[:search_labels]}%").order('labels.name').limit(10) - render 'issues/_search_labels', :layout => false - end - private def load_and_authorize_label diff --git a/app/models/label.rb b/app/models/label.rb index 3bfbab17d..cc031d15a 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -6,4 +6,5 @@ class Label < ActiveRecord::Base validates :name, :uniqueness => { :scope => :project_id} validates :name, :color, :presence => true validates :color, :format => { :with => /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, :message => I18n.t('layout.issues.invalid_labels')} + end diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/issues/_manage_sidebar.html.haml index 89c8f140d..bd70ac04c 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/issues/_manage_sidebar.html.haml @@ -23,7 +23,7 @@ .both - else .people.nopointer - .avatar=image_tag(@issue.user.avatar(25), :alt => 'avatar') + .avatar=image_tag avatar_url(@issue.user), :alt => 'avatar' .name="#{@issue.user.uname} (#{@issue.user.name})" .both =link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_executor") if can_manage @@ -36,26 +36,23 @@ .block %h3=t('layout.issues.labels') - - if @issue.persisted? - - if can_manage - =form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_labels issue'} do |f| - .current_labels - - (@issue.labels || []).each do |label| - .label.nopointer{:id => "flag#{label.id}"} - .flag{:style => "display:none; background: ##{label.color}"} - .labeltext.selected{:style => "background: ##{label.color}"}=label.name - =hidden_field_tag "label-#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]" - .both - - else - - (@issue.labels || []).each do |label| - .label.nopointer - .labeltext.selected{:style => "background: ##{label.color};"} - =label.name - .both - =link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_labels") if can_manage - if can_manage - =form_tag search_labels_project_issues_path(@project), :id => 'search_labels', :method => :get, :style => @issue.persisted? ? 'display:none' : '' do - =tracker_search_field(:search_labels, t('layout.issues.search_labels')) - #manage_issue_labels_list - =render 'issues/search_labels' - =link_to(t('layout.issues.done'), '#', :class => "button tmargin10 update_labels", :style => 'display:none') if can_manage + .current_labels + - (@project.labels || []).each do |label| + - is_issue_label = @issue.labels.include? label + .label{:id => "flag#{label.id}", :class => @issue.persisted? ? 'nopointer' : 'add_label'} + .flag{:style => "background: ##{label.color}; #{is_issue_label ? 'display:none;' : ''}"} + .labeltext{:class => is_issue_label ? 'selected' : '', :style => is_issue_label ? "background: ##{label.color}" : ''}=label.name + .both=hidden_field_tag "flag#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]" + =form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_labels issue'} do |f| + .manage_labels + - @issue.labels.each do |label| + =hidden_field_tag "flag#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]" + - else + - (@issue.labels || []).each do |label| + .label.nopointer + .labeltext.selected{:style => "background: ##{label.color};"}=label.name + .both + - if can_manage && @issue.persisted? + =link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_labels") + =link_to(t('layout.issues.done'), '#', :class => "button tmargin10 update_labels", :style => 'display:none') diff --git a/app/views/issues/_search_labels.html.haml b/app/views/issues/_search_labels.html.haml deleted file mode 100644 index b345a4b24..000000000 --- a/app/views/issues/_search_labels.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -- (@labels || []).each do |label| - .add_label.label{:id => "flag#{label.id}"} - .flag{:style => "background: ##{label.color};"} - .labeltext=label.name - =hidden_field_tag "label-#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]" - .both diff --git a/config/routes.rb b/config/routes.rb index bd091836c..2fe701b6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,7 +125,6 @@ Rosa::Application.routes.draw do collection do post :create_label get :search_collaborators - get :search_labels end end post "labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label From db8e1881ba27866d1983ca5acfdb0a646de34fec Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 20:48:33 +0600 Subject: [PATCH 14/41] [refs #195] change repo url to readonly --- app/views/projects/_repo_block.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index ff7f687a3..9a3bf0b1c 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -1,7 +1,7 @@ .description-top .img= image_tag 'code.png' = text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', - :type => 'text',:spellcheck => 'false', :disabled => 'disabled' + :type => 'text',:spellcheck => 'false', :readonly => true .role = t("layout.read_write_access") = render :partial => 'projects/branch_select', :locals => {:project => project} From b70e8db69555043b3c26fc840207e9052e6e1f09 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 22:04:37 +0600 Subject: [PATCH 15/41] [refs #194] fix selected labels in the index page --- app/views/issues/_labels.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/_labels.html.haml b/app/views/issues/_labels.html.haml index e9e518be9..bd7536170 100644 --- a/app/views/issues/_labels.html.haml +++ b/app/views/issues/_labels.html.haml @@ -3,7 +3,7 @@ #labels-stock =form_tag project_issues_path(@project), :id => 'filter_labels', :method => :get do - @project.labels.each_with_index do |label, index| - .div-tracker-labels{:id => "label-#{label.name}", :style => @labels.include?(label.name) ? "background-color:##{label.color};color:'#FFF'" : ''} + .div-tracker-labels{:id => "label-#{label.name}", :style => @labels.include?(label.name) ? "background-color:##{label.color};color:#FFF" : ''} .div-label-left .label .flag{:id => "flag-#{label.name}", :style => "background-color: ##{label.color};"} From 8df4fdfa5cd47d603ec5d196e130469284c058c5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 22:26:43 +0600 Subject: [PATCH 16/41] [refs #194] remove labels search from js --- app/assets/javascripts/application.js | 4 ---- app/assets/javascripts/extra/tracker.js | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8add68672..7913509af 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -31,10 +31,6 @@ $(document).ready(function() { disableNotifierCbx($(this)); }); - $('div.information > div.user').live('click', function() { - droplist(); - }); - $('div.information > div.profile > a').live('click', function(e) { e.preventDefault(); }); diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index 3ece43803..7543041d2 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -106,7 +106,7 @@ $(document).ready(function() { return false; }; - $('#search_user, #search_labels').live('submit', function() { + $('#search_user').live('submit', function() { var id = $(this).attr('id'); if(id.indexOf('user') != -1) { // FIXME var which = 'users'; @@ -248,7 +248,7 @@ $(document).ready(function() { }); $('.button.manage_labels').live('click', function() { - $('form#search_labels, .button.update_labels').fadeIn(0); + $('.button.update_labels').fadeIn(0); $('.current_labels .label .labeltext.selected').parent().addClass('remove_label selected').removeClass('nopointer'); $('.current_labels .label .labeltext:not(.selected)').parent().addClass('add_label').removeClass('nopointer'); $(this).fadeOut(0); @@ -281,7 +281,7 @@ $(document).ready(function() { data: form.serialize(), success: function(data){ $('.current_labels .label').removeClass('remove_label selected').addClass('nopointer'); - $('form#search_labels, .button.update_labels').fadeOut(0); + $('.button.update_labels').fadeOut(0); $('.button.manage_labels').fadeIn(0); $('#manage_issue_labels_list').html(''); }, From 185962890f06fda2b50a5601555980a3348839a3 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Mar 2012 22:27:12 +0600 Subject: [PATCH 17/41] [refs #194] issue executor --- app/controllers/issues_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 63e8e1e6b..147eaea1e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -38,12 +38,9 @@ class IssuesController < ApplicationController end def create - @user_id = params[:user_id] @user_uname = params[:user_uname] - @issue = @project.issues.new(params[:issue]) @issue.creator_id = current_user.id - @issue.user_id = @user_id if @issue.save @issue.subscribe_creator(current_user.id) From 41cd1ddaf33d5f52a93ae6038b2e2304ed961334 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 7 Mar 2012 23:34:49 +0200 Subject: [PATCH 18/41] Redo cusel assign to avoid side effects. Refactor and cleanup projects controller, routes, views. Apply new design and functionality for projcts list page. Add fork button and fix fork. Apply gap repo during repo fork. Apply attr_accessible for projects. Cleanup locales. Fix new_build link ability check. Refs #195 --- app/assets/javascripts/design/cusel-init.js | 2 +- app/assets/stylesheets/design/custom.scss | 2 + app/controllers/projects_controller.rb | 83 +++---------- app/helpers/projects_helper.rb | 4 + app/models/ability.rb | 1 + app/models/git/repository.rb | 2 +- app/models/project.rb | 5 +- app/views/build_lists/_filter.html.haml | 2 +- app/views/git/blobs/_editor.html.haml | 4 +- app/views/git/blobs/_show.html.haml | 4 +- app/views/git/repositories/_show.html.haml | 4 +- app/views/git/shared/_fork.html.haml | 2 + app/views/projects/_branch_select.html.haml | 3 +- .../projects/_own_projects_sidebar.html.haml | 16 --- app/views/projects/_project.html.haml | 12 +- app/views/projects/index.html.haml | 26 ++-- app/views/projects/new.html.haml | 5 +- app/views/projects/show.html.haml | 59 --------- app/views/search/_form_advanced.html.haml | 2 +- config/initializers/grit.rb | 6 + config/locales/models/project.en.yml | 6 +- config/locales/models/project.ru.yml | 6 +- config/routes.rb | 9 +- db/schema.rb | 117 +++++++++--------- spec/controllers/projects_controller_spec.rb | 4 +- vendor/assets/stylesheets/tablesorter.scss | 2 +- 26 files changed, 135 insertions(+), 253 deletions(-) create mode 100644 app/views/git/shared/_fork.html.haml delete mode 100644 app/views/projects/_own_projects_sidebar.html.haml delete mode 100644 app/views/projects/show.html.haml diff --git a/app/assets/javascripts/design/cusel-init.js b/app/assets/javascripts/design/cusel-init.js index 04a7f7093..c23d47791 100644 --- a/app/assets/javascripts/design/cusel-init.js +++ b/app/assets/javascripts/design/cusel-init.js @@ -1,7 +1,7 @@ jQuery(document).ready(function(){ var params = { - changedEl: ".lineForm select", + changedEl: ".lineForm select.cusel", visRows: 999999, scrollArrows: false } diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index eee5871a1..10698998f 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -442,3 +442,5 @@ table.wiki .history .td2 .name span.username { text-overflow: ellipsis; width: 164px; } + +#fork-and-edit {display:block;} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 738bdf950..abd09025b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,36 +1,11 @@ # -*- encoding : utf-8 -*- class ProjectsController < ApplicationController - is_related_controller! - - belongs_to :user, :group, :polymorphic => true, :optional => true - - before_filter :authenticate_user!, :except => :auto_build - before_filter :find_project, :only => [:show, :edit, :update, :destroy, :fork, :sections] - before_filter :get_paths, :only => [:new, :create, :edit, :update] - + before_filter :authenticate_user! load_and_authorize_resource def index - @projects = if parent? and !parent.nil? - parent.projects - else - Project - end.accessible_by(current_ability) - - @projects = if params[:query] - @projects.by_name("%#{params[:query]}%").order("CHAR_LENGTH(name) ASC") - else - @projects - end.paginate(:page => params[:project_page]) - - @own_projects = current_user.own_projects - #@part_projects = current_user.projects + current_user.groups.map(&:projects).flatten.uniq - @own_projects - end - - def show - @current_build_lists = @project.build_lists.current.recent.paginate :page => params[:page] - @branch = @project.branch(params[:treeish]) - @commit = @branch.present? ? @branch.commit : @git_repository.log(@treeish).first + @projects = current_user.projects.paginate(:page => params[:project_page]) + @projects = @projects.search(params[:query]).search_order if params[:query] end def new @@ -43,7 +18,6 @@ class ProjectsController < ApplicationController def create @project = Project.new params[:project] - #@project.owner = get_owner @project.owner = choose_owner @who_owns = (@project.owner_type == 'User' ? :me : :group) @@ -84,20 +58,6 @@ class ProjectsController < ApplicationController end end - # TODO remove this? - def auto_build - uname, name = params[:git_repo].split('/') - owner = User.find_by_uname(uname) || Group.find_by_uname(uname) - project = Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_name!(name) - project.delay.auto_build # TODO don't queue duplicates - - # p = params.delete_if{|k,v| k == 'controller' or k == 'action'} - # ActiveSupport::Notifications.instrument("event_log.observer", :object => project, :message => p.inspect) - logger.info "Git hook recieved from #{params[:git_user]} to #{params[:git_repo]}" - - render :nothing => true - end - def sections if request.post? if @project.update_attributes(params[:project]) @@ -110,32 +70,19 @@ class ProjectsController < ApplicationController end end + def remove_user + @project.relations.by_object(current_user).destroy_all + flash[:notice] = t("flash.project.user_removed") + redirect_to projects_path + end + protected - def get_paths - if params[:user_id] - @user = User.find params[:user_id] - @projects_path = user_path(@user) # user_projects_path @user - @new_project_path = new_project_path - elsif params[:group_id] - @group = Group.find params[:group_id] - @projects_path = group_path(@group) # group_projects_path @group - @new_projects_path = new_project_path - else - @projects_path = projects_path - @new_projects_path = new_project_path - end - end - - def find_project - @project = Project.find params[:id] - end - - def choose_owner - if params[:who_owns] == 'group' - Group.find(params[:owner_id]) - else - current_user - end + def choose_owner + if params[:who_owns] == 'group' + Group.find(params[:owner_id]) + else + current_user end + end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 1ccda682f..fcb7480f1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -15,4 +15,8 @@ module ProjectsHelper } ) end + + def visibility_icon(visibility) + visibility == 'open' ? 'unlock.png' : 'lock.png' + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 129982a40..8ede800f2 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -53,6 +53,7 @@ class Ability can([:update, :sections, :manage_collaborators], Project) {|project| local_admin? project} can(:fork, Project) {|project| can? :read, project} can(:destroy, Project) {|project| owner? project} + can :remove_user, Project # TODO: Turn on AAA when it will be updated #can :create, AutoBuildList diff --git a/app/models/git/repository.rb b/app/models/git/repository.rb index c1d0fec4d..779876de0 100644 --- a/app/models/git/repository.rb +++ b/app/models/git/repository.rb @@ -18,7 +18,7 @@ class Git::Repository end def repo - @repo ||= Grit::Repo.new(path) + @repo ||= Grit::Repo.new(path) rescue Grit::Repo.new(GAP_REPO_PATH) end # Adds a callback to be fired after update file. diff --git a/app/models/project.rb b/app/models/project.rb index a86a5ba6e..bb189c2c6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -26,10 +26,11 @@ class Project < ActiveRecord::Base validates_attachment_size :srpm, :less_than => 500.megabytes validates_attachment_content_type :srpm, :content_type => ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], :message => I18n.t('layout.invalid_content_type') - #attr_accessible :category_id, :name, :description, :visibility + attr_accessible :name, :description, :visibility, :srpm, :is_rpm, :default_branch, :has_issues, :has_wiki attr_readonly :name scope :recent, order("name ASC") + scope :search_order, order("CHAR_LENGTH(name) ASC") scope :search, lambda {|q| by_name("%#{q}%").open} scope :by_name, lambda {|name| where('projects.name ILIKE ?', name)} scope :by_visibilities, lambda {|v| where(:visibility => v)} @@ -151,7 +152,7 @@ class Project < ActiveRecord::Base end def fork(new_owner) - clone.tap do |c| + dup.tap do |c| c.parent_id = id c.owner = new_owner c.updated_at = nil; c.created_at = nil # :id = nil diff --git a/app/views/build_lists/_filter.html.haml b/app/views/build_lists/_filter.html.haml index 58e62c0f1..2a6ee9f6e 100644 --- a/app/views/build_lists/_filter.html.haml +++ b/app/views/build_lists/_filter.html.haml @@ -15,7 +15,7 @@ .righter= @build_server_status['count_build_task'] .both %br - = link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project => BuildList) + = link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project.build_lists.build) = form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f| .bordered.nopadding diff --git a/app/views/git/blobs/_editor.html.haml b/app/views/git/blobs/_editor.html.haml index 61263d9e3..64c40b743 100644 --- a/app/views/git/blobs/_editor.html.haml +++ b/app/views/git/blobs/_editor.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l - = render :partial => 'git/shared/whereami' + .l= render :partial => 'git/shared/whereami' + = render :partial => 'git/shared/fork' .both = form_tag blob_file_path, :name => 'blob-editor', :method => :put do diff --git a/app/views/git/blobs/_show.html.haml b/app/views/git/blobs/_show.html.haml index 5f21d3b1f..400efbff6 100644 --- a/app/views/git/blobs/_show.html.haml +++ b/app/views/git/blobs/_show.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l - = render :partial => 'git/shared/whereami' + .l= render :partial => 'git/shared/whereami' + = render :partial => 'git/shared/fork' .both - render_way = choose_render_way(@blob) diff --git a/app/views/git/repositories/_show.html.haml b/app/views/git/repositories/_show.html.haml index 11a1e92f4..c3f4229d2 100644 --- a/app/views/git/repositories/_show.html.haml +++ b/app/views/git/repositories/_show.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l - = render :partial => 'git/shared/whereami' + .l= render :partial => 'git/shared/whereami' + = render :partial => 'git/shared/fork' .both %table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"} diff --git a/app/views/git/shared/_fork.html.haml b/app/views/git/shared/_fork.html.haml new file mode 100644 index 000000000..001100dbb --- /dev/null +++ b/app/views/git/shared/_fork.html.haml @@ -0,0 +1,2 @@ +- if can? :fork, @project + .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), fork_project_path(@project), :method => :post, :confirm => t("layout.confirm"), :class => 'button' \ No newline at end of file diff --git a/app/views/projects/_branch_select.html.haml b/app/views/projects/_branch_select.html.haml index 1386e6023..7cb3c150d 100644 --- a/app/views/projects/_branch_select.html.haml +++ b/app/views/projects/_branch_select.html.haml @@ -1,6 +1,5 @@ .lineForm.fork - = select_tag :branch, branch_selector_options(project), - :class => 'sel80', :id => 'branch_selector' + = select_tag :branch, branch_selector_options(project), :id => 'branch_selector', :class => 'sel80' %form{ :action => '', :method => :get, :id => 'branch_changer', :'data-action' => "#{controller_name}"} .fork %p= t("layout.projects.#{params[:commit_hash].present? ? 'current_commit' : 'current_branch'}")+':' diff --git a/app/views/projects/_own_projects_sidebar.html.haml b/app/views/projects/_own_projects_sidebar.html.haml deleted file mode 100644 index 5b7ac9a92..000000000 --- a/app/views/projects/_own_projects_sidebar.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.block.notice - %h3= t("layout.users.own_projects") - .content - %p - %ul - - @own_projects.each do |project| - %li - = link_to project.name, project_path(project) --#.block.notice --# %h3= t("layout.users.part_projects") --# .content --# %p --# %ul --# - @part_projects.each do |project| --# %li --# = link_to project.owner.uname + '/' + project.name, project_path(project) diff --git a/app/views/projects/_project.html.haml b/app/views/projects/_project.html.haml index 6f6c7b68d..af40875a3 100644 --- a/app/views/projects/_project.html.haml +++ b/app/views/projects/_project.html.haml @@ -1,4 +1,8 @@ -%tr{:class => cycle("odd", "even")} - %td= link_to project.name, project_path(project) - %td= project.name - %td= project.description +%tr{:id => "Row#{project_counter}"} + %td + = link_to project do + .table-sort-left= image_tag visibility_icon(project.visibility) + .table-sort-right #{project.owner.uname} / #{project.name} + %td.td2= project.description + %td= t("layout.collaborators.role_names.#{project.relations.by_object(current_user).first.role}") + %td.td5= link_to image_tag('x.png'), remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") \ No newline at end of file diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index 395c9145c..744a114df 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -1,16 +1,12 @@ -.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_project_path - .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 += link_to t('layout.projects.new'), new_project_path, :class => 'button' if can?(:create, Project) -- content_for :sidebar, render(:partial => 'own_projects_sidebar') +%table#myTable.tablesorter{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th.th1= t("activerecord.attributes.project.name") + %th.th2= t("activerecord.attributes.project.description") + %th.th3= t("layout.projects.role") + %th.th4= t("layout.projects.remove_user") + %tbody= render @projects + += will_paginate diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index b540d8a8d..1d919ff29 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -1,7 +1,4 @@ -%h3.bpadding10 - = t("layout.projects.new_header") +%h3.bpadding10= t("layout.projects.new") = form_for @project, :html => { :class => :form, :multipart => true } do |f| = render :partial => "form", :locals => {:f => f} - --# content_for :sidebar, render('sidebar') diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml deleted file mode 100644 index e5c696f5f..000000000 --- a/app/views/projects/show.html.haml +++ /dev/null @@ -1,59 +0,0 @@ -= render :partial => 'projects/submenu' -= render :partial => 'projects/repo_block', :locals => {:project => @project} - -.description - %h3= t("layout.projects.about_subheader") - %p - = @project.description - = link_to t('layout.read_more'), '#' - -%h3= t("layout.projects.last_commit") -- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch) do |presenter| - = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1} - -%h3= t("layout.projects.files_in_project") -.files - .l - = render :partial => 'git/shared/whereami' - - #fork-and-edit.r - %a.button{:href => "#"} Fork and edit -.both - -#repo-wrapper - %table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"} - %thead - %tr - %th.th1.header= t("layout.project.filename") - %th.th2.header= t("layout.project.age") - %th.th3= t("layout.project.message") - %th.th4.header= t("layout.project.author") - %tbody - - if @path.present? - %tr - %td - .pic= image_tag 'folder.png' - .name - = link_to "..", tree_path(@project, @treeish, File.join([@path.dup.encode_to_default, ".."].compact).encode_to_default) - %td==   - %td==   - %td==   - - @project.tree_info(@tree, @treeish, @path).each_pair do |entry, commit| - %tr - %td - - entry_path = File.join([@path.present? ? @path : nil, entry.name].compact).encode_to_default - - if entry.is_a? Grit::Blob - .pic= image_tag 'code.png' - .name - = link_to(entry.name, blob_path(@project, @treeish, entry_path), :class => 'files-see').encode_to_default - - else - .pic= image_tag 'folder.png' - .name - = link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see').encode_to_default - %td - %span{:style => "display: none;"}= commit.committed_date || commit.authored_date#> Dec 31, 2011 - = l(commit.committed_date || commit.authored_date, :format => :short) #31 декабря 2011 - %td - = commit.short_message.encode_to_default #Redo autostart script to start from user - %td - = (commit.committer || commit.author).name.encode_to_default #chipiga diff --git a/app/views/search/_form_advanced.html.haml b/app/views/search/_form_advanced.html.haml index da785c6bc..8a49e7d2d 100644 --- a/app/views/search/_form_advanced.html.haml +++ b/app/views/search/_form_advanced.html.haml @@ -1,5 +1,5 @@ = form_tag search_index_path, :method => 'get' do .leftside= text_field_tag 'query', params[:query], :placeholder => t("layout.search.header"), :class => 'exsearch' - .lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, params[:type]), :class => 'sel80', :id => 'selSearch' + .lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, params[:type]), :class => 'sel80 cusel', :id => 'selSearch' .leftside= submit_tag t("layout.search.header"), :class => 'button width100' .both \ No newline at end of file diff --git a/config/initializers/grit.rb b/config/initializers/grit.rb index 04420c3cb..01d4857f4 100644 --- a/config/initializers/grit.rb +++ b/config/initializers/grit.rb @@ -1,3 +1,9 @@ # -*- encoding : utf-8 -*- require './lib/grit1' + +GAP_REPO_PATH = '/tmp/gap_repo.git' +unless File.directory? GAP_REPO_PATH + Grit::Repo.init_bare(GAP_REPO_PATH) + # FileUtils.chmod "a-w", GAP_REPO_PATH +end diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index add8be4fe..22a8657f9 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -3,6 +3,7 @@ en: projects: add: Add edit: Edit + fork_and_edit: Fork and Edit list: List list_header: Projects edit_header: Edit the project @@ -11,8 +12,6 @@ en: 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 @@ -23,6 +22,8 @@ en: collaborators: Collaborators groups: Groups edit_collaborators: Edit collaborators + role: Project role + remove_user: Leave project issues: Issues wiki: Wiki delete_warning: Attention! Deleted project can not be restored! @@ -51,6 +52,7 @@ en: destroyed: Project deleted forked: Project forked fork_error: Project fork error + user_removed: User successfully removed from project activerecord: models: diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 0cdefa439..f6eb91bcb 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -3,6 +3,7 @@ ru: projects: add: Добавить edit: Редактировать + fork_and_edit: Клонировать и редактировать list: Список list_header: Проекты edit_header: Редактировать проект @@ -11,8 +12,6 @@ ru: new_build: Новая сборка %{project_name} confirm_delete: Вы уверены, что хотите удалить этот проект? new: Новый проект - new_header: Новый проект - new_header: Новый проект location: Расположение git_repo_location: Путь к git-репозиторию current_project_header: Текущий проект @@ -23,6 +22,8 @@ ru: collaborators: Коллабораторы groups: Группы edit_collaborators: Изменить список участников + role: Роль в проекте + remove_user: Покинуть проект issues: Задачи wiki: Wiki delete_warning: Внимание! Удаленный проект восстановлению не подлежит. @@ -51,6 +52,7 @@ ru: destroyed: Проект успешно удален forked: Проект успешно форкнут fork_error: Ошибка форка + user_removed: Пользователь успешно удален из проекта activerecord: models: diff --git a/config/routes.rb b/config/routes.rb index b18b38ef5..21d95352e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -147,18 +147,13 @@ Rosa::Application.routes.draw do post :update end end -# resources :groups, :controller => 'project_groups' do -# end - collection do - get :auto_build - end member do post :fork -# get :new, :controller => 'projects', :action => 'new', :id => /new/, :as => :new get :show, :controller => 'git/trees', :action => :show get :sections post :sections + delete :remove_user end end @@ -189,8 +184,6 @@ Rosa::Application.routes.draw do resources :users, :groups do resources :platforms, :only => [:new, :create] - resources :projects, :only => [:index] - # resources :repositories, :only => [:new, :create] end diff --git a/db/schema.rb b/db/schema.rb index eb223e711..b6c5303f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -23,8 +23,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) do 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 @@ -33,8 +33,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -45,8 +45,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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| @@ -54,8 +54,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -69,8 +69,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -93,16 +93,16 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -110,8 +110,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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| @@ -123,8 +123,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -136,8 +136,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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| @@ -152,14 +152,14 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -172,8 +172,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -204,8 +204,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -218,8 +218,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -227,8 +227,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -238,8 +238,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -259,8 +259,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -269,14 +269,14 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -302,29 +302,30 @@ ActiveRecord::Schema.define(:version => 20120303171802) do 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" 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 @@ -332,8 +333,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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" @@ -346,8 +347,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -356,8 +357,8 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 @@ -365,18 +366,18 @@ ActiveRecord::Schema.define(:version => 20120303171802) 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 "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.integer "own_projects_count", :default => 0, :null => false + t.string "language", :default => "en" + t.integer "own_projects_count", :default => 0, :null => false t.text "professional_experience" t.string "site" t.string "company" diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 6066ba8c1..497c08695 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -77,7 +77,7 @@ describe ProjectsController do it_should_behave_like 'projects user with reader rights' - it 'should be able to perform show action' do + pending 'should be able to perform show action' do get :show, :id => @project.id response.should render_template(:show) end @@ -103,7 +103,7 @@ describe ProjectsController do set_session_for(@admin) end - it 'should return projects in right order' do + pending 'should return projects in right order' do get :index, :query => 'per' assigns(:projects).should eq([@project2, @project1]) end diff --git a/vendor/assets/stylesheets/tablesorter.scss b/vendor/assets/stylesheets/tablesorter.scss index ac5619c59..7757402fa 100644 --- a/vendor/assets/stylesheets/tablesorter.scss +++ b/vendor/assets/stylesheets/tablesorter.scss @@ -84,7 +84,7 @@ table.tablesorter .th2 { table.tablesorter .th3 { width: 110px; - padding-left: 17px; +// padding-left: 17px; } table.tablesorter .td2 { From 41ae79eb4675e92c79dfd9cea475da507f2d682c Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 01:25:17 +0200 Subject: [PATCH 19/41] Add configurable arch parameter to project build_for method. Write rake task for projects build. Refs #282 --- app/models/project.rb | 5 +++-- lib/tasks/build.rake | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 lib/tasks/build.rake diff --git a/app/models/project.rb b/app/models/project.rb index 08e487864..edc3d9a8e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,12 +61,13 @@ class Project < ActiveRecord::Base end end - def build_for(platform, user) + def build_for(platform, user, arch = 'x86_64') # Return i586 after mass rebuild + arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| bl.pl = platform bl.bpl = platform bl.update_type = 'newpackage' - bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild + bl.arch = arch bl.project_version = "latest_#{platform.name}" # "latest_import_mandriva2011" bl.build_requires = false # already set as db default bl.user = user diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake new file mode 100644 index 000000000..c1b057ed0 --- /dev/null +++ b/lib/tasks/build.rake @@ -0,0 +1,25 @@ +require 'highline/import' +require 'open-uri' + +namespace :build do + desc "Build projects from list" + task :projects => :environment do + source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/rebuild_list.txt' + user = User.find_by_uname(ENV['USER'] || 'warpc') + platform = Platform.find_by_name(ENV['PLATFORM'] || 'rosa2012lts') + arch = Arch.find_by_name(ENV['ARCH'] || 'i586') + + say "START build projects from #{source} for platform=#{platform.name}, user=#{user.uname}, arch=#{arch.name}" + open(source).readlines.each do |name| + name.chomp!; name.strip! #; name.downcase! + if p = Project.joins(:repositories).where('repositories.id IN (?)', platform.repositories).find_by_name(name) + p.build_for(platform, user, arch) + say "== Build #{p.name} ==" + else + say "== Not found #{name} ==" + end + sleep 0.2 + end + say 'DONE' + end +end From f6a91ec006ffe9d641b4a6307adcf20e496f07cd Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 01:47:48 +0200 Subject: [PATCH 20/41] Fix rake task. Refs #282 --- lib/tasks/build.rake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index c1b057ed0..b431fd2af 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -5,15 +5,15 @@ namespace :build do desc "Build projects from list" task :projects => :environment do source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/rebuild_list.txt' - user = User.find_by_uname(ENV['USER'] || 'warpc') - platform = Platform.find_by_name(ENV['PLATFORM'] || 'rosa2012lts') - arch = Arch.find_by_name(ENV['ARCH'] || 'i586') + owner = User.find_by_uname!(ENV['OWNER'] || 'warpc') + platform = Platform.find_by_name!(ENV['PLATFORM'] || 'rosa2012lts') + arch = Arch.find_by_name!(ENV['ARCH'] || 'i586') - say "START build projects from #{source} for platform=#{platform.name}, user=#{user.uname}, arch=#{arch.name}" + say "START build projects from #{source} for platform=#{platform.name}, owner=#{owner.uname}, arch=#{arch.name}" open(source).readlines.each do |name| name.chomp!; name.strip! #; name.downcase! if p = Project.joins(:repositories).where('repositories.id IN (?)', platform.repositories).find_by_name(name) - p.build_for(platform, user, arch) + p.build_for(platform, owner, arch) say "== Build #{p.name} ==" else say "== Not found #{name} ==" From 1cf2660cda3664b993b65300d7d5646fc639e0e4 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 02:32:12 +0200 Subject: [PATCH 21/41] Fix search order. Refs #255 --- app/controllers/search_controller.rb | 2 +- app/models/group.rb | 1 + app/models/platform.rb | 1 + app/models/user.rb | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 109dd1f0f..f174a20bc 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -20,6 +20,6 @@ class SearchController < ApplicationController def find_collection(type) var = :"@#{type}" - instance_variable_set var, type.classify.constantize.search(params[:query]).paginate(:page => params[:page]) unless instance_variable_defined?(var) + instance_variable_set var, type.classify.constantize.search(params[:query]).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var) end end diff --git a/app/models/group.rb b/app/models/group.rb index 4e0ce3981..ada4880a1 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -17,6 +17,7 @@ class Group < ActiveRecord::Base 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 :search_order, order("CHAR_LENGTH(uname) ASC") scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")} 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')} diff --git a/app/models/platform.rb b/app/models/platform.rb index fb0ee7f63..5399e9765 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -26,6 +26,7 @@ class Platform < ActiveRecord::Base after_destroy lambda { umount_directory_for_rsync unless hidden? } after_update :update_owner_relation + scope :search_order, order("CHAR_LENGTH(name) ASC") scope :search, lambda {|q| where("name ILIKE ?", "%#{q}%").open} scope :by_visibilities, lambda {|v| where(:visibility => v)} scope :open, where(:visibility => 'open') diff --git a/app/models/user.rb b/app/models/user.rb index d1dd648be..babf50819 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,6 +42,7 @@ class User < ActiveRecord::Base attr_readonly :uname attr_accessor :login + scope :search_order, order("CHAR_LENGTH(uname) ASC") scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")} after_create lambda { self.create_notifier } From cc6390f3a19e525bf421f5905066d37b860091dd Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 16:18:11 +0600 Subject: [PATCH 22/41] [refs #265] fixed partial name --- ...nt_notification.haml => _new_comment_commit_notification.haml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/views/activity_feeds/partials/{_new_commit_comment_notification.haml => _new_comment_commit_notification.haml} (100%) diff --git a/app/views/activity_feeds/partials/_new_commit_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_new_commit_comment_notification.haml rename to app/views/activity_feeds/partials/_new_comment_commit_notification.haml From 66b57f7a0abc0bc51a55e58482a6d2d3eccea6bb Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 17:56:56 +0600 Subject: [PATCH 23/41] [refs #265] fixed issue assignee --- app/controllers/issues_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 16e7acebe..7927378e7 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -38,12 +38,9 @@ class IssuesController < ApplicationController end def create - @user_id = params[:user_id] @user_uname = params[:user_uname] - @issue = @project.issues.new(params[:issue]) @issue.creator_id = current_user.id - @issue.user_id = @user_id if @issue.save @issue.subscribe_creator(current_user.id) From 849cbce91316b7d29bda4032179c1592a2717afa Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 21:30:45 +0600 Subject: [PATCH 24/41] [refs #265] add link to root --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 523926e10..fb0cee5c8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,7 +15,7 @@ .middle %menu = render 'layouts/menu/top' - .logo= image_tag 'logo-mini.png', :alt => 'logo' + .logo= link_to(image_tag 'logo-mini.png', :alt => 'logo'), root_path .information = render 'search/form' .user From e2b3eb7b7ff7f90f3855580c84bbb9951cfe9e75 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Sun, 11 Mar 2012 20:02:07 +0400 Subject: [PATCH 25/41] [Refs #285] Fix current_user avatar for all user, replace button Edit --- app/assets/stylesheets/design/main.scss | 5 +- app/views/users/show.html.haml | 95 +-------------------- doc/design/styles/main.css | 107 +++++++++++++++++++++++- 3 files changed, 112 insertions(+), 95 deletions(-) diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index ca43add8e..8bf6befa7 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -298,7 +298,7 @@ header div.droplist a:hover{ color: #575756; text-decoration: none; height: 34px; - padding: 0px 20px 6px 20px; + padding: 0px 20px 8px 20px; } .sub-menu nav ul li a.active { @@ -651,6 +651,9 @@ article div.all.bigpadding div.rightside { width: 70px; } +a.button.width81 { + width: 81px; +} /* Footer */ diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c15a26a88..a9fd4332d 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,7 @@ .left - = image_tag avatar_url(current_user, :big) + = image_tag avatar_url(@user, :big) + %br + = link_to t("layout.users.edit"), edit_user_path(@user), :class => 'button width81' if can? :edit, @user .left %h3= @user.uname = @user.name @@ -14,96 +16,5 @@ = link_to project.name, project %br - -.left - %br - = link_to t("layout.users.edit"), edit_user_path(@user), :class => 'button' if can? :edit, @user - :javascript $('article .all').addClass('verybigpadding'); - --#.block --# .secondary-navigation --# %ul.wat-cf --# %li.first= link_to t("layout.users.list"), users_path --# %li= link_to t("layout.users.new"), new_user_path --# %li.active= link_to t("layout.users.show"), user_path --# .content --# .inner --# %p --# %b --# Id --# \: --# = @user.id --# %p --# %b --# = t("activerecord.attributes.user.name") --# \: --# = @user.name --# %p --# %b --# = t("activerecord.attributes.user.uname") --# \: --# = @user.uname --# %p --# %b --# = t("activerecord.attributes.user.email") --# \: --# = @user.email --# %p --# %b --# = t("activerecord.attributes.user.created_at") --# \: --# = @user.created_at --# .wat-cf --# - if can? :edit, @user --# = link_to image_tag("code.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_user_path(@user), :class => "button" --# - if can? :destroy, @user --# = link_to image_tag("x.png", :alt => t("layout.delete")) + " " + t("layout.delete"), user_path(@user), :method => "delete", :class => "button", :confirm => t("layout.users.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_user_platform_path(@user) --# .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_user_repository_path(@user) --# .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_project_path --# .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/doc/design/styles/main.css b/doc/design/styles/main.css index 48fb0593d..033707c2e 100644 --- a/doc/design/styles/main.css +++ b/doc/design/styles/main.css @@ -298,7 +298,7 @@ header div.droplist a:hover{ color: #575756; text-decoration: none; height: 34px; - padding: 0px 20px 6px 20px; + padding: 0px 20px 8px 20px; } .sub-menu nav ul li a.active { @@ -651,6 +651,10 @@ article div.all.bigpadding div.rightside { width: 70px; } +a.button.width81 { + width: 81px; +} + /* Footer */ @@ -1936,6 +1940,13 @@ img.delete-row { cursor: pointer; } +table tbody tr.error td { + background: #e7bcbc; +} + +table tbody tr.success td { + background: #e3edb7; +} /* Create group */ @@ -2121,7 +2132,7 @@ div.pagination a { /*404*/ article div.all.error404 { - background: url("../pics/404.png") no-repeat 59% 0; + background: url("../pics/404.png") no-repeat 49% 0; height: 500px; text-align: center; } @@ -2163,6 +2174,98 @@ article div.all.error404 p.search { width: 230px; } +/*500*/ + +article div.all.error500 { + background: url("../pics/500.png") no-repeat 49% 0; + height: 500px; + text-align: center; +} + +article div.all.error500 h1 { + margin: 0; + padding: 0; + margin-top: 135px; + font-size: 48px; + font-weight: normal; +} + +article div.all.error500 h1 span { + color: #4496d0; +} + +article div.all.error500 h2 { + margin: 0; + padding: 0; + margin-top: 5px; + font-size: 18px; + font-weight: normal; + text-align: left; + margin-left: 298px; +} + +article div.all.error500 p { + margin: 0 auto; + padding: 0; + text-align: center; + font-size: 14px; +} + +article div.all.error500 p.pages { + margin-top: 55px; + width: 280px; +} + +article div.all.error500 p.search { + margin-top: 80px; + width: 230px; +} + +/*503*/ + +article div.all.error503 { + background: url("../pics/503.png") no-repeat 50% 0; + height: 500px; + text-align: center; +} + +article div.all.error503 h1 { + margin: 0; + padding: 0; + margin-top: 395px; + font-size: 38px; + font-weight: normal; + text-align: center; + +} + +article div.all.error503 h1 span { + color: #4496d0; +} + +article div.all.error503 h2 { + margin: 0; + padding: 0; + margin-top: 25px; + font-size: 18px; + font-weight: normal; + text-align: left; + margin-left: 215px; +} + +article div.all.error503 { + min-height: 630px; +} + +article div.all.error503 h2 span { + color: #4496d0; +} + +div.wrap.tmargin30 { + margin-top: 30px; + min-height: 91%; +} + /*search*/ input.button.width100 { From 11434ff423e42f8bbe171809530b414f3ab0df44 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Sun, 11 Mar 2012 20:38:28 +0400 Subject: [PATCH 26/41] [Refs #285] Fix css style, rename button --- app/assets/stylesheets/design/main.scss | 4 +++- app/views/users/show.html.haml | 2 +- config/locales/users.en.yml | 1 + config/locales/users.ru.yml | 1 + doc/design/styles/main.css | 5 ++++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index 8bf6befa7..bc13f0e97 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -652,7 +652,9 @@ article div.all.bigpadding div.rightside { } a.button.width81 { - width: 81px; + width: 79px; + padding: 4px 0px; + text-align: center; } /* Footer */ diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index a9fd4332d..b1df08bef 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,7 +1,7 @@ .left = image_tag avatar_url(@user, :big) %br - = link_to t("layout.users.edit"), edit_user_path(@user), :class => 'button width81' if can? :edit, @user + = link_to t("layout.users.settings"), edit_user_path(@user), :class => 'button width81' if can? :edit, @user .left %h3= @user.uname = @user.name diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 4328e808b..129710349 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -4,6 +4,7 @@ en: list: List new: Create edit: Edit + settings: Settings new_header: New user edit_header: Edit list_header: Users diff --git a/config/locales/users.ru.yml b/config/locales/users.ru.yml index 3ba4f318d..31d550160 100644 --- a/config/locales/users.ru.yml +++ b/config/locales/users.ru.yml @@ -4,6 +4,7 @@ ru: list: Список new: Создать edit: Редактировать + settings: Настройки new_header: Новый пользователь edit_header: Редактировать list_header: Пользователи diff --git a/doc/design/styles/main.css b/doc/design/styles/main.css index 033707c2e..b1caadb42 100644 --- a/doc/design/styles/main.css +++ b/doc/design/styles/main.css @@ -652,7 +652,10 @@ article div.all.bigpadding div.rightside { } a.button.width81 { - width: 81px; + width: 79px; + padding: 4px 0px; + text-align: center; + } From 37f4676bfbe8db0d8c8c6fb3c225c0e2cab9b508 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 22:40:09 +0600 Subject: [PATCH 27/41] [refs #265] fuuu fix logo --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index fb0cee5c8..58d8d569f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,7 +15,7 @@ .middle %menu = render 'layouts/menu/top' - .logo= link_to(image_tag 'logo-mini.png', :alt => 'logo'), root_path + .logo= link_to image_tag('logo-mini.png', :alt => 'logo'), root_path .information = render 'search/form' .user From 6a7d9636f5ddf373cc86ed57502dcc1f4c1d3a51 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 23:06:41 +0600 Subject: [PATCH 28/41] [refs #265] fixed user avatars --- app/helpers/users_helper.rb | 7 ++++++- .../partials/_git_new_push_notification.haml | 2 +- .../partials/_issue_assign_notification.haml | 2 +- .../partials/_new_comment_commit_notification.haml | 2 +- .../activity_feeds/partials/_new_comment_notification.haml | 2 +- .../activity_feeds/partials/_new_issue_notification.haml | 2 +- .../activity_feeds/partials/_new_user_notification.haml | 2 +- .../partials/_wiki_new_commit_notification.haml | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index b7eb55c05..b57b1bd88 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,7 +1,12 @@ # -*- encoding : utf-8 -*- module UsersHelper + + def avatar_url_by_email(email, size = :small) + avatar_url(User.where(:email => email).first, size) + end + def avatar_url(user, size = :small) - if user.avatar? + if user.try('avatar?') user.avatar.url(size) else gravatar_url(user.email, user.avatar.styles[size].geometry.split('x').first) 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 0e70af5fc..bc221f4f7 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,7 +1,7 @@ - if defined? user_email .top .image - = image_tag(gravatar_url(user_email, 30)) + = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span.name = link_to user_name, user_path(user_id) diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml index 4bd61663d..e7de5430b 100644 --- a/app/views/activity_feeds/partials/_issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(avatar_url_by_email(activity_feed.user.email, :small), :alt => 'avatar') .text %span.name = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) diff --git a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml index 583a75e1e..2ff7788cb 100644 --- a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(user_email, 30)) + = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span.name = link_to user_name, user_path(user_id) diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_notification.haml index cf44cb4a5..80d5ccd0c 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(user_email, 30)) + = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span.name = link_to user_name, user_path(user_id) diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml index 2e718a019..4a633ed5e 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(user_email, 30)) + = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span.name = link_to user_name, user_path(user_id) diff --git a/app/views/activity_feeds/partials/_new_user_notification.haml b/app/views/activity_feeds/partials/_new_user_notification.haml index b65b2a477..da64b25cd 100644 --- a/app/views/activity_feeds/partials/_new_user_notification.haml +++ b/app/views/activity_feeds/partials/_new_user_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(activity_feed.user.email, 30)) + = image_tag(avatar_url_by_email(activity_feed.user.email, :small), :alt => 'avatar') .text %span.name = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 4a85dd81c..9cc085309 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -1,6 +1,6 @@ .top .image - = image_tag(gravatar_url(user_email, 30)) + = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span.name = link_to user_name, user_path(user_id) From d86653e172066022fca46caf12cfaec46fd2b9bc Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Sun, 11 Mar 2012 21:21:31 +0400 Subject: [PATCH 29/41] Split code and tracker options in notification center --- app/views/settings/notifiers/_form.html.haml | 72 +++++--------------- config/locales/en.yml | 1 + config/locales/ru.yml | 1 + 3 files changed, 19 insertions(+), 55 deletions(-) diff --git a/app/views/settings/notifiers/_form.html.haml b/app/views/settings/notifiers/_form.html.haml index f41996d17..0aacc04da 100644 --- a/app/views/settings/notifiers/_form.html.haml +++ b/app/views/settings/notifiers/_form.html.haml @@ -4,6 +4,22 @@ = f.label :can_notify, t('activerecord.attributes.settings.notifier.can_notify') .both %h3= t("layout.settings.notifiers.code_header") +.leftside.w25 + = f.check_box :new_comment_commit_owner, :class => 'notify_cbx' +.leftside + = f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner') +.both +.leftside.w25 + = f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx' +.leftside + = f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner') +.both +.leftside.w25 + = f.check_box :new_comment_commit_commentor, :class => 'notify_cbx' +.leftside + = f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor') +.both +%h3= t("layout.settings.notifiers.tracker_header") .leftside.w25 = f.check_box :new_comment, :class => 'notify_cbx' .leftside @@ -24,21 +40,7 @@ .leftside = f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign') .both -.leftside.w25 - = f.check_box :new_comment_commit_owner, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner') -.both -.leftside.w25 - = f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner') -.both -.leftside.w25 - = f.check_box :new_comment_commit_commentor, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor') -.both + %br .leftside.w25 \  @@ -48,43 +50,3 @@ :javascript disableNotifierCbx($('#settings_notifier_can_notify')); - --#.group --# = f.label :can_notify, t('activerecord.attributes.settings.notifier.can_notify'), :class => :label --# = f.check_box :can_notify#, :class => 'text_field' --# --#.group --# = f.label :new_comment, t('activerecord.attributes.settings.notifier.new_comment'), :class => :label --# = f.check_box :new_comment, :class => 'notify_cbx' --# --#.group --# = f.label :new_comment_reply, t('activerecord.attributes.settings.notifier.new_comment_reply'), :class => :label --# = f.check_box :new_comment_reply, :class => 'notify_cbx' --# --#.group --# = f.label :new_issue, t('activerecord.attributes.settings.notifier.new_issue'), :class => :label --# = f.check_box :new_issue, :class => 'notify_cbx' --# --#.group --# = f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign'), :class => :label --# = f.check_box :issue_assign, :class => 'notify_cbx' --# --#.group --# = f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner'), :class => :label --# = f.check_box :new_comment_commit_owner, :class => 'notify_cbx' --# --#.group --# = f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner'), :class => :label --# = f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx' --# --#.group --# = f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor'), :class => :label --# = f.check_box :new_comment_commit_commentor, :class => 'notify_cbx' --# --#.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"), user_settings_notifier_path(@user), :class => "text_button_padding link_button" --# diff --git a/config/locales/en.yml b/config/locales/en.yml index 4ee2634f0..e226eebed 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -52,6 +52,7 @@ en: notice_header: You can receive notifies from other collaborators about changes into code of your projects. Notifies will be sent to your email %{email}. change_email_link: Change email address code_header: Code + tracker_header: Tracker devise: shared_links: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e4f97b54e..ac0c8e33c 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -52,6 +52,7 @@ ru: notice_header: Вы можете получать уведомления об изменениях, которые вносят другие участники, в код ваших программ. Уведомления будут высылаться на указанный вами адрес электронной почты %{email}. change_email_link: Изменить адрес электронной почты code_header: Код + tracker_header: Трекер задач devise: shared_links: From 35d1323549e8c0d8274ad784868728a27e1f0da4 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 11 Mar 2012 23:30:14 +0600 Subject: [PATCH 30/41] [refs #265] fixed message format --- .../partials/_git_new_push_notification.haml | 7 ++++--- .../partials/_issue_assign_notification.haml | 7 ++++--- .../partials/_new_comment_commit_notification.haml | 7 ++++--- .../activity_feeds/partials/_new_comment_notification.haml | 7 ++++--- .../activity_feeds/partials/_new_issue_notification.haml | 7 ++++--- .../activity_feeds/partials/_new_user_notification.haml | 7 ++++--- .../partials/_wiki_new_commit_notification.haml | 7 ++++--- config/locales/models/activity_feed.en.yml | 2 +- config/locales/models/activity_feed.ru.yml | 2 +- 9 files changed, 30 insertions(+), 23 deletions(-) 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 bc221f4f7..f87d4fa31 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -5,10 +5,11 @@ .text %span.name = link_to user_name, user_path(user_id) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject Branch #{ branch_name } has been #{ change_type }d + .both + .both + %span.subject Branch #{ branch_name } has been #{ change_type }d .both .fulltext - unless defined? user_email diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml index e7de5430b..285240d55 100644 --- a/app/views/activity_feeds/partials/_issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject= raw t("notifications.bodies.issue_assign_notification.title", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))) + .both + .both + %span.subject= raw t("notifications.bodies.issue_assign_notification.title", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))) .both .fulltext =# 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_commit_notification.haml b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml index 2ff7788cb..9bab56602 100644 --- a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to user_name, user_path(user_id) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject #{ t("notifications.bodies.new_commit_comment_notification.title", :user_name => user_name) } + .both + .both + %span.subject #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } .both .fulltext = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))}) diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_notification.haml index 80d5ccd0c..930a398eb 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to user_name, user_path(user_id) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } + .both + .both + %span.subject #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) } .both .fulltext = raw t("notifications.bodies.new_comment_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_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml index 4a633ed5e..5369a1c90 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to user_name, user_path(user_id) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } + .both + .both + %span.subject #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) } .both .fulltext = 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 index da64b25cd..aaa894d5d 100644 --- a/app/views/activity_feeds/partials/_new_user_notification.haml +++ b/app/views/activity_feeds/partials/_new_user_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to activity_feed.user.uname, user_path(activity_feed.user.uname) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } + .both + .both + %span.subject #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) } .both .fulltext #{ t("notifications.bodies.new_user_notification.content") } diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 9cc085309..5f1f633f1 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -4,10 +4,11 @@ .text %span.name = link_to user_name, user_path(user_id) - %br + .both %span.date= activity_feed.created_at - %br - %span.subject #{ t("notifications.bodies.wiki_new_commit_notification.title", :user_name => user_name) } + .both + .both + %span.subject #{ t("notifications.bodies.wiki_new_commit_notification.title", :user_name => user_name) } .both .fulltext = raw t("notifications.bodies.wiki_new_commit_notification.content", {:history_link => link_to("wiki", history_project_wiki_index_path(project_id)), :project_link => link_to(project_name, project_path(project_id)) }) diff --git a/config/locales/models/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml index ee50f9f0c..3a3e70e9b 100644 --- a/config/locales/models/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -21,7 +21,7 @@ en: new_comment_notification: title: User %{user_name} has been added a new comment. content: Issue %{issue_link} - commit_content: To the commit %{commit_link} added a comment. + commit_content: Commit %{commit_link} new_issue_notification: title: User %{user_name} has been added an issue. content: Project %{project_link}. Issue %{issue_link} diff --git a/config/locales/models/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml index 9f97b53c7..a89b1ce3e 100644 --- a/config/locales/models/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -21,7 +21,7 @@ ru: new_comment_notification: title: Пользователь %{user_name} добавил новый комментарий content: Задача %{issue_link} - commit_content: К коммиту %{commit_link} был добавлен новый комментарий. + commit_content: Коммит %{commit_link} new_issue_notification: title: Пользователь %{user_name} добавил новую задачу content: Проект %{project_link}. Задача %{issue_link} From c4fd73b52b5b508414c817ec46c8c2e5878d3b72 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 00:28:14 +0600 Subject: [PATCH 31/41] [refs #265] fixed double wiki feed --- app/controllers/wiki_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index fd398d1aa..bd242e62d 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -251,12 +251,14 @@ class WikiController < ApplicationController end def committer - p = commit_message.merge({:name => current_user.uname, :email => current_user.email}) - @committer ||= Gollum::Committer.new(@wiki, p) + unless @committer + p = commit_message.merge({:name => current_user.uname, :email => current_user.email}) + @committer = Gollum::Committer.new(@wiki, p) # @committer.after_commit do |committer, sha1| # here goes callback for notification # end - ActivityFeedObserver.instance.after_create(@committer).delay + ActivityFeedObserver.instance.after_create(@committer).delay + end @committer end From de61bc8cee78808c7a0b95abc4d48c9dd5cf2c44 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 02:00:54 +0600 Subject: [PATCH 32/41] [refs #265] fixed multiple "All my projects" --- app/views/activity_feeds/_sidebar.html.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/activity_feeds/_sidebar.html.haml index 49cee5b82..628a763ac 100644 --- a/app/views/activity_feeds/_sidebar.html.haml +++ b/app/views/activity_feeds/_sidebar.html.haml @@ -12,11 +12,11 @@ = image_tag("lock.png") %td = link_to "#{project.owner.uname}/#{project.name}", project_path(project) - %tr - %td - \  - %td - = link_to t("layout.activity_feed.all_my_projects"), projects_path + %tr + %td + \  + %td + = link_to t("layout.activity_feed.all_my_projects"), projects_path .block %h3= t("layout.activity_feed.my_builds_by_day") %table{:cellpadding => "0", :cellspacing => "0"} From 9c6ba7a58426f6f9898616251e7adb3b8b8039c6 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 02:04:49 +0600 Subject: [PATCH 33/41] [refs #265] fixed last project size --- app/views/activity_feeds/_sidebar.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/activity_feeds/_sidebar.html.haml index 628a763ac..22680450b 100644 --- a/app/views/activity_feeds/_sidebar.html.haml +++ b/app/views/activity_feeds/_sidebar.html.haml @@ -3,7 +3,7 @@ %h3= t("layout.activity_feed.my_last_projects") %table %tbody - - current_user.projects.each do |project| + - current_user.projects.order('updated_at DESC').limit(5).each do |project| %tr %td - if project.public? From 4b6b44d9683d1ce81f9fac7e414abd876dcc1634 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 12 Mar 2012 00:28:34 +0200 Subject: [PATCH 34/41] Fix deploy settings and gemfile --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 4614f8d9c..b422fa0b4 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,7 @@ gem 'wikicloth' gem 'unicorn', '~> 4.2.0' gem 'newrelic_rpm', '~> 3.3.2' +gem 'whenever', '~> 0.7.3', :require => false gem 'rails3-jquery-autocomplete', '~> 1.0.6' gem 'will_paginate', '~> 3.0.3' @@ -60,7 +61,6 @@ group :development do gem 'hirb' gem 'shotgun' # deploy - gem 'whenever', :require => false gem 'capistrano', :require => false gem 'cape', :require => false gem 'capistrano_colors', :require => false diff --git a/Gemfile.lock b/Gemfile.lock index b63f78f9d..e94e27f5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -341,6 +341,6 @@ DEPENDENCIES therubyracer (~> 0.9.10) uglifier (~> 1.2.1) unicorn (~> 4.2.0) - whenever + whenever (~> 0.7.3) wikicloth will_paginate (~> 3.0.3) From 3e344f90adce11eea7ddb2056adcefac571aedd5 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 12 Mar 2012 00:47:22 +0200 Subject: [PATCH 35/41] Display only 10 last activities. Refs #265 --- app/controllers/activity_feeds_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/activity_feeds_controller.rb b/app/controllers/activity_feeds_controller.rb index b23311937..e5b5274d8 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.order('created_at DESC') + @activity_feeds = current_user.activity_feeds.order('created_at DESC').limit(10) end end From ecfb4f81a04f5286fd6b84cfb0ec09af2bdb1056 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 14:52:38 +0600 Subject: [PATCH 36/41] [refs #265] fixed today builds --- app/views/activity_feeds/_sidebar.html.haml | 21 +++++++++++---------- config/locales/models/activity_feed.en.yml | 2 +- config/locales/models/activity_feed.ru.yml | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/activity_feeds/_sidebar.html.haml index 22680450b..5d6c0e3a4 100644 --- a/app/views/activity_feeds/_sidebar.html.haml +++ b/app/views/activity_feeds/_sidebar.html.haml @@ -18,29 +18,30 @@ %td = link_to t("layout.activity_feed.all_my_projects"), projects_path .block + - midnight = Time.new.midnight %h3= t("layout.activity_feed.my_builds_by_day") %table{:cellpadding => "0", :cellspacing => "0"} %tbody %tr %td.first - = link_to t("layout.build_lists.statuses.#{:build_published}"), build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED}) - %td= BuildList.for_status(BuildList::BUILD_PUBLISHED).for_user(current_user).count + = link_to t("layout.build_lists.statuses.#{:build_published}"), build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED, :notified_at => midnight}) + %td= BuildList.for_status(BuildList::BUILD_PUBLISHED).for_user(current_user).for_notified_date_period(midnight, nil).count %tr %td.first - = link_to t("layout.build_lists.statuses.#{:success}"), build_lists_path(:filter => {:status => BuildServer::SUCCESS}) - %td= BuildList.for_status(BuildServer::SUCCESS).for_user(current_user).count + = link_to t("layout.build_lists.statuses.#{:success}"), build_lists_path(:filter => {:status => BuildServer::SUCCESS, :notified_at => midnight}) + %td= BuildList.for_status(BuildServer::SUCCESS).for_user(current_user).for_notified_date_period(midnight, nil).count %tr %td.first - = link_to t("layout.build_lists.statuses.#{:build_started}"), build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED}) - %td= BuildList.for_status(BuildServer::BUILD_STARTED).for_user(current_user).count + = link_to t("layout.build_lists.statuses.#{:build_started}"), build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED, :notified_at => midnight}) + %td= BuildList.for_status(BuildServer::BUILD_STARTED).for_user(current_user).for_notified_date_period(midnight, nil).count %tr %td.first - = link_to t("layout.build_lists.statuses.#{:build_pending}"), build_lists_path(:filter => {:status => BuildList::BUILD_PENDING}) - %td= BuildList.for_status(BuildList::BUILD_PENDING).for_user(current_user).count + = link_to t("layout.build_lists.statuses.#{:build_pending}"), build_lists_path(:filter => {:status => BuildList::BUILD_PENDING, :notified_at => midnight}) + %td= BuildList.for_status(BuildList::BUILD_PENDING).for_user(current_user).for_notified_date_period(midnight, nil).count %tr %td.first - = link_to t("layout.build_lists.statuses.#{:build_error}"), build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR}) - %td= BuildList.for_status(BuildServer::BUILD_ERROR).for_user(current_user).count + = link_to t("layout.build_lists.statuses.#{:build_error}"), build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR, :notified_at => midnight}) + %td= BuildList.for_status(BuildServer::BUILD_ERROR).for_user(current_user).for_notified_date_period(midnight, nil).count %tr %td.first = link_to t("layout.activity_feed.all_my_builds"), build_lists_path diff --git a/config/locales/models/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml index 3a3e70e9b..c1ded633c 100644 --- a/config/locales/models/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -5,7 +5,7 @@ en: my_last_projects: My last projects all_my_projects: All my projects all_my_builds: All my builds - my_builds_by_day: My buils for last 24 hours + my_builds_by_day: My today builds new_project: Create project notifications: diff --git a/config/locales/models/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml index a89b1ce3e..cb4f93263 100644 --- a/config/locales/models/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -5,7 +5,7 @@ ru: my_last_projects: Мои последние проекты all_my_projects: Все мои проекты all_my_builds: Все мои сборки - my_builds_by_day: Мои сборки за 24 часа + my_builds_by_day: Мои сборки за день new_project: Создать проект notifications: From 26e80af8cb23318458ae2c273d0455decf62fe6e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 16:13:34 +0600 Subject: [PATCH 37/41] [refs #195] one click select --- app/views/projects/_repo_block.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index 9a3bf0b1c..825fc5242 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -1,7 +1,7 @@ .description-top .img= image_tag 'code.png' = text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', - :type => 'text',:spellcheck => 'false', :readonly => true + :type => 'text',:spellcheck => 'false', :readonly => true, :onfocus => "this.select()" .role = t("layout.read_write_access") = render :partial => 'projects/branch_select', :locals => {:project => project} From bb7cff5de86dffa3767c060b67c66a140a1d6321 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 12 Mar 2012 13:46:57 +0200 Subject: [PATCH 38/41] Fix abilities - allow users search build_lists. Refs #223 --- app/models/ability.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/ability.rb b/app/models/ability.rb index 0de2d5672..87a59203d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -59,6 +59,7 @@ class Ability #can :create, AutoBuildList #can [:index, :destroy], AutoBuildList, :project_id => user.own_project_ids + can :search, BuildList can [:read, :owned], BuildList, :user_id => user.id can :read, BuildList, :project => {:visibility => 'open'} can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} From 64926498d6b8d73bdc200fa1d08fb8b28847bb28 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Mon, 12 Mar 2012 16:05:19 +0400 Subject: [PATCH 39/41] [Refs #195] Fix pagination for index projects page --- app/controllers/projects_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index abd09025b..3bd7ed95a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,8 +4,8 @@ class ProjectsController < ApplicationController load_and_authorize_resource def index - @projects = current_user.projects.paginate(:page => params[:project_page]) - @projects = @projects.search(params[:query]).search_order if params[:query] + @projects = current_user.projects.paginate(:page => params[:page]) + #@projects = @projects.search(params[:query]).search_order if params[:query] end def new From 19bcdf94d9b712a940ea433619e4b89899f249f5 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Mon, 12 Mar 2012 18:31:25 +0400 Subject: [PATCH 40/41] [Refs #195] More space for project url --- app/assets/stylesheets/design/main.scss | 4 +- app/views/projects/_repo_block.html.haml | 1 - doc/design/abf-project main page.html | 3 -- doc/design/styles/main.css | 58 ++++++++++++++++++++++-- 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index bc13f0e97..4a3a37832 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -1413,8 +1413,8 @@ div.description-top input.name { height: 21px; width: auto; color: #575756; - font-size: 12px; - width: 215px; + font-size: 11px; + width: 415px; padding: 2px 5px 3px; } diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index 825fc5242..3730b1c5a 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -1,5 +1,4 @@ .description-top - .img= image_tag 'code.png' = text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :type => 'text',:spellcheck => 'false', :readonly => true, :onfocus => "this.select()" .role diff --git a/doc/design/abf-project main page.html b/doc/design/abf-project main page.html index 4db2e61b6..94715c854 100644 --- a/doc/design/abf-project main page.html +++ b/doc/design/abf-project main page.html @@ -138,9 +138,6 @@
-
- pic -
чтение и запись diff --git a/doc/design/styles/main.css b/doc/design/styles/main.css index b1caadb42..afb87364f 100644 --- a/doc/design/styles/main.css +++ b/doc/design/styles/main.css @@ -276,7 +276,7 @@ header div.droplist a:hover{ } -.sub-menu nav { /* */ +.sub-menu nav { /*��� ������� ��� ��������*/ float: left; margin: 0px 0px 0px 0px; } @@ -407,6 +407,10 @@ article h4 { padding-bottom: 2px; } +article h4.nomargin { + margin: 0px; +} + article p { margin: 0; padding: 0; @@ -1415,8 +1419,8 @@ div.desription-top input.name { height: 21px; width: auto; color: #575756; - font-size: 12px; - width: 215px; + font-size: 11px; + width: 415px; padding: 2px 5px 3px; } @@ -1592,6 +1596,10 @@ table td.width145 { width: 145px; } +.width125 { + width: 125px; +} + table td.width30 { width: 30px; } @@ -2110,6 +2118,22 @@ article div.rightlist div.load { padding: 5px 10px; } +.notify.blue { + border: 1px solid #a9c6dd; + background: #dcecfa; + border-radius: 1px; + width: 555px; + margin-top: 20px; + text-align: right; + padding: 5px; +} + +.notify.blue div.green { + border: 1px solid #bad099; + background: #d7e599; + float: left; +} + /* Pagination */ div.pagination em { @@ -2307,10 +2331,36 @@ div.tmargin10 { margin-top: 10px; } +.tmargin10 { + margin-top: 10px; +} + a.lmargin7 { margin-left: 7px; } a.lmargin5 { margin-left: 5px; -} \ No newline at end of file +} + +/*My projects*/ + +table.tablesorter tr.search td { + background: #dcecfa; +} + +table.tablesorter tr.search td input[type="text"] { + height: 16px; + width: 830px; + border: 1px solid #cdcdcd; + border-radius: 4px; + padding: 5px; + font-family: Tahoma, Geneva, Helvetica, sans-serif; + font-size: 12px; + margin-top: 2px; +} + + +table.tablesorter.width565 { + width: 565px; +} From fc465a46474fb2c2f9a2f2bc2c92e3f0dea2cf89 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 12 Mar 2012 20:46:11 +0600 Subject: [PATCH 41/41] [refs #195] onfocus -> onclick --- app/views/projects/_repo_block.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index 3730b1c5a..e4592efaf 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -1,7 +1,13 @@ .description-top = text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', - :type => 'text',:spellcheck => 'false', :readonly => true, :onfocus => "this.select()" + :type => 'text',:spellcheck => 'false', :readonly => true .role = t("layout.read_write_access") = render :partial => 'projects/branch_select', :locals => {:project => project} .both +:javascript + $(document).ready(function() { + $('#url').live('click', function() { + $(this).select(); + }); + });