From 20417241a82009424d3efdca693fb8b4ae752c92 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 2 Mar 2012 00:35:18 +0600 Subject: [PATCH] [refs 194] fix comments --- app/presenters/comment_presenter.rb | 1 + app/views/comments/_add.html.haml | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb index fe6fb9089..22f77b542 100644 --- a/app/presenters/comment_presenter.rb +++ b/app/presenters/comment_presenter.rb @@ -46,6 +46,7 @@ class CommentPresenter < ApplicationPresenter res << link_to(t("layout.delete"), dp, :method => "delete", :confirm => t("layout.comments.confirm_delete")).html_safe end + res end def header diff --git a/app/views/comments/_add.html.haml b/app/views/comments/_add.html.haml index f527eb041..efc5436a2 100644 --- a/app/views/comments/_add.html.haml +++ b/app/views/comments/_add.html.haml @@ -1,20 +1,27 @@ #open-comment.comment.view %h3.tmargin0= t("layout.comments.new_header") - - new_path = project_issue_comments_path(project, commentable) if commentable.class == Issue - - new_path = project_commit_comments_path(project, commentable) if commentable.class == Grit::Commit + - if commentable.class == Issue + - new_path = project_issue_comments_path(project, commentable) + - is_subscribed = commentable.subscribes.exists?(:user_id => current_user.id) + - subscribe_path = is_subscribed ? project_issue_subscribe_path(project, commentable, current_user.id) : project_issue_subscribes_path(project, commentable) + - else commentable.class == Grit::Commit + - new_path = project_commit_comments_path(project, commentable) + - is_subscribed = Subscribe.subscribed_to_commit?(project, current_user, commentable) + - subscribe_path = is_subscribed ? unsubscribe_commit_path(project, commentable) : subscribe_commit_path(project, commentable) + = form_for :comment, :url => new_path, :method => :post, :html => { :class => :form } do |f| = render :partial => "comments/form", :locals => {:f => f} .comment-left = t("layout.comments.notifications_are") %span.bold - - if Subscribe.subscribed_to_commit?(@project, current_user, @commit) + - if is_subscribed = t("layout.turned_on")\ - else = t("layout.turned_off")\ \. - - if Subscribe.subscribed_to_commit?(@project, current_user, @commit) - = link_to t('layout.commits.unsubscribe_btn'), unsubscribe_commit_path(@project, @commit), :method => :delete + - if is_subscribed + = link_to t('layout.commits.unsubscribe_btn'), subscribe_path, :method => :delete - else - = link_to t('layout.commits.subscribe_btn'), subscribe_commit_path(@project, @commit), :method => :post + = link_to t('layout.commits.subscribe_btn'), subscribe_path, :method => :post .both