• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Revision29e0b4b3a2d700af1b646892393bac0f5c5847f6 (tree)
Time2012-07-13 19:25:53
AuthorIgor Bondarenko <jetmind2@gmai...>
CommiterIgor Bondarenko

Log Message

[#4534] ticket:114 Save changes to neighborhood settings in audit trail

Change Summary

Incremental Difference

--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -477,22 +477,48 @@ class NeighborhoodAdminController(object):
477477 @require_post()
478478 @validate(W.neighborhood_overview_form, error_handler=overview)
479479 def update(self, name=None, css=None, homepage=None, project_template=None, icon=None, **kw):
480- self.neighborhood.name = name
481- self.neighborhood.redirect = kw.pop('redirect', '')
482- self.neighborhood.homepage = homepage
483- self.neighborhood.css = css
484- self.neighborhood.project_template = project_template
485- self.neighborhood.allow_browse = kw.get('allow_browse', False)
486- self.neighborhood.show_title = kw.get('show_title', False)
487- self.neighborhood.project_list_url = kw.get('project_list_url', '')
480+ nbhd = self.neighborhood
481+ c.project = nbhd.neighborhood_project
482+ if nbhd.name != name:
483+ M.AuditLog.log('change neighborhood name to %s', name)
484+ nbhd.name = name
485+ nbhd_redirect = kw.pop('redirect', '')
486+ if nbhd.redirect != nbhd_redirect:
487+ M.AuditLog.log('change neighborhood redirect to %s', nbhd_redirect)
488+ nbhd.redirect = nbhd_redirect
489+ if nbhd.homepage != homepage:
490+ M.AuditLog.log('change neighborhood homepage to %s', homepage)
491+ nbhd.homepage = homepage
492+ if nbhd.css != css:
493+ M.AuditLog.log('change neighborhood css to %s', css)
494+ nbhd.css = css
495+ if nbhd.project_template != project_template:
496+ M.AuditLog.log('change neighborhood project template to %s',
497+ project_template)
498+ nbhd.project_template = project_template
499+ allow_browse = kw.get('allow_browse', False)
500+ if nbhd.allow_browse != allow_browse:
501+ M.AuditLog.log('change neighborhood allow browse to %s',
502+ allow_browse)
503+ nbhd.allow_browse = allow_browse
504+ show_title = kw.get('show_title', False)
505+ if nbhd.show_title != show_title:
506+ M.AuditLog.log('change neighborhood show title to %s',
507+ show_title)
508+ nbhd.show_title = show_title
509+ project_list_url = kw.get('project_list_url', '')
510+ if nbhd.project_list_url != project_list_url:
511+ M.AuditLog.log('change neighborhood project list url to %s',
512+ project_list_url)
513+ nbhd.project_list_url = project_list_url
488514 tracking_id = kw.get('tracking_id', '')
489- if tracking_id != self.neighborhood.tracking_id:
490- c.project = self.neighborhood.neighborhood_project
515+ if tracking_id != nbhd.tracking_id:
491516 M.AuditLog.log('update neighborhood tracking_id')
492- self.neighborhood.tracking_id = tracking_id
517+ nbhd.tracking_id = tracking_id
493518 if icon is not None and icon != '':
494519 if self.neighborhood.icon:
495520 self.neighborhood.icon.delete()
521+ M.AuditLog.log('update neighborhood icon')
496522 M.NeighborhoodFile.save_image(
497523 icon.filename, icon.file, content_type=icon.type,
498524 square=True, thumbnail_size=(48, 48),
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -63,6 +63,44 @@ class TestNeighborhood(TestController):
6363 extra_environ=dict(username='root'))
6464 assert 'Invalid JSON' in r
6565
66+ def test_admin_overview_audit_log(self):
67+
68+ def check_log(message):
69+ return M.AuditLog.query.find({'message': message}).count() == 1
70+
71+ nbhd = M.Neighborhood.query.get(name='Projects')
72+ nbhd.features['css'] = 'custom'
73+ nbhd.features['google_analytics'] = True
74+ params = {
75+ 'name': 'Pjs',
76+ 'redirect': 'http://fake.org/',
77+ 'show_title': 'false',
78+ 'allow_browse': 'false',
79+ 'css': '.class { border: 1px; }',
80+ 'tracking_id': 'U-123456',
81+ 'homepage': '[Homepage]',
82+ 'project_list_url': 'http://fake.org/project_list',
83+ 'project_template': '{"name": "template"}'
84+
85+ }
86+ self.app.post('/p/_admin/update', params=params,
87+ extra_environ=dict(username='root'))
88+ # must get as many log records as many values are updated
89+ assert M.AuditLog.query.find().count() == len(params)
90+
91+ assert check_log('change neighborhood name to Pjs')
92+ assert check_log('change neighborhood redirect to http://fake.org/')
93+ assert check_log('change neighborhood show title to False')
94+ assert check_log('change neighborhood allow browse to False')
95+ assert check_log('change neighborhood css to .class { border: 1px; }')
96+ assert check_log('change neighborhood homepage to [Homepage]')
97+ assert check_log('change neighborhood project list url to '
98+ 'http://fake.org/project_list')
99+
100+ assert check_log('change neighborhood project template to '
101+ '{"name": "template"}')
102+ assert check_log('update neighborhood tracking_id')
103+
66104 def test_show_title(self):
67105 r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root'))
68106 neighborhood = M.Neighborhood.query.get(name='Adobe')