##// END OF EJS Templates
Changed creation of repository to vcs implementation,...
marcink -
r133:919b5bcd default
parent child Browse files
Show More
@@ -1,10 +1,10 b''
1 import logging
1 import logging
2 import os
2
3
3 from pylons import request, response, session, tmpl_context as c, url, app_globals as g
4 from pylons import request, response, session, tmpl_context as c, url, app_globals as g
4 from pylons.controllers.util import abort, redirect
5 from pylons.controllers.util import abort, redirect
5
6 from beaker.cache import region_invalidate
6 from pylons_app.lib.base import BaseController, render
7 from pylons_app.lib.base import BaseController, render
7 import os
8 from pylons_app.lib import auth
8 from pylons_app.lib import auth
9 from pylons_app.model.forms import LoginForm
9 from pylons_app.model.forms import LoginForm
10 import formencode
10 import formencode
@@ -18,7 +18,6 b' log = logging.getLogger(__name__)'
18 class AdminController(BaseController):
18 class AdminController(BaseController):
19
19
20 def __before__(self):
20 def __before__(self):
21
22 c.admin_user = session.get('admin_user', False)
21 c.admin_user = session.get('admin_user', False)
23 c.admin_username = session.get('admin_username')
22 c.admin_username = session.get('admin_username')
24
23
@@ -73,7 +72,7 b' class AdminController(BaseController):'
73 if new_repo == '_admin':
72 if new_repo == '_admin':
74 c.msg = 'DENIED'
73 c.msg = 'DENIED'
75 c.new_repo = ''
74 c.new_repo = ''
76 return render('add.html')
75 return render('admin/add.html')
77
76
78 new_repo = new_repo.replace(" ", "_")
77 new_repo = new_repo.replace(" ", "_")
79 new_repo = new_repo.replace("-", "_")
78 new_repo = new_repo.replace("-", "_")
@@ -82,19 +81,22 b' class AdminController(BaseController):'
82 self._create_repo(new_repo)
81 self._create_repo(new_repo)
83 c.new_repo = new_repo
82 c.new_repo = new_repo
84 c.msg = 'added repo'
83 c.msg = 'added repo'
84 from pylons_app.lib.base import _get_repos
85 #clear our cached list for refresh with new repo
86 region_invalidate(_get_repos, None, 'repo_list_2')
85 except Exception as e:
87 except Exception as e:
86 c.new_repo = 'Exception when adding: %s' % new_repo
88 c.new_repo = 'Exception when adding: %s' % new_repo
87 c.msg = str(e)
89 c.msg = str(e)
88
90
89 return render('add.html')
91 return render('admin/add.html')
90
92
91
93
92 def _create_repo(self, repo_name):
94 def _create_repo(self, repo_name):
93 if repo_name in [None, '', 'add']:
95 if repo_name in [None, '', 'add']:
94 raise Exception('undefined repo_name of repo')
96 raise Exception('undefined repo_name of repo')
95
97 repo_path = os.path.join(g.base_path, repo_name)
96 if check_repo(repo_name, g.base_path):
98 if check_repo(repo_name, g.base_path):
97 log.info('creating repo %s in %s', repo_name, self.repo_path)
99 log.info('creating repo %s in %s', repo_name, repo_path)
98 cmd = """mkdir %s && hg init %s""" \
100 from vcs.backends.hg import MercurialRepository
99 % (self.repo_path, self.repo_path)
101 MercurialRepository(repo_path, create=True)
100 os.popen(cmd)
102
General Comments 0
You need to be logged in to leave comments. Login now