Show More
@@ -21,10 +21,12 b' class BaseController(WSGIController):' | |||
|
21 | 21 | c.cached_repo_list = ScmModel().get_repos() |
|
22 | 22 | c.backends = BACKENDS.keys() |
|
23 | 23 | |
|
24 | self.sa = meta.Session() | |
|
25 | scm_model = ScmModel(self.sa) | |
|
26 | #c.unread_journal = scm_model.get_unread_journal() | |
|
27 | ||
|
24 | 28 | if c.repo_name: |
|
25 | scm_model = ScmModel() | |
|
26 | 29 | cached_repo = scm_model.get(c.repo_name) |
|
27 | ||
|
28 | 30 | if cached_repo: |
|
29 | 31 | c.repository_tags = cached_repo.tags |
|
30 | 32 | c.repository_branches = cached_repo.branches |
@@ -36,7 +38,6 b' class BaseController(WSGIController):' | |||
|
36 | 38 | c.repository_followers = 0 |
|
37 | 39 | c.repository_forks = 0 |
|
38 | 40 | |
|
39 | self.sa = meta.Session() | |
|
40 | 41 | |
|
41 | 42 | def __call__(self, environ, start_response): |
|
42 | 43 | """Invoke the Controller""" |
@@ -55,11 +55,11 b' class CachingQuery(Query):' | |||
|
55 | 55 | the "public" method of configuring this state upon the CachingQuery. |
|
56 | 56 | |
|
57 | 57 | """ |
|
58 | ||
|
58 | ||
|
59 | 59 | def __init__(self, manager, *args, **kw): |
|
60 | 60 | self.cache_manager = manager |
|
61 | 61 | Query.__init__(self, *args, **kw) |
|
62 | ||
|
62 | ||
|
63 | 63 | def __iter__(self): |
|
64 | 64 | """override __iter__ to pull results from Beaker |
|
65 | 65 | if particular attributes have been configured. |
@@ -101,7 +101,7 b' class CachingQuery(Query):' | |||
|
101 | 101 | """Set the value in the cache for this query.""" |
|
102 | 102 | |
|
103 | 103 | cache, cache_key = _get_cache_parameters(self) |
|
104 |
cache.put(cache_key, value) |
|
|
104 | cache.put(cache_key, value) | |
|
105 | 105 | |
|
106 | 106 | def query_callable(manager): |
|
107 | 107 | def query(*arg, **kw): |
@@ -110,11 +110,11 b' def query_callable(manager):' | |||
|
110 | 110 | |
|
111 | 111 | def get_cache_region(name, region): |
|
112 | 112 | if region not in beaker.cache.cache_regions: |
|
113 |
raise BeakerException('Cache region |
|
|
113 | raise BeakerException('Cache region `%s` not configured ' | |
|
114 | 114 | 'Check if proper cache settings are in the .ini files' % region) |
|
115 | 115 | kw = beaker.cache.cache_regions[region] |
|
116 | 116 | return beaker.cache.Cache._get_cache(name, kw) |
|
117 | ||
|
117 | ||
|
118 | 118 | def _get_cache_parameters(query): |
|
119 | 119 | """For a query with cache_region and cache_namespace configured, |
|
120 | 120 | return the correspoinding Cache instance and cache key, based |
@@ -125,7 +125,7 b' def _get_cache_parameters(query):' | |||
|
125 | 125 | raise ValueError("This Query does not have caching parameters configured.") |
|
126 | 126 | |
|
127 | 127 | region, namespace, cache_key = query._cache_parameters |
|
128 | ||
|
128 | ||
|
129 | 129 | namespace = _namespace_from_query(namespace, query) |
|
130 | 130 | |
|
131 | 131 | if cache_key is None: |
@@ -153,15 +153,15 b' def _namespace_from_query(namespace, que' | |||
|
153 | 153 | return namespace |
|
154 | 154 | |
|
155 | 155 | def _set_cache_parameters(query, region, namespace, cache_key): |
|
156 | ||
|
156 | ||
|
157 | 157 | if hasattr(query, '_cache_parameters'): |
|
158 | 158 | region, namespace, cache_key = query._cache_parameters |
|
159 | 159 | raise ValueError("This query is already configured " |
|
160 |
"for region %r namespace %r" % |
|
|
160 | "for region %r namespace %r" % | |
|
161 | 161 | (region, namespace) |
|
162 | 162 | ) |
|
163 | 163 | query._cache_parameters = region, namespace, cache_key |
|
164 | ||
|
164 | ||
|
165 | 165 | class FromCache(MapperOption): |
|
166 | 166 | """Specifies that a Query should load results from a cache.""" |
|
167 | 167 | |
@@ -187,10 +187,10 b' class FromCache(MapperOption):' | |||
|
187 | 187 | self.region = region |
|
188 | 188 | self.namespace = namespace |
|
189 | 189 | self.cache_key = cache_key |
|
190 | ||
|
190 | ||
|
191 | 191 | def process_query(self, query): |
|
192 | 192 | """Process a Query during normal loading operation.""" |
|
193 | ||
|
193 | ||
|
194 | 194 | _set_cache_parameters(query, self.region, self.namespace, self.cache_key) |
|
195 | 195 | |
|
196 | 196 | class RelationshipCache(MapperOption): |
@@ -263,13 +263,13 b' def _params_from_query(query):' | |||
|
263 | 263 | v = [] |
|
264 | 264 | def visit_bindparam(bind): |
|
265 | 265 | value = query._params.get(bind.key, bind.value) |
|
266 | ||
|
266 | ||
|
267 | 267 | # lazyloader may dig a callable in here, intended |
|
268 | 268 | # to late-evaluate params after autoflush is called. |
|
269 | 269 | # convert to a scalar value. |
|
270 | 270 | if callable(value): |
|
271 | 271 | value = value() |
|
272 | ||
|
272 | ||
|
273 | 273 | v.append(value) |
|
274 | 274 | if query._criterion is not None: |
|
275 | 275 | visitors.traverse(query._criterion, {}, {'bindparam':visit_bindparam}) |
@@ -46,7 +46,7 b' from rhodecode.model import BaseModel' | |||
|
46 | 46 | from rhodecode.model.user import UserModel |
|
47 | 47 | |
|
48 | 48 | from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
|
49 | UserFollowing | |
|
49 | UserFollowing, UserLog | |
|
50 | 50 | from rhodecode.model.caching_query import FromCache |
|
51 | 51 | |
|
52 | 52 | from sqlalchemy.orm import joinedload |
@@ -333,6 +333,11 b' class ScmModel(BaseModel):' | |||
|
333 | 333 | return self.sa.query(Repository)\ |
|
334 | 334 | .filter(Repository.fork_id == repo_id).count() |
|
335 | 335 | |
|
336 | ||
|
337 | def get_unread_journal(self): | |
|
338 | return self.sa.query(UserLog).count() | |
|
339 | ||
|
340 | ||
|
336 | 341 | def _should_invalidate(self, repo_name): |
|
337 | 342 | """ |
|
338 | 343 | Looks up database for invalidation signals for this repo_name |
@@ -190,18 +190,32 b' margin:0;' | |||
|
190 | 190 | padding:0 30px; |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | ||
|
194 | #header ul#logged-user{ | |
|
195 | margin-bottom:5px !important; | |
|
196 | -webkit-border-radius: 0px 0px 8px 8px; | |
|
197 | -khtml-border-radius: 0px 0px 8px 8px; | |
|
198 | -moz-border-radius: 0px 0px 8px 8px; | |
|
199 | border-radius: 0px 0px 8px 8px; | |
|
200 | height:37px; | |
|
201 | background:url("../images/header_inner.png") repeat-x scroll 0 0 #003367 | |
|
202 | } | |
|
203 | ||
|
193 | 204 | #header ul#logged-user li { |
|
194 | 205 | list-style:none; |
|
195 | 206 | float:left; |
|
196 | border-left:1px solid #bbb; | |
|
197 | border-right:1px solid #a5a5a5; | |
|
198 | margin:-2px 0 0; | |
|
199 | padding:10px 12px; | |
|
207 | margin:8px 0 0; | |
|
208 | padding:4px 12px; | |
|
209 | border-left: 1px solid #316293; | |
|
200 | 210 | } |
|
201 | 211 | |
|
202 | 212 | #header ul#logged-user li.first { |
|
203 | 213 | border-left:none; |
|
204 |
margin: |
|
|
214 | margin:4px; | |
|
215 | } | |
|
216 | ||
|
217 | #header ul#logged-user li.first div.gravatar { | |
|
218 | margin-top:-2px; | |
|
205 | 219 | } |
|
206 | 220 | |
|
207 | 221 | #header ul#logged-user li.first div.account { |
@@ -214,13 +228,12 b' border-right:none;' | |||
|
214 | 228 | } |
|
215 | 229 | |
|
216 | 230 | #header ul#logged-user li a { |
|
217 |
color:# |
|
|
231 | color:#fff; | |
|
218 | 232 | font-weight:700; |
|
219 | 233 | text-decoration:none; |
|
220 | 234 | } |
|
221 | 235 | |
|
222 | 236 | #header ul#logged-user li a:hover { |
|
223 | color:#376ea6; | |
|
224 | 237 | text-decoration:underline; |
|
225 | 238 | } |
|
226 | 239 | |
@@ -229,7 +242,7 b' color:#fff;' | |||
|
229 | 242 | } |
|
230 | 243 | |
|
231 | 244 | #header ul#logged-user li.highlight a:hover { |
|
232 |
color:# |
|
|
245 | color:#FFF; | |
|
233 | 246 | } |
|
234 | 247 | |
|
235 | 248 | #header #header-inner { |
@@ -16,26 +16,34 b'' | |||
|
16 | 16 | <div id="header"> |
|
17 | 17 | <!-- user --> |
|
18 | 18 | <ul id="logged-user"> |
|
19 | %if c.rhodecode_user.username == 'default': | |
|
20 | <li class="first"> | |
|
21 | <div class="account"> | |
|
22 | ## ${h.link_to('%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname),h.url('#'))}<br/> | |
|
23 | ## ${h.link_to(c.rhodecode_user.username,h.url('#'))} | |
|
24 | </div> | |
|
25 | </li> | |
|
26 | <li class="last highlight">${h.link_to(u'Login',h.url('login_home'))}</li> | |
|
27 | %else: | |
|
28 | 19 | <li class="first"> |
|
29 | 20 | <div class="gravatar"> |
|
30 |
<img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,2 |
|
|
21 | <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,20)}" /> | |
|
31 | 22 | </div> |
|
32 | 23 | <div class="account"> |
|
33 | ${h.link_to('%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname),h.url('admin_settings_my_account'))}<br/> | |
|
24 | %if c.rhodecode_user.username == 'default': | |
|
25 | ##${h.link_to('%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname),h.url('register'))}<br/> | |
|
26 | ${h.link_to('anonymous',h.url('register'))} | |
|
27 | %else: | |
|
28 | ##${h.link_to('%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname),h.url('admin_settings_my_account'))}<br/> | |
|
34 | 29 | ${h.link_to(c.rhodecode_user.username,h.url('admin_settings_my_account'))} |
|
30 | %endif | |
|
35 | 31 | </div> |
|
36 | 32 | </li> |
|
37 | <li class="last highlight">${h.link_to(u'Logout',h.url('logout_home'))}</li> | |
|
38 | %endif | |
|
33 | <li> | |
|
34 | <a href="${h.url('home')}">${_('Home')}</a> | |
|
35 | </li> | |
|
36 | <li> | |
|
37 | <a href="${h.url('journal')}">${_('Journal')}</a> | |
|
38 | ##(${c.unread_journal})</a> | |
|
39 | </li> | |
|
40 | %if c.rhodecode_user.username == 'default': | |
|
41 | <li class="last highlight">${h.link_to(u'Login',h.url('login_home'))}</li> | |
|
42 | %else: | |
|
43 | <li class="last highlight">${h.link_to(u'Log Out',h.url('logout_home'))}</li> | |
|
44 | %endif | |
|
45 | ||
|
46 | ||
|
39 | 47 | </ul> |
|
40 | 48 | <!-- end user --> |
|
41 | 49 | <div id="header-inner" class="title top-left-rounded-corner top-right-rounded-corner"> |
General Comments 0
You need to be logged in to leave comments.
Login now