if 'Screenshot-Url' in package.candidateRecord:
screenshot_url = package.candidateRecord['Screenshot-Url']
I usually prefer something like:
screenshot_url = package.candidateRecord.get('Screenshot-Url')
if screenshot_url is not None and screenshot_url not in app.screenshots:
app.applicationmedia_set.create(media_type='screenshot', url=screenshot_url)
The benefits I see in the second option are:
* you access the package.candidateRecord dict only once
* you do not duplicate the literal 'Screenshot-Url' and thus avoid risk of typos
* you avoid an if (and then another inner level in the logic)
So, if you think is worth it, feel free to tweak the code in this MP. I'll be approving anyways since this looks great.
Branch look pretty awesome.
One tiny note, instead of:
if 'Screenshot-Url' in package. candidateRecord : candidateRecord ['Screenshot- Url']
screenshot_url = package.
I usually prefer something like:
screenshot_url = package. candidateRecord .get('Screensho t-Url') applicationmedi a_set.create( media_type= 'screenshot' , url=screenshot_url)
if screenshot_url is not None and screenshot_url not in app.screenshots:
app.
The benefits I see in the second option are:
* you access the package. candidateRecord dict only once
* you do not duplicate the literal 'Screenshot-Url' and thus avoid risk of typos
* you avoid an if (and then another inner level in the logic)
So, if you think is worth it, feel free to tweak the code in this MP. I'll be approving anyways since this looks great.