Show More
@@ -384,16 +384,39 b' def make_map(config):' | |||
|
384 | 384 | m.connect("formatted_notification", "/notifications/{notification_id}.{format}", |
|
385 | 385 | action="show", conditions=dict(method=["GET"])) |
|
386 | 386 | |
|
387 | #ADMIN GIST | |
|
388 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
|
389 | controller='admin/gists') as m: | |
|
390 | m.connect("gists", "/gists", | |
|
391 | action="create", conditions=dict(method=["POST"])) | |
|
392 | m.connect("gists", "/gists", | |
|
393 | action="index", conditions=dict(method=["GET"])) | |
|
394 | m.connect("formatted_gists", "/gists.{format}", | |
|
395 | action="index", conditions=dict(method=["GET"])) | |
|
396 | m.connect("new_gist", "/gists/new", | |
|
397 | action="new", conditions=dict(method=["GET"])) | |
|
398 | m.connect("formatted_new_gist", "/gists/new.{format}", | |
|
399 | action="new", conditions=dict(method=["GET"])) | |
|
400 | m.connect("/gist/{gist_id}", | |
|
401 | action="update", conditions=dict(method=["PUT"])) | |
|
402 | m.connect("/gist/{gist_id}", | |
|
403 | action="delete", conditions=dict(method=["DELETE"])) | |
|
404 | m.connect("edit_gist", "/gist/{gist_id}/edit", | |
|
405 | action="edit", conditions=dict(method=["GET"])) | |
|
406 | m.connect("formatted_edit_gist", | |
|
407 | "/gist/{gist_id}.{format}/edit", | |
|
408 | action="edit", conditions=dict(method=["GET"])) | |
|
409 | m.connect("gist", "/gist/{gist_id}", | |
|
410 | action="show", conditions=dict(method=["GET"])) | |
|
411 | m.connect("formatted_gist", "/gists/{gist_id}.{format}", | |
|
412 | action="show", conditions=dict(method=["GET"])) | |
|
413 | ||
|
387 | 414 | #ADMIN MAIN PAGES |
|
388 | 415 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
389 | 416 | controller='admin/admin') as m: |
|
390 | 417 | m.connect('admin_home', '', action='index') |
|
391 | 418 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
392 | 419 | action='add_repo') |
|
393 | ||
|
394 | #ADMIN GIST | |
|
395 | rmap.resource('gist', 'gists', controller='admin/gists', | |
|
396 | path_prefix=ADMIN_PREFIX) | |
|
397 | 420 | #========================================================================== |
|
398 | 421 | # API V2 |
|
399 | 422 | #========================================================================== |
@@ -126,7 +126,7 b' class GistsController(BaseController):' | |||
|
126 | 126 | log.error(traceback.format_exc()) |
|
127 | 127 | h.flash(_('Error occurred during gist creation'), category='error') |
|
128 | 128 | return redirect(url('new_gist')) |
|
129 | return redirect(url('gist', id=new_gist_id)) | |
|
129 | return redirect(url('gist', gist_id=new_gist_id)) | |
|
130 | 130 | |
|
131 | 131 | @LoginRequired() |
|
132 | 132 | @NotAnonymous() |
@@ -138,26 +138,26 b' class GistsController(BaseController):' | |||
|
138 | 138 | |
|
139 | 139 | @LoginRequired() |
|
140 | 140 | @NotAnonymous() |
|
141 | def update(self, id): | |
|
142 | """PUT /admin/gists/id: Update an existing item""" | |
|
141 | def update(self, gist_id): | |
|
142 | """PUT /admin/gists/gist_id: Update an existing item""" | |
|
143 | 143 | # Forms posted to this method should contain a hidden field: |
|
144 | 144 | # <input type="hidden" name="_method" value="PUT" /> |
|
145 | 145 | # Or using helpers: |
|
146 | # h.form(url('gist', id=ID), | |
|
146 | # h.form(url('gist', gist_id=ID), | |
|
147 | 147 | # method='put') |
|
148 | # url('gist', id=ID) | |
|
148 | # url('gist', gist_id=ID) | |
|
149 | 149 | |
|
150 | 150 | @LoginRequired() |
|
151 | 151 | @NotAnonymous() |
|
152 | def delete(self, id): | |
|
153 | """DELETE /admin/gists/id: Delete an existing item""" | |
|
152 | def delete(self, gist_id): | |
|
153 | """DELETE /admin/gists/gist_id: Delete an existing item""" | |
|
154 | 154 | # Forms posted to this method should contain a hidden field: |
|
155 | 155 | # <input type="hidden" name="_method" value="DELETE" /> |
|
156 | 156 | # Or using helpers: |
|
157 | # h.form(url('gist', id=ID), | |
|
157 | # h.form(url('gist', gist_id=ID), | |
|
158 | 158 | # method='delete') |
|
159 | # url('gist', id=ID) | |
|
160 | gist = GistModel().get_gist(id) | |
|
159 | # url('gist', gist_id=ID) | |
|
160 | gist = GistModel().get_gist(gist_id) | |
|
161 | 161 | owner = gist.gist_owner == c.rhodecode_user.user_id |
|
162 | 162 | if h.HasPermissionAny('hg.admin')() or owner: |
|
163 | 163 | GistModel().delete(gist) |
@@ -169,10 +169,9 b' class GistsController(BaseController):' | |||
|
169 | 169 | return redirect(url('gists')) |
|
170 | 170 | |
|
171 | 171 | @LoginRequired() |
|
172 | def show(self, id, format='html'): | |
|
173 | """GET /admin/gists/id: Show a specific item""" | |
|
174 | # url('gist', id=ID) | |
|
175 | gist_id = id | |
|
172 | def show(self, gist_id, format='html'): | |
|
173 | """GET /admin/gists/gist_id: Show a specific item""" | |
|
174 | # url('gist', gist_id=ID) | |
|
176 | 175 | c.gist = Gist.get_or_404(gist_id) |
|
177 | 176 | |
|
178 | 177 | #check if this gist is not expired |
@@ -191,6 +190,6 b' class GistsController(BaseController):' | |||
|
191 | 190 | |
|
192 | 191 | @LoginRequired() |
|
193 | 192 | @NotAnonymous() |
|
194 | def edit(self, id, format='html'): | |
|
195 | """GET /admin/gists/id/edit: Form to edit an existing item""" | |
|
196 | # url('edit_gist', id=ID) | |
|
193 | def edit(self, gist_id, format='html'): | |
|
194 | """GET /admin/gists/gist_id/edit: Form to edit an existing item""" | |
|
195 | # url('edit_gist', gist_id=ID) |
@@ -2161,7 +2161,7 b' class Gist(Base, BaseModel):' | |||
|
2161 | 2161 | return alias_url.replace('{gistid}', self.gist_access_id) |
|
2162 | 2162 | |
|
2163 | 2163 | from pylons import url |
|
2164 | return url('gist', id=self.gist_access_id, qualified=True) | |
|
2164 | return url('gist', gist_id=self.gist_access_id, qualified=True) | |
|
2165 | 2165 | |
|
2166 | 2166 | @classmethod |
|
2167 | 2167 | def base_path(cls): |
@@ -42,7 +42,7 b'' | |||
|
42 | 42 | </div> |
|
43 | 43 | <div title="${gist.owner.full_contact}" class="user" style="font-size: 16px"> |
|
44 | 44 | <b>${h.person(gist.owner.full_contact)}</b> / |
|
45 | <b><a href="${h.url('gist',id=gist.gist_access_id)}">gist:${gist.gist_access_id}</a></b> | |
|
45 | <b><a href="${h.url('gist',gist_id=gist.gist_access_id)}">gist:${gist.gist_access_id}</a></b> | |
|
46 | 46 | </div> |
|
47 | 47 | <div style="padding: 4px 0px 0px 0px"> |
|
48 | 48 | ${_('Created')} ${h.age(gist.created_on)} / |
@@ -52,7 +52,7 b'' | |||
|
52 | 52 | ## only owner should see that |
|
53 | 53 | %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id: |
|
54 | 54 | ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")} |
|
55 | ${h.form(url('gist', id=c.gist.gist_id),method='delete')} | |
|
55 | ${h.form(url('gist', gist_id=c.gist.gist_id),method='delete')} | |
|
56 | 56 | ${h.submit('remove_gist', _('Delete'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this gist')+"');")} |
|
57 | 57 | ${h.end_form()} |
|
58 | 58 | %endif |
@@ -92,7 +92,7 b' class TestGistsController(TestController' | |||
|
92 | 92 | Session().add(gist) |
|
93 | 93 | Session().commit() |
|
94 | 94 | |
|
95 | response = self.app.get(url('gist', id=gist.gist_access_id), status=404) | |
|
95 | response = self.app.get(url('gist', gist_id=gist.gist_access_id), status=404) | |
|
96 | 96 | |
|
97 | 97 | def test_create_private(self): |
|
98 | 98 | self.log_user() |
@@ -128,28 +128,28 b' class TestGistsController(TestController' | |||
|
128 | 128 | |
|
129 | 129 | def test_update(self): |
|
130 | 130 | self.skipTest('not implemented') |
|
131 | response = self.app.put(url('gist', id=1)) | |
|
131 | response = self.app.put(url('gist', gist_id=1)) | |
|
132 | 132 | |
|
133 | 133 | def test_delete(self): |
|
134 | 134 | self.log_user() |
|
135 | 135 | gist = _create_gist('delete-me') |
|
136 | response = self.app.delete(url('gist', id=gist.gist_id)) | |
|
136 | response = self.app.delete(url('gist', gist_id=gist.gist_id)) | |
|
137 | 137 | self.checkSessionFlash(response, 'Deleted gist %s' % gist.gist_id) |
|
138 | 138 | |
|
139 | 139 | def test_delete_normal_user_his_gist(self): |
|
140 | 140 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
141 | 141 | gist = _create_gist('delete-me', owner=TEST_USER_REGULAR_LOGIN) |
|
142 | response = self.app.delete(url('gist', id=gist.gist_id)) | |
|
142 | response = self.app.delete(url('gist', gist_id=gist.gist_id)) | |
|
143 | 143 | self.checkSessionFlash(response, 'Deleted gist %s' % gist.gist_id) |
|
144 | 144 | |
|
145 | 145 | def test_delete_normal_user_not_his_own_gist(self): |
|
146 | 146 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
147 | 147 | gist = _create_gist('delete-me') |
|
148 | response = self.app.delete(url('gist', id=gist.gist_id), status=403) | |
|
148 | response = self.app.delete(url('gist', gist_id=gist.gist_id), status=403) | |
|
149 | 149 | |
|
150 | 150 | def test_show(self): |
|
151 | 151 | gist = _create_gist('gist-show-me') |
|
152 | response = self.app.get(url('gist', id=gist.gist_access_id)) | |
|
152 | response = self.app.get(url('gist', gist_id=gist.gist_access_id)) | |
|
153 | 153 | response.mustcontain('added file: gist-show-me<') |
|
154 | 154 | response.mustcontain('test_admin (RhodeCode Admin) - created') |
|
155 | 155 | response.mustcontain('gist-desc') |
@@ -157,4 +157,4 b' class TestGistsController(TestController' | |||
|
157 | 157 | |
|
158 | 158 | def test_edit(self): |
|
159 | 159 | self.skipTest('not implemented') |
|
160 | response = self.app.get(url('edit_gist', id=1)) | |
|
160 | response = self.app.get(url('edit_gist', gist_id=1)) |
General Comments 0
You need to be logged in to leave comments.
Login now