Show More
@@ -33,8 +33,7 b' from tg.i18n import ugettext as _' | |||||
33 | from kallithea.lib import webutils |
|
33 | from kallithea.lib import webutils | |
34 | from kallithea.lib.utils import extract_mentioned_users |
|
34 | from kallithea.lib.utils import extract_mentioned_users | |
35 | from kallithea.lib.utils2 import shorter |
|
35 | from kallithea.lib.utils2 import shorter | |
36 | from kallithea.model import db, meta |
|
36 | from kallithea.model import db, meta, notification | |
37 | from kallithea.model.notification import NotificationModel |
|
|||
38 |
|
37 | |||
39 |
|
38 | |||
40 | log = logging.getLogger(__name__) |
|
39 | log = logging.getLogger(__name__) | |
@@ -69,7 +68,7 b' class ChangesetCommentsModel(object):' | |||||
69 |
|
68 | |||
70 | # changeset |
|
69 | # changeset | |
71 | if revision: |
|
70 | if revision: | |
72 | notification_type = NotificationModel.TYPE_CHANGESET_COMMENT |
|
71 | notification_type = notification.NotificationModel.TYPE_CHANGESET_COMMENT | |
73 | cs = repo.scm_instance.get_changeset(revision) |
|
72 | cs = repo.scm_instance.get_changeset(revision) | |
74 | desc = cs.short_id |
|
73 | desc = cs.short_id | |
75 |
|
74 | |||
@@ -114,7 +113,7 b' class ChangesetCommentsModel(object):' | |||||
114 | } |
|
113 | } | |
115 | # pull request |
|
114 | # pull request | |
116 | elif pull_request: |
|
115 | elif pull_request: | |
117 | notification_type = NotificationModel.TYPE_PULL_REQUEST_COMMENT |
|
116 | notification_type = notification.NotificationModel.TYPE_PULL_REQUEST_COMMENT | |
118 | desc = comment.pull_request.title |
|
117 | desc = comment.pull_request.title | |
119 | _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':') |
|
118 | _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':') | |
120 | _other_ref_type, other_ref_name, _other_rev = comment.pull_request.other_ref.split(':') |
|
119 | _other_ref_type, other_ref_name, _other_rev = comment.pull_request.other_ref.split(':') | |
@@ -208,7 +207,7 b' class ChangesetCommentsModel(object):' | |||||
208 | closing_pr=closing_pr) |
|
207 | closing_pr=closing_pr) | |
209 | email_kwargs['is_mention'] = False |
|
208 | email_kwargs['is_mention'] = False | |
210 | # create notification objects, and emails |
|
209 | # create notification objects, and emails | |
211 | NotificationModel().create( |
|
210 | notification.NotificationModel().create( | |
212 | created_by=author, subject=subj, body=body, |
|
211 | created_by=author, subject=subj, body=body, | |
213 | recipients=recipients, type_=notification_type, |
|
212 | recipients=recipients, type_=notification_type, | |
214 | email_kwargs=email_kwargs, |
|
213 | email_kwargs=email_kwargs, | |
@@ -219,7 +218,7 b' class ChangesetCommentsModel(object):' | |||||
219 | email_kwargs['is_mention'] = True |
|
218 | email_kwargs['is_mention'] = True | |
220 | subj = _('[Mention]') + ' ' + subj |
|
219 | subj = _('[Mention]') + ' ' + subj | |
221 | # FIXME: this subject is wrong and unused! |
|
220 | # FIXME: this subject is wrong and unused! | |
222 | NotificationModel().create( |
|
221 | notification.NotificationModel().create( | |
223 | created_by=author, subject=subj, body=body, |
|
222 | created_by=author, subject=subj, body=body, | |
224 | recipients=mention_recipients, |
|
223 | recipients=mention_recipients, | |
225 | type_=notification_type, |
|
224 | type_=notification_type, |
@@ -34,9 +34,7 b' import traceback' | |||||
34 |
|
34 | |||
35 | from kallithea.lib import ext_json |
|
35 | from kallithea.lib import ext_json | |
36 | from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, time_to_datetime |
|
36 | from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, time_to_datetime | |
37 | from kallithea.model import db, meta |
|
37 | from kallithea.model import db, meta, repo, scm | |
38 | from kallithea.model.repo import RepoModel |
|
|||
39 | from kallithea.model.scm import ScmModel |
|
|||
40 |
|
38 | |||
41 |
|
39 | |||
42 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
@@ -58,12 +56,12 b' class GistModel(object):' | |||||
58 |
|
56 | |||
59 | :param gist: gist object |
|
57 | :param gist: gist object | |
60 | """ |
|
58 | """ | |
61 | root_path = RepoModel().repos_path |
|
59 | root_path = repo.RepoModel().repos_path | |
62 | rm_path = os.path.join(root_path, db.Gist.GIST_STORE_LOC, gist.gist_access_id) |
|
60 | rm_path = os.path.join(root_path, db.Gist.GIST_STORE_LOC, gist.gist_access_id) | |
63 | log.info("Removing %s", rm_path) |
|
61 | log.info("Removing %s", rm_path) | |
64 | shutil.rmtree(rm_path) |
|
62 | shutil.rmtree(rm_path) | |
65 |
|
63 | |||
66 | def _store_metadata(self, repo, gist_id, gist_access_id, user_id, gist_type, |
|
64 | def _store_metadata(self, fs_repo, gist_id, gist_access_id, user_id, gist_type, | |
67 | gist_expires): |
|
65 | gist_expires): | |
68 | """ |
|
66 | """ | |
69 | store metadata inside the gist, this can be later used for imports |
|
67 | store metadata inside the gist, this can be later used for imports | |
@@ -78,7 +76,7 b' class GistModel(object):' | |||||
78 | 'gist_expires': gist_expires, |
|
76 | 'gist_expires': gist_expires, | |
79 | 'gist_updated': time.time(), |
|
77 | 'gist_updated': time.time(), | |
80 | } |
|
78 | } | |
81 | with open(os.path.join(repo.path, '.hg', db.Gist.GIST_METADATA_FILE), 'wb') as f: |
|
79 | with open(os.path.join(fs_repo.path, '.hg', db.Gist.GIST_METADATA_FILE), 'wb') as f: | |
82 | f.write(ascii_bytes(ext_json.dumps(metadata))) |
|
80 | f.write(ascii_bytes(ext_json.dumps(metadata))) | |
83 |
|
81 | |||
84 | def get_gist(self, gist): |
|
82 | def get_gist(self, gist): | |
@@ -90,8 +88,8 b' class GistModel(object):' | |||||
90 |
|
88 | |||
91 | :param gist_access_id: |
|
89 | :param gist_access_id: | |
92 | """ |
|
90 | """ | |
93 | repo = db.Gist.get_by_access_id(gist_access_id) |
|
91 | gist_repo = db.Gist.get_by_access_id(gist_access_id) | |
94 | cs = repo.scm_instance.get_changeset(revision) |
|
92 | cs = gist_repo.scm_instance.get_changeset(revision) | |
95 | return cs, [n for n in cs.get_node('/')] |
|
93 | return cs, [n for n in cs.get_node('/')] | |
96 |
|
94 | |||
97 | def create(self, description, owner, ip_addr, gist_mapping, |
|
95 | def create(self, description, owner, ip_addr, gist_mapping, | |
@@ -125,7 +123,7 b' class GistModel(object):' | |||||
125 | gist.gist_access_id = str(gist.gist_id) |
|
123 | gist.gist_access_id = str(gist.gist_id) | |
126 |
|
124 | |||
127 | log.debug('Creating new %s GIST repo %s', gist_type, gist.gist_access_id) |
|
125 | log.debug('Creating new %s GIST repo %s', gist_type, gist.gist_access_id) | |
128 | repo = RepoModel()._create_filesystem_repo( |
|
126 | fs_repo = repo.RepoModel()._create_filesystem_repo( | |
129 | repo_name=gist.gist_access_id, repo_type='hg', repo_group=db.Gist.GIST_STORE_LOC) |
|
127 | repo_name=gist.gist_access_id, repo_type='hg', repo_group=db.Gist.GIST_STORE_LOC) | |
130 |
|
128 | |||
131 | processed_mapping = {} |
|
129 | processed_mapping = {} | |
@@ -151,9 +149,9 b' class GistModel(object):' | |||||
151 | # fake Kallithea Repository object |
|
149 | # fake Kallithea Repository object | |
152 | fake_repo = AttributeDict(dict( |
|
150 | fake_repo = AttributeDict(dict( | |
153 | repo_name=os.path.join(db.Gist.GIST_STORE_LOC, gist.gist_access_id), |
|
151 | repo_name=os.path.join(db.Gist.GIST_STORE_LOC, gist.gist_access_id), | |
154 | scm_instance_no_cache=lambda: repo, |
|
152 | scm_instance_no_cache=lambda: fs_repo, | |
155 | )) |
|
153 | )) | |
156 | ScmModel().create_nodes( |
|
154 | scm.ScmModel().create_nodes( | |
157 | user=owner.user_id, |
|
155 | user=owner.user_id, | |
158 | ip_addr=ip_addr, |
|
156 | ip_addr=ip_addr, | |
159 | repo=fake_repo, |
|
157 | repo=fake_repo, | |
@@ -162,7 +160,7 b' class GistModel(object):' | |||||
162 | trigger_push_hook=False |
|
160 | trigger_push_hook=False | |
163 | ) |
|
161 | ) | |
164 |
|
162 | |||
165 | self._store_metadata(repo, gist.gist_id, gist.gist_access_id, |
|
163 | self._store_metadata(fs_repo, gist.gist_id, gist.gist_access_id, | |
166 | owner.user_id, gist.gist_type, gist.gist_expires) |
|
164 | owner.user_id, gist.gist_type, gist.gist_expires) | |
167 | return gist |
|
165 | return gist | |
168 |
|
166 | |||
@@ -221,7 +219,7 b' class GistModel(object):' | |||||
221 | self._store_metadata(gist_repo, gist.gist_id, gist.gist_access_id, |
|
219 | self._store_metadata(gist_repo, gist.gist_id, gist.gist_access_id, | |
222 | owner.user_id, gist.gist_type, gist.gist_expires) |
|
220 | owner.user_id, gist.gist_type, gist.gist_expires) | |
223 |
|
221 | |||
224 | ScmModel().update_nodes( |
|
222 | scm.ScmModel().update_nodes( | |
225 | user=owner.user_id, |
|
223 | user=owner.user_id, | |
226 | ip_addr=ip_addr, |
|
224 | ip_addr=ip_addr, | |
227 | repo=fake_repo, |
|
225 | repo=fake_repo, |
@@ -36,8 +36,7 b' from kallithea.lib import auth, webutils' | |||||
36 | from kallithea.lib.hooks import log_create_pullrequest |
|
36 | from kallithea.lib.hooks import log_create_pullrequest | |
37 | from kallithea.lib.utils import extract_mentioned_users |
|
37 | from kallithea.lib.utils import extract_mentioned_users | |
38 | from kallithea.lib.utils2 import ascii_bytes, short_ref_name, shorter |
|
38 | from kallithea.lib.utils2 import ascii_bytes, short_ref_name, shorter | |
39 | from kallithea.model import db, meta |
|
39 | from kallithea.model import changeset_status, comment, db, meta, notification | |
40 | from kallithea.model.notification import NotificationModel |
|
|||
41 |
|
40 | |||
42 |
|
41 | |||
43 | log = logging.getLogger(__name__) |
|
42 | log = logging.getLogger(__name__) | |
@@ -114,18 +113,18 b' class PullRequestModel(object):' | |||||
114 | 'is_mention': False, |
|
113 | 'is_mention': False, | |
115 | } |
|
114 | } | |
116 | if reviewers: |
|
115 | if reviewers: | |
117 | NotificationModel().create(created_by=user, subject=subject, body=body, |
|
116 | notification.NotificationModel().create(created_by=user, subject=subject, body=body, | |
118 | recipients=reviewers, |
|
117 | recipients=reviewers, | |
119 | type_=NotificationModel.TYPE_PULL_REQUEST, |
|
118 | type_=notification.NotificationModel.TYPE_PULL_REQUEST, | |
120 | email_kwargs=email_kwargs) |
|
119 | email_kwargs=email_kwargs) | |
121 |
|
120 | |||
122 | if mention_recipients: |
|
121 | if mention_recipients: | |
123 | email_kwargs['is_mention'] = True |
|
122 | email_kwargs['is_mention'] = True | |
124 | subject = _('[Mention]') + ' ' + subject |
|
123 | subject = _('[Mention]') + ' ' + subject | |
125 | # FIXME: this subject is wrong and unused! |
|
124 | # FIXME: this subject is wrong and unused! | |
126 | NotificationModel().create(created_by=user, subject=subject, body=body, |
|
125 | notification.NotificationModel().create(created_by=user, subject=subject, body=body, | |
127 | recipients=mention_recipients, |
|
126 | recipients=mention_recipients, | |
128 | type_=NotificationModel.TYPE_PULL_REQUEST, |
|
127 | type_=notification.NotificationModel.TYPE_PULL_REQUEST, | |
129 | email_kwargs=email_kwargs) |
|
128 | email_kwargs=email_kwargs) | |
130 |
|
129 | |||
131 | return reviewers, redundant_reviewers |
|
130 | return reviewers, redundant_reviewers | |
@@ -272,9 +271,7 b' class CreatePullRequestAction(object):' | |||||
272 | self.org_repo.scm_instance._repo[b"refs/pull/%d/head" % pr.pull_request_id] = ascii_bytes(self.org_rev) |
|
271 | self.org_repo.scm_instance._repo[b"refs/pull/%d/head" % pr.pull_request_id] = ascii_bytes(self.org_rev) | |
273 |
|
272 | |||
274 | # reset state to under-review |
|
273 | # reset state to under-review | |
275 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
274 | new_comment = comment.ChangesetCommentsModel().create( | |
276 | from kallithea.model.comment import ChangesetCommentsModel |
|
|||
277 | comment = ChangesetCommentsModel().create( |
|
|||
278 | text='', |
|
275 | text='', | |
279 | repo=self.org_repo, |
|
276 | repo=self.org_repo, | |
280 | author=created_by, |
|
277 | author=created_by, | |
@@ -282,11 +279,11 b' class CreatePullRequestAction(object):' | |||||
282 | send_email=False, |
|
279 | send_email=False, | |
283 | status_change=db.ChangesetStatus.STATUS_UNDER_REVIEW, |
|
280 | status_change=db.ChangesetStatus.STATUS_UNDER_REVIEW, | |
284 | ) |
|
281 | ) | |
285 | ChangesetStatusModel().set_status( |
|
282 | changeset_status.ChangesetStatusModel().set_status( | |
286 | self.org_repo, |
|
283 | self.org_repo, | |
287 | db.ChangesetStatus.STATUS_UNDER_REVIEW, |
|
284 | db.ChangesetStatus.STATUS_UNDER_REVIEW, | |
288 | created_by, |
|
285 | created_by, | |
289 | comment, |
|
286 | new_comment, | |
290 | pull_request=pr, |
|
287 | pull_request=pr, | |
291 | ) |
|
288 | ) | |
292 |
|
289 | |||
@@ -393,8 +390,7 b' class CreatePullRequestIterationAction(o' | |||||
393 | pull_request = self.create_action.execute() |
|
390 | pull_request = self.create_action.execute() | |
394 |
|
391 | |||
395 | # Close old iteration |
|
392 | # Close old iteration | |
396 |
|
|
393 | comment.ChangesetCommentsModel().create( | |
397 | ChangesetCommentsModel().create( |
|
|||
398 | text=_('Closed, next iteration: %s .') % pull_request.url(canonical=True), |
|
394 | text=_('Closed, next iteration: %s .') % pull_request.url(canonical=True), | |
399 | repo=self.old_pull_request.other_repo_id, |
|
395 | repo=self.old_pull_request.other_repo_id, | |
400 | author=request.authuser.user_id, |
|
396 | author=request.authuser.user_id, |
@@ -39,7 +39,7 b' from kallithea.lib.hooks import log_dele' | |||||
39 | from kallithea.lib.utils import is_valid_repo_uri, make_ui |
|
39 | from kallithea.lib.utils import is_valid_repo_uri, make_ui | |
40 | from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix |
|
40 | from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix | |
41 | from kallithea.lib.vcs.backends import get_backend |
|
41 | from kallithea.lib.vcs.backends import get_backend | |
42 | from kallithea.model import db, meta |
|
42 | from kallithea.model import db, meta, scm | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | log = logging.getLogger(__name__) |
|
45 | log = logging.getLogger(__name__) | |
@@ -131,7 +131,6 b' class RepoModel(object):' | |||||
131 | from tg import tmpl_context as c |
|
131 | from tg import tmpl_context as c | |
132 |
|
132 | |||
133 | import kallithea.lib.helpers as h |
|
133 | import kallithea.lib.helpers as h | |
134 | from kallithea.model.scm import ScmModel |
|
|||
135 |
|
134 | |||
136 | def repo_lnk(name, rtype, rstate, private, fork_of): |
|
135 | def repo_lnk(name, rtype, rstate, private, fork_of): | |
137 | return _render('repo_name', name, rtype, rstate, private, fork_of, |
|
136 | return _render('repo_name', name, rtype, rstate, private, fork_of, | |
@@ -187,7 +186,7 b' class RepoModel(object):' | |||||
187 | repo.repo_state, repo.private, repo.fork), |
|
186 | repo.repo_state, repo.private, repo.fork), | |
188 | "following": following( |
|
187 | "following": following( | |
189 | repo.repo_id, |
|
188 | repo.repo_id, | |
190 | ScmModel().is_following_repo(repo.repo_name, request.authuser.user_id), |
|
189 | scm.ScmModel().is_following_repo(repo.repo_name, request.authuser.user_id), | |
191 | ), |
|
190 | ), | |
192 | "last_change_iso": repo.last_db_change.isoformat(), |
|
191 | "last_change_iso": repo.last_db_change.isoformat(), | |
193 | "last_change": last_change(repo.last_db_change), |
|
192 | "last_change": last_change(repo.last_db_change), | |
@@ -332,8 +331,6 b' class RepoModel(object):' | |||||
332 | executed by create() repo, with exception of importing existing repos. |
|
331 | executed by create() repo, with exception of importing existing repos. | |
333 |
|
332 | |||
334 | """ |
|
333 | """ | |
335 | from kallithea.model.scm import ScmModel |
|
|||
336 |
|
||||
337 | owner = db.User.guess_instance(owner) |
|
334 | owner = db.User.guess_instance(owner) | |
338 | fork_of = db.Repository.guess_instance(fork_of) |
|
335 | fork_of = db.Repository.guess_instance(fork_of) | |
339 | repo_group = db.RepoGroup.guess_instance(repo_group) |
|
336 | repo_group = db.RepoGroup.guess_instance(repo_group) | |
@@ -408,7 +405,7 b' class RepoModel(object):' | |||||
408 | self._create_default_perms(new_repo, private) |
|
405 | self._create_default_perms(new_repo, private) | |
409 |
|
406 | |||
410 | # now automatically start following this repository as owner |
|
407 | # now automatically start following this repository as owner | |
411 | ScmModel().toggle_following_repo(new_repo.repo_id, owner.user_id) |
|
408 | scm.ScmModel().toggle_following_repo(new_repo.repo_id, owner.user_id) | |
412 | # we need to flush here, in order to check if database won't |
|
409 | # we need to flush here, in order to check if database won't | |
413 | # throw any exceptions, create filesystem dirs at the very end |
|
410 | # throw any exceptions, create filesystem dirs at the very end | |
414 | meta.Session().flush() |
|
411 | meta.Session().flush() | |
@@ -628,7 +625,6 b' class RepoModel(object):' | |||||
628 | Note: clone_uri is low level and not validated - it might be a file system path used for validated cloning |
|
625 | Note: clone_uri is low level and not validated - it might be a file system path used for validated cloning | |
629 | """ |
|
626 | """ | |
630 | from kallithea.lib.utils import is_valid_repo, is_valid_repo_group |
|
627 | from kallithea.lib.utils import is_valid_repo, is_valid_repo_group | |
631 | from kallithea.model.scm import ScmModel |
|
|||
632 |
|
628 | |||
633 | if '/' in repo_name: |
|
629 | if '/' in repo_name: | |
634 | raise ValueError('repo_name must not contain groups got `%s`' % repo_name) |
|
630 | raise ValueError('repo_name must not contain groups got `%s`' % repo_name) | |
@@ -669,7 +665,7 b' class RepoModel(object):' | |||||
669 | elif repo_type == 'git': |
|
665 | elif repo_type == 'git': | |
670 | repo = backend(repo_path, create=True, src_url=clone_uri, bare=True) |
|
666 | repo = backend(repo_path, create=True, src_url=clone_uri, bare=True) | |
671 | # add kallithea hook into this repo |
|
667 | # add kallithea hook into this repo | |
672 | ScmModel().install_git_hooks(repo) |
|
668 | scm.ScmModel().install_git_hooks(repo) | |
673 | else: |
|
669 | else: | |
674 | raise Exception('Not supported repo_type %s expected hg/git' % repo_type) |
|
670 | raise Exception('Not supported repo_type %s expected hg/git' % repo_type) | |
675 |
|
671 |
@@ -34,7 +34,7 b' import traceback' | |||||
34 |
|
34 | |||
35 | import kallithea.lib.utils2 |
|
35 | import kallithea.lib.utils2 | |
36 | from kallithea.lib.utils2 import LazyProperty |
|
36 | from kallithea.lib.utils2 import LazyProperty | |
37 | from kallithea.model import db, meta |
|
37 | from kallithea.model import db, meta, repo | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
@@ -189,7 +189,6 b' class RepoGroupModel(object):' | |||||
189 | perms_updates=None, recursive=None, |
|
189 | perms_updates=None, recursive=None, | |
190 | check_perms=True): |
|
190 | check_perms=True): | |
191 | from kallithea.lib.auth import HasUserGroupPermissionLevel |
|
191 | from kallithea.lib.auth import HasUserGroupPermissionLevel | |
192 | from kallithea.model.repo import RepoModel |
|
|||
193 |
|
192 | |||
194 | if not perms_new: |
|
193 | if not perms_new: | |
195 | perms_new = [] |
|
194 | perms_new = [] | |
@@ -210,7 +209,7 b' class RepoGroupModel(object):' | |||||
210 | # we set group permission but we have to switch to repo |
|
209 | # we set group permission but we have to switch to repo | |
211 | # permission |
|
210 | # permission | |
212 | perm = perm.replace('group.', 'repository.') |
|
211 | perm = perm.replace('group.', 'repository.') | |
213 | RepoModel().grant_user_permission( |
|
212 | repo.RepoModel().grant_user_permission( | |
214 | repo=obj, user=user, perm=perm |
|
213 | repo=obj, user=user, perm=perm | |
215 | ) |
|
214 | ) | |
216 |
|
215 | |||
@@ -223,7 +222,7 b' class RepoGroupModel(object):' | |||||
223 | # we set group permission but we have to switch to repo |
|
222 | # we set group permission but we have to switch to repo | |
224 | # permission |
|
223 | # permission | |
225 | perm = perm.replace('group.', 'repository.') |
|
224 | perm = perm.replace('group.', 'repository.') | |
226 | RepoModel().grant_user_group_permission( |
|
225 | repo.RepoModel().grant_user_group_permission( | |
227 | repo=obj, group_name=users_group, perm=perm |
|
226 | repo=obj, group_name=users_group, perm=perm | |
228 | ) |
|
227 | ) | |
229 |
|
228 | |||
@@ -335,7 +334,6 b' class RepoGroupModel(object):' | |||||
335 | raise |
|
334 | raise | |
336 |
|
335 | |||
337 | def add_permission(self, repo_group, obj, obj_type, perm, recursive): |
|
336 | def add_permission(self, repo_group, obj, obj_type, perm, recursive): | |
338 | from kallithea.model.repo import RepoModel |
|
|||
339 | repo_group = db.RepoGroup.guess_instance(repo_group) |
|
337 | repo_group = db.RepoGroup.guess_instance(repo_group) | |
340 | perm = db.Permission.guess_instance(perm) |
|
338 | perm = db.Permission.guess_instance(perm) | |
341 |
|
339 | |||
@@ -367,9 +365,9 b' class RepoGroupModel(object):' | |||||
367 | # for repos we need to hotfix the name of permission |
|
365 | # for repos we need to hotfix the name of permission | |
368 | _perm = perm.permission_name.replace('group.', 'repository.') |
|
366 | _perm = perm.permission_name.replace('group.', 'repository.') | |
369 | if obj_type == 'user': |
|
367 | if obj_type == 'user': | |
370 | RepoModel().grant_user_permission(el, user=obj, perm=_perm) |
|
368 | repo.RepoModel().grant_user_permission(el, user=obj, perm=_perm) | |
371 | elif obj_type == 'user_group': |
|
369 | elif obj_type == 'user_group': | |
372 | RepoModel().grant_user_group_permission(el, group_name=obj, perm=_perm) |
|
370 | repo.RepoModel().grant_user_group_permission(el, group_name=obj, perm=_perm) | |
373 | else: |
|
371 | else: | |
374 | raise Exception('undefined object type %s' % obj_type) |
|
372 | raise Exception('undefined object type %s' % obj_type) | |
375 | else: |
|
373 | else: | |
@@ -391,7 +389,6 b' class RepoGroupModel(object):' | |||||
391 | :param obj_type: user or user group type |
|
389 | :param obj_type: user or user group type | |
392 | :param recursive: recurse to all children of group |
|
390 | :param recursive: recurse to all children of group | |
393 | """ |
|
391 | """ | |
394 | from kallithea.model.repo import RepoModel |
|
|||
395 | repo_group = db.RepoGroup.guess_instance(repo_group) |
|
392 | repo_group = db.RepoGroup.guess_instance(repo_group) | |
396 |
|
393 | |||
397 | for el in repo_group.recursive_groups_and_repos(): |
|
394 | for el in repo_group.recursive_groups_and_repos(): | |
@@ -420,9 +417,9 b' class RepoGroupModel(object):' | |||||
420 | raise Exception('undefined object type %s' % obj_type) |
|
417 | raise Exception('undefined object type %s' % obj_type) | |
421 | elif isinstance(el, db.Repository): |
|
418 | elif isinstance(el, db.Repository): | |
422 | if obj_type == 'user': |
|
419 | if obj_type == 'user': | |
423 | RepoModel().revoke_user_permission(el, user=obj) |
|
420 | repo.RepoModel().revoke_user_permission(el, user=obj) | |
424 | elif obj_type == 'user_group': |
|
421 | elif obj_type == 'user_group': | |
425 | RepoModel().revoke_user_group_permission(el, group_name=obj) |
|
422 | repo.RepoModel().revoke_user_group_permission(el, group_name=obj) | |
426 | else: |
|
423 | else: | |
427 | raise Exception('undefined object type %s' % obj_type) |
|
424 | raise Exception('undefined object type %s' % obj_type) | |
428 | else: |
|
425 | else: |
@@ -166,7 +166,7 b' class UserModel(object):' | |||||
166 | raise |
|
166 | raise | |
167 |
|
167 | |||
168 | def create_registration(self, form_data): |
|
168 | def create_registration(self, form_data): | |
169 |
from kallithea.model |
|
169 | from kallithea.model import notification | |
170 |
|
170 | |||
171 | form_data['admin'] = False |
|
171 | form_data['admin'] = False | |
172 | form_data['extern_type'] = db.User.DEFAULT_AUTH_TYPE |
|
172 | form_data['extern_type'] = db.User.DEFAULT_AUTH_TYPE | |
@@ -188,9 +188,9 b' class UserModel(object):' | |||||
188 | 'new_username': new_user.username, |
|
188 | 'new_username': new_user.username, | |
189 | 'new_email': new_user.email, |
|
189 | 'new_email': new_user.email, | |
190 | 'new_full_name': new_user.full_name} |
|
190 | 'new_full_name': new_user.full_name} | |
191 | NotificationModel().create(created_by=new_user, subject=subject, |
|
191 | notification.NotificationModel().create(created_by=new_user, subject=subject, | |
192 | body=body, recipients=None, |
|
192 | body=body, recipients=None, | |
193 | type_=NotificationModel.TYPE_REGISTRATION, |
|
193 | type_=notification.NotificationModel.TYPE_REGISTRATION, | |
194 | email_kwargs=email_kwargs) |
|
194 | email_kwargs=email_kwargs) | |
195 |
|
195 | |||
196 | def update(self, user_id, form_data, skip_attrs=None): |
|
196 | def update(self, user_id, form_data, skip_attrs=None): | |
@@ -315,7 +315,7 b' class UserModel(object):' | |||||
315 | email. |
|
315 | email. | |
316 | """ |
|
316 | """ | |
317 | from kallithea.lib.celerylib import tasks |
|
317 | from kallithea.lib.celerylib import tasks | |
318 |
from kallithea.model |
|
318 | from kallithea.model import notification | |
319 |
|
319 | |||
320 | user_email = data['email'] |
|
320 | user_email = data['email'] | |
321 | user = db.User.get_by_email(user_email) |
|
321 | user = db.User.get_by_email(user_email) | |
@@ -336,13 +336,13 b' class UserModel(object):' | |||||
336 | else: |
|
336 | else: | |
337 | log.debug('password reset user %s found but was managed', user) |
|
337 | log.debug('password reset user %s found but was managed', user) | |
338 | token = link = None |
|
338 | token = link = None | |
339 | reg_type = EmailNotificationModel.TYPE_PASSWORD_RESET |
|
339 | reg_type = notification.EmailNotificationModel.TYPE_PASSWORD_RESET | |
340 | body = EmailNotificationModel().get_email_tmpl( |
|
340 | body = notification.EmailNotificationModel().get_email_tmpl( | |
341 | reg_type, 'txt', |
|
341 | reg_type, 'txt', | |
342 | user=user.short_contact, |
|
342 | user=user.short_contact, | |
343 | reset_token=token, |
|
343 | reset_token=token, | |
344 | reset_url=link) |
|
344 | reset_url=link) | |
345 | html_body = EmailNotificationModel().get_email_tmpl( |
|
345 | html_body = notification.EmailNotificationModel().get_email_tmpl( | |
346 | reg_type, 'html', |
|
346 | reg_type, 'html', | |
347 | user=user.short_contact, |
|
347 | user=user.short_contact, | |
348 | reset_token=token, |
|
348 | reset_token=token, |
General Comments 0
You need to be logged in to leave comments.
Login now