##// END OF EJS Templates
gists: fixes for tests and cleanup code that is now handled by the form deserializer
super-admin -
r4996:7fcb67da default
parent child Browse files
Show More
@@ -337,7 +337,7 b' class TestGistsController(TestController'
337 337 route_path('gist_show_formatted',
338 338 gist_id=gist.gist_access_id, revision='tip',
339 339 format='raw'))
340 assert response.body == 'GIST CONTENT'
340 assert response.text == 'GIST CONTENT'
341 341
342 342 def test_show_as_raw_individual_file(self, create_gist):
343 343 gist = create_gist('gist-show-me-raw', content='GIST BODY')
@@ -345,7 +345,7 b' class TestGistsController(TestController'
345 345 route_path('gist_show_formatted_path',
346 346 gist_id=gist.gist_access_id, format='raw',
347 347 revision='tip', f_path='gist-show-me-raw'))
348 assert response.body == 'GIST BODY'
348 assert response.text == 'GIST BODY'
349 349
350 350 def test_edit_page(self, create_gist):
351 351 self.log_user()
@@ -142,22 +142,14 b' class GistView(BaseAppView):'
142 142 c = self.load_default_context()
143 143
144 144 data = dict(self.request.POST)
145 data['filename'] = data.get('filename') or Gist.DEFAULT_FILENAME
145
146 filename = data.pop('filename', '') or Gist.DEFAULT_FILENAME
146 147
147 148 data['nodes'] = [{
148 'filename': data['filename'],
149 'content': data.get('content'),
150 'mimetype': data.get('mimetype') # None is autodetect
149 'filename': filename,
150 'content': data.pop('content', ''),
151 'mimetype': data.pop('mimetype', None) # None is autodetect
151 152 }]
152 gist_type = {
153 'public': Gist.GIST_PUBLIC,
154 'private': Gist.GIST_PRIVATE
155 }.get(data.get('gist_type')) or Gist.GIST_PRIVATE
156
157 data['gist_type'] = gist_type
158
159 data['gist_acl_level'] = (
160 data.get('gist_acl_level') or Gist.ACL_LEVEL_PRIVATE)
161 153
162 154 schema = gist_schema.GistSchema().bind(
163 155 lifetime_options=[x[0] for x in c.lifetime_values])
@@ -165,9 +157,9 b' class GistView(BaseAppView):'
165 157 try:
166 158
167 159 schema_data = schema.deserialize(data)
160
168 161 # convert to safer format with just KEYs so we sure no duplicates
169 schema_data['nodes'] = gist_schema.sequence_to_nodes(
170 schema_data['nodes'])
162 schema_data['nodes'] = gist_schema.sequence_to_nodes(schema_data['nodes'])
171 163
172 164 gist = GistModel().create(
173 165 gist_id=schema_data['gistid'], # custom access id not real ID
General Comments 0
You need to be logged in to leave comments. Login now