Commit 562acc220a444d2d67b538631624a1e2a8d71c2d

Authored by Oleksandr Iskryzhytskyi
1 parent a313d39e

common

- fixed: preparing tender data
Showing 1 changed file with 28 additions and 12 deletions
... ... @@ -198,9 +198,9 @@ def generate_dictionary_from_field_path_and_value(path, value):
198 198 return data
199 199
200 200
201   -#Percentage conversion
  201 +# Percentage conversion
202 202 def multiply_hundred(number):
203   - return number*100
  203 + return number * 100
204 204
205 205
206 206 # prepares data for filling form in easiest way
... ... @@ -211,42 +211,58 @@ def prepare_tender_data(data):
211 211
212 212 # moves features to its related items
213 213 if 'features' in data:
214   - for i, feature in enumerate(data['features']):
215   - if feature['featureOf'] == 'lot':
  214 + i = 0
  215 + l = len(data['features'])
  216 + while i < l:
  217 + if data['features'][i]['featureOf'] == 'lot':
216 218 for lot in data['lots']:
217   - if lot['id'] == feature['relatedItem']:
  219 + if lot['id'] == data['features'][i]['relatedItem']:
218 220 if 'features' not in lot:
219 221 lot['features'] = []
220 222 lot['features'].append(data['features'].pop(i))
221   - if feature['featureOf'] == 'item':
  223 + l = l - 1
  224 + i = i - 1
  225 + if data['features'][i]['featureOf'] == 'item':
222 226 for item in data['items']:
223   - if item['id'] == feature['relatedItem']:
  227 + if item['id'] == data['features'][i]['relatedItem']:
224 228 if 'features' not in item:
225 229 item['features'] = []
226 230 item['features'].append(data['features'].pop(i))
  231 + l = l - 1
  232 + i = i - 1
  233 + i = i + 1
227 234
228 235 if len(data['features']) == 0:
229 236 del data['features']
230 237
231 238 # moves items to its related lots
232   - for i, item in enumerate(data['items']):
  239 + i = 0
  240 + l = len(data['items'])
  241 + while i < l:
233 242 for lot in data['lots']:
234   - if lot['id'] == item['relatedLot']:
  243 + if lot['id'] == data['items'][i]['relatedLot']:
235 244 if 'items' not in lot:
236 245 lot['items'] = []
237 246 lot['items'].append(data['items'].pop(i))
  247 + l = l - 1
  248 + i = i - 1
  249 + i = i + 1
238 250
239 251 del data['items']
240 252
241 253 # moves milestones to its related lots
242   - for i, milestone in enumerate(data['milestones']):
  254 + i = 0
  255 + l = len(data['milestones'])
  256 + while i < l:
243 257 for lot in data['lots']:
244   - if lot['id'] == milestone['relatedLot']:
  258 + if lot['id'] == data['milestones'][i]['relatedLot']:
245 259 if 'milestones' not in lot:
246 260 lot['milestones'] = []
247 261 lot['milestones'].append(data['milestones'].pop(i))
  262 + l = l - 1
  263 + i = i - 1
  264 + i = i + 1
248 265
249 266 del data['milestones']
250 267
251 268 return data
252   -
... ...
Please register or login to post a comment