Beispiel #1
0
 def test_initialization_5(self):
     # Clear out any preexisting files
     shutil.rmtree(Upload.UPLOADS_DIR)
     storage = FieldStorageDummy('arscca/test/upload_test_files/nested.zip')
     upload = Upload(storage)
     upload.process()
     assert os.listdir(Upload.UPLOADS_DIR) == []
Beispiel #2
0
    def test_initialization_7(self):
        storage = FieldStorageDummy('arscca/test/upload_test_files/06_snow__no_meta.jpg')
        upload = Upload(storage)
        key = upload.process()[0]

        assert not 'taken_at' in metadata(key)
        assert not 'ip' in metadata(key)
Beispiel #3
0
 def test_initialization_4(self):
     storage = FieldStorageDummy('arscca/test/upload_test_files/nested.zip')
     upload = Upload(storage)
     keys = upload.process()
     today = date.today()
     assert keys == [f'guessed-{today}__6175f2cae66964fe925526e129d8af9d96a08be74dc9d00105f16ab0b0ae40c1_medium.png',
                     f'guessed-{today}__ad66e755eb605c03508871673b9efe6e6d1d940931441535f46a6d8cfb873f99_medium.png']
Beispiel #4
0
 def test_initialization_3(self):
     storage = FieldStorageDummy('arscca/test/upload_test_files/plain.zip')
     upload = Upload(storage)
     keys = upload.process()
     today = date.today()
     assert keys == [f'guessed-{today}__17c31999e60f5f6e2282446453e67b26e318f37d14946ed6d3ea5840af6c952b_medium.png',
                     f'guessed-{today}__c559e58035d6e042758a84ea1c1f65d5cf31f10965477d88ee022bb894f904ff_medium.png']
Beispiel #5
0
def photo_upload_create_view(request):
    password = request.params.get('password')
    if not Util.user_password_auth(password) and not Util.from_arkansas(
            request):
        request.session.flash('Password Error or Geolocation Error')
        return HTTPFound(location=request.path)

    storages = request.params.getall('images[]')

    keys = set()
    ip = request.headers.get('X-Real-Ip')
    for storage in storages:
        if storage == b'':
            # You will arrive here if you do not select a file
            continue
        upload = Upload(storage, ip)
        local_keys = upload.process()
        for key in local_keys:
            keys.add(key)

    msg = f'{len(keys)} files successfully uploaded. '
    guessed_keys = [key for key in keys if 'guessed' in key]

    if guessed_count := len(guessed_keys):
        msg += f'However, for {guessed_count} of them we could not determine when the photo was taken. Please upload originals (with metadata) whenever possible so that we can assign the photo to the correct day/event.'
Beispiel #6
0
    def test_initialization_6(self):
        storage = FieldStorageDummy('arscca/test/upload_test_files/00_xyl__with_meta.jpg')
        upload = Upload(storage, '192.168.1.1')
        key = upload.process()[0]

        now_truncated = datetime.now().strftime('%Y-%m-%d %H')
        uploaded_at = metadata(key)['uploaded_at']

        # Check enough of the digits that we are confident it is dynamically generated
        assert now_truncated == uploaded_at[0:13]
        assert metadata(key)['ip'] == '192.168.1.1'
Beispiel #7
0
 def test_initialization_2(self):
     storage = FieldStorageDummy('arscca/test/upload_test_files/00_xyl__with_meta.jpg')
     upload = Upload(storage)
     keys = upload.process()
     assert keys == ['snapped-2008-04-10__0e72357f94407127dd950f3ce4bf8954af6a4842beb2c615d125b837f4946f1b_medium.png']