Mercurial > kallithea
comparison rhodecode/lib/helpers.py @ 2375:bc2d8c03c050 beta
Implemented #467 Journal logs comments on changesets
- added created/updated user action to journal
- added created/updated users group action journal
- added ip adresses to most of action_log calls to track IP changes
- rewrote action_parser to simpler and more efficient solution
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 03 Jun 2012 00:40:14 +0200 |
parents | 86aa4f1f130b |
children | 679363531571 |
comparison
equal
deleted
inserted
replaced
2374:be2163ef127e | 2375:bc2d8c03c050 |
---|---|
535 def get_fork_name(): | 535 def get_fork_name(): |
536 repo_name = action_params | 536 repo_name = action_params |
537 return _('fork name ') + str(link_to(action_params, url('summary_home', | 537 return _('fork name ') + str(link_to(action_params, url('summary_home', |
538 repo_name=repo_name,))) | 538 repo_name=repo_name,))) |
539 | 539 |
540 action_map = {'user_deleted_repo': (_('[deleted] repository'), None), | 540 def get_user_name(): |
541 'user_created_repo': (_('[created] repository'), None), | 541 user_name = action_params |
542 'user_created_fork': (_('[created] repository as fork'), None), | 542 return user_name |
543 'user_forked_repo': (_('[forked] repository'), get_fork_name), | 543 |
544 'user_updated_repo': (_('[updated] repository'), None), | 544 def get_users_group(): |
545 'admin_deleted_repo': (_('[delete] repository'), None), | 545 group_name = action_params |
546 'admin_created_repo': (_('[created] repository'), None), | 546 return group_name |
547 'admin_forked_repo': (_('[forked] repository'), None), | 547 |
548 'admin_updated_repo': (_('[updated] repository'), None), | 548 # action : translated str, callback(extractor), icon |
549 'push': (_('[pushed] into'), get_cs_links), | 549 action_map = { |
550 'push_local': (_('[committed via RhodeCode] into'), get_cs_links), | 550 'user_deleted_repo': (_('[deleted] repository'), None, |
551 'push_remote': (_('[pulled from remote] into'), get_cs_links), | 551 'database_delete.png'), |
552 'pull': (_('[pulled] from'), None), | 552 'user_created_repo': (_('[created] repository'), None, |
553 'started_following_repo': (_('[started following] repository'), None), | 553 'database_add.png'), |
554 'stopped_following_repo': (_('[stopped following] repository'), None), | 554 'user_created_fork': (_('[created] repository as fork'), None, |
555 } | 555 'arrow_divide.png'), |
556 'user_forked_repo': (_('[forked] repository'), get_fork_name, | |
557 'arrow_divide.png'), | |
558 'user_updated_repo': (_('[updated] repository'), None, | |
559 'database_edit.png'), | |
560 'admin_deleted_repo': (_('[delete] repository'), None, | |
561 'database_delete.png'), | |
562 'admin_created_repo': (_('[created] repository'), None, | |
563 'database_add.png'), | |
564 'admin_forked_repo': (_('[forked] repository'), None, | |
565 'arrow_divide.png'), | |
566 'admin_updated_repo': (_('[updated] repository'), None, | |
567 'database_edit.png'), | |
568 'admin_created_user': (_('[created] user'), get_user_name, | |
569 'user_add.png'), | |
570 'admin_updated_user': (_('[updated] user'), get_user_name, | |
571 'user_edit.png'), | |
572 'admin_created_users_group': (_('[created] users group'), get_users_group, | |
573 'group_add.png'), | |
574 'admin_updated_users_group': (_('[updated] users group'), get_users_group, | |
575 'group_edit.png'), | |
576 'user_commented_revision': (_('[commented] on revision'), get_cs_links, | |
577 'comment_add.png'), | |
578 'push': (_('[pushed] into'), get_cs_links, | |
579 'script_add.png'), | |
580 'push_local': (_('[committed via RhodeCode] into'), get_cs_links, | |
581 'script_edit.png'), | |
582 'push_remote': (_('[pulled from remote] into'), get_cs_links, | |
583 'connect.png'), | |
584 'pull': (_('[pulled] from'), None, | |
585 'down_16.png'), | |
586 'started_following_repo': (_('[started following] repository'), None, | |
587 'heart_add.png'), | |
588 'stopped_following_repo': (_('[stopped following] repository'), None, | |
589 'heart_delete.png'), | |
590 } | |
556 | 591 |
557 action_str = action_map.get(action, action) | 592 action_str = action_map.get(action, action) |
558 if feed: | 593 if feed: |
559 action = action_str[0].replace('[', '').replace(']', '') | 594 action = action_str[0].replace('[', '').replace(']', '') |
560 else: | 595 else: |
565 action_params_func = lambda: "" | 600 action_params_func = lambda: "" |
566 | 601 |
567 if callable(action_str[1]): | 602 if callable(action_str[1]): |
568 action_params_func = action_str[1] | 603 action_params_func = action_str[1] |
569 | 604 |
570 return [literal(action), action_params_func] | 605 def action_parser_icon(): |
571 | 606 action = user_log.action |
572 | 607 action_params = None |
573 def action_parser_icon(user_log): | 608 x = action.split(':') |
574 action = user_log.action | 609 |
575 action_params = None | 610 if len(x) > 1: |
576 x = action.split(':') | 611 action, action_params = x |
577 | 612 |
578 if len(x) > 1: | 613 tmpl = """<img src="%s%s" alt="%s"/>""" |
579 action, action_params = x | 614 ico = action_map.get(action, ['', '', ''])[2] |
580 | 615 return literal(tmpl % ((url('/images/icons/')), ico, action)) |
581 tmpl = """<img src="%s%s" alt="%s"/>""" | 616 |
582 map = {'user_deleted_repo':'database_delete.png', | 617 # returned callbacks we need to call to get |
583 'user_created_repo':'database_add.png', | 618 return [lambda: literal(action), action_params_func, action_parser_icon] |
584 'user_created_fork':'arrow_divide.png', | 619 |
585 'user_forked_repo':'arrow_divide.png', | |
586 'user_updated_repo':'database_edit.png', | |
587 'admin_deleted_repo':'database_delete.png', | |
588 'admin_created_repo':'database_add.png', | |
589 'admin_forked_repo':'arrow_divide.png', | |
590 'admin_updated_repo':'database_edit.png', | |
591 'push':'script_add.png', | |
592 'push_local':'script_edit.png', | |
593 'push_remote':'connect.png', | |
594 'pull':'down_16.png', | |
595 'started_following_repo':'heart_add.png', | |
596 'stopped_following_repo':'heart_delete.png', | |
597 } | |
598 return literal(tmpl % ((url('/images/icons/')), | |
599 map.get(action, action), action)) | |
600 | 620 |
601 | 621 |
602 #============================================================================== | 622 #============================================================================== |
603 # PERMS | 623 # PERMS |
604 #============================================================================== | 624 #============================================================================== |