Show More
@@ -32,7 +32,7 from pylons_app.lib import helpers as h | |||
|
32 | 32 | from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
|
33 | 33 | HasPermissionAnyDecorator |
|
34 | 34 | from pylons_app.lib.base import BaseController, render |
|
35 | from pylons_app.lib.utils import invalidate_cache | |
|
35 | from pylons_app.lib.utils import invalidate_cache, action_logger | |
|
36 | 36 | from pylons_app.model.db import User |
|
37 | 37 | from pylons_app.model.forms import RepoForm |
|
38 | 38 | from pylons_app.model.hg_model import HgModel |
@@ -78,6 +78,13 class ReposController(BaseController): | |||
|
78 | 78 | h.flash(_('created repository %s') % form_result['repo_name'], |
|
79 | 79 | category='success') |
|
80 | 80 | |
|
81 | if request.POST.get('user_created'): | |
|
82 | action_logger(self.hg_app_user, 'user_created_repo', | |
|
83 | form_result['repo_name'], '', self.sa) | |
|
84 | else: | |
|
85 | action_logger(self.hg_app_user, 'admin_created_repo', | |
|
86 | form_result['repo_name'], '', self.sa) | |
|
87 | ||
|
81 | 88 | except formencode.Invalid as errors: |
|
82 | 89 | c.new_repo = errors.value['repo_name'] |
|
83 | 90 | |
@@ -169,10 +176,14 class ReposController(BaseController): | |||
|
169 | 176 | |
|
170 | 177 | return redirect(url('repos')) |
|
171 | 178 | try: |
|
179 | action_logger(self.hg_app_user, 'admin_deleted_repo', | |
|
180 | repo_name, '', self.sa) | |
|
172 | 181 | repo_model.delete(repo) |
|
173 | 182 | invalidate_cache('cached_repo_list') |
|
174 | 183 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
175 | except Exception: | |
|
184 | ||
|
185 | except Exception, e: | |
|
186 | log.error(traceback.format_exc()) | |
|
176 | 187 | h.flash(_('An error occured during deletion of %s') % repo_name, |
|
177 | 188 | category='error') |
|
178 | 189 |
@@ -101,7 +101,7 class SettingsController(BaseController) | |||
|
101 | 101 | initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) |
|
102 | 102 | repo2db_mapper(initial, rm_obsolete) |
|
103 | 103 | invalidate_cache('cached_repo_list') |
|
104 | h.flash(_('Repositories sucessfully rescanned'), category='success') | |
|
104 | h.flash(_('Repositories successfully rescanned'), category='success') | |
|
105 | 105 | |
|
106 | 106 | if setting_id == 'whoosh': |
|
107 | 107 | repo_location = get_hg_ui_settings()['paths_root_path'] |
@@ -134,7 +134,7 class SettingsController(BaseController) | |||
|
134 | 134 | |
|
135 | 135 | except: |
|
136 | 136 | log.error(traceback.format_exc()) |
|
137 | h.flash(_('error occured during updating application settings'), | |
|
137 | h.flash(_('error occurred during updating application settings'), | |
|
138 | 138 | category='error') |
|
139 | 139 | |
|
140 | 140 | self.sa.rollback() |
@@ -187,7 +187,7 class SettingsController(BaseController) | |||
|
187 | 187 | |
|
188 | 188 | except: |
|
189 | 189 | log.error(traceback.format_exc()) |
|
190 | h.flash(_('error occured during updating application settings'), | |
|
190 | h.flash(_('error occurred during updating application settings'), | |
|
191 | 191 | category='error') |
|
192 | 192 | |
|
193 | 193 | self.sa.rollback() |
@@ -17,6 +17,7 | |||
|
17 | 17 | # along with this program; if not, write to the Free Software |
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 | # MA 02110-1301, USA. |
|
20 | from pylons_app.lib.utils import action_logger | |
|
20 | 21 | """ |
|
21 | 22 | Created on April 4, 2010 |
|
22 | 23 | users controller for pylons |
@@ -71,6 +72,7 class UsersController(BaseController): | |||
|
71 | 72 | user_model.create(form_result) |
|
72 | 73 | h.flash(_('created user %s') % form_result['username'], |
|
73 | 74 | category='success') |
|
75 | #action_logger(self.hg_app_user, 'new_user', '', '', self.sa) | |
|
74 | 76 | except formencode.Invalid as errors: |
|
75 | 77 | return htmlfill.render( |
|
76 | 78 | render('admin/users/user_add.html'), |
@@ -28,7 +28,7 from pylons.controllers.util import redi | |||
|
28 | 28 | from pylons.i18n.translation import _ |
|
29 | 29 | from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAllDecorator |
|
30 | 30 | from pylons_app.lib.base import BaseController, render |
|
31 | from pylons_app.lib.utils import invalidate_cache | |
|
31 | from pylons_app.lib.utils import invalidate_cache, action_logger | |
|
32 | 32 | from pylons_app.model.forms import RepoSettingsForm, RepoForkForm |
|
33 | 33 | from pylons_app.model.repo_model import RepoModel |
|
34 | 34 | import formencode |
@@ -79,7 +79,7 class SettingsController(BaseController) | |||
|
79 | 79 | form_result = _form.to_python(dict(request.POST)) |
|
80 | 80 | repo_model.update(repo_name, form_result) |
|
81 | 81 | invalidate_cache('cached_repo_list') |
|
82 | h.flash(_('Repository %s updated succesfully' % repo_name), | |
|
82 | h.flash(_('Repository %s updated successfully' % repo_name), | |
|
83 | 83 | category='success') |
|
84 | 84 | changed_name = form_result['repo_name'] |
|
85 | 85 | except formencode.Invalid as errors: |
@@ -121,11 +121,13 class SettingsController(BaseController) | |||
|
121 | 121 | |
|
122 | 122 | return redirect(url('hg_home')) |
|
123 | 123 | try: |
|
124 | action_logger(self.hg_app_user, 'user_deleted_repo', | |
|
125 | repo_name, '', self.sa) | |
|
124 | 126 | repo_model.delete(repo) |
|
125 | 127 | invalidate_cache('cached_repo_list') |
|
126 | 128 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
127 | 129 | except Exception: |
|
128 | h.flash(_('An error occured during deletion of %s') % repo_name, | |
|
130 | h.flash(_('An error occurred during deletion of %s') % repo_name, | |
|
129 | 131 | category='error') |
|
130 | 132 | |
|
131 | 133 | return redirect(url('hg_home')) |
@@ -158,7 +160,8 class SettingsController(BaseController) | |||
|
158 | 160 | h.flash(_('fork %s repository as %s task added') \ |
|
159 | 161 | % (repo_name, form_result['fork_name']), |
|
160 | 162 | category='success') |
|
161 | ||
|
163 | action_logger(self.hg_app_user, 'user_forked_repo', | |
|
164 | repo_name, '', self.sa) | |
|
162 | 165 | except formencode.Invalid as errors: |
|
163 | 166 | c.new_repo = errors.value['fork_name'] |
|
164 | 167 | r = render('settings/repo_fork.html') |
@@ -40,7 +40,7 class BaseController(WSGIController): | |||
|
40 | 40 | # available in environ['pylons.routes_dict'] |
|
41 | 41 | try: |
|
42 | 42 | #putting this here makes sure that we update permissions every time |
|
43 | c.hg_app_user = auth.get_user(session) | |
|
43 | self.hg_app_user = c.hg_app_user = auth.get_user(session) | |
|
44 | 44 | return WSGIController.__call__(self, environ, start_response) |
|
45 | 45 | finally: |
|
46 | 46 | meta.Session.remove() |
@@ -57,21 +57,21 def action_logger(user, action, repo, ip | |||
|
57 | 57 | if not sa: |
|
58 | 58 | sa = meta.Session |
|
59 | 59 | |
|
60 | ||
|
60 | try: | |
|
61 | 61 | if hasattr(user, 'user_id'): |
|
62 | 62 | user_id = user.user_id |
|
63 | 63 | elif isinstance(user, basestring): |
|
64 | ||
|
65 | user_id = sa.Query(User).filter(User.username == user).one() | |
|
64 | user_id = sa.query(User).filter(User.username == user).one() | |
|
66 | 65 | else: |
|
67 | 66 | raise Exception('You have to provide user object or username') |
|
68 | 67 | |
|
69 | try: | |
|
68 | repo_name = repo.lstrip('/') | |
|
70 | 69 | user_log = UserLog() |
|
71 | 70 | user_log.user_id = user_id |
|
72 | 71 | user_log.action = action |
|
72 | user_log.repository_name = repo_name | |
|
73 | 73 | user_log.repository = sa.query(Repository)\ |
|
74 |
.filter(Repository.repo_name== |
|
|
74 | .filter(Repository.repo_name == repo_name).one() | |
|
75 | 75 | user_log.action_date = datetime.datetime.now() |
|
76 | 76 | user_log.user_ip = ipaddr |
|
77 | 77 | sa.add(user_log) |
@@ -66,7 +66,8 class UserLog(Base): | |||
|
66 | 66 | __table_args__ = {'useexisting':True} |
|
67 | 67 | user_log_id = Column("user_log_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
|
68 | 68 | user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None) |
|
69 |
repository_id = Column("repository", |
|
|
69 | repository_id = Column("repository_id", INTEGER(length=None, convert_unicode=False, assert_unicode=None), ForeignKey(u'repositories.repo_id'), nullable=False, unique=None, default=None) | |
|
70 | repository_name = Column("repository_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
|
70 | 71 | user_ip = Column("user_ip", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
71 | 72 | action = Column("action", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
72 | 73 | action_date = Column("action_date", DATETIME(timezone=False), nullable=True, unique=None, default=None) |
@@ -12,7 +12,13 | |||
|
12 | 12 | %for cnt,l in enumerate(c.users_log): |
|
13 | 13 | <tr class="parity${cnt%2}"> |
|
14 | 14 | <td>${h.link_to(l.user.username,h.url('edit_user', id=l.user.user_id))}</td> |
|
15 | <td>${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))}</td> | |
|
15 | <td> | |
|
16 | %if l.repository: | |
|
17 | ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))} | |
|
18 | %else: | |
|
19 | ${l.repository_name} | |
|
20 | %endif | |
|
21 | </td> | |
|
16 | 22 | <td> |
|
17 | 23 | % if l.action == 'push' and l.revision: |
|
18 | 24 | ${h.link_to('%s - %s' % (l.action,l.revision), |
General Comments 0
You need to be logged in to leave comments.
Login now