Mercurial > kallithea
comparison rhodecode/model/pull_request.py @ 2608:58c529332e7e beta
Added option to close pull requests, in future that will be close & merge
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 15 Jul 2012 03:14:58 +0200 |
parents | 7b092b919f4f |
children | 3f50a5e8fc4d |
comparison
equal
deleted
inserted
replaced
2607:7ae36df760ce | 2608:58c529332e7e |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """ | 2 """ |
3 rhodecode.model.pull_reuquest | 3 rhodecode.model.pull_request |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5 | 5 |
6 pull request model for RhodeCode | 6 pull request model for RhodeCode |
7 | 7 |
8 :created_on: Jun 6, 2012 | 8 :created_on: Jun 6, 2012 |
9 :author: marcink | 9 :author: marcink |
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 import logging | 26 import logging |
27 import binascii | 27 import binascii |
28 import datetime | |
28 | 29 |
29 from pylons.i18n.translation import _ | 30 from pylons.i18n.translation import _ |
30 | 31 |
31 from rhodecode.model.meta import Session | 32 from rhodecode.model.meta import Session |
32 from rhodecode.lib import helpers as h | 33 from rhodecode.lib import helpers as h |
41 | 42 |
42 | 43 |
43 class PullRequestModel(BaseModel): | 44 class PullRequestModel(BaseModel): |
44 | 45 |
45 cls = PullRequest | 46 cls = PullRequest |
47 | |
48 def __get_pull_request(self, pull_request): | |
49 return self._get_instance(PullRequest, pull_request) | |
46 | 50 |
47 def get_all(self, repo): | 51 def get_all(self, repo): |
48 repo = self._get_repo(repo) | 52 repo = self._get_repo(repo) |
49 return PullRequest.query().filter(PullRequest.other_repo == repo).all() | 53 return PullRequest.query().filter(PullRequest.other_repo == repo).all() |
50 | 54 |
91 recipients=reviewers, | 95 recipients=reviewers, |
92 type_=Notification.TYPE_PULL_REQUEST,) | 96 type_=Notification.TYPE_PULL_REQUEST,) |
93 | 97 |
94 return new | 98 return new |
95 | 99 |
100 def close_pull_request(self, pull_request): | |
101 pull_request = self.__get_pull_request(pull_request) | |
102 pull_request.status = PullRequest.STATUS_CLOSED | |
103 pull_request.updated_on = datetime.datetime.now() | |
104 self.sa.add(pull_request) | |
105 | |
96 def _get_changesets(self, org_repo, org_ref, other_repo, other_ref, | 106 def _get_changesets(self, org_repo, org_ref, other_repo, other_ref, |
97 discovery_data): | 107 discovery_data): |
98 """ | 108 """ |
99 Returns a list of changesets that are incoming from org_repo@org_ref | 109 Returns a list of changesets that are incoming from org_repo@org_ref |
100 to other_repo@other_ref | 110 to other_repo@other_ref |