##// 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 else:
58 else:
59 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
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 app = HttpsFixup(app)
62 app = HttpsFixup(app)
63
62 # Establish the Registry for this application
64 # Establish the Registry for this application
63 app = RegistryManager(app)
65 app = RegistryManager(app)
64
66
@@ -7,7 +7,6 b' from pylons_app.lib.base import BaseCont'
7 from pylons_app.model import meta
7 from pylons_app.model import meta
8 from pylons_app.model.db import UserLogs
8 from pylons_app.model.db import UserLogs
9 from webhelpers.paginate import Page
9 from webhelpers.paginate import Page
10 from pylons_app.lib.utils import check_repo, invalidate_cache
11 from pylons_app.lib.auth import LoginRequired
10 from pylons_app.lib.auth import LoginRequired
12
11
13 log = logging.getLogger(__name__)
12 log = logging.getLogger(__name__)
@@ -31,37 +30,5 b' class AdminController(BaseController):'
31 c.log_data = render('admin/admin_log.html')
30 c.log_data = render('admin/admin_log.html')
32 if request.params.get('partial'):
31 if request.params.get('partial'):
33 return c.log_data
32 return c.log_data
34 return render('admin/admin.html')
33 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)
67
34
@@ -2,7 +2,7 b''
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Repository managment')}
5 ${_('Administration')}
6 </%def>
6 </%def>
7 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
8 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
@@ -10,20 +10,13 b''
10 </%def>
10 </%def>
11 <%def name="page_nav()">
11 <%def name="page_nav()">
12 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('')}
13 </%def>
14 </%def>
14 <%def name="main()">
15 <%def name="main()">
15 %if c.admin_user:
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 <div>
17 <div>
26 <h2>Welcome ${c.admin_username}</h2>
18 <h2>Welcome ${c.admin_username}</h2>
19 ${_('Last actions')}
27 <div id="user_log">
20 <div id="user_log">
28 ${c.log_data}
21 ${c.log_data}
29 </div>
22 </div>
@@ -2,39 +2,39 b''
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Add new repository')}
5 ${_('Repositories administration')}
6 </%def>
6 </%def>
7
8 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
9 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
10 /
9 /
11 </%def>
10 </%def>
12
13 <%def name="page_nav()">
11 <%def name="page_nav()">
14 ${self.menu('admin')}
12 ${self.menu('admin')}
15 </%def>
13 ${self.submenu('repos')}
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>
26 </%def>
14 </%def>
27
15 <%def name="main()">
28
16 <div>
29
17 <h2>${_('Repositories')} - ${_('add new')}</h2>
30
18 ${h.form(url('repos'))}
31
19 <table>
32
20 <tr>
33
21 <td>${_('Name')}</td>
34
22 <td>${h.text('name',c.new_repo)}</td>
35
23 </tr>
36
24 <tr>
37
25 <td>${_('Description')}</td>
38
26 <td>${h.textarea('description',cols=23,rows=5)}</td>
39
27 </tr>
40
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 <%def name="title()">
4 <%def name="title()">
3 ${_('Repository managment')}
5 ${_('Repositories administration')}
4 </%def>
6 </%def>
5 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
9 /
8 ${h.link_to(u'Repos managment',h.url('repos'))}
9 </%def>
10 </%def>
10 <%def name="page_nav()">
11 <%def name="page_nav()">
11 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('repos')}
12 </%def>
14 </%def>
13 <%def name="main()">
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 <div>
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 </div>
39 </div>
25 </%def> No newline at end of file
40 </%def>
@@ -1,26 +1,20 b''
1 ## -*- coding: utf-8 -*-
1 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
2 <%def name="title()">
4 <%def name="title()">
3 ${_('Repository managment')}
5 ${_('Repositories administration')}
4 </%def>
6 </%def>
5 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
9 /
8 ${h.link_to(u'Repos managment',h.url('repos'))}
9 </%def>
10 </%def>
10 <%def name="page_nav()">
11 <%def name="page_nav()">
11 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('repos')}
12 </%def>
14 </%def>
13 <%def name="main()">
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 <div>
16 <div>
23 <h2>${_('Mercurial repos')}</h2>
17 <h2>${_('Repositories administration')}</h2>
24 <table>
18 <table>
25 %for cnt,repo in enumerate(c.repos_list):
19 %for cnt,repo in enumerate(c.repos_list):
26 <tr class="parity${cnt%2}">
20 <tr class="parity${cnt%2}">
@@ -35,4 +29,4 b''
35 %endfor
29 %endfor
36 </table>
30 </table>
37 </div>
31 </div>
38 </%def> No newline at end of file
32 </%def>
@@ -1,24 +1,18 b''
1 ## -*- coding: utf-8 -*-
1 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
2 <%def name="title()">
4 <%def name="title()">
3 ${_('User')} - ${_('add new')}
5 ${_('User administration')}
4 </%def>
6 </%def>
5 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
9 /
8 ${h.link_to(u'Users',h.url('users'))}
9 </%def>
10 </%def>
10 <%def name="page_nav()">
11 <%def name="page_nav()">
11 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 </%def>
14 </%def>
13 <%def name="main()">
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 <div>
16 <div>
23 <h2>${_('User')} - ${_('add new')}</h2>
17 <h2>${_('User')} - ${_('add new')}</h2>
24 ${h.form(url('users'))}
18 ${h.form(url('users'))}
@@ -41,7 +35,6 b''
41 </tr>
35 </tr>
42
36
43 </table>
37 </table>
44
45 ${h.end_form()}
38 ${h.end_form()}
46 </div>
39 </div>
47 </%def> No newline at end of file
40 </%def>
@@ -1,24 +1,18 b''
1 ## -*- coding: utf-8 -*-
1 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
2 <%def name="title()">
4 <%def name="title()">
3 ${_('User')} - ${c.user.username}
5 ${_('User administration')}
4 </%def>
6 </%def>
5 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
9 /
8 ${h.link_to(u'Users',h.url('users'))}
9 </%def>
10 </%def>
10 <%def name="page_nav()">
11 <%def name="page_nav()">
11 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 </%def>
14 </%def>
13 <%def name="main()">
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 <div>
16 <div>
23 <h2>${_('User')} - ${c.user.username}</h2>
17 <h2>${_('User')} - ${c.user.username}</h2>
24 ${h.form(url('user', id=c.user.user_id),method='put')}
18 ${h.form(url('user', id=c.user.user_id),method='put')}
@@ -41,7 +35,6 b''
41 </tr>
35 </tr>
42
36
43 </table>
37 </table>
44
45 ${h.end_form()}
38 ${h.end_form()}
46 </div>
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 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
2 <%def name="title()">
4 <%def name="title()">
3 ${_('Users managment')}
5 ${_('Users administration')}
4 </%def>
6 </%def>
5 <%def name="breadcrumbs()">
7 <%def name="breadcrumbs()">
6 ${h.link_to(u'Admin',h.url('admin_home'))}
8 ${h.link_to(u'Admin',h.url('admin_home'))}
7 /
9 /
8 ${h.link_to(u'Users managment',h.url('users'))}
9 </%def>
10 </%def>
10 <%def name="page_nav()">
11 <%def name="page_nav()">
11 ${self.menu('admin')}
12 ${self.menu('admin')}
13 ${self.submenu('users')}
12 </%def>
14 </%def>
13 <%def name="main()">
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 <div>
16 <div>
23 <h2>${_('Mercurial users')}</h2>
17 <h2>${_('Mercurial users')}</h2>
24 <table>
18 <table>
@@ -45,5 +39,4 b''
45 </table>
39 </table>
46 <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3>
40 <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3>
47 </div>
41 </div>
48
42 </%def>
49 </%def> No newline at end of file
@@ -5,6 +5,7 b''
5 <link rel="icon" href="/images/hgicon.png" type="image/png" />
5 <link rel="icon" href="/images/hgicon.png" type="image/png" />
6 <meta name="robots" content="index, nofollow"/>
6 <meta name="robots" content="index, nofollow"/>
7 <title>${next.title()}</title>
7 <title>${next.title()}</title>
8 ##For future use yui reset for cross browser compatability.
8 ##<link rel="stylesheet" href="/js/yui/reset-fonts-grids/reset-fonts-grids.css" type="text/css" />
9 ##<link rel="stylesheet" href="/js/yui/reset-fonts-grids/reset-fonts-grids.css" type="text/css" />
9 ${self.css()}
10 ${self.css()}
10 ${self.js()}
11 ${self.js()}
@@ -15,12 +16,11 b''
15 <div class="page-header">
16 <div class="page-header">
16 <h1>${next.breadcrumbs()}</h1>
17 <h1>${next.breadcrumbs()}</h1>
17 ${self.page_nav()}
18 ${self.page_nav()}
18 </div>
19 <div id="main">
19 <div id="main">
20 ${next.main()}
20 ${next.main()}
21 </div>
21 </div>
22 <div class="page-footer">
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 </div>
24 </div>
25
25
26 <div id="powered-by">
26 <div id="powered-by">
@@ -43,6 +43,7 b''
43
43
44 <%def name="page_nav()">
44 <%def name="page_nav()">
45 ${self.menu()}
45 ${self.menu()}
46 ${self.submenu()}
46 </%def>
47 </%def>
47
48
48 <%def name="menu(current)">
49 <%def name="menu(current)">
@@ -52,6 +53,7 b' def is_current(selected):'
52 return "class='current'"
53 return "class='current'"
53 %>
54 %>
54 %if current not in ['home','admin']:
55 %if current not in ['home','admin']:
56 ##regular menu
55 <script type="text/javascript">
57 <script type="text/javascript">
56 YAHOO.util.Event.onDOMReady(function(){
58 YAHOO.util.Event.onDOMReady(function(){
57 YAHOO.util.Event.addListener('repo_switcher','click',function(){
59 YAHOO.util.Event.addListener('repo_switcher','click',function(){
@@ -93,13 +95,32 b' def is_current(selected):'
93 <li ${is_current('files')}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li>
95 <li ${is_current('files')}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li>
94 </ul>
96 </ul>
95 %else:
97 %else:
98 ##Root menu
96 <ul class="page-nav">
99 <ul class="page-nav">
97 <li ${is_current('home')}>${h.link_to(_('Home'),h.url('/'))}</li>
100 <li ${is_current('home')}>${h.link_to(_('Home'),h.url('/'))}</li>
98 <li ${is_current('admin')}>${h.link_to(_('Admin'),h.url('admin_home'))}</li>
101 <li ${is_current('admin')}>${h.link_to(_('Admin'),h.url('admin_home'))}</li>
99 <li class="logout">${h.link_to(u'Logout',h.url('logout_home'))}</li>
102 <li class="logout">${h.link_to(u'Logout',h.url('logout_home'))}</li>
100 </ul>
103 </ul>
101 %endif
104 %endif
105 </div>
102 </%def>
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 <%def name="css()">
125 <%def name="css()">
105 <link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
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