Changeset 36

Show
Ignore:
Timestamp:
2008年07月31日 01时41分30秒 (4 years ago)
Author:
jiangx
Message:

See #7: admin can rollback to history revision from log page.

Location:
trunk/pysvnmanager
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/pysvnmanager/controllers/logs.py

    r35 r36  
    6969            'who' : logs[i].get('author',''),  
    7070            'when': logs[i].get('date',''),  
    71             'why' : logs[i].get('log',''),  
     71            'why' : h.link_to(logs[i].get('log',''), h.url(action='view', id=logs[i].get('revision',''))),  
    7272            } 
    7373         
     
    134134        buff += "<pre>%s</pre>" % self.rcslog.differ(left, right) 
    135135        return buff 
     136 
     137 
     138    def view(self, id): 
     139        assert id and isinstance(id, basestring) 
     140        c.contents = unicode(self.rcslog.cat(id), 'utf-8') 
     141        c.log = self.rcslog.get_logs(id, id)[0] 
     142        return render('/logs/view.mako') 
     143     
     144    def rollback(self, id): 
     145        msg = _("Rollback to revision: %s" % id) 
     146        try: 
     147            assert id and isinstance(id, basestring) 
     148            self.rcslog.restore(id) 
     149            self.rcslog.backup(comment=msg, user=self.login_as) 
     150        except Exception, e: 
     151            return e 
     152        else: 
     153            return msg 
  • trunk/pysvnmanager/i18n/en/LC_MESSAGES/pysvnmanager.po

    r35 r36  
    1010"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    1111"POT-Creation-Date: 2008-07-03 22:14+0800\n" 
    12 "PO-Revision-Date: 2008-07-31 00:22+0800\n" 
     12"PO-Revision-Date: 2008-07-31 01:18+0800\n" 
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
    1414"Language-Team: en <LL@li.org>\n" 
     
    123123#: pysvnmanager/controllers/logs.py:130 
    124124msgid "Compares between" 
     125msgstr "" 
     126 
     127#: pysvnmanager/controllers/logs.py:145 
     128#, python-format 
     129msgid "Rollback to revision: %s" 
    125130msgstr "" 
    126131 
     
    470475#: pysvnmanager/templates/logs/index.mako:5 
    471476#: pysvnmanager/templates/logs/index.mako:60 
     477#: pysvnmanager/templates/logs/view.mako:5 
    472478msgid "Administration logs" 
    473479msgstr "" 
     
    475481#: pysvnmanager/templates/logs/index.mako:66 
    476482msgid "Compare revisions" 
     483msgstr "" 
     484 
     485#: pysvnmanager/templates/logs/view.mako:16 
     486msgid "View history, revision" 
     487msgstr "" 
     488 
     489#: pysvnmanager/templates/logs/view.mako:23 
     490msgid "Rollback to this revision" 
    477491msgstr "" 
    478492 
  • trunk/pysvnmanager/i18n/pysvnmanager.pot

    r35 r36  
    99"Project-Id-Version: pySvnManager 0.1.2\n" 
    1010"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    11 "POT-Creation-Date: 2008-07-31 00:22+0800\n" 
     11"POT-Creation-Date: 2008-07-31 01:18+0800\n" 
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
     
    116116#: pysvnmanager/controllers/logs.py:130 
    117117msgid "Compares between" 
     118msgstr "" 
     119 
     120#: pysvnmanager/controllers/logs.py:145 
     121#, python-format 
     122msgid "Rollback to revision: %s" 
    118123msgstr "" 
    119124 
     
    462467#: pysvnmanager/templates/logs/index.mako:5 
    463468#: pysvnmanager/templates/logs/index.mako:60 
     469#: pysvnmanager/templates/logs/view.mako:5 
    464470msgid "Administration logs" 
    465471msgstr "" 
     
    467473#: pysvnmanager/templates/logs/index.mako:66 
    468474msgid "Compare revisions" 
     475msgstr "" 
     476 
     477#: pysvnmanager/templates/logs/view.mako:16 
     478msgid "View history, revision" 
     479msgstr "" 
     480 
     481#: pysvnmanager/templates/logs/view.mako:23 
     482msgid "Rollback to this revision" 
    469483msgstr "" 
    470484 
  • trunk/pysvnmanager/i18n/zh/LC_MESSAGES/pysvnmanager.po

    r35 r36  
    1212"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    1313"POT-Creation-Date: 2008-07-03 22:14+0800\n" 
    14 "PO-Revision-Date: 2008-07-31 00:24+0800\n" 
     14"PO-Revision-Date: 2008-07-31 01:20+0800\n" 
    1515"Last-Translator: Jiang Xin <worldhello.net@gmail.com>\n" 
    1616"Language-Team:  <zh@li.org>\n" 
     
    128128msgstr "版本间比较" 
    129129 
     130#: pysvnmanager/controllers/logs.py:145 
     131#, python-format 
     132msgid "Rollback to revision: %s" 
     133msgstr "回滚至版本: %s" 
     134 
    130135#: pysvnmanager/controllers/role.py:103 
    131136#, python-format 
     
    493498#: pysvnmanager/templates/logs/index.mako:5 
    494499#: pysvnmanager/templates/logs/index.mako:60 
     500#: pysvnmanager/templates/logs/view.mako:5 
    495501msgid "Administration logs" 
    496502msgstr "修改记录" 
     
    499505msgid "Compare revisions" 
    500506msgstr "版本比较" 
     507 
     508#: pysvnmanager/templates/logs/view.mako:16 
     509msgid "View history, revision" 
     510msgstr "查看历史, 版本" 
     511 
     512#: pysvnmanager/templates/logs/view.mako:23 
     513msgid "Rollback to this revision" 
     514msgstr "回滚至此版本" 
    501515 
    502516#: pysvnmanager/templates/role/index.mako:5 
  • trunk/pysvnmanager/model/rcsbackup.py

    r34 r36  
    305305    def differ(self, rev1="", rev2=""): 
    306306        return differ(self.__file, rev1, rev2) 
    307          
     307     
     308    def restore(self, revision): 
     309        return restore(self.__file, revision) 
     310 
     311    def backup(self, comment='', user=''): 
     312        return backup(self.__file, comment, user) 
  • trunk/pysvnmanager/tests/functional/test_authz.py

    r22 r36  
    1414        self.login('nobody') 
    1515        res = self.app.get(url_for(controller='authz')) 
    16         assert res.status == 200 
    17         assert 'Permission denied.' in res.body, res.body 
     16        assert res.status == 302 
     17        self.assertEqual(res.header('location'), '/security/failed', res.header('location')) 
    1818         
    1919        # Login as repos admin 
     
    4040        self.login('nobody') 
    4141        res = self.app.get(url_for(controller='authz', action='init_repos_list')) 
    42         assert res.status == 200, res.status 
    43         self.assert_('Permission denied.' in res.body, res.body) 
     42        assert res.status == 302, res.status 
     43        assert res.header('location')== '/security/failed', res.header('location') 
    4444 
    4545        # Login as superuser 
     
    6666        self.login('nobody') 
    6767        res = self.app.get(url_for(controller='authz', action='repos_changed')) 
    68         assert res.status == 200, res.status 
    69         self.assert_('Permission denied.' in res.body, res.body) 
     68        assert res.status == 302, res.status 
     69        assert res.header('location')== '/security/failed', res.header('location') 
    7070 
    7171        # Login as superuser 
     
    107107        self.login('nobody') 
    108108        res = self.app.get(url_for(controller='authz', action='path_changed')) 
    109         assert res.status == 200, res.status 
    110         self.assert_('Permission denied.' in res.body, res.body) 
     109        assert res.status == 302, res.status 
     110        assert res.header('location')== '/security/failed', res.header('location') 
    111111 
    112112        self.login('root') 
     
    153153            self.login('nobody') 
    154154            res = self.app.get(url_for(controller='authz', action='save_authz')) 
    155             assert res.status == 200, res.status 
    156             self.assert_('Permission denied.' in res.body, res.body) 
     155            assert res.status == 302, res.status 
     156            assert res.header('location')== '/security/failed', res.header('location') 
    157157             
    158158            # Login as superuser 
     
    316316        res = self.app.get(url_for(controller='authz', action='delete_authz')) 
    317317        assert res.status == 302 
    318         self.assertEqual(res.header('location'), '/security') 
     318        assert res.header('location')== '/security', res.header('location') 
    319319 
    320320        # authz test 
    321321        self.login('nobody') 
    322322        res = self.app.get(url_for(controller='authz', action='delete_authz')) 
    323         assert res.status == 200, res.status 
    324         self.assert_('Permission denied.' in res.body, res.body) 
     323        assert res.status == 302, res.status 
     324        assert res.header('location')== '/security/failed', res.header('location') 
    325325 
    326326        authz = self.load_authz() 
  • trunk/pysvnmanager/tests/functional/test_check.py

    r22 r36  
    1515        self.login('nobody') 
    1616        res = self.app.get(url_for(controller='check')) 
    17         assert res.status == 200 
    18         assert 'Permission denied.' in res.body, res.body 
     17        assert res.status == 302, res.status 
     18        assert res.header('location')== '/security/failed', res.header('location') 
    1919         
    2020        # Login as repos admin 
     
    4545        self.login('nobody') 
    4646        res = self.app.get(url_for(controller='check', action='access_map')) 
    47         assert res.status == 200, res.status 
    48         self.assert_('Permission denied.' in res.body, res.body) 
     47        assert res.status == 302, res.status 
     48        assert res.header('location')== '/security/failed', res.header('location') 
    4949         
    5050        # Login as superuser 
     
    206206                  } 
    207207        res = self.app.get(url_for(controller='check', action='access_map'), params) 
    208         assert res.status == 200 
    209         assert 'Permission denied.' in res.body, res.body 
     208        assert res.status == 200, res.status 
     209        assert res.body== 'Permission denied.', res.header('location') 
    210210 
    211211    def test_authz_path(self): 
     
    213213        res = self.app.get(url_for(controller='check', action='get_auth_path')) 
    214214        assert res.status == 302 
    215         self.assertEqual(res.header('location'), '/security') 
     215        assert res.header('location')== '/security', res.header('location') 
    216216 
    217217        # authz test 
    218218        self.login('nobody') 
    219219        res = self.app.get(url_for(controller='check', action='get_auth_path')) 
    220         assert res.status == 200, res.status 
    221         self.assert_('Permission denied.' in res.body, res.body) 
     220        assert res.status == 302, res.status 
     221        assert res.header('location')== '/security/failed', res.header('location') 
    222222 
    223223        self.login('root') 
  • trunk/pysvnmanager/tests/functional/test_role.py

    r24 r36  
    1515        self.login('nobody') 
    1616        res = self.app.get(url_for(controller='role')) 
    17         assert res.status == 200 
    18         assert 'Permission denied.' in res.body, res.body 
     17        assert res.status == 302, res.status 
     18        assert res.header('location')== '/security/failed', res.header('location') 
    1919         
    2020        # Permission denied for repos admin(not root admin) 
    2121        self.login('admin2') 
    2222        res = self.app.get(url_for(controller='role')) 
    23         assert res.status == 200 
    24         assert "Permission denied." in res.body, res.body 
     23        assert res.status == 302, res.status 
     24        assert res.header('location')== '/security/failed', res.header('location') 
    2525 
    2626        # Login as superuser 
     
    3939        self.login('nobody') 
    4040        res = self.app.get(url_for(controller='role', action='get_role_info')) 
    41         assert res.status == 200, res.status 
    42         self.assert_('Permission denied.' in res.body, res.body) 
     41        assert res.status == 302, res.status 
     42        assert res.header('location')== '/security/failed', res.header('location') 
    4343         
    4444        # Login as superuser 
     
    114114        self.login('nobody') 
    115115        res = self.app.get(url_for(controller='role', action='save_group')) 
    116         assert res.status == 200, res.status 
    117         self.assert_('Permission denied.' in res.body, res.body) 
     116        assert res.status == 302, res.status 
     117        assert res.header('location')== '/security/failed', res.header('location') 
    118118 
    119119        # Change group members, autodrop=no 
     
    198198        self.login('nobody') 
    199199        res = self.app.get(url_for(controller='role', action='delete_group')) 
    200         assert res.status == 200, res.status 
    201         self.assert_('Permission denied.' in res.body, res.body) 
     200        assert res.status == 302, res.status 
     201        assert res.header('location')== '/security/failed', res.header('location') 
    202202 
    203203        # Delete group failed, ref by other group. 
     
    260260        self.login('nobody') 
    261261        res = self.app.get(url_for(controller='role', action='save_alias')) 
    262         assert res.status == 200, res.status 
    263         self.assert_('Permission denied.' in res.body, res.body) 
     262        assert res.status == 302, res.status 
     263        assert res.header('location')== '/security/failed', res.header('location') 
    264264 
    265265        # Change alias successfully 
     
    337337        self.login('nobody') 
    338338        res = self.app.get(url_for(controller='role', action='delete_alias')) 
    339         assert res.status == 200, res.status 
    340         self.assert_('Permission denied.' in res.body, res.body) 
     339        assert res.status == 302, res.status 
     340        assert res.header('location')== '/security/failed', res.header('location') 
    341341 
    342342        # Delete alias successfully 
  • trunk/pysvnmanager/tests/test_rcs_backup.py

    r30 r36  
    176176        assert rcslog.total_page == 2, rcslog.total_page 
    177177        rcslog.log_per_page=0 
    178         assert rcslog.log_per_page==10, rcslog.log_per_page 
     178        assert rcslog.log_per_page>1, rcslog.log_per_page 
    179179        rcslog.log_per_page=5 
    180180        assert rcslog.log_per_page==5, rcslog.log_per_page 
     
    189189        logs = rcslog.get_page_logs(2) 
    190190        assert [x['revision'] for x in logs] == \ 
    191                 ['1.4', '1.5', '1.6', '1.7', '1.8', '1.14'], \ 
     191                ['1.5', '1.6', '1.7', '1.8', '1.9', '1.14'], \ 
    192192                [x['revision'] for x in logs] 
    193193 
     
    196196        assert logs == logs2 
    197197        assert [x['revision'] for x in logs] == \ 
    198                 ['1.1', '1.2', '1.3', '1.14'], \ 
     198                ['1.1', '1.2', '1.3', '1.4', '1.5', '1.14'], \ 
    199199                [x['revision'] for x in logs] 
    200200