Mercurial > kallithea
comparison rhodecode/model/repo.py @ 786:2889a4446960 beta
when new repo is created make user follow it automatically,
add tilte to currently logged in user.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 28 Nov 2010 21:06:16 +0100 |
parents | 89b9037d68b7 |
children | 4502ceec31be |
comparison
equal
deleted
inserted
replaced
785:277427ac29a9 | 786:2889a4446960 |
---|---|
1 #!/usr/bin/env python | 1 # -*- coding: utf-8 -*- |
2 # encoding: utf-8 | 2 """ |
3 # model for handling repositories actions | 3 package.rhodecode.model.repo |
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | 4 ~~~~~~~~~~~~~~ |
5 | |
6 Repository model for rhodecode | |
7 | |
8 :created_on: Jun 5, 2010 | |
9 :author: marcink | |
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
11 :license: GPLv3, see COPYING for more details. | |
12 """ | |
5 # This program is free software; you can redistribute it and/or | 13 # This program is free software; you can redistribute it and/or |
6 # modify it under the terms of the GNU General Public License | 14 # modify it under the terms of the GNU General Public License |
7 # as published by the Free Software Foundation; version 2 | 15 # as published by the Free Software Foundation; version 2 |
8 # of the License or (at your opinion) any later version of the license. | 16 # of the License or (at your opinion) any later version of the license. |
9 # | 17 # |
14 # | 22 # |
15 # 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 |
16 # along with this program; if not, write to the Free Software | 24 # along with this program; if not, write to the Free Software |
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
18 # MA 02110-1301, USA. | 26 # MA 02110-1301, USA. |
19 """ | 27 import os |
20 Created on Jun 5, 2010 | 28 import shutil |
21 model for handling repositories actions | 29 import logging |
22 :author: marcink | 30 import traceback |
23 """ | |
24 from vcs.backends import get_backend | |
25 from datetime import datetime | 31 from datetime import datetime |
32 | |
26 from pylons import app_globals as g | 33 from pylons import app_globals as g |
34 | |
35 from rhodecode.model import BaseModel | |
36 from rhodecode.model.caching_query import FromCache | |
27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \ | 37 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \ |
28 Statistics | 38 Statistics |
29 from rhodecode.model import BaseModel | |
30 from rhodecode.model.user import UserModel | 39 from rhodecode.model.user import UserModel |
31 from rhodecode.model.caching_query import FromCache | 40 |
32 import logging | 41 from vcs.backends import get_backend |
33 import os | 42 |
34 import shutil | |
35 import traceback | |
36 log = logging.getLogger(__name__) | 43 log = logging.getLogger(__name__) |
37 | 44 |
38 class RepoModel(BaseModel): | 45 class RepoModel(BaseModel): |
39 | 46 |
40 def get(self, repo_id, cache=False): | 47 def get(self, repo_id, cache=False): |
156 repo_to_perm.user_id = UserModel(self.sa)\ | 163 repo_to_perm.user_id = UserModel(self.sa)\ |
157 .get_by_username('default', cache=False).user_id | 164 .get_by_username('default', cache=False).user_id |
158 | 165 |
159 self.sa.add(repo_to_perm) | 166 self.sa.add(repo_to_perm) |
160 self.sa.commit() | 167 self.sa.commit() |
168 | |
169 | |
170 #now automatically start following this repository as owner | |
171 from rhodecode.model.scm import ScmModel | |
172 ScmModel(self.sa).toggle_following_repo(new_repo.repo_id, | |
173 cur_user.user_id) | |
174 | |
161 if not just_db: | 175 if not just_db: |
162 self.__create_repo(repo_name, form_data['repo_type']) | 176 self.__create_repo(repo_name, form_data['repo_type']) |
163 except: | 177 except: |
164 log.error(traceback.format_exc()) | 178 log.error(traceback.format_exc()) |
165 self.sa.rollback() | 179 self.sa.rollback() |