##// END OF EJS Templates
merge with default
marcink -
r863:4c123ade merge default
parent child Browse files
Show More
@@ -1,9 +1,10 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 package.rhodecode.controllers.admin.ldap_settings
3 rhodecode.controllers.admin.ldap_settings
4 ~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 ldap controller for RhodeCode
6 ldap controller for RhodeCode
7
7 :created_on: Nov 26, 2010
8 :created_on: Nov 26, 2010
8 :author: marcink
9 :author: marcink
9 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
@@ -64,9 +65,7 b' class LdapSettingsController(BaseControl'
64 force_defaults=True,)
65 force_defaults=True,)
65
66
66 def ldap_settings(self):
67 def ldap_settings(self):
67 """
68 """POST ldap create and store ldap settings"""
68 POST ldap create and store ldap settings
69 """
70
69
71 settings_model = SettingsModel()
70 settings_model = SettingsModel()
72 _form = LdapSettingsForm()()
71 _form = LdapSettingsForm()()
@@ -100,7 +99,7 b' class LdapSettingsController(BaseControl'
100 encoding="UTF-8")
99 encoding="UTF-8")
101 except Exception:
100 except Exception:
102 log.error(traceback.format_exc())
101 log.error(traceback.format_exc())
103 h.flash(_('error occured during update of ldap settings'),
102 h.flash(_('error occurred during update of ldap settings'),
104 category='error')
103 category='error')
105
104
106 return redirect(url('ldap_home'))
105 return redirect(url('ldap_home'))
@@ -120,7 +120,7 b' class PermissionsController(BaseControll'
120 encoding="UTF-8")
120 encoding="UTF-8")
121 except Exception:
121 except Exception:
122 log.error(traceback.format_exc())
122 log.error(traceback.format_exc())
123 h.flash(_('error occured during update of permissions'),
123 h.flash(_('error occurred during update of permissions'),
124 category='error')
124 category='error')
125
125
126 return redirect(url('edit_permission', id=id))
126 return redirect(url('edit_permission', id=id))
@@ -107,7 +107,7 b' class ReposController(BaseController):'
107
107
108 except Exception:
108 except Exception:
109 log.error(traceback.format_exc())
109 log.error(traceback.format_exc())
110 msg = _('error occured during creation of repository %s') \
110 msg = _('error occurred during creation of repository %s') \
111 % form_result.get('repo_name')
111 % form_result.get('repo_name')
112 h.flash(msg, category='error')
112 h.flash(msg, category='error')
113 if request.POST.get('user_created'):
113 if request.POST.get('user_created'):
@@ -206,7 +206,7 b' class ReposController(BaseController):'
206
206
207 except Exception, e:
207 except Exception, e:
208 log.error(traceback.format_exc())
208 log.error(traceback.format_exc())
209 h.flash(_('An error occured during deletion of %s') % repo_name,
209 h.flash(_('An error occurred during deletion of %s') % repo_name,
210 category='error')
210 category='error')
211
211
212 return redirect(url('repos'))
212 return redirect(url('repos'))
@@ -222,7 +222,7 b' class ReposController(BaseController):'
222 repo_model = RepoModel()
222 repo_model = RepoModel()
223 repo_model.delete_perm_user(request.POST, repo_name)
223 repo_model.delete_perm_user(request.POST, repo_name)
224 except Exception, e:
224 except Exception, e:
225 h.flash(_('An error occured during deletion of repository user'),
225 h.flash(_('An error occurred during deletion of repository user'),
226 category='error')
226 category='error')
227 raise HTTPInternalServerError()
227 raise HTTPInternalServerError()
228
228
@@ -237,14 +237,14 b' class ReposController(BaseController):'
237 repo_model = RepoModel()
237 repo_model = RepoModel()
238 repo_model.delete_stats(repo_name)
238 repo_model.delete_stats(repo_name)
239 except Exception, e:
239 except Exception, e:
240 h.flash(_('An error occured during deletion of repository stats'),
240 h.flash(_('An error occurred during deletion of repository stats'),
241 category='error')
241 category='error')
242 return redirect(url('edit_repo', repo_name=repo_name))
242 return redirect(url('edit_repo', repo_name=repo_name))
243
243
244 @HasPermissionAllDecorator('hg.admin')
244 @HasPermissionAllDecorator('hg.admin')
245 def repo_cache(self, repo_name):
245 def repo_cache(self, repo_name):
246 """
246 """
247 INVALIDATE exisitings repository cache
247 INVALIDATE existing repository cache
248 :param repo_name:
248 :param repo_name:
249 """
249 """
250
250
@@ -1,7 +1,8 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 package.rhodecode.controllers.admin.settings
3 rhodecode.controllers.admin.settings
4 ~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5 settings controller for rhodecode admin
6 settings controller for rhodecode admin
6
7
7 :created_on: Jul 14, 2010
8 :created_on: Jul 14, 2010
@@ -87,7 +87,7 b' class UsersController(BaseController):'
87 encoding="UTF-8")
87 encoding="UTF-8")
88 except Exception:
88 except Exception:
89 log.error(traceback.format_exc())
89 log.error(traceback.format_exc())
90 h.flash(_('error occured during creation of user %s') \
90 h.flash(_('error occurred during creation of user %s') \
91 % request.POST.get('username'), category='error')
91 % request.POST.get('username'), category='error')
92 return redirect(url('users'))
92 return redirect(url('users'))
93
93
@@ -144,7 +144,7 b' class UsersController(BaseController):'
144 except (UserOwnsReposException, DefaultUserException), e:
144 except (UserOwnsReposException, DefaultUserException), e:
145 h.flash(str(e), category='warning')
145 h.flash(str(e), category='warning')
146 except Exception:
146 except Exception:
147 h.flash(_('An error occured during deletion of user'),
147 h.flash(_('An error occurred during deletion of user'),
148 category='error')
148 category='error')
149 return redirect(url('users'))
149 return redirect(url('users'))
150
150
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # branches controller for pylons
3 rhodecode.controllers.branches
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 branches controller for rhodecode
7
8 :created_on: Apr 21, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,31 +24,31 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on April 21, 2010
28 import logging
22 branches controller for pylons
29
23 @author: marcink
24 """
25 from pylons import tmpl_context as c
30 from pylons import tmpl_context as c
31
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
32 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
33 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.utils import OrderedDict
34 from rhodecode.lib.utils import OrderedDict
29 from rhodecode.model.scm import ScmModel
35 from rhodecode.model.scm import ScmModel
30 import logging
36
31 log = logging.getLogger(__name__)
37 log = logging.getLogger(__name__)
32
38
33 class BranchesController(BaseController):
39 class BranchesController(BaseController):
34
40
35 @LoginRequired()
41 @LoginRequired()
36 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
42 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
43 'repository.admin')
37 def __before__(self):
44 def __before__(self):
38 super(BranchesController, self).__before__()
45 super(BranchesController, self).__before__()
39
46
40 def index(self):
47 def index(self):
41 hg_model = ScmModel()
48 hg_model = ScmModel()
42 c.repo_info = hg_model.get_repo(c.repo_name)
49 c.repo_info = hg_model.get_repo(c.repo_name)
43 c.repo_branches = OrderedDict()
50 c.repo_branches = OrderedDict()
44 for name, hash_ in c.repo_info.branches.items():
51 for name, hash_ in c.repo_info.branches.items():
45 c.repo_branches[name] = c.repo_info.get_changeset(hash_)
52 c.repo_branches[name] = c.repo_info.get_changeset(hash_)
46
53
47 return render('branches/branches.html')
54 return render('branches/branches.html')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # changelog controller for pylons
3 rhodecode.controllers.changelog
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 changelog controller for rhodecode
7
8 :created_on: Apr 21, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,24 +24,24 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on April 21, 2010
28 import logging
22 changelog controller for pylons
23 @author: marcink
24 """
25
29
26 try:
30 try:
27 import json
31 import json
28 except ImportError:
32 except ImportError:
29 #python 2.5 compatibility
33 #python 2.5 compatibility
30 import simplejson as json
34 import simplejson as json
35
31 from mercurial.graphmod import colored, CHANGESET, revisions as graph_rev
36 from mercurial.graphmod import colored, CHANGESET, revisions as graph_rev
32 from pylons import request, session, tmpl_context as c
37 from pylons import request, session, tmpl_context as c
38
33 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
34 from rhodecode.lib.base import BaseController, render
40 from rhodecode.lib.base import BaseController, render
35 from rhodecode.model.scm import ScmModel
41 from rhodecode.model.scm import ScmModel
42
36 from webhelpers.paginate import Page
43 from webhelpers.paginate import Page
37 import logging
44
38 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
39
46
40 class ChangelogController(BaseController):
47 class ChangelogController(BaseController):
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 package.rhodecode.controllers.error
3 rhodecode.controllers.error
4 ~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 RhodeCode error controller
6 RhodeCode error controller
7
7
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # feed controller for pylons
3 rhodecode.controllers.feed
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Feed controller for rhodecode
7
8 :created_on: Apr 23, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,21 +24,24 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on April 23, 2010
28 import logging
22 feed controller for pylons
29
23 @author: marcink
30 from pylons import url, response
24 """
31
25 from pylons import tmpl_context as c, url, response
32 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
26 from rhodecode.lib.base import BaseController, render
33 from rhodecode.lib.base import BaseController
27 from rhodecode.model.scm import ScmModel
34 from rhodecode.model.scm import ScmModel
35
28 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
36 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
29 import logging
37
30 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
31
39
32 class FeedController(BaseController):
40 class FeedController(BaseController):
33
41
34 #secure it or not ?
42 @LoginRequired()
43 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
44 'repository.admin')
35 def __before__(self):
45 def __before__(self):
36 super(FeedController, self).__before__()
46 super(FeedController, self).__before__()
37 #common values for feeds
47 #common values for feeds
@@ -48,7 +58,7 b' class FeedController(BaseController):'
48 description=self.description % repo_name,
58 description=self.description % repo_name,
49 language=self.language,
59 language=self.language,
50 ttl=self.ttl)
60 ttl=self.ttl)
51
61
52 changesets = ScmModel().get_repo(repo_name)
62 changesets = ScmModel().get_repo(repo_name)
53
63
54 for cs in changesets[:self.feed_nr]:
64 for cs in changesets[:self.feed_nr]:
@@ -56,11 +66,11 b' class FeedController(BaseController):'
56 link=url('changeset_home', repo_name=repo_name,
66 link=url('changeset_home', repo_name=repo_name,
57 revision=cs.raw_id, qualified=True),
67 revision=cs.raw_id, qualified=True),
58 description=str(cs.date))
68 description=str(cs.date))
59
69
60 response.content_type = feed.mime_type
70 response.content_type = feed.mime_type
61 return feed.writeString('utf-8')
71 return feed.writeString('utf-8')
62
72
63
73
64 def rss(self, repo_name):
74 def rss(self, repo_name):
65 """Produce an rss2 feed via feedgenerator module"""
75 """Produce an rss2 feed via feedgenerator module"""
66 feed = Rss201rev2Feed(title=self.title % repo_name,
76 feed = Rss201rev2Feed(title=self.title % repo_name,
@@ -68,13 +78,13 b' class FeedController(BaseController):'
68 description=self.description % repo_name,
78 description=self.description % repo_name,
69 language=self.language,
79 language=self.language,
70 ttl=self.ttl)
80 ttl=self.ttl)
71
81
72 changesets = ScmModel().get_repo(repo_name)
82 changesets = ScmModel().get_repo(repo_name)
73 for cs in changesets[:self.feed_nr]:
83 for cs in changesets[:self.feed_nr]:
74 feed.add_item(title=cs.message,
84 feed.add_item(title=cs.message,
75 link=url('changeset_home', repo_name=repo_name,
85 link=url('changeset_home', repo_name=repo_name,
76 revision=cs.raw_id, qualified=True),
86 revision=cs.raw_id, qualified=True),
77 description=str(cs.date))
87 description=str(cs.date))
78
88
79 response.content_type = feed.mime_type
89 response.content_type = feed.mime_type
80 return feed.writeString('utf-8')
90 return feed.writeString('utf-8')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # hg controller for pylons
3 rhodecode.controllers.home
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Home controller for Rhodecode
7
8 :created_on: Feb 18, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,17 +24,16 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on February 18, 2010
28 import logging
22 hg controller for pylons
23 @author: marcink
24 """
25 from operator import itemgetter
29 from operator import itemgetter
30
26 from pylons import tmpl_context as c, request
31 from pylons import tmpl_context as c, request
32
27 from rhodecode.lib.auth import LoginRequired
33 from rhodecode.lib.auth import LoginRequired
28 from rhodecode.lib.base import BaseController, render
34 from rhodecode.lib.base import BaseController, render
29 from rhodecode.model.scm import ScmModel
35 from rhodecode.model.scm import ScmModel
30 import logging
36
31 log = logging.getLogger(__name__)
37 log = logging.getLogger(__name__)
32
38
33 class HomeController(BaseController):
39 class HomeController(BaseController):
@@ -51,8 +57,10 b' class HomeController(BaseController):'
51
57
52 sort_key = current_sort_slug + '_sort'
58 sort_key = current_sort_slug + '_sort'
53 if c.sort_by.startswith('-'):
59 if c.sort_by.startswith('-'):
54 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
60 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key),
61 reverse=True)
55 else:
62 else:
56 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
63 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key),
64 reverse=False)
57
65
58 return render('/index.html')
66 return render('/index.html')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # journal controller for pylons
3 rhodecode.controllers.journal
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Journal controller for pylons
7
8 :created_on: Nov 21, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,22 +24,19 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on November 21, 2010
28 import logging
22 journal controller for pylons
29 from sqlalchemy import or_
23 @author: marcink
24 """
25
30
26 from pylons import request, response, session, tmpl_context as c, url
31 from pylons import request, response, session, tmpl_context as c, url
27 from pylons.controllers.util import abort, redirect
32
28 from rhodecode.lib.auth import LoginRequired, NotAnonymous
33 from rhodecode.lib.auth import LoginRequired, NotAnonymous
29 from rhodecode.lib.base import BaseController, render
34 from rhodecode.lib.base import BaseController, render
30 from rhodecode.lib.helpers import get_token
35 from rhodecode.lib.helpers import get_token
31 from rhodecode.model.db import UserLog, UserFollowing
36 from rhodecode.model.db import UserLog, UserFollowing
32 from rhodecode.model.scm import ScmModel
37 from rhodecode.model.scm import ScmModel
33 from sqlalchemy import or_
38
34 import logging
39 from paste.httpexceptions import HTTPInternalServerError
35 from paste.httpexceptions import HTTPInternalServerError, HTTPNotFound
36
40
37 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
38
42
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # login controller for pylons
3 rhodecode.controllers.login
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Login controller for rhodeocode
7
8 :created_on: Apr 22, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -18,22 +25,21 b''
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20
27
21 """
28 import logging
22 Created on April 22, 2010
29 import formencode
23 login controller for pylons
30
24 @author: marcink
25 """
26 from formencode import htmlfill
31 from formencode import htmlfill
32
33 from pylons.i18n.translation import _
34 from pylons.controllers.util import abort, redirect
27 from pylons import request, response, session, tmpl_context as c, url
35 from pylons import request, response, session, tmpl_context as c, url
28 from pylons.controllers.util import abort, redirect
36
37 import rhodecode.lib.helpers as h
29 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
38 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
30 from rhodecode.lib.base import BaseController, render
39 from rhodecode.lib.base import BaseController, render
31 import rhodecode.lib.helpers as h
32 from pylons.i18n.translation import _
33 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
40 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
34 from rhodecode.model.user import UserModel
41 from rhodecode.model.user import UserModel
35 import formencode
42
36 import logging
37
43
38 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
39
45
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # search controller for pylons
3 rhodecode.controllers.search
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Search controller for rhodecode
7
8 :created_on: Aug 7, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,24 +24,23 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27 import logging
21 Created on Aug 7, 2010
28 import traceback
22 search controller for pylons
29
23 @author: marcink
30 from pylons.i18n.translation import _
24 """
25 from pylons import request, response, config, session, tmpl_context as c, url
31 from pylons import request, response, config, session, tmpl_context as c, url
26 from pylons.controllers.util import abort, redirect
32 from pylons.controllers.util import abort, redirect
33
27 from rhodecode.lib.auth import LoginRequired
34 from rhodecode.lib.auth import LoginRequired
28 from rhodecode.lib.base import BaseController, render
35 from rhodecode.lib.base import BaseController, render
29 from rhodecode.lib.indexers import SCHEMA, IDX_NAME, ResultWrapper
36 from rhodecode.lib.indexers import SCHEMA, IDX_NAME, ResultWrapper
37
30 from webhelpers.paginate import Page
38 from webhelpers.paginate import Page
31 from webhelpers.util import update_params
39 from webhelpers.util import update_params
32 from pylons.i18n.translation import _
40
33 from whoosh.index import open_dir, EmptyIndexError
41 from whoosh.index import open_dir, EmptyIndexError
34 from whoosh.qparser import QueryParser, QueryParserError
42 from whoosh.qparser import QueryParser, QueryParserError
35 from whoosh.query import Phrase
43 from whoosh.query import Phrase
36 import logging
37 import traceback
38
44
39 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
40
46
@@ -107,7 +113,8 b' class SearchController(BaseController):'
107 except (EmptyIndexError, IOError):
113 except (EmptyIndexError, IOError):
108 log.error(traceback.format_exc())
114 log.error(traceback.format_exc())
109 log.error('Empty Index data')
115 log.error('Empty Index data')
110 c.runtime = _('There is no index to search in. Please run whoosh indexer')
116 c.runtime = _('There is no index to search in. '
117 'Please run whoosh indexer')
111
118
112 # Return a rendered template
119 # Return a rendered template
113 return render('/search/search.html')
120 return render('/search/search.html')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # settings controller for pylons
3 rhodecode.controllers.settings
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Settings controller for rhodecode
7
8 :created_on: Jun 30, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,24 +24,23 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on June 30, 2010
28 import logging
22 settings controller for pylons
29 import traceback
23 @author: marcink
30
24 """
31 import formencode
25 from formencode import htmlfill
32 from formencode import htmlfill
33
26 from pylons import tmpl_context as c, request, url
34 from pylons import tmpl_context as c, request, url
27 from pylons.controllers.util import redirect
35 from pylons.controllers.util import redirect
28 from pylons.i18n.translation import _
36 from pylons.i18n.translation import _
37
38 import rhodecode.lib.helpers as h
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator
39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator
30 from rhodecode.lib.base import BaseController, render
40 from rhodecode.lib.base import BaseController, render
31 from rhodecode.lib.utils import invalidate_cache, action_logger
41 from rhodecode.lib.utils import invalidate_cache, action_logger
32 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
42 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
33 from rhodecode.model.repo import RepoModel
43 from rhodecode.model.repo import RepoModel
34 import formencode
35 import logging
36 import rhodecode.lib.helpers as h
37 import traceback
38
44
39 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
40
46
@@ -50,7 +56,7 b' class SettingsController(BaseController)'
50 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
56 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
51 if not repo:
57 if not repo:
52 h.flash(_('%s repository is not mapped to db perhaps'
58 h.flash(_('%s repository is not mapped to db perhaps'
53 ' it was created or renamed from the filesystem'
59 ' it was created or renamed from the file system'
54 ' please run the application again'
60 ' please run the application again'
55 ' in order to rescan repositories') % repo_name,
61 ' in order to rescan repositories') % repo_name,
56 category='error')
62 category='error')
@@ -139,7 +145,7 b' class SettingsController(BaseController)'
139 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
145 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
140 if not repo:
146 if not repo:
141 h.flash(_('%s repository is not mapped to db perhaps'
147 h.flash(_('%s repository is not mapped to db perhaps'
142 ' it was created or renamed from the filesystem'
148 ' it was created or renamed from the file system'
143 ' please run the application again'
149 ' please run the application again'
144 ' in order to rescan repositories') % repo_name,
150 ' in order to rescan repositories') % repo_name,
145 category='error')
151 category='error')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # shortlog controller for pylons
3 rhodecode.controllers.shortlog
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Shortlog controller for rhodecode
7
8 :created_on: Apr 18, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,27 +24,27 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27
21 Created on April 18, 2010
28 import logging
22 shortlog controller for pylons
29
23 @author: marcink
24 """
25 from pylons import tmpl_context as c, request
30 from pylons import tmpl_context as c, request
31
32 from webhelpers.paginate import Page
33
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
34 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
35 from rhodecode.lib.base import BaseController, render
28 from rhodecode.model.scm import ScmModel
36 from rhodecode.model.scm import ScmModel
29 from webhelpers.paginate import Page
37
30 import logging
31 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
32
39
33 class ShortlogController(BaseController):
40 class ShortlogController(BaseController):
34
41
35 @LoginRequired()
42 @LoginRequired()
36 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
43 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
37 'repository.admin')
44 'repository.admin')
38 def __before__(self):
45 def __before__(self):
39 super(ShortlogController, self).__before__()
46 super(ShortlogController, self).__before__()
40
47
41 def index(self):
48 def index(self):
42 p = int(request.params.get('page', 1))
49 p = int(request.params.get('page', 1))
43 repo = ScmModel().get_repo(c.repo_name)
50 repo = ScmModel().get_repo(c.repo_name)
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 package.rhodecode.controllers.summary
3 rhodecode.controllers.summary
4 ~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Summary controller for Rhodecode
6 Summary controller for Rhodecode
7
7
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # tags controller for pylons
3 rhodecode.controllers.tags
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 #
5
6 Tags controller for rhodecode
7
8 :created_on: Apr 21, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,31 +24,30 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27 import logging
21 Created on April 21, 2010
28
22 tags controller for pylons
23 @author: marcink
24 """
25 from pylons import tmpl_context as c
29 from pylons import tmpl_context as c
30
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
31 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
32 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.utils import OrderedDict
33 from rhodecode.lib.utils import OrderedDict
29 from rhodecode.model.scm import ScmModel
34 from rhodecode.model.scm import ScmModel
30 import logging
35
31 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
32
37
33 class TagsController(BaseController):
38 class TagsController(BaseController):
34
39
35 @LoginRequired()
40 @LoginRequired()
36 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
41 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
42 'repository.admin')
37 def __before__(self):
43 def __before__(self):
38 super(TagsController, self).__before__()
44 super(TagsController, self).__before__()
39
45
40 def index(self):
46 def index(self):
41 hg_model = ScmModel()
47 hg_model = ScmModel()
42 c.repo_info = hg_model.get_repo(c.repo_name)
48 c.repo_info = hg_model.get_repo(c.repo_name)
43 c.repo_tags = OrderedDict()
49 c.repo_tags = OrderedDict()
44 for name, hash_ in c.repo_info.tags.items():
50 for name, hash_ in c.repo_info.tags.items():
45 c.repo_tags[name] = c.repo_info.get_changeset(hash_)
51 c.repo_tags[name] = c.repo_info.get_changeset(hash_)
46
52
47 return render('tags/tags.html')
53 return render('tags/tags.html')
@@ -424,7 +424,7 b' def action_parser(user_log):'
424
424
425 def get_cs_links():
425 def get_cs_links():
426 if action == 'push':
426 if action == 'push':
427 revs_limit = 5
427 revs_limit = 1000
428 revs = action_params.split(',')
428 revs = action_params.split(',')
429 cs_links = " " + ', '.join ([link(rev,
429 cs_links = " " + ', '.join ([link(rev,
430 url('changeset_home',
430 url('changeset_home',
@@ -113,6 +113,7 b' def action_logger(user, action, repo, ip'
113 def get_repos(path, recursive=False, initial=False):
113 def get_repos(path, recursive=False, initial=False):
114 """
114 """
115 Scans given path for repos and return (name,(type,path)) tuple
115 Scans given path for repos and return (name,(type,path)) tuple
116
116 :param prefix:
117 :param prefix:
117 :param path:
118 :param path:
118 :param recursive:
119 :param recursive:
@@ -137,7 +138,7 b' def get_repos(path, recursive=False, ini'
137
138
138 def check_repo_fast(repo_name, base_path):
139 def check_repo_fast(repo_name, base_path):
139 """
140 """
140 Check given path for existance of directory
141 Check given path for existence of directory
141 :param repo_name:
142 :param repo_name:
142 :param base_path:
143 :param base_path:
143
144
@@ -233,8 +234,8 b" def make_ui(read_from='file', path=None,"
233
234
234
235
235 def set_rhodecode_config(config):
236 def set_rhodecode_config(config):
236 """
237 """Updates pylons config with new settings from database
237 Updates pylons config with new settings from database
238
238 :param config:
239 :param config:
239 """
240 """
240 from rhodecode.model.settings import SettingsModel
241 from rhodecode.model.settings import SettingsModel
@@ -244,10 +245,10 b' def set_rhodecode_config(config):'
244 config[k] = v
245 config[k] = v
245
246
246 def invalidate_cache(cache_key, *args):
247 def invalidate_cache(cache_key, *args):
247 """
248 """Puts cache invalidation task into db for
248 Puts cache invalidation task into db for
249 further global cache invalidation
249 further global cache invalidation
250 """
250 """
251
251 from rhodecode.model.scm import ScmModel
252 from rhodecode.model.scm import ScmModel
252
253
253 if cache_key.startswith('get_repo_cached_'):
254 if cache_key.startswith('get_repo_cached_'):
@@ -269,10 +270,10 b' class EmptyChangeset(BaseChangeset):'
269
270
270 @LazyProperty
271 @LazyProperty
271 def raw_id(self):
272 def raw_id(self):
272 """
273 """Returns raw string identifying this changeset, useful for web
273 Returns raw string identifying this changeset, useful for web
274 representation.
274 representation.
275 """
275 """
276
276 return self._empty_cs
277 return self._empty_cs
277
278
278 @LazyProperty
279 @LazyProperty
@@ -289,8 +290,7 b' class EmptyChangeset(BaseChangeset):'
289 return 0
290 return 0
290
291
291 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
292 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
292 """
293 """maps all found repositories into db
293 maps all found repositories into db
294 """
294 """
295
295
296 sa = meta.Session()
296 sa = meta.Session()
@@ -443,10 +443,10 b' def add_cache(settings):'
443 beaker.cache.cache_regions[region] = region_settings
443 beaker.cache.cache_regions[region] = region_settings
444
444
445 def get_current_revision():
445 def get_current_revision():
446 """
446 """Returns tuple of (number, id) from repository containing this package
447 Returns tuple of (number, id) from repository containing this package
448 or None if repository could not be found.
447 or None if repository could not be found.
449 """
448 """
449
450 try:
450 try:
451 from vcs import get_repo
451 from vcs import get_repo
452 from vcs.utils.helpers import get_scm
452 from vcs.utils.helpers import get_scm
General Comments 0
You need to be logged in to leave comments. Login now