diff --git a/rhodecode/apps/gist/tests/test_admin_gists.py b/rhodecode/apps/gist/tests/test_admin_gists.py --- a/rhodecode/apps/gist/tests/test_admin_gists.py +++ b/rhodecode/apps/gist/tests/test_admin_gists.py @@ -337,7 +337,7 @@ class TestGistsController(TestController route_path('gist_show_formatted', gist_id=gist.gist_access_id, revision='tip', format='raw')) - assert response.body == 'GIST CONTENT' + assert response.text == 'GIST CONTENT' def test_show_as_raw_individual_file(self, create_gist): gist = create_gist('gist-show-me-raw', content='GIST BODY') @@ -345,7 +345,7 @@ class TestGistsController(TestController route_path('gist_show_formatted_path', gist_id=gist.gist_access_id, format='raw', revision='tip', f_path='gist-show-me-raw')) - assert response.body == 'GIST BODY' + assert response.text == 'GIST BODY' def test_edit_page(self, create_gist): self.log_user() diff --git a/rhodecode/apps/gist/views.py b/rhodecode/apps/gist/views.py --- a/rhodecode/apps/gist/views.py +++ b/rhodecode/apps/gist/views.py @@ -142,22 +142,14 @@ class GistView(BaseAppView): c = self.load_default_context() data = dict(self.request.POST) - data['filename'] = data.get('filename') or Gist.DEFAULT_FILENAME + + filename = data.pop('filename', '') or Gist.DEFAULT_FILENAME data['nodes'] = [{ - 'filename': data['filename'], - 'content': data.get('content'), - 'mimetype': data.get('mimetype') # None is autodetect + 'filename': filename, + 'content': data.pop('content', ''), + 'mimetype': data.pop('mimetype', None) # None is autodetect }] - gist_type = { - 'public': Gist.GIST_PUBLIC, - 'private': Gist.GIST_PRIVATE - }.get(data.get('gist_type')) or Gist.GIST_PRIVATE - - data['gist_type'] = gist_type - - data['gist_acl_level'] = ( - data.get('gist_acl_level') or Gist.ACL_LEVEL_PRIVATE) schema = gist_schema.GistSchema().bind( lifetime_options=[x[0] for x in c.lifetime_values]) @@ -165,9 +157,9 @@ class GistView(BaseAppView): try: schema_data = schema.deserialize(data) + # convert to safer format with just KEYs so we sure no duplicates - schema_data['nodes'] = gist_schema.sequence_to_nodes( - schema_data['nodes']) + schema_data['nodes'] = gist_schema.sequence_to_nodes(schema_data['nodes']) gist = GistModel().create( gist_id=schema_data['gistid'], # custom access id not real ID