Beispiel #1
0
 def copy_id_uploaded(self) -> bool:
     possible_filenames = [f"{self.id}.{ext}" for ext in SUPPORTED_FILE_EXTENSIONS]
     copy_id_path = util.get_copy_ids_path()
     possible_copy_id_file_paths = [
         (copy_id_path / filename) for filename in possible_filenames
     ]
     return any(path.exists() for path in possible_copy_id_file_paths)
Beispiel #2
0
 def profile_percentage(self) -> float:
     result = 0
     possible_filenames = [f"{self.id}.{ext}" for ext in SUPPORTED_FILE_EXTENSIONS]
     copy_id_path = util.get_copy_ids_path()
     possible_copy_id_file_paths = [
         (copy_id_path / filename) for filename in possible_filenames
     ]
     proof_of_income_path = util.get_proof_of_income_path()
     possible_proof_of_income_file_paths = [
         (proof_of_income_path / filename) for filename in possible_filenames
     ]
     proof_of_enrollment_path = util.get_proof_of_enrollment_path()
     possible_proof_of_enrollment_file_paths = [
         (proof_of_enrollment_path / filename) for filename in possible_filenames
     ]
     if any(path.exists() for path in possible_copy_id_file_paths):
         result += 20
     if any(path.exists() for path in possible_proof_of_income_file_paths):
         result += 10
     if any(path.exists() for path in possible_proof_of_enrollment_file_paths):
         result += 10
     if self.social_accounts:
         result += 10
     assert result <= 100
     return result
Beispiel #3
0
def test_landlord_percentage_profile(landlord: Landlord, file,
                                     application: Application, clear_upload):
    copy_id_path = util.get_copy_ids_path()
    proof_of_income_path = util.get_proof_of_income_path()
    proof_of_enrollment_path = util.get_proof_of_enrollment_path()
    paths = [copy_id_path, proof_of_income_path, proof_of_enrollment_path]
    assert all(not application.file_service.list_files(path) for path in paths)
    assert landlord.profile_percentage == 0
    application.upload_copy_id(landlord, file, "pdf")
    assert landlord.profile_percentage == 30
Beispiel #4
0
def test_tenant_percentage_profile(tenant: Tenant, file,
                                   application: Application, clear_upload):
    copy_id_path = util.get_copy_ids_path()
    proof_of_income_path = util.get_proof_of_income_path()
    proof_of_enrollment_path = util.get_proof_of_enrollment_path()
    paths = [copy_id_path, proof_of_income_path, proof_of_enrollment_path]
    assert all(not application.file_service.list_files(path) for path in paths)
    assert tenant.profile_percentage == 0
    application.upload_copy_id(tenant, file, "pdf")
    assert tenant.profile_percentage == 20
    application.upload_proof_of_enrollment(tenant, file, "pdf")
    assert tenant.profile_percentage == 30
    application.upload_proof_of_income(tenant, file, "pdf")
    assert tenant.profile_percentage == 40
Beispiel #5
0
def download_copy_id(user: User = Depends(deps.get_current_active_user), ):
    """
    Download user copy id
    """
    possible_filenames = [
        f"{user.id}.{ext}" for ext in config.SUPPORTED_FILE_EXTENSIONS
    ]
    copy_id_folder_path = get_copy_ids_path()
    for filename in possible_filenames:
        file_path: Path = copy_id_folder_path / filename
        if file_path.exists():
            with open(file_path, "rb") as f:
                return Response(
                    f.read(),
                    media_type="application/octet-stream",
                    headers={
                        "Content-Disposition":
                        f"attachment;filename={filename}"
                    },
                )
Beispiel #6
0
 def upload_copy_id(self, user: User, file: IO, extension: str) -> User:
     return self.__upload_file(user, file, extension,
                               util.get_copy_ids_path())