Mercurial > kallithea
comparison rhodecode/model/comment.py @ 1670:d2de0c2f02cd beta
#77 code review
- initial very simple version of changeset comments
- RST parsed
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 11 Nov 2011 20:41:53 +0200 |
parents | |
children | 7c487d2678c7 |
comparison
equal
deleted
inserted
replaced
1669:f522f4d3bf93 | 1670:d2de0c2f02cd |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 rhodecode.model.comment | |
4 ~~~~~~~~~~~~~~~~~~~~~~~ | |
5 | |
6 comments model for RhodeCode | |
7 | |
8 :created_on: Nov 11, 2011 | |
9 :author: marcink | |
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
11 :license: GPLv3, see COPYING for more details. | |
12 """ | |
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 | |
15 # the Free Software Foundation, either version 3 of the License, or | |
16 # (at your option) any later version. | |
17 # | |
18 # This program is distributed in the hope that it will be useful, | |
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 # GNU General Public License for more details. | |
22 # | |
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/>. | |
25 | |
26 | |
27 import logging | |
28 import traceback | |
29 | |
30 from rhodecode.model import BaseModel | |
31 from rhodecode.model.db import ChangesetComment | |
32 | |
33 log = logging.getLogger(__name__) | |
34 | |
35 | |
36 class ChangesetCommentsModel(BaseModel): | |
37 | |
38 | |
39 def create(self, text, repo_id, user_id, commit_id, f_path=None, | |
40 line_no=None): | |
41 """ | |
42 Creates new comment for changeset | |
43 | |
44 :param text: | |
45 :param repo_id: | |
46 :param user_id: | |
47 :param commit_id: | |
48 :param f_path: | |
49 :param line_no: | |
50 """ | |
51 | |
52 comment = ChangesetComment() | |
53 comment.repo_id = repo_id | |
54 comment.user_id = user_id | |
55 comment.commit_id = commit_id | |
56 comment.text = text | |
57 comment.f_path = f_path | |
58 comment.line_no = line_no | |
59 | |
60 self.sa.add(comment) | |
61 self.sa.commit() | |
62 return comment | |
63 | |
64 def delete(self, comment_id): | |
65 """ | |
66 Deletes given comment | |
67 | |
68 :param comment_id: | |
69 """ | |
70 comment = ChangesetComment.get(comment_id) | |
71 self.sa.delete(comment) | |
72 self.sa.commit() | |
73 return comment |