Show More
@@ -151,10 +151,12 b' class ReposController(BaseController):' | |||||
151 | if request.POST.get('user_created'): |
|
151 | if request.POST.get('user_created'): | |
152 | # created by regular non admin user |
|
152 | # created by regular non admin user | |
153 | action_logger(self.rhodecode_user, 'user_created_repo', |
|
153 | action_logger(self.rhodecode_user, 'user_created_repo', | |
154 |
form_result['repo_name_full'], |
|
154 | form_result['repo_name_full'], self.ip_addr, | |
|
155 | self.sa) | |||
155 | else: |
|
156 | else: | |
156 | action_logger(self.rhodecode_user, 'admin_created_repo', |
|
157 | action_logger(self.rhodecode_user, 'admin_created_repo', | |
157 |
form_result['repo_name_full'], |
|
158 | form_result['repo_name_full'], self.ip_addr, | |
|
159 | self.sa) | |||
158 | Session.commit() |
|
160 | Session.commit() | |
159 | except formencode.Invalid, errors: |
|
161 | except formencode.Invalid, errors: | |
160 |
|
162 | |||
@@ -212,7 +214,7 b' class ReposController(BaseController):' | |||||
212 | category='success') |
|
214 | category='success') | |
213 | changed_name = repo.repo_name |
|
215 | changed_name = repo.repo_name | |
214 | action_logger(self.rhodecode_user, 'admin_updated_repo', |
|
216 | action_logger(self.rhodecode_user, 'admin_updated_repo', | |
215 |
changed_name, |
|
217 | changed_name, self.ip_addr, self.sa) | |
216 | Session.commit() |
|
218 | Session.commit() | |
217 | except formencode.Invalid, errors: |
|
219 | except formencode.Invalid, errors: | |
218 | defaults = self.__load_data(repo_name) |
|
220 | defaults = self.__load_data(repo_name) | |
@@ -253,7 +255,7 b' class ReposController(BaseController):' | |||||
253 | return redirect(url('repos')) |
|
255 | return redirect(url('repos')) | |
254 | try: |
|
256 | try: | |
255 | action_logger(self.rhodecode_user, 'admin_deleted_repo', |
|
257 | action_logger(self.rhodecode_user, 'admin_deleted_repo', | |
256 |
repo_name, |
|
258 | repo_name, self.ip_addr, self.sa) | |
257 | repo_model.delete(repo) |
|
259 | repo_model.delete(repo) | |
258 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
260 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
259 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
261 | h.flash(_('deleted repository %s') % repo_name, category='success') |
@@ -42,6 +42,7 b' from rhodecode.model.db import User, Per' | |||||
42 | from rhodecode.model.forms import UserForm |
|
42 | from rhodecode.model.forms import UserForm | |
43 | from rhodecode.model.user import UserModel |
|
43 | from rhodecode.model.user import UserModel | |
44 | from rhodecode.model.meta import Session |
|
44 | from rhodecode.model.meta import Session | |
|
45 | from rhodecode.lib.utils import action_logger | |||
45 |
|
46 | |||
46 | log = logging.getLogger(__name__) |
|
47 | log = logging.getLogger(__name__) | |
47 |
|
48 | |||
@@ -76,10 +77,12 b' class UsersController(BaseController):' | |||||
76 | try: |
|
77 | try: | |
77 | form_result = user_form.to_python(dict(request.POST)) |
|
78 | form_result = user_form.to_python(dict(request.POST)) | |
78 | user_model.create(form_result) |
|
79 | user_model.create(form_result) | |
79 |
|
|
80 | usr = form_result['username'] | |
|
81 | action_logger(self.rhodecode_user, 'admin_created_user:%s' % usr, | |||
|
82 | None, self.ip_addr, self.sa) | |||
|
83 | h.flash(_('created user %s') % usr, | |||
80 | category='success') |
|
84 | category='success') | |
81 | Session.commit() |
|
85 | Session.commit() | |
82 | #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa) |
|
|||
83 | except formencode.Invalid, errors: |
|
86 | except formencode.Invalid, errors: | |
84 | return htmlfill.render( |
|
87 | return htmlfill.render( | |
85 | render('admin/users/user_add.html'), |
|
88 | render('admin/users/user_add.html'), | |
@@ -115,6 +118,9 b' class UsersController(BaseController):' | |||||
115 | try: |
|
118 | try: | |
116 | form_result = _form.to_python(dict(request.POST)) |
|
119 | form_result = _form.to_python(dict(request.POST)) | |
117 | user_model.update(id, form_result) |
|
120 | user_model.update(id, form_result) | |
|
121 | usr = form_result['username'] | |||
|
122 | action_logger(self.rhodecode_user, 'admin_updated_user:%s' % usr, | |||
|
123 | None, self.ip_addr, self.sa) | |||
118 | h.flash(_('User updated successfully'), category='success') |
|
124 | h.flash(_('User updated successfully'), category='success') | |
119 | Session.commit() |
|
125 | Session.commit() | |
120 | except formencode.Invalid, errors: |
|
126 | except formencode.Invalid, errors: |
@@ -43,6 +43,7 b' from rhodecode.model.users_group import ' | |||||
43 | from rhodecode.model.db import User, UsersGroup, Permission, UsersGroupToPerm |
|
43 | from rhodecode.model.db import User, UsersGroup, Permission, UsersGroupToPerm | |
44 | from rhodecode.model.forms import UsersGroupForm |
|
44 | from rhodecode.model.forms import UsersGroupForm | |
45 | from rhodecode.model.meta import Session |
|
45 | from rhodecode.model.meta import Session | |
|
46 | from rhodecode.lib.utils import action_logger | |||
46 |
|
47 | |||
47 | log = logging.getLogger(__name__) |
|
48 | log = logging.getLogger(__name__) | |
48 |
|
49 | |||
@@ -76,9 +77,11 b' class UsersGroupsController(BaseControll' | |||||
76 | form_result = users_group_form.to_python(dict(request.POST)) |
|
77 | form_result = users_group_form.to_python(dict(request.POST)) | |
77 | UsersGroupModel().create(name=form_result['users_group_name'], |
|
78 | UsersGroupModel().create(name=form_result['users_group_name'], | |
78 | active=form_result['users_group_active']) |
|
79 | active=form_result['users_group_active']) | |
79 | h.flash(_('created users group %s') \ |
|
80 | gr = form_result['users_group_name'] | |
80 | % form_result['users_group_name'], category='success') |
|
81 | action_logger(self.rhodecode_user, | |
81 | #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa) |
|
82 | 'admin_created_users_group:%s' % gr, | |
|
83 | None, self.ip_addr, self.sa) | |||
|
84 | h.flash(_('created users group %s') % gr, category='success') | |||
82 | Session.commit() |
|
85 | Session.commit() | |
83 | except formencode.Invalid, errors: |
|
86 | except formencode.Invalid, errors: | |
84 | return htmlfill.render( |
|
87 | return htmlfill.render( | |
@@ -125,10 +128,11 b' class UsersGroupsController(BaseControll' | |||||
125 | try: |
|
128 | try: | |
126 | form_result = users_group_form.to_python(request.POST) |
|
129 | form_result = users_group_form.to_python(request.POST) | |
127 | UsersGroupModel().update(c.users_group, form_result) |
|
130 | UsersGroupModel().update(c.users_group, form_result) | |
128 | h.flash(_('updated users group %s') \ |
|
131 | gr = form_result['users_group_name'] | |
129 | % form_result['users_group_name'], |
|
132 | action_logger(self.rhodecode_user, | |
130 | category='success') |
|
133 | 'admin_updated_users_group:%s' % gr, | |
131 | #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa) |
|
134 | None, self.ip_addr, self.sa) | |
|
135 | h.flash(_('updated users group %s') % gr, category='success') | |||
132 | Session.commit() |
|
136 | Session.commit() | |
133 | except formencode.Invalid, errors: |
|
137 | except formencode.Invalid, errors: | |
134 | e = errors.error_dict or {} |
|
138 | e = errors.error_dict or {} |
@@ -40,7 +40,7 b' from rhodecode.lib.vcs.nodes import File' | |||||
40 | import rhodecode.lib.helpers as h |
|
40 | import rhodecode.lib.helpers as h | |
41 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
41 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
42 | from rhodecode.lib.base import BaseRepoController, render |
|
42 | from rhodecode.lib.base import BaseRepoController, render | |
43 | from rhodecode.lib.utils import EmptyChangeset |
|
43 | from rhodecode.lib.utils import EmptyChangeset, action_logger | |
44 | from rhodecode.lib.compat import OrderedDict |
|
44 | from rhodecode.lib.compat import OrderedDict | |
45 | from rhodecode.lib import diffs |
|
45 | from rhodecode.lib import diffs | |
46 | from rhodecode.model.db import ChangesetComment |
|
46 | from rhodecode.model.db import ChangesetComment | |
@@ -373,7 +373,12 b' class ChangesetController(BaseRepoContro' | |||||
373 | f_path=request.POST.get('f_path'), |
|
373 | f_path=request.POST.get('f_path'), | |
374 | line_no=request.POST.get('line') |
|
374 | line_no=request.POST.get('line') | |
375 | ) |
|
375 | ) | |
|
376 | action_logger(self.rhodecode_user, | |||
|
377 | 'user_commented_revision:%s' % revision, | |||
|
378 | c.rhodecode_db_repo, self.ip_addr, self.sa) | |||
|
379 | ||||
376 | Session.commit() |
|
380 | Session.commit() | |
|
381 | ||||
377 | if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
|
382 | if not request.environ.get('HTTP_X_PARTIAL_XHR'): | |
378 | return redirect(h.url('changeset_home', repo_name=repo_name, |
|
383 | return redirect(h.url('changeset_home', repo_name=repo_name, | |
379 | revision=revision)) |
|
384 | revision=revision)) |
@@ -192,7 +192,6 b' class JournalController(BaseController):' | |||||
192 | ttl=self.ttl) |
|
192 | ttl=self.ttl) | |
193 |
|
193 | |||
194 | for entry in journal[:self.feed_nr]: |
|
194 | for entry in journal[:self.feed_nr]: | |
195 | #tmpl = h.action_parser(entry)[0] |
|
|||
196 | action, action_extra = h.action_parser(entry, feed=True) |
|
195 | action, action_extra = h.action_parser(entry, feed=True) | |
197 | title = "%s - %s %s" % (entry.user.short_contact, action, |
|
196 | title = "%s - %s %s" % (entry.user.short_contact, action, | |
198 | entry.repository.repo_name) |
|
197 | entry.repository.repo_name) | |
@@ -226,7 +225,6 b' class JournalController(BaseController):' | |||||
226 | ttl=self.ttl) |
|
225 | ttl=self.ttl) | |
227 |
|
226 | |||
228 | for entry in journal[:self.feed_nr]: |
|
227 | for entry in journal[:self.feed_nr]: | |
229 | #tmpl = h.action_parser(entry)[0] |
|
|||
230 | action, action_extra = h.action_parser(entry, feed=True) |
|
228 | action, action_extra = h.action_parser(entry, feed=True) | |
231 | title = "%s - %s %s" % (entry.user.short_contact, action, |
|
229 | title = "%s - %s %s" % (entry.user.short_contact, action, | |
232 | entry.repository.repo_name) |
|
230 | entry.repository.repo_name) |
@@ -104,7 +104,7 b' class SettingsController(BaseRepoControl' | |||||
104 | category='success') |
|
104 | category='success') | |
105 | changed_name = form_result['repo_name_full'] |
|
105 | changed_name = form_result['repo_name_full'] | |
106 | action_logger(self.rhodecode_user, 'user_updated_repo', |
|
106 | action_logger(self.rhodecode_user, 'user_updated_repo', | |
107 |
changed_name, |
|
107 | changed_name, self.ip_addr, self.sa) | |
108 | Session.commit() |
|
108 | Session.commit() | |
109 | except formencode.Invalid, errors: |
|
109 | except formencode.Invalid, errors: | |
110 | c.repo_info = repo_model.get_by_repo_name(repo_name) |
|
110 | c.repo_info = repo_model.get_by_repo_name(repo_name) | |
@@ -145,7 +145,7 b' class SettingsController(BaseRepoControl' | |||||
145 | return redirect(url('home')) |
|
145 | return redirect(url('home')) | |
146 | try: |
|
146 | try: | |
147 | action_logger(self.rhodecode_user, 'user_deleted_repo', |
|
147 | action_logger(self.rhodecode_user, 'user_deleted_repo', | |
148 |
repo_name, |
|
148 | repo_name, self.ip_addr, self.sa) | |
149 | repo_model.delete(repo) |
|
149 | repo_model.delete(repo) | |
150 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
150 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
151 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
151 | h.flash(_('deleted repository %s') % repo_name, category='success') |
@@ -537,22 +537,57 b' def action_parser(user_log, feed=False):' | |||||
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: | |
@@ -567,36 +602,21 b' def action_parser(user_log, feed=False):' | |||||
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 | ||
|
607 | action_params = None | |||
|
608 | x = action.split(':') | |||
572 |
|
609 | |||
573 | def action_parser_icon(user_log): |
|
610 | if len(x) > 1: | |
574 | action = user_log.action |
|
611 | action, action_params = x | |
575 | action_params = None |
|
|||
576 | x = action.split(':') |
|
|||
577 |
|
||||
578 | if len(x) > 1: |
|
|||
579 | action, action_params = x |
|
|||
580 |
|
612 | |||
581 | tmpl = """<img src="%s%s" alt="%s"/>""" |
|
613 | tmpl = """<img src="%s%s" alt="%s"/>""" | |
582 | map = {'user_deleted_repo':'database_delete.png', |
|
614 | ico = action_map.get(action, ['', '', ''])[2] | |
583 | 'user_created_repo':'database_add.png', |
|
615 | return literal(tmpl % ((url('/images/icons/')), ico, action)) | |
584 | 'user_created_fork':'arrow_divide.png', |
|
616 | ||
585 | 'user_forked_repo':'arrow_divide.png', |
|
617 | # returned callbacks we need to call to get | |
586 | 'user_updated_repo':'database_edit.png', |
|
618 | return [lambda: literal(action), action_params_func, action_parser_icon] | |
587 | 'admin_deleted_repo':'database_delete.png', |
|
619 | ||
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 | #============================================================================== |
@@ -146,13 +146,14 b' def action_logger(user, action, repo, ip' | |||||
146 | repo_name = repo.lstrip('/') |
|
146 | repo_name = repo.lstrip('/') | |
147 | repo_obj = Repository.get_by_repo_name(repo_name) |
|
147 | repo_obj = Repository.get_by_repo_name(repo_name) | |
148 | else: |
|
148 | else: | |
149 | raise Exception('You have to provide repository to action logger') |
|
149 | repo_obj = None | |
|
150 | repo_name = '' | |||
150 |
|
151 | |||
151 | user_log = UserLog() |
|
152 | user_log = UserLog() | |
152 | user_log.user_id = user_obj.user_id |
|
153 | user_log.user_id = user_obj.user_id | |
153 | user_log.action = safe_unicode(action) |
|
154 | user_log.action = safe_unicode(action) | |
154 |
|
155 | |||
155 |
user_log.repository |
|
156 | user_log.repository = repo_obj | |
156 | user_log.repository_name = repo_name |
|
157 | user_log.repository_name = repo_name | |
157 |
|
158 | |||
158 | user_log.action_date = datetime.datetime.now() |
|
159 | user_log.action_date = datetime.datetime.now() |
@@ -12,7 +12,7 b'' | |||||
12 | %for cnt,l in enumerate(c.users_log): |
|
12 | %for cnt,l in enumerate(c.users_log): | |
13 | <tr class="parity${cnt%2}"> |
|
13 | <tr class="parity${cnt%2}"> | |
14 | <td>${h.link_to(l.user.username,h.url('edit_user', id=l.user.user_id))}</td> |
|
14 | <td>${h.link_to(l.user.username,h.url('edit_user', id=l.user.user_id))}</td> | |
15 | <td>${h.action_parser(l)[0]} |
|
15 | <td>${h.action_parser(l)[0]()} | |
16 | <div class="journal_action_params"> |
|
16 | <div class="journal_action_params"> | |
17 | ${h.literal(h.action_parser(l)[1]())}</div> |
|
17 | ${h.literal(h.action_parser(l)[1]())}</div> | |
18 | </td> |
|
18 | </td> |
@@ -11,8 +11,8 b'' | |||||
11 | <div class="journal_user">${user.name} ${user.lastname}</div> |
|
11 | <div class="journal_user">${user.name} ${user.lastname}</div> | |
12 | <div class="journal_action_container"> |
|
12 | <div class="journal_action_container"> | |
13 | % for entry in entries: |
|
13 | % for entry in entries: | |
14 |
<div class="journal_icon"> ${h.action_parser |
|
14 | <div class="journal_icon"> ${h.action_parser(entry)[2]()}</div> | |
15 | <div class="journal_action">${h.action_parser(entry)[0]}</div> |
|
15 | <div class="journal_action">${h.action_parser(entry)[0]()}</div> | |
16 | <div class="journal_repo"> |
|
16 | <div class="journal_repo"> | |
17 | <span class="journal_repo_name"> |
|
17 | <span class="journal_repo_name"> | |
18 | %if entry.repository is not None: |
|
18 | %if entry.repository is not None: |
General Comments 0
You need to be logged in to leave comments.
Login now