Show More
@@ -1,93 +1,95 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.model.comment |
|
3 | rhodecode.model.comment | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | comments model for RhodeCode |
|
6 | comments model for RhodeCode | |
7 |
|
7 | |||
8 | :created_on: Nov 11, 2011 |
|
8 | :created_on: Nov 11, 2011 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software: you can redistribute it and/or modify |
|
13 | # This program is free software: you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by |
|
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation, either version 3 of the License, or |
|
15 | # the Free Software Foundation, either version 3 of the License, or | |
16 | # (at your option) any later version. |
|
16 | # (at your option) any later version. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 |
|
25 | |||
26 |
|
26 | |||
27 | import logging |
|
27 | import logging | |
28 | import traceback |
|
28 | import traceback | |
29 |
|
29 | |||
30 | from rhodecode.model import BaseModel |
|
30 | from rhodecode.model import BaseModel | |
31 | from rhodecode.model.db import ChangesetComment |
|
31 | from rhodecode.model.db import ChangesetComment | |
32 | from sqlalchemy.util.compat import defaultdict |
|
32 | from sqlalchemy.util.compat import defaultdict | |
33 |
|
33 | |||
34 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class ChangesetCommentsModel(BaseModel): |
|
37 | class ChangesetCommentsModel(BaseModel): | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | def create(self, text, repo_id, user_id, revision, f_path=None, |
|
40 | def create(self, text, repo_id, user_id, revision, f_path=None, | |
41 | line_no=None): |
|
41 | line_no=None): | |
42 | """ |
|
42 | """ | |
43 | Creates new comment for changeset |
|
43 | Creates new comment for changeset | |
44 |
|
44 | |||
45 | :param text: |
|
45 | :param text: | |
46 | :param repo_id: |
|
46 | :param repo_id: | |
47 | :param user_id: |
|
47 | :param user_id: | |
48 | :param revision: |
|
48 | :param revision: | |
49 | :param f_path: |
|
49 | :param f_path: | |
50 | :param line_no: |
|
50 | :param line_no: | |
51 | """ |
|
51 | """ | |
52 | if text: |
|
52 | if text: | |
53 | comment = ChangesetComment() |
|
53 | comment = ChangesetComment() | |
54 | comment.repo_id = repo_id |
|
54 | comment.repo_id = repo_id | |
55 | comment.user_id = user_id |
|
55 | comment.user_id = user_id | |
56 | comment.revision = revision |
|
56 | comment.revision = revision | |
57 | comment.text = text |
|
57 | comment.text = text | |
58 | comment.f_path = f_path |
|
58 | comment.f_path = f_path | |
59 | comment.line_no = line_no |
|
59 | comment.line_no = line_no | |
60 |
|
60 | |||
61 | self.sa.add(comment) |
|
61 | self.sa.add(comment) | |
62 | self.sa.commit() |
|
62 | self.sa.commit() | |
63 | return comment |
|
63 | return comment | |
64 |
|
64 | |||
65 | def delete(self, comment_id): |
|
65 | def delete(self, comment_id): | |
66 | """ |
|
66 | """ | |
67 | Deletes given comment |
|
67 | Deletes given comment | |
68 |
|
68 | |||
69 | :param comment_id: |
|
69 | :param comment_id: | |
70 | """ |
|
70 | """ | |
71 | comment = ChangesetComment.get(comment_id) |
|
71 | comment = ChangesetComment.get(comment_id) | |
72 | self.sa.delete(comment) |
|
72 | self.sa.delete(comment) | |
73 | self.sa.commit() |
|
73 | self.sa.commit() | |
74 | return comment |
|
74 | return comment | |
75 |
|
75 | |||
76 |
|
76 | |||
77 | def get_comments(self, repo_id, revision): |
|
77 | def get_comments(self, repo_id, revision): | |
78 | return ChangesetComment.query()\ |
|
78 | return ChangesetComment.query()\ | |
79 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
79 | .filter(ChangesetComment.repo_id == repo_id)\ | |
80 | .filter(ChangesetComment.revision == revision)\ |
|
80 | .filter(ChangesetComment.revision == revision)\ | |
81 | .filter(ChangesetComment.line_no == None)\ |
|
81 | .filter(ChangesetComment.line_no == None)\ | |
82 | .filter(ChangesetComment.f_path == None).all() |
|
82 | .filter(ChangesetComment.f_path == None).all() | |
83 |
|
83 | |||
84 | def get_inline_comments(self, repo_id, revision): |
|
84 | def get_inline_comments(self, repo_id, revision): | |
85 | comments = self.sa.query(ChangesetComment)\ |
|
85 | comments = self.sa.query(ChangesetComment)\ | |
86 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
86 | .filter(ChangesetComment.repo_id == repo_id)\ | |
87 |
.filter(ChangesetComment.revision == revision) |
|
87 | .filter(ChangesetComment.revision == revision)\ | |
|
88 | .filter(ChangesetComment.line_no != None)\ | |||
|
89 | .filter(ChangesetComment.f_path != None).all() | |||
88 |
|
90 | |||
89 | paths = defaultdict(lambda:defaultdict(list)) |
|
91 | paths = defaultdict(lambda:defaultdict(list)) | |
90 |
|
92 | |||
91 | for co in comments: |
|
93 | for co in comments: | |
92 | paths[co.f_path][co.line_no].append(co) |
|
94 | paths[co.f_path][co.line_no].append(co) | |
93 | return paths.items() |
|
95 | return paths.items() |
@@ -1,214 +1,216 | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | <%inherit file="/base/base.html"/> |
|
3 | <%inherit file="/base/base.html"/> | |
4 |
|
4 | |||
5 | <%def name="title()"> |
|
5 | <%def name="title()"> | |
6 | ${c.repo_name} ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name} |
|
6 | ${c.repo_name} ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name} | |
7 | </%def> |
|
7 | </%def> | |
8 |
|
8 | |||
9 | <%def name="breadcrumbs_links()"> |
|
9 | <%def name="breadcrumbs_links()"> | |
10 | ${h.link_to(u'Home',h.url('/'))} |
|
10 | ${h.link_to(u'Home',h.url('/'))} | |
11 | » |
|
11 | » | |
12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} | |
13 | » |
|
13 | » | |
14 | ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
14 | ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} | |
15 | </%def> |
|
15 | </%def> | |
16 |
|
16 | |||
17 | <%def name="page_nav()"> |
|
17 | <%def name="page_nav()"> | |
18 | ${self.menu('changelog')} |
|
18 | ${self.menu('changelog')} | |
19 | </%def> |
|
19 | </%def> | |
20 |
|
20 | |||
21 | <%def name="main()"> |
|
21 | <%def name="main()"> | |
22 | <div class="box"> |
|
22 | <div class="box"> | |
23 | <!-- box / title --> |
|
23 | <!-- box / title --> | |
24 | <div class="title"> |
|
24 | <div class="title"> | |
25 | ${self.breadcrumbs()} |
|
25 | ${self.breadcrumbs()} | |
26 | </div> |
|
26 | </div> | |
27 | <div class="table"> |
|
27 | <div class="table"> | |
28 | <div class="diffblock"> |
|
28 | <div class="diffblock"> | |
29 | <div class="code-header"> |
|
29 | <div class="code-header"> | |
30 | <div> |
|
30 | <div> | |
31 | ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
31 | ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} | |
32 | » <span>${h.link_to(_('raw diff'), |
|
32 | » <span>${h.link_to(_('raw diff'), | |
33 | h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show'))}</span> |
|
33 | h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show'))}</span> | |
34 | » <span>${h.link_to(_('download diff'), |
|
34 | » <span>${h.link_to(_('download diff'), | |
35 | h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download'))}</span> |
|
35 | h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download'))}</span> | |
36 | </div> |
|
36 | </div> | |
37 | </div> |
|
37 | </div> | |
38 | </div> |
|
38 | </div> | |
39 | <div id="changeset_content"> |
|
39 | <div id="changeset_content"> | |
40 | <div class="container"> |
|
40 | <div class="container"> | |
41 | <div class="left"> |
|
41 | <div class="left"> | |
42 | <div class="date">${_('commit')} ${c.changeset.revision}: ${h.short_id(c.changeset.raw_id)}@${c.changeset.date}</div> |
|
42 | <div class="date">${_('commit')} ${c.changeset.revision}: ${h.short_id(c.changeset.raw_id)}@${c.changeset.date}</div> | |
43 | <div class="author"> |
|
43 | <div class="author"> | |
44 | <div class="gravatar"> |
|
44 | <div class="gravatar"> | |
45 | <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/> |
|
45 | <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/> | |
46 | </div> |
|
46 | </div> | |
47 | <span>${h.person(c.changeset.author)}</span><br/> |
|
47 | <span>${h.person(c.changeset.author)}</span><br/> | |
48 | <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> |
|
48 | <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> | |
49 | </div> |
|
49 | </div> | |
50 | <div class="message">${h.link_to(h.wrap_paragraphs(c.changeset.message),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</div> |
|
50 | <div class="message">${h.link_to(h.wrap_paragraphs(c.changeset.message),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</div> | |
51 | </div> |
|
51 | </div> | |
52 | <div class="right"> |
|
52 | <div class="right"> | |
53 | <div class="changes"> |
|
53 | <div class="changes"> | |
54 | % if len(c.changeset.affected_files) <= c.affected_files_cut_off: |
|
54 | % if len(c.changeset.affected_files) <= c.affected_files_cut_off: | |
55 | <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span> |
|
55 | <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span> | |
56 | <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span> |
|
56 | <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span> | |
57 | <span class="added" title="${_('added')}">${len(c.changeset.added)}</span> |
|
57 | <span class="added" title="${_('added')}">${len(c.changeset.added)}</span> | |
58 | % else: |
|
58 | % else: | |
59 | <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
59 | <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
60 | <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
60 | <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
61 | <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
61 | <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
62 | % endif |
|
62 | % endif | |
63 | </div> |
|
63 | </div> | |
64 | %if len(c.changeset.parents)>1: |
|
64 | %if len(c.changeset.parents)>1: | |
65 | <div class="merge"> |
|
65 | <div class="merge"> | |
66 | ${_('merge')}<img alt="merge" src="${h.url('/images/icons/arrow_join.png')}"/> |
|
66 | ${_('merge')}<img alt="merge" src="${h.url('/images/icons/arrow_join.png')}"/> | |
67 | </div> |
|
67 | </div> | |
68 | %endif |
|
68 | %endif | |
69 |
|
69 | |||
70 | %if c.changeset.parents: |
|
70 | %if c.changeset.parents: | |
71 | %for p_cs in reversed(c.changeset.parents): |
|
71 | %for p_cs in reversed(c.changeset.parents): | |
72 | <div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(h.short_id(p_cs.raw_id), |
|
72 | <div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(h.short_id(p_cs.raw_id), | |
73 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)} |
|
73 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)} | |
74 | </div> |
|
74 | </div> | |
75 | %endfor |
|
75 | %endfor | |
76 | %else: |
|
76 | %else: | |
77 | <div class="parent">${_('No parents')}</div> |
|
77 | <div class="parent">${_('No parents')}</div> | |
78 | %endif |
|
78 | %endif | |
79 | <span class="logtags"> |
|
79 | <span class="logtags"> | |
80 | <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}"> |
|
80 | <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}"> | |
81 | ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> |
|
81 | ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> | |
82 | %for tag in c.changeset.tags: |
|
82 | %for tag in c.changeset.tags: | |
83 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> |
|
83 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> | |
84 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> |
|
84 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> | |
85 | %endfor |
|
85 | %endfor | |
86 | </span> |
|
86 | </span> | |
87 | </div> |
|
87 | </div> | |
88 | </div> |
|
88 | </div> | |
89 | <span style="font-size:1.1em;font-weight: bold"> |
|
89 | <span style="font-size:1.1em;font-weight: bold"> | |
90 | ${_('%s files affected with %s additions and %s deletions.') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)} |
|
90 | ${_('%s files affected with %s additions and %s deletions.') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)} | |
91 | </span> |
|
91 | </span> | |
92 | <div class="cs_files"> |
|
92 | <div class="cs_files"> | |
93 | %for change,filenode,diff,cs1,cs2,stat in c.changes: |
|
93 | %for change,filenode,diff,cs1,cs2,stat in c.changes: | |
94 | <div class="cs_${change}"> |
|
94 | <div class="cs_${change}"> | |
95 | <div class="node">${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor='C-%s-%s' % (h.short_id(filenode.changeset.raw_id),h.safeid(h.safe_unicode(filenode.path)))))}</div> |
|
95 | <div class="node">${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor='C-%s-%s' % (h.short_id(filenode.changeset.raw_id),h.safeid(h.safe_unicode(filenode.path)))))}</div> | |
96 | <div class="changes">${h.fancy_file_stats(stat)}</div> |
|
96 | <div class="changes">${h.fancy_file_stats(stat)}</div> | |
97 | </div> |
|
97 | </div> | |
98 | %endfor |
|
98 | %endfor | |
99 | % if c.cut_off: |
|
99 | % if c.cut_off: | |
100 | ${_('Changeset was too big and was cut off...')} |
|
100 | ${_('Changeset was too big and was cut off...')} | |
101 | % endif |
|
101 | % endif | |
102 | </div> |
|
102 | </div> | |
103 | </div> |
|
103 | </div> | |
104 |
|
104 | |||
105 | </div> |
|
105 | </div> | |
106 |
|
106 | |||
107 | %for change,filenode,diff,cs1,cs2,stat in c.changes: |
|
107 | %for change,filenode,diff,cs1,cs2,stat in c.changes: | |
108 | %if change !='removed': |
|
108 | %if change !='removed': | |
109 | <div style="clear:both;height:10px"></div> |
|
109 | <div style="clear:both;height:10px"></div> | |
110 | <div class="diffblock margined"> |
|
110 | <div class="diffblock margined"> | |
111 | <div id="${'C-%s-%s' % (h.short_id(filenode.changeset.raw_id),h.safeid(h.safe_unicode(filenode.path)))}" class="code-header"> |
|
111 | <div id="${'C-%s-%s' % (h.short_id(filenode.changeset.raw_id),h.safeid(h.safe_unicode(filenode.path)))}" class="code-header"> | |
112 | <div class="changeset_header"> |
|
112 | <div class="changeset_header"> | |
113 | <span class="changeset_file"> |
|
113 | <span class="changeset_file"> | |
114 | ${h.link_to_if(change!='removed',h.safe_unicode(filenode.path),h.url('files_home',repo_name=c.repo_name, |
|
114 | ${h.link_to_if(change!='removed',h.safe_unicode(filenode.path),h.url('files_home',repo_name=c.repo_name, | |
115 | revision=filenode.changeset.raw_id,f_path=h.safe_unicode(filenode.path)))} |
|
115 | revision=filenode.changeset.raw_id,f_path=h.safe_unicode(filenode.path)))} | |
116 | </span> |
|
116 | </span> | |
117 | » <span>${h.link_to(_('diff'), |
|
117 | » <span>${h.link_to(_('diff'), | |
118 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='diff'))}</span> |
|
118 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='diff'))}</span> | |
119 | » <span>${h.link_to(_('raw diff'), |
|
119 | » <span>${h.link_to(_('raw diff'), | |
120 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='raw'))}</span> |
|
120 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='raw'))}</span> | |
121 | » <span>${h.link_to(_('download diff'), |
|
121 | » <span>${h.link_to(_('download diff'), | |
122 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='download'))}</span> |
|
122 | h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='download'))}</span> | |
123 | </div> |
|
123 | </div> | |
124 | </div> |
|
124 | </div> | |
125 | <div class="code-body"> |
|
125 | <div class="code-body"> | |
126 | <div class="full_f_path" path="${filenode.path}"></div> |
|
126 | <div class="full_f_path" path="${filenode.path}"></div> | |
127 | %if diff: |
|
127 | %if diff: | |
128 | ${diff|n} |
|
128 | ${diff|n} | |
129 | %else: |
|
129 | %else: | |
130 | ${_('No changes in this file')} |
|
130 | ${_('No changes in this file')} | |
131 | %endif |
|
131 | %endif | |
132 | </div> |
|
132 | </div> | |
133 | </div> |
|
133 | </div> | |
134 | %endif |
|
134 | %endif | |
135 | %endfor |
|
135 | %endfor | |
136 |
|
136 | |||
137 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
137 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> | |
138 | ## template for inline comment form |
|
138 | ## template for inline comment form | |
139 | ${comment.comment_inline_form()} |
|
139 | ${comment.comment_inline_form()} | |
140 |
|
140 | |||
141 | <div class="comments"> |
|
141 | <div class="comments"> | |
142 | <div class="comments-number">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div> |
|
142 | <div class="comments-number">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div> | |
143 |
|
143 | |||
144 | %for path, lines in c.inline_comments: |
|
144 | %for path, lines in c.inline_comments: | |
145 | <div class="inline-comment-placeholder" path="${path} "> |
|
145 | <div class="inline-comment-placeholder" path="${path} "> | |
146 | % for line,comments in lines.iteritems(): |
|
146 | % for line,comments in lines.iteritems(): | |
147 | <div class="inline-comment-placeholder-line" line="${line}"> |
|
147 | <div class="inline-comment-placeholder-line" line="${line}"> | |
148 | %for co in comments: |
|
148 | %for co in comments: | |
149 | ${comment.comment_block(co)} |
|
149 | ${comment.comment_block(co)} | |
150 | %endfor |
|
150 | %endfor | |
151 | </div> |
|
151 | </div> | |
152 | %endfor |
|
152 | %endfor | |
153 | </div> |
|
153 | </div> | |
154 | %endfor |
|
154 | %endfor | |
155 |
|
155 | |||
156 | %for co in c.comments: |
|
156 | %for co in c.comments: | |
157 | ${comment.comment_block(co)} |
|
157 | ${comment.comment_block(co)} | |
158 | %endfor |
|
158 | %endfor | |
159 | %if c.rhodecode_user.username != 'default': |
|
159 | %if c.rhodecode_user.username != 'default': | |
160 | <div class="comment-form"> |
|
160 | <div class="comment-form"> | |
161 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id))} |
|
161 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id))} | |
162 | <strong>${_('Leave a comment')}</strong> |
|
162 | <strong>${_('Leave a comment')}</strong> | |
163 | <div class="clearfix"> |
|
163 | <div class="clearfix"> | |
164 |
<div class="comment-help"> |
|
164 | <div class="comment-help"> | |
|
165 | ${_('Comments parsed using')} <a href="${h.url('rst_help')}">RST</a> ${_('syntax')} | |||
|
166 | </div> | |||
165 | ${h.textarea('text')} |
|
167 | ${h.textarea('text')} | |
166 | </div> |
|
168 | </div> | |
167 | <div class="comment-button"> |
|
169 | <div class="comment-button"> | |
168 | ${h.submit('save', _('Comment'), class_='ui-button')} |
|
170 | ${h.submit('save', _('Comment'), class_='ui-button')} | |
169 | </div> |
|
171 | </div> | |
170 | ${h.end_form()} |
|
172 | ${h.end_form()} | |
171 | </div> |
|
173 | </div> | |
172 | %endif |
|
174 | %endif | |
173 | </div> |
|
175 | </div> | |
174 | <script type="text/javascript"> |
|
176 | <script type="text/javascript"> | |
175 | var deleteComment = function(comment_id){ |
|
177 | var deleteComment = function(comment_id){ | |
176 |
|
178 | |||
177 | var url = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}".replace('__COMMENT_ID__',comment_id); |
|
179 | var url = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}".replace('__COMMENT_ID__',comment_id); | |
178 | var postData = '_method=delete'; |
|
180 | var postData = '_method=delete'; | |
179 | var success = function(o){ |
|
181 | var success = function(o){ | |
180 | var n = YUD.get('comment-'+comment_id); |
|
182 | var n = YUD.get('comment-'+comment_id); | |
181 | n.parentNode.removeChild(n); |
|
183 | n.parentNode.removeChild(n); | |
182 | } |
|
184 | } | |
183 | ajaxPOST(url,postData,success); |
|
185 | ajaxPOST(url,postData,success); | |
184 | } |
|
186 | } | |
185 |
|
187 | |||
186 | YUE.onDOMReady(function(){ |
|
188 | YUE.onDOMReady(function(){ | |
187 | YUE.on(YUQ('.line'),'mouseenter',function(e){ |
|
189 | YUE.on(YUQ('.line'),'mouseenter',function(e){ | |
188 | var tr = e.currentTarget; |
|
190 | var tr = e.currentTarget; | |
189 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context')){ |
|
191 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context')){ | |
190 | return |
|
192 | return | |
191 | } |
|
193 | } | |
192 | YUD.addClass(tr,'highlight'); |
|
194 | YUD.addClass(tr,'highlight'); | |
193 | }); |
|
195 | }); | |
194 | YUE.on(YUQ('.line'),'mouseleave',function(e){ |
|
196 | YUE.on(YUQ('.line'),'mouseleave',function(e){ | |
195 | YUD.removeClass(e.currentTarget,'highlight'); |
|
197 | YUD.removeClass(e.currentTarget,'highlight'); | |
196 | }); |
|
198 | }); | |
197 |
|
199 | |||
198 | YUE.on(YUQ('.line'),'click',function(e){ |
|
200 | YUE.on(YUQ('.line'),'click',function(e){ | |
199 | var tr = e.currentTarget; |
|
201 | var tr = e.currentTarget; | |
200 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context')){ |
|
202 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context')){ | |
201 | return |
|
203 | return | |
202 | } |
|
204 | } | |
203 | YUD.addClass(tr,'form-open'); |
|
205 | YUD.addClass(tr,'form-open'); | |
204 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; |
|
206 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; | |
205 | var f_path = YUD.getAttribute(node,'path'); |
|
207 | var f_path = YUD.getAttribute(node,'path'); | |
206 | var lineno = getLineNo(tr); |
|
208 | var lineno = getLineNo(tr); | |
207 | var form = createInlineForm(tr, f_path, lineno); |
|
209 | var form = createInlineForm(tr, f_path, lineno); | |
208 | YUD.insertAfter(form,tr); |
|
210 | YUD.insertAfter(form,tr); | |
209 | }) |
|
211 | }) | |
210 | }) |
|
212 | }) | |
211 |
|
213 | |||
212 | </script> |
|
214 | </script> | |
213 | </div> |
|
215 | </div> | |
214 | </%def> |
|
216 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now