##// END OF EJS Templates
Cleaned the way based was used to generate submenu for admin, now it's much more clear to use submenu. Cleaned admin and added comment to middleware
marcink -
r216:c8162373 default
parent child Browse files
Show More
@@ -58,7 +58,9 b' def make_app(global_conf, full_stack=Tru'
58 58 else:
59 59 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
60 60
61 #enable https redirets based on HTTP_X_URL_SCHEME set by proxy
61 62 app = HttpsFixup(app)
63
62 64 # Establish the Registry for this application
63 65 app = RegistryManager(app)
64 66
@@ -7,7 +7,6 b' from pylons_app.lib.base import BaseCont'
7 7 from pylons_app.model import meta
8 8 from pylons_app.model.db import UserLogs
9 9 from webhelpers.paginate import Page
10 from pylons_app.lib.utils import check_repo, invalidate_cache
11 10 from pylons_app.lib.auth import LoginRequired
12 11
13 12 log = logging.getLogger(__name__)
@@ -31,37 +30,5 b' class AdminController(BaseController):'
31 30 c.log_data = render('admin/admin_log.html')
32 31 if request.params.get('partial'):
33 32 return c.log_data
34 return render('admin/admin.html')
35
36 def add_repo(self, new_repo):
37 #extra check it can be add since it's the command
38 if new_repo == '_admin':
39 c.msg = 'DENIED'
40 c.new_repo = ''
41 return render('admin/add.html')
42
43 new_repo = new_repo.replace(" ", "_")
44 new_repo = new_repo.replace("-", "_")
45
46 try:
47 self._create_repo(new_repo)
48 c.new_repo = new_repo
49 c.msg = 'added repo'
50 #clear our cached list for refresh with new repo
51 invalidate_cache('cached_repo_list')
52 except Exception as e:
53 c.new_repo = 'Exception when adding: %s' % new_repo
54 c.msg = str(e)
55
56 return render('admin/add.html')
57
58
59 def _create_repo(self, repo_name):
60 if repo_name in [None, '', 'add']:
61 raise Exception('undefined repo_name of repo')
62 repo_path = os.path.join(g.base_path, repo_name)
63 if check_repo(repo_name, g.base_path):
64 log.info('creating repo %s in %s', repo_name, repo_path)
65 from vcs.backends.hg import MercurialRepository
66 MercurialRepository(repo_path, create=True)
33 return render('admin/admin.html')
67 34
@@ -2,7 +2,7 b''
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 ${_('Repository managment')}
5 ${_('Administration')}
6 6 </%def>
7 7 <%def name="breadcrumbs()">
8 8 ${h.link_to(u'Admin',h.url('admin_home'))}
@@ -10,20 +10,13 b''
10 10 </%def>
11 11 <%def name="page_nav()">
12 12 ${self.menu('admin')}
13 ${self.submenu('')}
13 14 </%def>
14 15 <%def name="main()">
15 16 %if c.admin_user:
16 <ul class="submenu">
17 <li>
18 ${h.link_to(u'Repos',h.url('repos'))}
19 </li>
20 <li>
21 ${h.link_to(u'Users',h.url('users'))}
22 </li>
23 </ul>
24 <br/>
25 17 <div>
26 18 <h2>Welcome ${c.admin_username}</h2>
19 ${_('Last actions')}
27 20 <div id="user_log">
28 21 ${c.log_data}
29 22 </div>
@@ -2,39 +2,39 b''
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 ${_('Add new repository')}
5 ${_('Repositories administration')}
6 6 </%def>
7
8 7 <%def name="breadcrumbs()">
9 8 ${h.link_to(u'Admin',h.url('admin_home'))}
10 /
9 /
11 10 </%def>
12
13 11 <%def name="page_nav()">
14 12 ${self.menu('admin')}
15 </%def>
16
17 <%def name="main()">
18 <table cellspacing="0">
19 <tr>
20 <td><h1>${c.msg}</h1></td>
21 </tr>
22 <tr>
23 <td><h2>${c.new_repo}</h2></td>
24 </tr>
25 </table>
13 ${self.submenu('repos')}
26 14 </%def>
27
28
29
30
31
32
33
34
35
36
37
38
39
40
15 <%def name="main()">
16 <div>
17 <h2>${_('Repositories')} - ${_('add new')}</h2>
18 ${h.form(url('repos'))}
19 <table>
20 <tr>
21 <td>${_('Name')}</td>
22 <td>${h.text('name',c.new_repo)}</td>
23 </tr>
24 <tr>
25 <td>${_('Description')}</td>
26 <td>${h.textarea('description',cols=23,rows=5)}</td>
27 </tr>
28 <tr>
29 <td>${_('Private')}</td>
30 <td>${h.checkbox('private')}</td>
31 </tr>
32 <tr>
33 <td></td>
34 <td>${h.submit('add','add')}</td>
35 </tr>
36
37 </table>
38 ${h.end_form()}
39 </div>
40 </%def>
@@ -1,25 +1,40 b''
1 <%inherit file="base/base.html"/>
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
3
2 4 <%def name="title()">
3 ${_('Repository managment')}
5 ${_('Repositories administration')}
4 6 </%def>
5 7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
8 ${h.link_to(u'Repos managment',h.url('repos'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
9 /
9 10 </%def>
10 11 <%def name="page_nav()">
11 12 ${self.menu('admin')}
13 ${self.submenu('repos')}
12 14 </%def>
13 15 <%def name="main()">
14 <ul class="submenu">
15 <li class="current_submenu">
16 ${h.link_to(u'Repos',h.url('repos'))}
17 </li>
18 <li>
19 ${h.link_to(u'Users',h.url('users'))}
20 </li>
21 </ul>
22 16 <div>
23 <h2>${_('Mercurial repos')}</h2>
17 <h2>${_('Repositories')} - ${_('edit')}</h2>
18 ${h.form(url('repos'))}
19 <table>
20 <tr>
21 <td>${_('Name')}</td>
22 <td>${h.text('name',c.new_repo)}</td>
23 </tr>
24 <tr>
25 <td>${_('Description')}</td>
26 <td>${h.textarea('description',cols=23,rows=5)}</td>
27 </tr>
28 <tr>
29 <td>${_('Private')}</td>
30 <td>${h.checkbox('private')}</td>
31 </tr>
32 <tr>
33 <td></td>
34 <td>${h.submit('add','add')}</td>
35 </tr>
36
37 </table>
38 ${h.end_form()}
24 39 </div>
25 </%def> No newline at end of file
40 </%def>
@@ -1,26 +1,20 b''
1 ## -*- coding: utf-8 -*-
1 2 <%inherit file="/base/base.html"/>
3
2 4 <%def name="title()">
3 ${_('Repository managment')}
5 ${_('Repositories administration')}
4 6 </%def>
5 7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
8 ${h.link_to(u'Repos managment',h.url('repos'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
9 /
9 10 </%def>
10 11 <%def name="page_nav()">
11 12 ${self.menu('admin')}
13 ${self.submenu('repos')}
12 14 </%def>
13 15 <%def name="main()">
14 <ul class="submenu">
15 <li>
16 ${h.link_to(u'Repos',h.url('repos'), class_="current_submenu")}
17 </li>
18 <li>
19 ${h.link_to(u'Users',h.url('users'))}
20 </li>
21 </ul>
22 16 <div>
23 <h2>${_('Mercurial repos')}</h2>
17 <h2>${_('Repositories administration')}</h2>
24 18 <table>
25 19 %for cnt,repo in enumerate(c.repos_list):
26 20 <tr class="parity${cnt%2}">
@@ -35,4 +29,4 b''
35 29 %endfor
36 30 </table>
37 31 </div>
38 </%def> No newline at end of file
32 </%def>
@@ -1,24 +1,18 b''
1 ## -*- coding: utf-8 -*-
1 2 <%inherit file="/base/base.html"/>
3
2 4 <%def name="title()">
3 ${_('User')} - ${_('add new')}
5 ${_('User administration')}
4 6 </%def>
5 7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
8 ${h.link_to(u'Users',h.url('users'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
9 /
9 10 </%def>
10 11 <%def name="page_nav()">
11 12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 14 </%def>
13 15 <%def name="main()">
14 <ul class="submenu">
15 <li>
16 ${h.link_to(u'Repos',h.url('repos'))}
17 </li>
18 <li class="current_submenu">
19 ${h.link_to(u'Users',h.url('users'))}
20 </li>
21 </ul>
22 16 <div>
23 17 <h2>${_('User')} - ${_('add new')}</h2>
24 18 ${h.form(url('users'))}
@@ -41,7 +35,6 b''
41 35 </tr>
42 36
43 37 </table>
44
45 38 ${h.end_form()}
46 39 </div>
47 40 </%def> No newline at end of file
@@ -1,24 +1,18 b''
1 ## -*- coding: utf-8 -*-
1 2 <%inherit file="/base/base.html"/>
3
2 4 <%def name="title()">
3 ${_('User')} - ${c.user.username}
5 ${_('User administration')}
4 6 </%def>
5 7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
8 ${h.link_to(u'Users',h.url('users'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
9 /
9 10 </%def>
10 11 <%def name="page_nav()">
11 12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 14 </%def>
13 15 <%def name="main()">
14 <ul class="submenu">
15 <li>
16 ${h.link_to(u'Repos',h.url('repos'))}
17 </li>
18 <li class="current_submenu">
19 ${h.link_to(u'Users',h.url('users'))}
20 </li>
21 </ul>
22 16 <div>
23 17 <h2>${_('User')} - ${c.user.username}</h2>
24 18 ${h.form(url('user', id=c.user.user_id),method='put')}
@@ -41,7 +35,6 b''
41 35 </tr>
42 36
43 37 </table>
44
45 38 ${h.end_form()}
46 39 </div>
47 </%def> No newline at end of file
40 </%def> No newline at end of file
@@ -1,24 +1,18 b''
1 ## -*- coding: utf-8 -*-
1 2 <%inherit file="/base/base.html"/>
3
2 4 <%def name="title()">
3 ${_('Users managment')}
5 ${_('Users administration')}
4 6 </%def>
5 7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
8 ${h.link_to(u'Users managment',h.url('users'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
9 /
9 10 </%def>
10 11 <%def name="page_nav()">
11 12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 14 </%def>
13 15 <%def name="main()">
14 <ul class="submenu">
15 <li>
16 ${h.link_to(u'Repos',h.url('repos'))}
17 </li>
18 <li>
19 ${h.link_to(u'Users',h.url('users'), class_="current_submenu")}
20 </li>
21 </ul>
22 16 <div>
23 17 <h2>${_('Mercurial users')}</h2>
24 18 <table>
@@ -45,5 +39,4 b''
45 39 </table>
46 40 <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3>
47 41 </div>
48
49 </%def> No newline at end of file
42 </%def>
@@ -5,6 +5,7 b''
5 5 <link rel="icon" href="/images/hgicon.png" type="image/png" />
6 6 <meta name="robots" content="index, nofollow"/>
7 7 <title>${next.title()}</title>
8 ##For future use yui reset for cross browser compatability.
8 9 ##<link rel="stylesheet" href="/js/yui/reset-fonts-grids/reset-fonts-grids.css" type="text/css" />
9 10 ${self.css()}
10 11 ${self.js()}
@@ -15,12 +16,11 b''
15 16 <div class="page-header">
16 17 <h1>${next.breadcrumbs()}</h1>
17 18 ${self.page_nav()}
18 </div>
19 19 <div id="main">
20 20 ${next.main()}
21 21 </div>
22 22 <div class="page-footer">
23 Hg App ${c.hg_app_version} &copy; 2010
23 Hg App ${c.hg_app_version} &copy; 2010 by Marcin Kuzminski
24 24 </div>
25 25
26 26 <div id="powered-by">
@@ -43,6 +43,7 b''
43 43
44 44 <%def name="page_nav()">
45 45 ${self.menu()}
46 ${self.submenu()}
46 47 </%def>
47 48
48 49 <%def name="menu(current)">
@@ -52,6 +53,7 b' def is_current(selected):'
52 53 return "class='current'"
53 54 %>
54 55 %if current not in ['home','admin']:
56 ##regular menu
55 57 <script type="text/javascript">
56 58 YAHOO.util.Event.onDOMReady(function(){
57 59 YAHOO.util.Event.addListener('repo_switcher','click',function(){
@@ -93,13 +95,32 b' def is_current(selected):'
93 95 <li ${is_current('files')}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li>
94 96 </ul>
95 97 %else:
98 ##Root menu
96 99 <ul class="page-nav">
97 100 <li ${is_current('home')}>${h.link_to(_('Home'),h.url('/'))}</li>
98 101 <li ${is_current('admin')}>${h.link_to(_('Admin'),h.url('admin_home'))}</li>
99 102 <li class="logout">${h.link_to(u'Logout',h.url('logout_home'))}</li>
100 103 </ul>
101 104 %endif
105 </div>
102 106 </%def>
107 <%def name="submenu(current=None)">
108 <%
109 def is_current(selected):
110 if selected == current:
111 return "class='current_submenu'"
112 %>
113 %if current != None:
114 <div>
115 <ul class="submenu">
116 <li ${is_current('repos')}>${h.link_to(u'repos',h.url('repos'))}</li>
117 <li ${is_current('users')}>${h.link_to(u'users',h.url('users'))}</li>
118 </ul>
119 <br/>
120 </div>
121 %endif
122 </%def>
123
103 124
104 125 <%def name="css()">
105 126 <link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
General Comments 0
You need to be logged in to leave comments. Login now