Mercurial > kallithea
comparison rhodecode/lib/helpers.py @ 1764:39b49c999efb beta
fixes issue #320.
- added mapping of commit users into rhodecode users
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 08 Dec 2011 01:23:11 +0200 |
parents | 1d1ccb873d00 |
children | 6079061886fc |
comparison
equal
deleted
inserted
replaced
1763:d09c52be40e0 | 1764:39b49c999efb |
---|---|
36 convert_boolean_attrs, NotGiven, _make_safe_id_component | 36 convert_boolean_attrs, NotGiven, _make_safe_id_component |
37 | 37 |
38 from rhodecode.lib.annotate import annotate_highlight | 38 from rhodecode.lib.annotate import annotate_highlight |
39 from rhodecode.lib.utils import repo_name_slug | 39 from rhodecode.lib.utils import repo_name_slug |
40 from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe | 40 from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe |
41 | |
42 from rhodecode.lib.markup_renderer import MarkupRenderer | 41 from rhodecode.lib.markup_renderer import MarkupRenderer |
43 | 42 |
44 def _reset(name, value=None, id=NotGiven, type="reset", **attrs): | 43 def _reset(name, value=None, id=NotGiven, type="reset", **attrs): |
45 """ | 44 """ |
46 Reset button | 45 Reset button |
286 #============================================================================== | 285 #============================================================================== |
287 # SCM FILTERS available via h. | 286 # SCM FILTERS available via h. |
288 #============================================================================== | 287 #============================================================================== |
289 from vcs.utils import author_name, author_email | 288 from vcs.utils import author_name, author_email |
290 from rhodecode.lib import credentials_filter, age as _age | 289 from rhodecode.lib import credentials_filter, age as _age |
290 from rhodecode.model.db import User | |
291 | 291 |
292 age = lambda x:_age(x) | 292 age = lambda x:_age(x) |
293 capitalize = lambda x: x.capitalize() | 293 capitalize = lambda x: x.capitalize() |
294 email = author_email | 294 email = author_email |
295 email_or_none = lambda x: email(x) if email(x) != x else None | |
296 person = lambda x: author_name(x) | 295 person = lambda x: author_name(x) |
297 short_id = lambda x: x[:12] | 296 short_id = lambda x: x[:12] |
298 hide_credentials = lambda x: ''.join(credentials_filter(x)) | 297 hide_credentials = lambda x: ''.join(credentials_filter(x)) |
298 | |
299 | |
300 def email_or_none(x): | |
301 if email(x) != '': | |
302 return email(x) | |
303 | |
304 # See if it contains a username we can get an email from | |
305 user = User.get_by_username(author_name(x), case_insensitive=True, | |
306 cache=True) | |
307 if user is not None: | |
308 return user.email | |
309 | |
310 # No valid email, not a valid user in the system, none! | |
311 return None | |
312 | |
313 def person(x): | |
314 # Valid email in the attribute passed, see if they're in the system | |
315 | |
316 # attr to return from fetched user | |
317 person_getter = lambda usr: usr.username | |
318 | |
319 if email(x) != '': | |
320 user = User.get_by_email(email(x), case_insensitive=True, cache=True) | |
321 if user is not None: | |
322 return person_getter(user) | |
323 return email(x) | |
324 | |
325 # Maybe it's a username? | |
326 user = User.get_by_username(author_name(x), case_insensitive=True, | |
327 cache=True) | |
328 if user is not None: | |
329 return person_getter(user) | |
330 | |
331 # Still nothing? Just pass back the author name then | |
332 return author_name(x) | |
299 | 333 |
300 def bool2icon(value): | 334 def bool2icon(value): |
301 """Returns True/False values represented as small html image of true/false | 335 """Returns True/False values represented as small html image of true/false |
302 icons | 336 icons |
303 | 337 |