##// END OF EJS Templates
fixed escaping for new webhelpers and added perm2user constraint
marcink -
r414:27f801e0 default
parent child Browse files
Show More
@@ -1,103 +1,103 b''
1 1 from pylons_app.model.meta import Base
2 2 from sqlalchemy.orm import relation, backref
3 3 from sqlalchemy import *
4 4 from vcs.utils.lazy import LazyProperty
5 5
6 6 class HgAppSettings(Base):
7 7 __tablename__ = 'hg_app_settings'
8 8 __table_args__ = (UniqueConstraint('app_settings_name'), {'useexisting':True})
9 9 app_settings_id = Column("app_settings_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
10 10 app_settings_name = Column("app_settings_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
11 11 app_settings_value = Column("app_settings_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
12 12
13 13 class HgAppUi(Base):
14 14 __tablename__ = 'hg_app_ui'
15 15 __table_args__ = {'useexisting':True}
16 16 ui_id = Column("ui_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
17 17 ui_section = Column("ui_section", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
18 18 ui_key = Column("ui_key", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
19 19 ui_value = Column("ui_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
20 20 ui_active = Column("ui_active", BOOLEAN(), nullable=True, unique=None, default=True)
21 21
22 22
23 23 class User(Base):
24 24 __tablename__ = 'users'
25 25 __table_args__ = {'useexisting':True}
26 26 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
27 27 username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
28 28 password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
29 29 active = Column("active", BOOLEAN(), nullable=True, unique=None, default=None)
30 30 admin = Column("admin", BOOLEAN(), nullable=True, unique=None, default=False)
31 31 name = Column("name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
32 32 lastname = Column("lastname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
33 33 email = Column("email", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
34 34 last_login = Column("last_login", DATETIME(timezone=False), nullable=True, unique=None, default=None)
35 35
36 36 user_log = relation('UserLog')
37 37
38 38 @LazyProperty
39 39 def full_contact(self):
40 40 return '%s %s <%s>' % (self.name, self.lastname, self.email)
41 41
42 42 def __repr__(self):
43 43 return "<User('%s:%s')>" % (self.user_id, self.username)
44 44
45 45 class UserLog(Base):
46 46 __tablename__ = 'user_logs'
47 47 __table_args__ = {'useexisting':True}
48 48 user_log_id = Column("user_log_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
49 49 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None)
50 50 user_ip = Column("user_ip", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
51 51 repository = Column("repository", TEXT(length=None, convert_unicode=False, assert_unicode=None), ForeignKey(u'repositories.repo_name'), nullable=False, unique=None, default=None)
52 52 action = Column("action", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
53 53 action_date = Column("action_date", DATETIME(timezone=False), nullable=True, unique=None, default=None)
54 54
55 55 user = relation('User')
56 56
57 57 class Repository(Base):
58 58 __tablename__ = 'repositories'
59 59 __table_args__ = (UniqueConstraint('repo_name'), {'useexisting':True},)
60 60 repo_id = Column("repo_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
61 61 repo_name = Column("repo_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
62 62 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=False, default=None)
63 63 private = Column("private", BOOLEAN(), nullable=True, unique=None, default=None)
64 64 description = Column("description", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
65 65
66 66 user = relation('User')
67 67 repo_to_perm = relation('RepoToPerm', cascade='all')
68 68
69 69 class Permission(Base):
70 70 __tablename__ = 'permissions'
71 71 __table_args__ = {'useexisting':True}
72 72 permission_id = Column("permission_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
73 73 permission_name = Column("permission_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
74 74 permission_longname = Column("permission_longname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
75 75
76 76 def __repr__(self):
77 77 return "<Permission('%s:%s')>" % (self.permission_id, self.permission_name)
78 78
79 79 class RepoToPerm(Base):
80 80 __tablename__ = 'repo_to_perm'
81 81 __table_args__ = (UniqueConstraint('user_id', 'repository_id'), {'useexisting':True})
82 82 repo_to_perm_id = Column("repo_to_perm_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
83 83 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None)
84 84 permission_id = Column("permission_id", INTEGER(), ForeignKey(u'permissions.permission_id'), nullable=False, unique=None, default=None)
85 85 repository_id = Column("repository_id", INTEGER(), ForeignKey(u'repositories.repo_id'), nullable=False, unique=None, default=None)
86 86
87 87 user = relation('User')
88 88 permission = relation('Permission')
89 89 repository = relation('Repository')
90 90
91 91 class UserToPerm(Base):
92 92 __tablename__ = 'user_to_perm'
93 __table_args__ = {'useexisting':True}
93 __table_args__ = (UniqueConstraint('user_id', 'permission_id'), {'useexisting':True})
94 94 user_to_perm_id = Column("user_to_perm_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
95 95 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None)
96 96 permission_id = Column("permission_id", INTEGER(), ForeignKey(u'permissions.permission_id'), nullable=False, unique=None, default=None)
97 97
98 98 user = relation('User')
99 99 permission = relation('Permission')
100 100
101 101
102 102
103 103
@@ -1,255 +1,255 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 3 <html xmlns="http://www.w3.org/1999/xhtml" id="mainhtml">
4 4 <head>
5 5 <title>${next.title()}</title>
6 6 <link rel="icon" href="/images/hgicon.png" type="image/png" />
7 7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8 8 <meta name="robots" content="index, nofollow"/>
9 9 <!-- stylesheets -->
10 10 ${self.css()}
11 11 <!-- scripts -->
12 12 ${self.js()}
13 13 </head>
14 14 <body>
15 15 <!-- header -->
16 16 <div id="header">
17 17 <!-- user -->
18 18 <ul id="logged-user">
19 19 <li class="first">
20 20 <div class="gravatar">
21 21 <img alt="gravatar" src="${h.gravatar_url(c.hg_app_user.email,24)}" />
22 22 </div>
23 23 <div class="account">
24 24 ${h.link_to('%s %s'%(c.hg_app_user.name,c.hg_app_user.lastname),h.url('admin_settings_my_account'))}<br/>
25 25 ${h.link_to(c.hg_app_user.username,h.url('admin_settings_my_account'))}
26 26 </div>
27 27 </li>
28 28 <li class="last highlight">${h.link_to(u'Logout',h.url('logout_home'))}</li>
29 29 </ul>
30 30 <!-- end user -->
31 31 <div id="header-inner">
32 32 <div id="home">
33 33 <a href="${h.url('hg_home')}"></a>
34 34 </div>
35 35 <!-- logo -->
36 36 <div id="logo">
37 37 <h1><a href="${h.url('hg_home')}">${c.hg_app_name}</a></h1>
38 38 </div>
39 39 <!-- end logo -->
40 40 <!-- quick menu -->
41 41 ${self.page_nav()}
42 42 <!-- end quick -->
43 43 <div class="corner tl"></div>
44 44 <div class="corner tr"></div>
45 45 </div>
46 46 </div>
47 47 <!-- end header -->
48 48
49 49 <!-- CONTENT -->
50 50 <div id="content">
51 51 <div class="flash_msg">
52 52 <% messages = h.flash.pop_messages() %>
53 53 % if messages:
54 54 <ul id="flash-messages">
55 55 % for message in messages:
56 56 <li class="${message.category}_msg">${message}</li>
57 57 % endfor
58 58 </ul>
59 59 % endif
60 60 </div>
61 61 <div id="main">
62 62 ${next.main()}
63 63 </div>
64 64 </div>
65 65 <!-- END CONTENT -->
66 66
67 67 <!-- footer -->
68 68 <div id="footer">
69 69 <p>Hg App ${c.hg_app_version} &copy; 2010 by Marcin Kuzminski</p>
70 70 <script type="text/javascript">${h.tooltip.activate()}</script>
71 71 </div>
72 72 <!-- end footer -->
73 73 </body>
74 74
75 75 </html>
76 76
77 77 ### MAKO DEFS ###
78 78 <%def name="page_nav()">
79 79 ${self.menu()}
80 80 </%def>
81 81
82 82 <%def name="menu(current=None)">
83 83 <%
84 84 def is_current(selected):
85 85 if selected == current:
86 return "class='current'"
86 return h.literal('class="current"')
87 87 %>
88 88 %if current not in ['home','admin']:
89 89 <script type="text/javascript">
90 90 YAHOO.util.Event.onDOMReady(function(){
91 91 YAHOO.util.Event.addListener('repo_switcher','click',function(){
92 92 if(YAHOO.util.Dom.hasClass('repo_switcher','selected')){
93 93 YAHOO.util.Dom.setStyle('switch_repos','display','none');
94 94 YAHOO.util.Dom.setStyle('repo_switcher','background','');
95 95 YAHOO.util.Dom.removeClass('repo_switcher','selected');
96 96 YAHOO.util.Dom.get('repo_switcher').removeAttribute('style');
97 97 }
98 98 else{
99 99 YAHOO.util.Dom.setStyle('switch_repos','display','');
100 100 YAHOO.util.Dom.addClass('repo_switcher','selected');
101 101 }
102 102 });
103 103 YAHOO.util.Event.addListener('repos_list','change',function(e){
104 104 var wa = YAHOO.util.Dom.get('repos_list').value;
105 105
106 106 var url = "${h.url('summary_home',repo_name='__REPO__')}".replace('__REPO__',wa);
107 107 window.location = url;
108 108 })
109 109 });
110 110 </script>
111 111
112 112 ##REGULAR MENU
113 113 <ul id="quick">
114 114 <!-- repo switcher -->
115 115 <li>
116 116 <a id="repo_switcher" title="${_('Switch repository')}" href="#">
117 117 <span class="icon">
118 118 <img src="/images/icons/database.png" alt="${_('Products')}" />
119 119 </span>
120 120 <span>&darr;</span>
121 121 </a>
122 122 <div id="switch_repos" style="display:none;">
123 123 <select id="repos_list" size="10">
124 124 %for repo in c.repo_switcher_list:
125 125 <option value="${repo}">${repo}</option>
126 126 %endfor
127 127 </select>
128 128 </div>
129 129 </li>
130 130
131 131 <li ${is_current('summary')}>
132 132 <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
133 133 <span class="icon">
134 134 <img src="/images/icons/clipboard_16.png" alt="${_('Summary')}" />
135 135 </span>
136 136 <span>${_('Summary')}</span>
137 137 </a>
138 138 </li>
139 139 <li ${is_current('shortlog')}>
140 140 <a title="${_('Shortlog')}" href="${h.url('shortlog_home',repo_name=c.repo_name)}">
141 141 <span class="icon">
142 142 <img src="/images/icons/application_double.png" alt="${_('Shortlog')}" />
143 143 </span>
144 144 <span>${_('Shortlog')}</span>
145 145 </a>
146 146 </li>
147 147 <li ${is_current('changelog')}>
148 148 <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=c.repo_name)}">
149 149 <span class="icon">
150 150 <img src="/images/icons/time.png" alt="${_('Changelog')}" />
151 151 </span>
152 152 <span>${_('Changelog')}</span>
153 153 </a>
154 154 </li>
155 155 <li ${is_current('branches')}>
156 156 <a title="${_('Branches')}" href="${h.url('branches_home',repo_name=c.repo_name)}">
157 157 <span class="icon">
158 158 <img src="/images/icons/arrow_branch.png" alt="${_('Branches')}" />
159 159 </span>
160 160 <span>${_('Branches')}</span>
161 161 </a>
162 162 </li>
163 163 <li ${is_current('tags')}>
164 164 <a title="${_('Tags')}" href="${h.url('tags_home',repo_name=c.repo_name)}">
165 165 <span class="icon">
166 166 <img src="/images/icons/tag_blue.png" alt="${_('Tags')}" />
167 167 </span>
168 168 <span>${_('Tags')}</span>
169 169 </a>
170 170 </li>
171 171 <li ${is_current('files')}>
172 172 <a title="${_('Files')}" href="${h.url('files_home',repo_name=c.repo_name)}">
173 173 <span class="icon">
174 174 <img src="/images/icons/file.png" alt="${_('Files')}" />
175 175 </span>
176 176 <span>${_('Files')}</span>
177 177 </a>
178 178 </li>
179 179 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
180 180 <li ${is_current('settings')}>
181 181 <a title="${_('Settings')}" href="${h.url('repo_settings_home',repo_name=c.repo_name)}">
182 182 <span class="icon">
183 183 <img src="/images/icons/cog_edit.png" alt="${_('Settings')}" />
184 184 </span>
185 185 <span>${_('Settings')}</span>
186 186 </a>
187 187 </li>
188 188 %endif
189 189 </ul>
190 190 %else:
191 191 ##ROOT MENU
192 192 <ul id="quick">
193 193 <li>
194 194 <a title="${_('Home')}" href="${h.url('hg_home')}">
195 195 <span class="icon">
196 196 <img src="/images/icons/home_16.png" alt="${_('Home')}" />
197 197 </span>
198 198 <span>${_('Home')}</span>
199 199 </a>
200 200 </li>
201 201
202 202 <li>
203 203 <a title="${_('Search')}" href="${h.url('search')}">
204 204 <span class="icon">
205 205 <img src="/images/icons/search_16.png" alt="${_('Search')}" />
206 206 </span>
207 207 <span>${_('Search')}</span>
208 208 </a>
209 209 </li>
210 210
211 211 %if h.HasPermissionAll('hg.admin')('access admin main page'):
212 212 <li ${is_current('admin')}>
213 213 <a title="${_('Admin')}" href="${h.url('admin_home')}">
214 214 <span class="icon">
215 215 <img src="/images/icons/cog_edit.png" alt="${_('Admin')}" />
216 216 </span>
217 217 <span>${_('Admin')}</span>
218 218 </a>
219 219 <ul>
220 220 <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
221 221 <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
222 222 <li>${h.link_to(_('permissions'),h.url('permissions'),class_='permissions')}</li>
223 223 <li>${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>
224 224 </ul>
225 225 </li>
226 226 %endif
227 227
228 228 </ul>
229 229 %endif
230 230 </%def>
231 231
232 232
233 233 <%def name="css()">
234 234 <link rel="stylesheet" type="text/css" href="/css/reset.css" />
235 235 <link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" />
236 236 <link rel="stylesheet" type="text/css" href="/css/style_full.css" />
237 237 <link id="color" rel="stylesheet" type="text/css" href="/css/colors/blue.css" />
238 238 <link rel="stylesheet" type="text/css" href="/css/pygments.css" />
239 239 <link rel="stylesheet" type="text/css" href="/css/diff.css" />
240 240 </%def>
241 241
242 242 <%def name="js()">
243 243 <script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
244 244 <!--[if IE]><script language="javascript" type="text/javascript" src="/js/excanvas.min.js"></script><![endif]-->
245 245 <script type="text/javascript" src="/js/yui/container/container-min.js"></script>
246 246 <script type="text/javascript" src="/js/yui/datasource/datasource-min.js"></script>
247 247 <script type="text/javascript" src="/js/yui/autocomplete/autocomplete-min.js"></script>
248 248 <script type="text/javascript" src="/js/yui.flot.js"></script>
249 249 </%def>
250 250
251 251 <%def name="breadcrumbs()">
252 252 <div class="breadcrumbs">
253 253 ${self.breadcrumbs_links()}
254 254 </div>
255 255 </%def> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now