pax_global_header00006660000000000000000000000064146266147730014532gustar00rootroot0000000000000052 comment=4e9e80f8686a123e4199681792084ef48c0993c1 django-qr-code-4.1.0/000077500000000000000000000000001462661477300143265ustar00rootroot00000000000000django-qr-code-4.1.0/.editorconfig000066400000000000000000000001741462661477300170050ustar00rootroot00000000000000root = true [*] indent_style = space indent_size = 4 insert_final_newline = true charset = utf-8 [*.html] indent_size = 2 django-qr-code-4.1.0/.github/000077500000000000000000000000001462661477300156665ustar00rootroot00000000000000django-qr-code-4.1.0/.github/workflows/000077500000000000000000000000001462661477300177235ustar00rootroot00000000000000django-qr-code-4.1.0/.github/workflows/ci.yml000066400000000000000000000005661462661477300210500ustar00rootroot00000000000000name: Django QR Code Build and Test on: push: branches: - master - features/** - dependabot/** pull_request: branches: - master jobs: docker: timeout-minutes: 10 runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - name: Run tests run: | cd scripts ./run-tests.sh django-qr-code-4.1.0/.github/workflows/python-publish.yml000066400000000000000000000020741462661477300234360ustar00rootroot00000000000000# This workflow will upload a Python Package using Twine when a release is created # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. name: Upload Python Package on: release: types: [published] permissions: contents: read jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v3 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install build - name: Build package run: python -m build - name: Publish package uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} django-qr-code-4.1.0/.gitignore000066400000000000000000000025711462661477300163230ustar00rootroot00000000000000# Generated data and logs during tests. tests_result/ tests_result.back/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ django-qr-code-4.1.0/CHANGELOG.md000066400000000000000000000230321462661477300161370ustar00rootroot00000000000000# Change Log ## 4.1.0 (2024-06-01) * Upgrade dependencies and drop support for Python < 3.10 and Pydantic <2.7. * Add the capability to generate embedded Base64 SVG images as data URIs through template tags (in addition to the API capability introduced in version 4.0.1). * Add support for alternative text customization (both template tags and API). * Add support for CSS classes injection (both template tags and API). * Reorganize and improve documentation. ## 4.0.1 (2024-01-04) * Upgrade dependencies, and drop support for Pydantic <2.5, Django<4.2, Python 3.8 * Remove dependency to pytz. * Add support for Python 3.12. * Add support for Django 5.0. * Introduce support for floating point size QR code modules. * Introduce embedded Base64 SVG image as data URI. * Behavior change: white background is no longer interpreted as transparent for SVG output (#41). If you want to avoid path fill of SVG to reduce the size of the SVG image, you have to explicitly set `light_color` to `None` in `QRCodeOptions`. ## 3.1.2 (2023-04-10) * Fix bug in `WifiConfig` data class (#43). * Fix typo in documentation (#45) * Add support for Django 4.1 and Django 4.2. * Add support for Python 3.11. * Improved documentation. ## 3.1.1 (2022-07-28) * Fix regression in demo site due to improper runtime type validation on `QRCodeOptions`. * Minor improvements to documentation. * Modernize code syntax for Python >= 3.7. ## 3.1.0 (2022-06-26) * Add support for more properties for vCard: cellphone (TEL;TYPE=CELL), homephone (TEL;TYPE=HOME), workphone (TEL;TYPE=WORK) * Add support for simple iCalendar event (VEVENT). (#38) * Add support for Django 4.0. * BREAKING CHANGES: * Introduce type validation at runtime with pydantic. Existing code might need some type-related fixes. * Drop support for Django 2.2. ## 3.0.0 (2021-11-27) * Add support for European Payments Council Quick Response Code (EPC QR Code) version 002. * Add support for vCard v3 QR code. * Revamp support for MeCARD QR code to provide a cleaner API (old API remains available for compatibility). * Introduce `qr_from_data` and `qr_url_from_data` to allow optimized encoding of alphanumeric, numeric, and byte data (adopt appropriate encoding mode depending on data content). * Introduce support for `boost_error` flag. * Introduce support for `encoding` parameter. * Several breaking changes in API and generated QR codes: * `text` parameters renamed to `data`; * class methods `make_qr_text` renamed to `make_qr_data`; * uses UTF-8 encoding by default for application and text QR codes (you must set the new `encoding` option or use the new `qr_from_data` and `qr_url_from_data` template tags to emulate old behavior); * encoded geolocations always contain a decimal separator. * Improve API documentation. * Add support for Python 3.10 * Drop support for Python 3.6. * Drop support for Django 3.1. ## 2.3.0 (2021-11-07) * Add support for `ECI mode` to control bytes encoding. * Fix handling of `micro` QR code option when using URLs to serve image via `{% qr_url_from_text %}`. * Fix handling of `cache_enabled` option when using URLs to serve image via `{% qr_url_from_text %}`. * Fix handling of `url_signature_enabled` option when using URLs to serve image via `{% qr_url_from_text %}`. ## 2.2.0 (2021-06-03) * Change encoding from URL-safe Base64 to standard Base64 for `text` query argument (used for serving QR code images). * Fix #31 by passing the border parameter for segno.QRCode.save. * Ensure compatibility with Django 3.2. * Drop support for Django 3.0. ## 2.1.0 (2021-01-23) * Change encoding from URL-safe Base64 to standard Base64 for `text` query argument (used for serving QR code images). * Introduce setting `SERVE_QR_CODE_IMAGE_PATH` to configure the path under which QR Code images are served. * Reorganize and improve documentation. * Fix #23 * Introduce usage of type hints. ## 2.0.1 (2020-11-24) * Update the install_requires after the move from qrcode to Segno. ## 2.0.0 (2020-11-22) * Remove dependency to Pillow / qrcode * Switch to [Segno](https://pypi.org/project/segno/) for generating QR Codes * Add support for QR Codes with multiple colors * Add support for Micro QR Codes * Stable SVG format for QR code between 32-bit and 64-bit architecture (#19) * Use hyphens in URLs (#16) * Add support for Python 3.9 ## 1.3.1 (2020-09-07) * Fix local testing script. * Fix date of release 1.3.0 in readme. * Code cleanup. ## 1.3.0 (2020-09-05) * Drop support for Django 2.1. * Ensure compatibility with Django 3.1. ## 1.2.0 (2020-04-26) * Ensure compatibility with Django 3.0. * Upgrade Pillow requirement to 7.1. * Drop support for Python 3.5. * Drop support for Django <2.2. * More modern build environment and configuration for ReadTheDocs. ## 1.1.0 (2019-11-16) * Ensure compatibility with Django 2.1. * Ensure compatibility with Django 2.2. * Upgrade qr_code library from 5.3 to 6.1 (several fixes). * Drop support for Python 3.4. * Fixed error when generating qr code from lazy text. (#1) * Add support for customizing usage of URL signature token via template tags (allows to generate URLs for serving QR code images that do not include a signature token). (#4) * The caching of QR codes images could allow to bypass checking the user when external access is active. * Upgrade Pillow requirement to 6.2.0 (CVE-2019-16865). * Adopt a dedicated logger, and move message "Pillow is not installed. No support available for PNG format." from info to debug. (#6) ## 1.0.0 (2018-03-23) * BREAKING CHANGES: * QR code options have been factorized and now use the `QRCodeOptions` class. * The context for rendering a QR code encoding a Wi-Fi configuration uses the dedicated `WifiConfig` class. * The context for rendering a QR code encoding a contact detail uses the dedicated `ContactDetail` class. * `qr_for_contact` and `qr_url_for_contact` keyword arg has been renamed from `contact_dict` to `contact_detail`. * `qr_for_wifi` and `qr_url_for_wifi` keyword arg has been renamed from `wifi_dict` to `wifi_config`. * Reorganize code and split qr_code.py into several modules. The changes mentioned above might break the compatibility with code using qr_code.py's API directly, but template tags are not impacted, except for `qr_for_contact`, `qr_url_for_contact`, `qr_for_wifi`, and `qr_url_for_wifi` if they were using a keyword argument. * Other changes: * Added support for `error_correction` parameter when generating a QR code. * Added support for `coordinates` keyword argument to `qr_for_geolocation`, `qr_for_google_maps`, `qr_url_for_geolocation`, and `qr_url_for_google_maps`. * Additions to documentation. * Added ability to use a `QRCodeOptions` instance with `options` keyword argument in all tags. * Bug fixes: * Fixed non-closed tag when generating embedded PNG image. * Escape colon char (':') if it appears within a contact detail or a wifi configuration. * Add a second terminal semi-colon at the end of the text representing a wifi configuration, as recommended in some sources. ## 0.4.1 (2018-03-10) * Fixed unescaped chars when generating QR code for a contact. * Simplify handling of default values for QR code options. * Add documentation about what a QR code can encode. ## 0.4.0 (2018-03-09) * Added support for multiple new tags: * `qr_for_email` and `qr_url_for_email` * `qr_for_tel` and `qr_url_for_tel` * `qr_for_sms` and `qr_url_for_sms` * `qr_for_geolocation` and `qr_url_for_geolocation` * `qr_for_google_maps` and `qr_url_for_google_maps` * `qr_for_youtube` and `qr_url_for_youtube` * `qr_for_google_play` and `qr_url_for_google_play` * `qr_for_contact` and `qr_url_for_contact` * `qr_for_wifi` and `qr_url_for_wifi` * Reformat documentation on the demo site for better readability. * Drop support for Django <1.11. ## 0.3.3 (2017-08-16) * Added `app_name` namespace to `qr_code.urls` (better compatibility with `include()` function provided with Django >= 1.9). * Update documentation regarding the inclusion of `qr_code.urls` for distinct versions of Django. * Minor improvements to the documentation. ## 0.3.2 (2017-08-13) * Allows optional installation of Pillow (PNG format unavailable, fallback to SVG). * Fixed caching of images (not working due protection against external queries). * Fixed conditional view processing (HTTP 304) for rendered QR codes (not working due protection against external queries). ## 0.3.1 (2017-08-12) * Added a mention about Pillow library requirement in documentation. * Minor improvements to the documentation and the demo application. ## 0.3.0 (2017-08-12) * Added new tag qr_url_from_text: * Separate image from the page displaying the image * Handle caching of images * Conditional view processing (HTTP 304) for rendered QR codes * Protection against external requests * Settings to configure URLs accesses as a service for generating QR code images * Add documentation for new features * Add tests for new features * Add examples to demo site * More robust testing of make_embedded_qr_code's arguments. * Improved documentation. * Demo site is compatible with Django 1.8. * Added support for Docker Compose for running the demo application and running the tests. ## 0.2.1 (2017-08-05) * Added support for Django 1.8. * Fixed version specifiers for Django requirement so that it wont force the installation of Django 1.11. * Added badges for PyPi, Read the Docs and Travis CI to readme file. * Several additions to the documentation. ## 0.2.0 (2017-08-04) * Add support for PNG image format via an `img` tag. * Add documentation for users and developers. * Improve examples in demo app. ## 0.1.1 (2017-08-02) First public release. django-qr-code-4.1.0/Dockerfile000066400000000000000000000021061462661477300163170ustar00rootroot00000000000000ARG PYTHON_VERSION FROM python:${PYTHON_VERSION} LABEL vendor="dProg - Philippe Docourt" maintainer="Philippe Docourt" description="Demo Site for Django QR code" ENV PYTHONUNBUFFERED 1 # Avoid possible occurrences of UnicodeEncodeError when running on x86 architecture. ENV PYTHONIOENCODING utf-8 # Set env variables used in this Dockerfile (add a unique prefix, such as ) # Directory in container for project source files. ARG APP_BASE_DIR=/usr/src/app # Declare a proper Django settings file. ENV DJANGO_SETTINGS_MODULE=demo_site.settings # Make app dir. RUN mkdir -p "$APP_BASE_DIR" WORKDIR "$APP_BASE_DIR" # Install requirements (separate step for caching intermediate image). COPY requirements.txt "$APP_BASE_DIR/" RUN pip install --upgrade pip RUN pip install -r requirements.txt COPY requirements-web-deployment.txt "$APP_BASE_DIR/" RUN pip install -r requirements-web-deployment.txt # Copy entrypoint script into the image. COPY ./docker-entrypoint.sh / # Invoke app's entrypoint via dumb-init so that sub-processes are handled properly. CMD ["/docker-entrypoint.sh"] django-qr-code-4.1.0/LICENSE000066400000000000000000000027711462661477300153420ustar00rootroot00000000000000BSD 3-Clause License Copyright (c) 2017-2021, dProg - Philippe Docourt All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. django-qr-code-4.1.0/MANIFEST.in000066400000000000000000000000671462661477300160670ustar00rootroot00000000000000include README.md include LICENSE include CHANGELOG.md django-qr-code-4.1.0/README.md000066400000000000000000000136641462661477300156170ustar00rootroot00000000000000# Django QR Code [![Latest PyPI version](https://badge.fury.io/py/django-qr-code.svg)](https://badge.fury.io/py/django-qr-code) [![Downloads](https://img.shields.io/pypi/dm/django-qr-code.svg)](https://pypi.python.org/pypi/django-qr-code) [![Documentation Status](https://readthedocs.org/projects/django-qr-code/badge/?version=latest)](https://django-qr-code.readthedocs.io/latest/pages/README.html) [![Build and Test](https://github.com/dprog-philippe-docourt/django-qr-code/actions/workflows/ci.yml/badge.svg)](https://github.com/dprog-philippe-docourt/django-qr-code/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/c47e79bf51f6a2bb8264/maintainability)](https://codeclimate.com/github/dprog-philippe-docourt/django-qr-code/maintainability) This is an application that provides tools for displaying QR codes on your [Django](https://www.djangoproject.com/) site. This application depends on the [Segno QR Code generator](https://pypi.org/project/segno/) library. This app makes no usage of the Django models and therefore do not use any database. Only Python >= 3.10 is supported. ## Features * Generate QR codes as embedded SVG or PNG images in HTML templates. * Customize QR codes with various parameters (size, error correction, border, etc.). * Generate URLs for QR code images. * Support for specific application QR codes (e.g., contact info, Wi-Fi config). * Cache QR code images for performance. * Secure QR code image serving with URL protection and user authentication. ## Installation ### Binary Package from PyPi In order to use this app in a Django project, the simplest way is to install it from [PyPi](https://pypi.python.org/pypi/django-qr-code): ```bash pip install django-qr-code ``` ### From the Source Code In order to modify or test this app you may want to install it from the source code. Clone the [GitHub repository](https://github.com/dprog-philippe-docourt/django-qr-code) and install dependencies: ```bash git clone https://github.com/dprog-philippe-docourt/django-qr-code pip install -r requirements.txt -r requirements-dev.txt python manage.py collectstatic --no-input ``` ## Usage Start by adding `qr_code` to your `INSTALLED_APPS` setting like this: ```python INSTALLED_APPS = ( # ..., 'qr_code', ) ``` You need to load the tags provided by this app in your template with: ```htmldjango {% load qr_code %} ``` The source code on [GitHub](https://github.com/dprog-philippe-docourt/django-qr-code) contains a simple demo app. Please check out the [templates folder](https://github.com/dprog-philippe-docourt/django-qr-code/tree/master/qr_code_demo/templates/qr_code_demo) for an example of template, and the [setting](https://github.com/dprog-philippe-docourt/django-qr-code/tree/master/demo_site/settings.py) and [urls](https://github.com/dprog-philippe-docourt/django-qr-code/tree/master/demo_site/urls.py) files for an example of configuration and integration. ### Example: Inline QR Code Generate a simple QR code: ```htmldjango {% qr_from_text "Hello World!" size="T" %} ``` ### Example: URL QR Code Generate a URL for a QR code image: ```htmldjango Hello World! ``` ### Advanced Usage of Tags Refer to the [official documentation for tags](https://django-qr-code.readthedocs.io/latest/pages/template-tags.html) for more detailed information and advanced usage examples. ### Demo Application If you want to try this app, you may want to use the demo application shipped alongside the source code. Get the source code from [GitHub](https://github.com/dprog-philippe-docourt/django-qr-code), follow the [installation instructions](#from-the-source-code) above, and run the `runserver` command of Django: ```bash python manage.py runserver ``` The demo application should be running at . If you have [Docker Compose](https://docs.docker.com/compose/) installed, you can simply run the following from a terminal (this will save you the burden of setting up a proper python environment): ```bash cd scripts ./run-demo-app.sh ``` The demo application should be running at . ## Generating Image Object Representing a QR Code If you do not want to use Django tags for rendering QR code in a template, you can simply use the API in your code. For instance, `qr_code.qrcode.maker.make_qr_code_image` will return bytes representing an image according to the image_format passed in the `qr_code_options` parameter. Refer to the [official API documentation](https://django-qr-code.readthedocs.io/latest/pages/api.html) for more detailed information. ## Testing Get the source code from [GitHub](https://github.com/dprog-philippe-docourt/django-qr-code), follow the [installation instructions](#from-the-source-code) above, and run the `test` command of Django: ```bash python manage.py test ``` This will run the test suite with the locally installed version of Python and Django. If you have [Docker Compose](https://docs.docker.com/compose/) installed, you can simply run the following from a terminal (this will save you the burden of setting up a proper python environment): ```bash cd scripts ./run-tests.sh ``` This will run the test suite with all supported versions of Python and Django. The test results are stored within `tests_result` folder. ## Projects Using this App This app is used in the following projects: * [MyGym Web](https://mygym-web.ch/): a web platform for managing sports clubs. The QR codes are used for importing members' contact information in a phone book. * [Gymna-Score](https://gymna-score.acjg.ch/): a web platform for entering scores during gymnastics competitions organized by the Association Cantonale Jurassienne de Gymnastique (ACJG). The QR codes are used to provide an easy way for the public to follow an ongoing competition. They are also used to authenticate judges that need to enter scores. * [AC-Ju](https://www.ac-ju.ch/): a website that generates digital vouchers that can be redeemed at affiliate merchants. django-qr-code-4.1.0/demo_site/000077500000000000000000000000001462661477300162765ustar00rootroot00000000000000django-qr-code-4.1.0/demo_site/__init__.py000066400000000000000000000000001462661477300203750ustar00rootroot00000000000000django-qr-code-4.1.0/demo_site/settings.py000066400000000000000000000076741462661477300205260ustar00rootroot00000000000000""" Django settings for qr_code_demo project. Generated by 'django-admin startproject' using Django 2.2. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os import django # Build paths inside the project like this: os.path.join(BASE_DIR, ...) from qr_code.qrcode import constants BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = "8l4)()f1&tg*dtxh6whlew#k-d5&79npe#j_dg9l0b)m8^g#8u" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ["django.contrib.auth", "django.contrib.contenttypes", "django.contrib.staticfiles", "qr_code", "qr_code_demo"] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "demo_site.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], }, }, ] WSGI_APPLICATION = "demo_site.wsgi.application" # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = {} # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = "/static/" STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") # Caches. CACHES = { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", }, "qr-code": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "qr-code-cache", "TIMEOUT": 3600}, } # Django QR Code specific options. QR_CODE_CACHE_ALIAS = "qr-code" QR_CODE_URL_PROTECTION = { constants.TOKEN_LENGTH: 30, # Optional random token length for URL protection. Defaults to 20. constants.SIGNING_KEY: "my-secret-signing-key", # Optional signing key for URL token. Uses SECRET_KEY if not defined. constants.SIGNING_SALT: "my-signing-salt", # Optional signing salt for URL token. constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: lambda u: True, # Tells whether a registered user can request the QR code URLs from outside a site that uses this app. It can be a boolean value used for any user, or a callable that takes a user as parameter. Defaults to False (nobody can access the URL without the security token). } SERVE_QR_CODE_IMAGE_PATH = "qr-code-image/" django-qr-code-4.1.0/demo_site/urls.py000066400000000000000000000005431462661477300176370ustar00rootroot00000000000000from django.conf.urls import include from django.urls import path from django.views.generic import RedirectView urlpatterns = [ path("", RedirectView.as_view(url="qr-code-demo/", permanent=True)), path("qr-code-demo/", include("qr_code_demo.urls", namespace="qr_code_demo")), path("qr-code/", include("qr_code.urls", namespace="qr_code")), ] django-qr-code-4.1.0/demo_site/wsgi.py000066400000000000000000000006221462661477300176210ustar00rootroot00000000000000""" WSGI config for qr_code_demo project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "qr_code_demo.settings") application = get_wsgi_application() django-qr-code-4.1.0/docker-compose.yml000066400000000000000000000004171462661477300177650ustar00rootroot00000000000000version: '3.7' services: django-qr-code: build: context: . dockerfile: Dockerfile args: - PYTHON_VERSION volumes: - ./:/usr/src/app environment: - APP_PORT=8910 expose: - "8910" ports: - "8910:8910" django-qr-code-4.1.0/docker-entrypoint.sh000077500000000000000000000010611462661477300203430ustar00rootroot00000000000000#!/bin/bash echo APP_PORT=$APP_PORT echo DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE # Collect static files first. python3 manage.py collectstatic --noinput echo --- Start Gunicorn processes and replace the shell [i.e. invoke gunicorn with exec] echo Starting Gunicorn. exec gunicorn demo_site.wsgi:application \ --name django-qr-code \ --bind 0.0.0.0:$APP_PORT \ --workers 2 \ --worker-class=gthread \ --log-level=info \ --log-file=- \ --access-logfile=- \ --env DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE \ "$@" django-qr-code-4.1.0/docs/000077500000000000000000000000001462661477300152565ustar00rootroot00000000000000django-qr-code-4.1.0/docs/Makefile000066400000000000000000000011451462661477300167170ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = python -msphinx SPHINXPROJ = DjangoQRcode SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) django-qr-code-4.1.0/docs/_static/000077500000000000000000000000001462661477300167045ustar00rootroot00000000000000django-qr-code-4.1.0/docs/_static/colors/000077500000000000000000000000001462661477300202055ustar00rootroot00000000000000django-qr-code-4.1.0/docs/_static/colors/alignment_dark.png000066400000000000000000000012251462661477300236720ustar00rootroot00000000000000PNG  IHDR PLTE ,?GIDATxZY@ sG]ҧy)[?C34R#/qYs~33>sYǮ7ahfc:xe3OUʺMC<\] C "nT] "\g݋ˇZ!.C6Re^q0Ʌ][^5hMA5K9=m-@!2a "]Bud0*6k0 tD "Qr4+Q.ie'ծe ?x\{?dˇՎ8[*Ү>:-5z.֫0xË|Rqt#fcCLʇaj(*a!\@}({ս^U8xz|2sձ_gXڸΣ7m`8]yvnަݡvnh!7pj?|?焛dW~:~«X!.%s CU/Ce5UihAӽTT^&9L2Ay Qx -!a~( yPm(_a7A%iWU6dWZa$zOfA~qB-KP\~#-zKI?-xpb4WjV(~CR^ yz\ WI˅0 Y<Ŋ|2xF欇ć*€PaH!P*I%yxIP@\Vy@Z?b;aZFQI@TL6e~ G:N}VxGg>:Oة Юx۔e4|iŗ Q=<>\;^K=uwWo)MIENDB`django-qr-code-4.1.0/docs/_static/colors/dark.png000066400000000000000000000011121462661477300216270ustar00rootroot00000000000000PNG  IHDR[PLTEIDATxAj@ CM/R7p䡋B7- M~>d1%Y' {3,>x5\%/UoBXR^ƓRVmCf.[ţߎ(>96J*ȧBgTN(߆@g[ Adh~0 E$ {+.L7=7ȿqJDY^çK N.g`S|ZdP0Cn5B2vN?6[M L~U.z27I}ճG{O%:XKt>!}.;=]ũ7׺>h2-4Lu3o&Z;!ǹvҟ՗ jfIj퓂)(v+od[o{لz)$s`?xK@*~t_#}Z5 |1G} EMIENDB`django-qr-code-4.1.0/docs/_static/colors/dark_module.png000066400000000000000000000011701462661477300232000ustar00rootroot00000000000000PNG  IHDR PLTE ,?*IDATxZj1 +Grƒ|1.ʵےW^uWvfL|驏xe窧]HF+[g0g0a@UTBrdS[Fnš/ǬQaP rr^kNu)+ɘoKJw+'!>ϕj]9}R2^Ŋ;^jmz#է@QC *x .7| IKݗ2^CuRE1'ѡRuu#sClCaj(0L`=q,D>iKP/I KvKPðJ+Dz F`x p#$~X*_D쩨e_$zUѾ)ۯ#T}Xy Lq>aSA]xD00E`N+ ܆>ӇkNj\i} ^uU'IE4IENDB`django-qr-code-4.1.0/docs/_static/colors/data_dark.png000066400000000000000000000012631462661477300226270ustar00rootroot00000000000000PNG  IHDR PLTE ,?eIDATxZJ@ dڦ ""B`'{,MnlxWU?]r//mûsU=s= ^w f ,/wkõ^;2ݮ2;*.wj=N{+2븂"6FI_ӓЊfזFXtU+ (|kg$6k ᎨB[Ce|+;0`׽[E&dM: HUFwHIt k13i9bv79ٱkcǔnppK7''ʡ WZJW&R_PC~aLI:X uֿ|nG"GHN<,Q˱`]`֗KIqYzO̓kȝXެ/_^(ą4v#^9GAvQz~TX!f|hKvhH}0_.즛_ t*W]1!㞆0cGL;Vz#+z  LfK4R33_k?E+!fsŠW-i~ejP3?|@zٱe|rp:3}~RQC7δW6롇#v;fچy YU)'zIENDB`django-qr-code-4.1.0/docs/_static/colors/finder_dark.png000066400000000000000000000012111462661477300231560ustar00rootroot00000000000000PNG  IHDR PLTE ,?;IDATxZJP {|֦;wn̵MnYzvt׹ԻOZבz|%/\o\߸|1>+8ƨp]B-N ^ qAi8:rXy[`}5~C/X8]iA@c|LWxUiiqb ʹ2TUBū3a 6D pY&BwH%N!4gS_h򘢂9{F$bEZ1󾪹AnPv> nw%,(!>qZ/qpa.bN@IX~#ZY. K3}5(lk I y~|eby:b9ʈ 7;7S(>& G3jbQF3ŋ&=ΚG(41b#og3 5+L 0V1ڔS(ޘCמ['w=pzL=aKA .x3d }~cd{tW_mpp+̴y ]q(}xEIENDB`django-qr-code-4.1.0/docs/_static/colors/finder_light.png000066400000000000000000000012011462661477300233430ustar00rootroot00000000000000PNG  IHDR PLTE ,?3IDATxZj@ >WMlKna2d%%ٗǽ^u*\u񼚧.\p~^TǫA1,T3BVE;;9!WE o T_4f/ppE ;Z]g%)68UQ:xQG,ZPJ oGU_䡢9{fID`eI%AnPv? 8J^,(!^J-q0]n#aIw|V. k飬Aa_XHe$q1p%j\>LN-tL8ްz{rD0` E<7"J5T/HKH;kDsi| Fߠx5 5 x,UL6ek _$M<m|_ip=pE-4d ~C2fs=:ͫ/k};<>\;^tL;PU?] b)J" IENDB`django-qr-code-4.1.0/docs/_static/colors/format_dark.png000066400000000000000000000012051462661477300232020ustar00rootroot00000000000000PNG  IHDR PLTE ,?7IDATxZ0 +G}ү%ǁIvr'zf=~; |zx:>s֊kp@3&׏N?ו!4+@*8f.0^_qVbfW8lKkCL\Ň7jzvOHZ_ \h1j+Ž\XLiD|QeD El)ChC;\kaU0I5L`{KIWƓN.fA80\B-, } tubi~c磬@vV| Ia>F7Õpa\CqbEl`8ްfcCLCah(0$`98"PJE*WHKfK;Ds0\cvXP~ǫVW*7bj5)cûTHR'QTe훰J;P@EP0 0>CoHƬ0[y ߆y'ǎWr_)g3Og}CKIENDB`django-qr-code-4.1.0/docs/_static/colors/format_light.png000066400000000000000000000011761462661477300233770ustar00rootroot00000000000000PNG  IHDR PLTE ,?0IDATxZj@ ^ymw,[8rK@mI'yV=U {Lw}Oꅋ?ϰ~zlb8p>\N7] J(\!.CuEOu|(VŋQi-u(u> gU_x}V_P>±h5y8Gh>sWR]T_reKJ"Zn!Uu:e~C(H\&i{98ݥPq t%DbVXo?RC'wh.,] ( k[/roDxM|T4(D}C.#| %Fõq2]&֣#b.^#d:*7oZM& XO"xeŋ!=G(141O;"```x=  x#,Ul6es _=]A!oVP\ORP{sH7,c1أӾ?!õT.ϴ y Y~9A:>+IENDB`django-qr-code-4.1.0/docs/_static/colors/light.png000066400000000000000000000011071462661477300220210ustar00rootroot00000000000000PNG  IHDR[PLTEIDATxKj#@ D\K@+5"jHvgfڏ۳*U ?Ir[juo"xoW7t*;?DE?ᙟR-Q:Bh=>oh`?}+d;;ַp-xԫtAKeu"O mNA?7ۓ _cĐӯ\?ui诓~=>Ny;&ZI$~Ѥ\$h~Fltʩ.sz{Es͇#?& #P0d.D݁.S/ss@sd)c5s"Cr)g7CϫR1ǵvr?&goTL,A0XlA!(ܜt]F k׋KѸC0zu3s\|į,^{KH* ni˨e>Cn⪐J'IENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_alignment_dark.png000066400000000000000000000003301462661477300245450ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ1 x+Bqf =)"Ystri?کޜvѫcBqP,UL|'CPs馬,f07׫3o6Nz"|E*JЯi #/tIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_alignment_light.png000066400000000000000000000003301462661477300247330ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ1 x+Bqf =)"Ystri?کޜvѫcBqP,UL|'CPs馬,f07׫3o6Nz"|E*JЯi #/tIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_dark.png000066400000000000000000000003071462661477300225130ustar00rootroot00000000000000PNG  IHDRTT&PLTE|IDATxڵ 1 /dR䫗H ϶ f|C#V{Hoqcl''\xͨGIUofv{e? Oy[89}F˚*IENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_dark_module.png000066400000000000000000000003301462661477300240540ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ1 x+Bqf =)"Ystri?کޜvѫcBqP,UL|'CPs馬,f07׫3o6Nz"|E*JЯi #/tIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_data_dark.png000066400000000000000000000003331462661477300235030ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ10QO&ȒUjR.USٗCez2]ܸ`Ժ J0˕^+·ڇx!ܪH k0z-+ jE E;l)W7բz]J_n^czf,IENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_data_light.png000066400000000000000000000003361462661477300236740ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕA 0 +mi"lA#Ba\D—TsŅ]&0xMظv`q */~FsÝŔ Xq啫c[R,$ؖWfcf{W V֚o9\îIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_finder_dark.png000066400000000000000000000003311462661477300240370ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ90 -+I|ѤA)Űۊ˷㗝ͭwX?;oeA顸[8=7ۥ sTͪw58:7<<<{1 oBEVZ4'޷_C7V:wIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_finder_light.png000066400000000000000000000003311462661477300242250ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕA O9h5p6CQO_^MUx7s#m,EL҃ʋCCv za9/ݧsS~ugvS~Kt.n6ЯArQ՟J0oF/C7琏dQIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_format_dark.png000066400000000000000000000003331462661477300240620ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕA '-pb2]" [iT˳rչjOfvTMc ڭT! C6Fi9š?;~1ݽ[)̯|}  & [W -ky9t\% IENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_format_light.png000066400000000000000000000003321462661477300242470ustar00rootroot00000000000000PNG  IHDRTTaR PLTE ,?IDATxՕ1 oc>W $3[h@f |*}y5NNIENDB`django-qr-code-4.1.0/docs/_static/colors/mqr_light.png000066400000000000000000000003021462661477300226740ustar00rootroot00000000000000PNG  IHDRTT&PLTEwIDATxڵ 0Q`-v&.raY#i݁DؓGz= 5Oj7zu8X[4V}% Uw^U|TU!zsyպ#?!.r(Cs+/p{;6ceՅ)֠Ps̬auA!(J/0ɄiD l)C _B D$}Vt(X|'azC(I\"Je{GsݥPR# n;+Yu͖ASf.3l.ŪE'`o^lb0lxmt-̱n0Hȸ2ߓ;l.sqHH˗՜D2x|#sK0>$| in/Q0,?I[́5@q~Q@>jD49jRg+L abڔ[*$'lTȂb-aƊ12_ ,1ppx'촃p=oQcIENDB`django-qr-code-4.1.0/docs/_static/colors/rain.png000066400000000000000000000003321462661477300216420ustar00rootroot00000000000000PNG  IHDRTTaR PLTEFIDATxՕ10 #OiCWbpXN_ K;=॔VEak wp9>܆ ^ )4cŸkZS߬`E[U K+|wEnݷ_C'@IENDB`django-qr-code-4.1.0/docs/_static/colors/separator.png000066400000000000000000000012061462661477300227120ustar00rootroot00000000000000PNG  IHDR PLTE ,?8IDATxZJP ;|MEM{ m;yV=U]{;_;o7|w\ub=tCIG?BvU +B|S ^ qaP8W+!l%&"?aWh}C[U_ D P8LWxUiƔr (J%@^Z&LF]CEsa~c"Gb}|o;' %ip-){!z<尼ԢK 򊝈.3L[wrp'HXRExıVi~c#י>I 4.71D݇2i5ܘi7^ovOS(>TG3Ąͣ4l ŋ&5G(kF1B73^B~iapNd#>̳9OKĶoW'x{0{z–@\4d ~C2fs=:ͫ/k5w8y|xѕK30|zVOH+LjIENDB`django-qr-code-4.1.0/docs/_static/colors/timing_dark.png000066400000000000000000000012101462661477300231750ustar00rootroot00000000000000PNG  IHDR PLTE ,?:IDATxZj0 Grk8@WJ@YVXϬg3뷳_ύLOYϛ_gq1xdÂSO":݄7 JC[r@\ZN'Np6+q|(VFuUX_Qe^+-(^?¡Y]PDnd/o덗X *^ E#aybڀ~+8Jv uX5Z1ӾZsQ5J'ẵ0މދYPbC\K-K‡O갹0.W*aI;Q. 0ݨ<e X8H0b7~yTe= }Ps\Ò!:*#7o|= eoD>T-QI^hE\2-,?ʭDSiԌ&@Ax 5 +fפqwEZ7q OF~`Pz=a@\xX2~!L4o}Yo"v/S`-xII$֯+g3Og})AMIENDB`django-qr-code-4.1.0/docs/_static/colors/timing_light.png000066400000000000000000000012071462661477300233710ustar00rootroot00000000000000PNG  IHDR PLTE ,?9IDATxZj@ ;IYӗR@tAmYe7ǺWݫU>J|.,bp/2a ";ZPuҎ\﹘r'KE$I& *^;0\/P!OEU_^V+_0Lo4%4+fڗ5{ IK,|.*v%Wfx`)Z2[V_a^X2r] JyGhcc̠p ` I}yC% ZΏ!oj5}X_~P iEGl9GA8z ˅.LL4*w3k`9ymT& v<Ƅ6Qz5]0ƆL^Bg+&CR1M)4IԾ+5U&l^(=PՓ X!V$=2P9ˌoC|'ǎWyL;oݫU 9.AIENDB`django-qr-code-4.1.0/docs/_static/colors/version_dark.png000066400000000000000000000012001462661477300233720ustar00rootroot00000000000000PNG  IHDR PLTE ,?2IDATxZ@ G}Rf,]8eY$M2Pa[=zV=U An\7'Os +J<8&׹d f\PF}|\TN'alTkWx1ޓXP|\ÐC}#+鑊V/NΆ3[p%mP%J Mk(h9BIH\BD$r]E!ٗ %\b{98ݥPq /DbVXo'Wu^!;4.V5_t[7? L>}T4(D}C.#| %Fõq2]&_GPs]GtUFoDdŵ!60` M)W1dQe~ApE +ZUgE)6(ȋY@&5D pY:BnJ~u Ed3<`>o(wUR(IKNwKѻ!?(, ?}rͅa\3%aI;xF. G> c!Ia>Pb~#mQpaLC5qRGl9'ӡVqa}#fzŇ݄c؄F=jŋ&&ͣ|hn= SpbAHOvф7ֹe:_#\XmňmSI;|J$yUۯGxz0y)8znc"l0GyeoCp>LJcNj\=ԯ)gճOW}/hZ,蟶//l *Gxv_Ut>X.DP5_]Rϟ{&3bO(טGU z<"cM8fWY( Z|ebLZSy+ ZsW[T՟agP쏋\y3J;|;C78g.Wza?;^vHB~OU?/ dIENDB`django-qr-code-4.1.0/docs/conf.py000066400000000000000000000157111462661477300165620ustar00rootroot00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Django QR Code documentation build configuration file, created by # sphinx-quickstart on Wed Aug 2 22:36:45 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os import re import sys import django sys.path.insert(0, os.path.abspath("../")) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo_site.settings") django.setup() # Symlink CHANGELOG.md from repo root to the pages dir. basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) filenames = ["CHANGELOG.md", "README.md"] for filename in filenames: target = os.path.join(basedir, "docs", "pages", filename) if not os.path.islink(target): os.symlink(os.path.join(basedir, filename), target) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.autodoc", "sphinx.ext.doctest", "sphinx.ext.intersphinx", "sphinx.ext.todo", "sphinx.ext.coverage", "sphinx.ext.mathjax", "sphinx.ext.ifconfig", "sphinx.ext.viewcode", "sphinx.ext.githubpages", "myst_parser", ] # https://myst-parser.readthedocs.io/en/latest/syntax/optional.html myst_enable_extensions = [ "amsmath", "attrs_inline", "colon_fence", "deflist", "dollarmath", "fieldlist", "html_admonition", "html_image", "linkify", "replacements", "smartquotes", "strikethrough", "substitution", "tasklist", ] myst_heading_anchors = 4 # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = { '.rst': 'restructuredtext', '.md': 'markdown', } # The master toctree document. master_doc = "index" # General information about the project. project = "Django QR Code" copyright = "2017-2024, Philippe Docourt" author = "Philippe Docourt" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # Get version without importing with open("../qr_code/__init__.py", "rb") as f: VERSION = str(re.search('__version__ = "(.+?)"', f.read().decode("utf-8")).group(1)) # The short X.Y version. version = VERSION # The full version, including alpha/beta/rc tags. release = VERSION # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { "**": [ "about.html", "navigation.html", "relations.html", # needs 'show_related': True theme option to display "searchbox.html", "donate.html", ] } # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = "DjangoQRCodeDoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, "DjangoQRCode.tex", "Django QR Code Documentation", "Philippe Docourt", "manual"), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "djangoqrcode", "Django QR Code Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "DjangoQRCode", "Django QR Code Documentation", author, "DjangoQRCode", "An application that provides tools for displaying QR codes on your Django site.", "Miscellaneous", ), ] # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. epub_title = project epub_author = author epub_publisher = author epub_copyright = copyright # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] django-qr-code-4.1.0/docs/index.rst000066400000000000000000000010731462661477300171200ustar00rootroot00000000000000.. Django QR code documentation master file, created by sphinx-quickstart on Wed Aug 2 22:36:45 2017. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to Django QR Code's Documentation! ========================================== .. toctree:: :maxdepth: 2 :caption: Contents: pages/README.md pages/template-tags.md pages/module-colors.rst pages/api.rst pages/CHANGELOG.md Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` django-qr-code-4.1.0/docs/make.bat000066400000000000000000000014521462661477300166650ustar00rootroot00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=python -msphinx ) set SOURCEDIR=. set BUILDDIR=_build set SPHINXPROJ=DjangoQRcode if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The Sphinx module was not found. Make sure you have Sphinx installed, echo.then set the SPHINXBUILD environment variable to point to the full echo.path of the 'sphinx-build' executable. Alternatively you may add the echo.Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% :end popd django-qr-code-4.1.0/docs/pages/000077500000000000000000000000001462661477300163555ustar00rootroot00000000000000django-qr-code-4.1.0/docs/pages/api.rst000066400000000000000000000010171462661477300176570ustar00rootroot00000000000000API Reference ============= qrcode.maker ------------ .. automodule:: qr_code.qrcode.maker :members: qrcode.serve ------------ .. automodule:: qr_code.qrcode.serve :members: qrcode.utils ------------ .. automodule:: qr_code.qrcode.utils :members: :special-members: qrcode.views -------------------- .. automodule:: qr_code.views :members: templatetags.qr_code -------------------- .. automodule:: qr_code.templatetags.qr_code :members: tests ----- .. automodule:: qr_code.tests :members: django-qr-code-4.1.0/docs/pages/module-colors.rst000066400000000000000000000150431462661477300216760ustar00rootroot00000000000000Module Colors ============= By default the QR codes are rendered in black and white but this project supports individual colors for each QR Code module type, i.e. the alignment and finder patterns may use another color than the data modules. The color values can be provided as tuple ``(R, G, B)``, as web color name (like 'red') or as hexadecimal ``#RRGGBB`` value (i.e. '#085A75'). The value ``None`` is used to indicate transparency, i.e. ``light_color=None`` indicates that all light modules should be transparent. .. code-block:: {% qr_from_text "Yellow Submarine" dark_color="darkred" data_dark="darkorange" data_light="yellow" %} .. image:: ../_static/colors/yellow-submarine.png :alt: Colorful 7-H QR code encoding "Yellow Submarine" .. code-block:: {% qr_from_text "Rain" dark_color="darkblue" data_dark="steelblue" micro=True %} .. image:: ../_static/colors/rain.png :alt: Colorful M4-Q QR code encoding "RAIN" Module names ------------ The following examples show the results of all supported module types. The unaffected modules are rendered as grey or white modules, the red modules show the result of the keyword. dark_color ~~~~~~~~~~ Sets the (default) color of dark modules. .. image:: ../_static/colors/dark.png :alt: Picture showing the dark modules .. image:: ../_static/colors/mqr_dark.png :alt: Picture showing the dark modules of a Micro QR code light_color ~~~~~~~~~~~ Sets the (default) color of light modules. .. image:: ../_static/colors/light.png :alt: Picture showing the light modules .. image:: ../_static/colors/mqr_light.png :alt: Picture showing the light modules of a Micro QR code alignment_dark_color ~~~~~~~~~~~~~~~~~~~~ Sets the color of the dark alignment pattern modules. Micro QR Codes don't have alignment patterns. .. image:: ../_static/colors/alignment_dark.png :alt: Picture showing the dark alignment modules .. image:: ../_static/colors/mqr_alignment_dark.png :alt: Picture showing the dark alignment modules of a Micro QR code (none) alignment_light_color ~~~~~~~~~~~~~~~~~~~~~ Sets the color of the light alignment pattern modules. Micro QR Codes don't have alignment patterns. .. image:: ../_static/colors/alignment_light.png :alt: Picture showing the light alignment modules .. image:: ../_static/colors/mqr_alignment_light.png :alt: Picture showing the light alignment modules of a Micro QR code (none) dark_module_color ~~~~~~~~~~~~~~~~~ Sets the color of the dark module. Micro QR Codes don't have a dark module. .. image:: ../_static/colors/dark_module.png :alt: Picture showing the dark modules .. image:: ../_static/colors/mqr_dark_module.png :alt: Picture showing the dark modules of a Micro QR code (none) data_dark_color ~~~~~~~~~~~~~~~ Sets the color of the dark data modules. .. image:: ../_static/colors/data_dark.png :alt: Picture showing the dark data modules .. image:: ../_static/colors/mqr_data_dark.png :alt: Picture showing the dark data modules of a Micro QR code data_light_color ~~~~~~~~~~~~~~~~ Sets the color of the light data modules. .. image:: ../_static/colors/data_light.png :alt: Picture showing the light modules .. image:: ../_static/colors/mqr_data_light.png :alt: Picture showing the light modules of a Micro QR code finder_dark_color ~~~~~~~~~~~~~~~~~ Sets the color of the dark modules of the finder pattern. .. image:: ../_static/colors/finder_dark.png :alt: Picture showing the dark finder modules .. image:: ../_static/colors/mqr_finder_dark.png :alt: Picture showing the dark finder modules of a Micro QR code finder_light_color ~~~~~~~~~~~~~~~~~~ Sets the color of the light modules of the finder pattern. .. image:: ../_static/colors/finder_light.png :alt: Picture showing the light finder modules .. image:: ../_static/colors/mqr_finder_light.png :alt: Picture showing the light finder modules of a Micro QR code format_dark_color ~~~~~~~~~~~~~~~~~ Sets the color of the dark modules of the format information. .. image:: ../_static/colors/format_dark.png :alt: Picture showing the dark format information modules .. image:: ../_static/colors/mqr_format_dark.png :alt: Picture showing the dark format information modules of a Micro QR code (none) format_light_color ~~~~~~~~~~~~~~~~~~ Sets the color of the light modules of the format information. .. image:: ../_static/colors/format_light.png :alt: Picture showing the light format information modules .. image:: ../_static/colors/mqr_format_light.png :alt: Picture showing the light format information modules of a Micro QR code (none) quiet_zone_color ~~~~~~~~~~~~~~~~ Sets the color of the quiet zone. .. image:: ../_static/colors/quiet_zone.png :alt: Picture showing the quiet zone .. image:: ../_static/colors/mqr_quiet_zone.png :alt: Picture showing the quiet zone of a Micro QR code separator_color ~~~~~~~~~~~~~~~ Sets the color of the separator. .. image:: ../_static/colors/separator.png :alt: Picture showing the separator .. image:: ../_static/colors/mqr_separator.png :alt: Picture showing the separator of a Micro QR code timing_dark_color ~~~~~~~~~~~~~~~~~ Sets the color of the dark modules of the timing pattern. .. image:: ../_static/colors/timing_dark.png :alt: Picture showing the dark timing pattern modules .. image:: ../_static/colors/mqr_timing_dark.png :alt: Picture showing the dark timing pattern modules of a Micro QR code timing_light_color ~~~~~~~~~~~~~~~~~~ Sets the color of the light modules of the timing pattern. .. image:: ../_static/colors/timing_light.png :alt: Picture showing the light timing pattern modules .. image:: ../_static/colors/mqr_timing_light.png :alt: Picture showing the light timing pattern modules of a Micro QR code version_dark_color ~~~~~~~~~~~~~~~~~~ Sets the color of the dark modules of the version information. Micro QR Codes and QR Codes lesser than version 7 don't carry any version information. .. image:: ../_static/colors/version_dark.png :alt: Picture showing the dark version modules .. image:: ../_static/colors/mqr_version_dark.png :alt: Picture showing the dark version modules of a Micro QR code (none) version_light_color ~~~~~~~~~~~~~~~~~~~ Sets the color of the light modules of the version information. Micro QR Codes and QR Codes lesser than version 7 don't carry any version information. .. image:: ../_static/colors/version_light.png :alt: Picture showing the light version modules .. image:: ../_static/colors/mqr_version_light.png :alt: Picture showing the light version modules of a Micro QR code (none) django-qr-code-4.1.0/docs/pages/template-tags.md000066400000000000000000000641751462661477300214630ustar00rootroot00000000000000# Template Tags ## Generating inline QR code in your HTML (qr_from_text) The tag **`qr_from_text`** generates an embedded `` or `` tag within the HTML code produced by your template. The following renders a tiny "hello world" QR code in SVG format with an inline `` tag: ```htmldjango {% qr_from_text "Hello World!" size="T" %} ``` Here is a medium "hello world" QR code in PNG format: ```htmldjango {% qr_from_text "Hello World!" size="m" image_format="png" error_correction="L" %} ``` This will output an `` tag with data URI: `` ### Customizing the HTML output for inline QR codes You can customize `alt` and `class` attributes can be customized through `alt_text` and `class_names` arguments of `qr_from_text`: ```htmldjango {% qr_from_text "Hello World!" alt_text="My Hello World image" class_names="ui centered image" %} ``` The `alt_text` argument indicates the value of the alternative text embedded in the `alt` attribute of the returned image tag. When set to `None`, the alternative text is set to the string representation of data. The alternative text is automatically escaped. You may use an empty string to explicitly set an empty alternative text. The `class_names` argument indicates the value of the `class` attribute of the returned image tag. When set to `None` or empty, the class attribute is not set. By default, when SVG format is specified, the generated tag is an inline SVG path: ``. To change that, you can p ass `use_data_uri_for_svg=True` to the `qr_from_text` tag: ```htmldjango {% qr_from_text "Hello World!" use_data_uri_for_svg=True %} ``` This will output an `` tag with a data URI similar to what you get by default for the PNG format: ``. This also allows you to define the `class` and `alt` HTML attributes of the `` tag as shown above. When `use_data_uri_for_svg` is not set or is set to `False`, the `alt_text` and `class_names` arguments are ignored. ## Generating URLs to QR code images (qr_url_from_text) The **`qr_url_from_text`** tag generates an url to an image representing the QR code. It comes with the same options as `qr_from_text` to customize the image format (SVG or PNG), the size, the border, and the matrix size. It also has an additional option **`cache_enabled`** to disable caching of served image. Here is a medium "hello world" QR code that uses a URL to serve the image in SVG format: ```htmldjango Hello World! ``` Here is a "hello world" QR code in version 10 that uses a URL to serve the image in PNG format: ```htmldjango Hello World! ``` The image targeted by the generated URL is served by a view provided in `qr_code.urls`. Therefore, you need to include the URLs provided by `qr_code.urls` in your app in order to make this tag work. This can be achieved with something like this: ```python from django.conf.urls import include from django.urls import path urlpatterns = [ path('qr_code/', include('qr_code.urls', namespace="qr_code")), ] ``` The QR code images are served via a URL named **`qr_code:serve_qr_code_image`**. You can customize the path under which the images are served (i.e. the path bound to the URL named `qr_code:serve_qr_code_image`) with the optional setting **`SERVE_QR_CODE_IMAGE_PATH`** which defaults to `images/serve-qr-code-image/`. Note that the trailing slash is mandatory and that defining this setting to an empty string leads to using the default value. The example below will serve any QR code image from `/qr-code-image/`: ```python # In urls.py from django.conf.urls import include from django.urls import path urlpatterns = [ path('', include('qr_code.urls', namespace='qr_code')), ] # In your settings SERVE_QR_CODE_IMAGE_PATH = 'qr-code-image/' ``` ### Caching served images A large QR code (version 40) requires 0.2 second to be generated on a powerful machine (in 2018), and probably more than half a second on a really cheap hosting. The image served by the *qr_code* app can be cached to improve performances and reduce CPU usage required to generate the QR codes. In order to activate caching, you simply need to declare a cache alias with the setting **`QR_CODE_CACHE_ALIAS`** to indicate in which cache to store the generated QR codes. For instance, you may declare an additional cache for your QR codes like this in your Django settings: ```python CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, 'qr-code': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'qr-code-cache', 'TIMEOUT': 3600 } } QR_CODE_CACHE_ALIAS = 'qr-code' ``` The `QR_CODE_CACHE_ALIAS = 'qr-code'` tells the *qr_code* app to use that cache for storing the generated QR codes. All QR codes will be cached with the specified *TIMEOUT* when a non-empty value is set to `QR_CODE_CACHE_ALIAS`. If you want to activate the cache for QR codes, but skip the caching for some specific codes, you can use the keyword argument `cache_enabled=False` when using `qr_url_from_text`. Here is a "hello world" QR code in version 20 with an error correction level Q (25% of redundant data) that uses a URL to serve the image in SVG format, and disable caching for served image: ```htmldjango Hello World! ``` ### Protecting access to QR code images The default settings protect the URLs that serve QR code images against external requests, and thus against possibly easy (D)DoS attacks. Here are the available settings to manage the protection for served images: ```python from qr_code.qrcode import constants QR_CODE_URL_PROTECTION = { constants.TOKEN_LENGTH: 30, # Optional random token length for URL protection. Defaults to 20. constants.SIGNING_KEY: 'my-secret-signing-key', # Optional signing key for URL token. Uses SECRET_KEY if not defined. constants.SIGNING_SALT: 'my-signing-salt', # Optional signing salt for URL token. constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: True # Tells whether a registered user can request the QR code URLs from outside a site that uses this app. It can be a boolean value used for any user or a callable that takes a user as parameter. Defaults to False (nobody can access the URL without the signature token). } ``` #### Signing request URLs By default, the application only serves QR code images for authenticated URLs (requests generated from your application and addressed to your application). The authentication uses a HMAC to sign the request query arguments. The authentication code is passed as a query argument named **`token`** which is automatically generated by `qr_url_from_text` or `qr_url_from_data`. Whenever the signature is invalid, the application returns a *HTTP 403 Permission denied* response when processing the request for serving a QR code image. This mechanism ensures that, by default, nobody can send external requests to your application to obtain custom QR codes for free. This is especially useful if you display QR code URLs on public pages (no user authentication). The `token` query argument is not mandatory and, when a request reaches the `qr_code:serve_qr_code_image` URL without that token, the protection mechanism falls back to the user authentication mechanism (see chapter below). It is possible to explicitly remove the signature token that protects a specific URL with the parameter **`url_signature_enabled=False`**. Here is a "hello world" QR code that uses a URL to serve the image in SVG format without the `token` query argument : ```htmldjango Hello World! ``` The `token` parameter will not be part of the query string of the generated URL, making possible to build a simpler, predictable URL. However, this will trigger the user authentication mechanism (see chapter below). #### Handling user authentication when serving QR code images If you are interested in providing the QR code images as a service, there is a setting named **`ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER`** to grant access to some controlled users. This setting tells who can bypass the url signature token (see chapter above). It can be a boolean value used for any authenticated user, or a callable that takes a user as only parameter. Setting the `ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER` option to `True` tells the application to serve QR code images to authenticated users only. Hence, to grant access to any authenticated user to generated images, you can use this in your settings: ```python from qr_code.qrcode import constants QR_CODE_URL_PROTECTION = { constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: True } ``` Setting the option `ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER` to a callable that always returns `True` (even for anonymous users) will allow anyone to access QR code image generation from outside your Django app. The following settings will grant access to anonymous users to generated images: ```python from qr_code.qrcode import constants QR_CODE_URL_PROTECTION = { constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: lambda u: True } ``` Please note that, if your service is available on the Internet, allowing anyone to generate any kind of QR code via your Django application - as shown above - might generate a very heavy load on your server. ## Special encoding modes with qr_from_data and qr_url_from_data The tags **`qr_from_data`** and **`qr_url_from_data`** produce results similar to those of `qr_from_text` and `qr_url_from_text`, but they avoid converting everything to text (UTF-8 encoded by default, or any supported charset depending on `encoding` option). The ISO/IEC 18004 standard defines four modes in order to encode the data as efficiently as possible. ### Numeric mode The numeric mode is the most efficient way to encode digits. This mode does not cover negative numbers because it does not support the minus sign (or plus sign). The numeric mode is supported by QR Codes and Micro QR Codes. The encoding engine detects (Segno) the numeric mode if the data is provided as string (e.g. '54') or integer (e.g. 54) to `qr_from_data` or `qr_url_from_data`. ### Alphanumeric mode The alphanumeric mode extends the numeric mode by various characters. Namely, about the upper case letters ABCDEFGHIJKLMNOPQRSTUVWXYZ, a space character " " and other letters $%*+-./:. ### Kanji mode Kanji can be encoded compactly and efficiently and requires significantly less space than encoding the characters in UTF-8. ### Byte mode The byte mode covers all data which cannot be represented by the other modes. When the `encoding` option is set to `None`, the encoding engine (Segno) detects, according to ISO/IEC 18004, to encode the data with ISO 8859-1. In case the data cannot be represented by ISO 8859-1, UTF-8 is used as fallback. NOTE: When using `qr_from_text` or `qr_url_from_text`, the byte mode with UTF-8 encoding is forced by default . You may use the `encoding` option to change this behavior. It appears to be one of the most portable way of encoding text for proper decoding among the readers. ### Examples The following renders a tiny numeric QR code containing the value `2021` with a `svg` tag: ```htmldjango {% qr_from_data 2021 size="T" %} ``` Here is a micro QR code with an `img` tag containing the value `2021`: ```htmldjango {% qr_from_data 2021 micro=True image_format="png" %} ``` ## QR codes for apps Aside from generating a QR code from a given text, you can also generate codes for specific application purposes, that a reader can interpret as an action to take: open a mail client to send an e-mail to a given address, add a contact to your phone book, connect to a Wi-Fi, start a SMS, etc. See [this documentation](https://github.com/zxing/zxing/wiki/Barcode-Contents) about what a QR code can encode. Django QR Code proposes several utility tags to ease the generation of such codes, without having to build the appropriate text representation for each action you need. This remove the hassle of reading the specifications and handling all the required escaping for reserved chars. Please note that some commands are common patterns, rather than formal specifications. Therefore, there is no guarantee that all QR code readers will handle them properly. The following tags targeting apps are available: * `qr_for_email` and `qr_url_for_email` * `qr_for_tel` and `qr_url_for_tel` * `qr_for_sms` and `qr_url_for_sms` * `qr_for_geolocation` and `qr_url_for_geolocation` * `qr_for_google_maps` and `qr_url_for_google_maps` * `qr_for_youtube` and `qr_url_for_youtube` * `qr_for_google_play` and `qr_url_for_google_play` * `qr_for_mecard` and `qr_url_for_mecard` * `qr_for_vcard` and `qr_url_for_vcard` * `qr_for_wifi` and `qr_url_for_wifi` * `qr_for_epc` and `qr_url_for_epc` * `qr_for_event` and `qr_url_for_event` * `qr_for_contact` and `qr_url_for_contact` (legacy, do not use in new projects) **Note**: All options and settings presented for `qr_from_text`, `qr_url_from_text`, `qr_from_data`, and `qr_url_from_data` also apply to any of the above "QR codes for apps". You could write a view like this: ```python import datetime from datetime import date from django.shortcuts import render from qr_code.qrcode.utils import MeCard, VCard, EpcData, VEvent, EventClass, EventTransparency, EventStatus, WifiConfig, Coordinates, QRCodeOptions def application_qr_code_demo(request): # Use a MeCard instance to encapsulate the detail of the contact. mecard_contact = MeCard( name='Doe, John', phone='+41769998877', email='j.doe@company.com', url='http://www.company.com', birthday=date(year=1985, month=10, day=2), memo='Development Manager', org='Company Ltd' ) # Use a VCard instance to encapsulate the detail of the contact. vcard_contact = VCard( name='Doe; John', phone='+41769998877', email='j.doe@company.com', url='http://www.company.com', birthday=date(year=1985, month=10, day=2), street='Cras des Fourches 987', city='Delémont', zipcode=2800, region='Jura', country='Switzerland', memo='Development Manager', org='Company Ltd' ) # Use a WifiConfig instance to encapsulate the configuration of the connexion. wifi_config = WifiConfig( ssid='my-wifi', authentication=WifiConfig.AUTHENTICATION.WPA, password='wifi-password' ) # Use a EpcData instance to encapsulate the data of the European Payments Council Quick Response Code. epc_data = EpcData( name='Wikimedia Foerdergesellschaft', iban='DE33100205000001194700', amount=50.0, text='To Wikipedia' ) # Build coordinates instances. google_maps_coordinates = Coordinates(latitude=586000.32, longitude=250954.19) geolocation_coordinates = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) # Build event data (VEVENT properties) # NB for start and end of event: # - Naive date and time is rendered as floating time. # - Aware date and time is rendered as UTC converted time. event = VEvent( uid="some-event-id", summary="Vacations", start=datetime.datetime(2022, 8, 6, hour=8, minute=30), end=datetime.datetime(2022, 8, 17, hour=12), location="New-York, Statue de la Liberté", geo=(40.69216097988203, -74.04460073403436), categories=["PERSO", "holidays"], status=EventStatus.CONFIRMED, event_class=EventClass.PRIVATE, transparency=EventTransparency.OPAQUE, organizer="foo@bar.com", url="https://bar.com", description="""Fake description. Meeting to provide technical review for "Phoenix" design. Happy Face Conference Room. Phoenix design team MUST attend this meeting. RSVP to team leader.""" ) # Build context for rendering QR codes. context = dict( mecard_contact=mecard_contact, vcard_contact=vcard_contact, wifi_config=wifi_config, epc_data=epc_data, event=event, video_id='J9go2nj6b3M', google_maps_coordinates=google_maps_coordinates, geolocation_coordinates=geolocation_coordinates, options_example=QRCodeOptions(size='t', border=6, error_correction='L'), ) # Render the index page. return render(request, 'my_app/application_qr_code_demo.html', context=context) ``` Then, in your template, you can render the appropriate QR codes for the given context: ```htmldjango

Add contact '{{ mecard_contact.name }}' to phone book

{% qr_for_mecard mecard=mecard_contact size='S' %}

or:

{% qr_for_contact mecard_contact size='S' %}

or:

{% qr_for_contact mecard_contact options=options_example %}

Add contact '{{ vcard_contact.name }}' to phone book

{% qr_for_vcard vcard=vcard_contact size='S' %}

or:

{% qr_for_contact vcard_contact size='S' %}

or:

{% qr_for_contact vcard_contact options=options_example %}

Configure Wi-Fi connexion to '{{ wifi_config.ssid }}'

or:

or:

EPC QR Code'

or:

Event QR Code'

or:

{% qr_for_event event=event %}

Watch YouTube video '{{ video_id }}'

{% qr_for_youtube video_id image_format='png' size='T' %}

or:

{% qr_for_youtube video_id options=options_example %}

Open map at location: ({{ geolocation_coordinates }})

or:

or:

Open Google Maps App at location: ({{ google_maps_coordinates }})

{% qr_for_google_maps coordinates=google_maps_coordinates %}

or:

{% qr_for_google_maps latitude=google_maps_coordinates.latitude longitude=google_maps_coordinates.longitude %}

or:

{% qr_for_google_maps latitude=google_maps_coordinates.latitude longitude=google_maps_coordinates.longitude options=options_example %} ``` Please check out the [demo application](README.md#demo-application) to see more examples. ## QR code rendering options ### Overview of customization options * `size`: Size of each module (e.g., T, S, M, L, H or specific integer). Default is 'M' * `image_format`: Format of the image (e.g., 'svg', 'png'). Default is 'svg'. * `border`: Border size in modules. Default is 4. * `error_correction`: Error correction level ('L', 'M', 'Q', 'H'). Default is 'M'. * `use_data_uri_for_svg`: Generate a data URI for SVG images. Default is `False`. * `encoding`: Text encoding . Default is 'UTF-8'. * `micro`: enforce the creation of a Micro QR Code. Default is `False`. * `boost_error` indicates whether the QR code encoding engine (Segno) tries to increase the error correction level if it does not affect the version. Default is `False`. * `eci` indicates if binary data which does not use the default encoding (ISO/IEC 8859-1). Default is `False`. * `options`: Use an instance of QRCodeOptions to encapsulate multiple settings. ### Examples of rendering options The `size` parameter gives the size of each module of the QR code matrix. It can be either a positive integer or one of the following letters: * t or T: tiny (value: 6) * s or S: small (value: 12) * m or M: medium (value: 18) * l or L: large (value: 30) * h or H: huge (value: 48) For PNG image format the size unit is in pixels, while the unit is 1 mm for SVG format. Here is a "hello world" QR code using the version 12: ```htmldjango {% qr_from_text "Hello World!" size=8 version=12 %} ``` The `version` parameter is an integer from 1 to 40 that controls the size of the QR code matrix. Set to None to determine this automatically. The smallest, version 1, is a 21 x 21 matrix. The biggest, version 40, is 177 x 177 matrix. The size grows by 4 modules/side. Here is a "hello world" QR code using a border of 6 modules: ```htmldjango {% qr_from_text "Hello World!" size=10 border=6 %} ``` The `border` parameter controls how many modules thick the border should be (the default is 4, which is the minimum according to the specs). There are 4 error correction levels used for QR codes, with each one adding different amounts of "backup" data depending on how much damage the QR code is expected to suffer in its intended environment, and hence how much error correction may be required. The correction level can be configured with the `error_correction` parameter as follows: * l or L: error correction level L – up to 7% damage * m or M: error correction level M – up to 15% damage * q or Q: error correction level Q – up to 25% damage * h or H: error correction level H – up to 30% damage You may enforce the creation of a Micro QR Code with `micro=True`. The `micro` option defaults to `False`. The `encoding` option controls the text encoding used in mode "byte" (used for any general text content). By default `encoding` is ``UTF-8``. When set to ``None``, the implementation (based on Segno) tries to use the standard conform ISO/IEC 8859-1 encoding and if it does not fit, it will use UTF-8. Note that no ECI mode indicator is inserted by default (see `eci` option). The `encoding` parameter is case-insensitive. The `boost_error` indicates whether the QR code encoding engine (Segno) tries to increase the error correction level if it does not affect the version. Error correction level is not increased when it impacts the version of the code. The `eci` option indicates if binary data which does not use the default encoding (ISO/IEC 8859-1) should enforce the ECI mode. Since a lot of QR code readers do not support the ECI mode, this feature is disabled by default and the data is encoded in the provided encoding using the usual “byte” mode. Set eci to `True` if an ECI header should be inserted into the QR Code. Note that the implementation may not know the ECI designator for the provided encoding and may raise an exception if the ECI designator cannot be found. The ECI mode is not supported by Micro QR Codes. Alternatively, you may use the `options` keyword argument with an instance of `QRCodeOptions` as value instead of listing every requested options. Here is an example of view: ```python from django.shortcuts import render from qr_code.qrcode.utils import QRCodeOptions def my_view(request): # Build context for rendering QR codes. context = dict( my_options=QRCodeOptions(size='t', border=6, error_correction='L'), ) # Render the view. return render(request, 'my_app/my_view.html', context=context) ``` and an example of template for the view above: ```htmldjango {% qr_from_text "Hello World!" options=my_options %} ``` ## Notes ### Image formats The SVG is the default image format. It is a vector image format, so it can be scaled up and down without quality loss. However, it has two drawbacks. The size is not given in pixel, which can be problematic if the design of your website relies on a fixed width (in pixels). The format is less compact than PNG and results in a larger HTML content. Note that a base64 PNG is less compressible than a SVG tag, so it might not matter that much of you use HTML compression on your web server. SVG has [broad support](http://caniuse.com/#feat=svg) now, and it will work properly on any modern web browser. ### Embedded image tag VS URL for images The tag `qr_url_from_text` has several advantages over `qr_from_text`, despite the fact that it requires a bit more of writing: * the generated HTML code does not contain heavy inline image data (lighter and cleaner content) * the generated images can be cached (served with a separate HTML request) * the HTML tag used to render the QR code is always an `` tag, which may simplify CSS handling. * the HTML tag embedding the image is not generated for you, which allows for customization of attributes (*height*, *width*) * the page can be loaded asynchronously, which improves responsiveness * you can provide links to QR codes instead of displaying them, which is not possible with `qr_from_text` One disadvantage of `qr_url_from_text` is that it increases the number of requests to the server: one request to serve the page containing the URL and another to request the image. Be aware that serving image files (which are generated on the fly) from a URL can be abused and lead to (D)DoS attack pretty easily, for instance by requesting very large QR codes from outside your application. This is the reason why the associated setting `ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER` in `QR_CODE_URL_PROTECTION` defaults to completely forbid external access to the API. Be careful when opening external access. ### QR codes caching Caching QR codes reduces CPU usage, but the usage of `qr_url_from_text` (which caching depends on) increases the number of requests to the server (one request to serve the page containing the URL and another to request the image). Moreover, be aware that the largest QR codes, in version 40 with a border of 4 modules and rendered in SVG format, have a size of ~800 KB. Be sure that your cache options are reasonable and can be supported by your server(s), especially for in-memory caching. Note that even without caching the generated QR codes, the app will return an *HTTP 304 Not Modified* status code whenever the same QR code is requested again. The URL named **`qr_code:serve_qr_code_image`** adds the `ETag` and `Last-Modified` headers to the response if the headers aren't already set, enabling *HTTP 304 Not Modified* response upon following requests. django-qr-code-4.1.0/docs/requirements.txt000066400000000000000000000002051462661477300205370ustar00rootroot00000000000000sphinx==7.3.7 sphinx-autobuild==2024.4.16 docutils==0.21.2 myst-parser[code_style,linkify,testing,rtd]==3.0.1 -r ../requirements.txt django-qr-code-4.1.0/manage.py000077500000000000000000000014471462661477300161410ustar00rootroot00000000000000#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo_site.settings") try: from django.core.management import execute_from_command_line except ImportError: # The above import may fail for some other reason. Ensure that the # issue is really that Django is missing to avoid masking other # exceptions on Python 2. try: import django except ImportError: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) raise execute_from_command_line(sys.argv) django-qr-code-4.1.0/qr_code/000077500000000000000000000000001462661477300157425ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/__init__.py000066400000000000000000000000261462661477300200510ustar00rootroot00000000000000__version__ = "4.1.0" django-qr-code-4.1.0/qr_code/apps.py000066400000000000000000000001741462661477300172610ustar00rootroot00000000000000from django.apps import AppConfig class QrCodeConfig(AppConfig): name = "qr_code" verbose_name = "Django QR Code" django-qr-code-4.1.0/qr_code/qrcode/000077500000000000000000000000001462661477300172175ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/qrcode/__init__.py000066400000000000000000000001341462661477300213260ustar00rootroot00000000000000from pydantic import ConfigDict PYDANTIC_CONFIG = ConfigDict(arbitrary_types_allowed=True) django-qr-code-4.1.0/qr_code/qrcode/constants.py000066400000000000000000000014741462661477300216130ustar00rootroot00000000000000from datetime import datetime from typing import Optional QR_CODE_GENERATION_VERSION_DATE: datetime = datetime(year=2020, month=9, day=8, hour=12) SIZE_DICT: dict = {"t": 6, "s": 12, "m": 18, "l": 30, "h": 48} ERROR_CORRECTION_DICT: dict = {"L": "l", "M": "m", "Q": "q", "H": "h"} DEFAULT_MODULE_SIZE: str | int = "m" DEFAULT_BORDER_SIZE: int = 4 DEFAULT_VERSION: Optional[int] = None DEFAULT_IMAGE_FORMAT: str = "svg" DEFAULT_ERROR_CORRECTION: str = "m" DEFAULT_ECI: bool = False DEFAULT_BOOST_ERROR: bool = True DEFAULT_ENCODING: str = "utf-8" DEFAULT_CACHE_ENABLED: bool = True DEFAULT_URL_SIGNATURE_ENABLED: bool = True ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: str = "ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER" SIGNING_KEY: str = "SIGNING_KEY" TOKEN_LENGTH: str = "TOKEN_LENGTH" SIGNING_SALT: str = "SIGNING_SALT" django-qr-code-4.1.0/qr_code/qrcode/maker.py000066400000000000000000000143171462661477300206760ustar00rootroot00000000000000"""Tools for generating QR codes. This module depends on the Segno library.""" import base64 import io from typing import Mapping, Any from django.utils.html import escape from django.utils.safestring import mark_safe import segno from pydantic import validate_call from qr_code.qrcode import PYDANTIC_CONFIG from qr_code.qrcode.constants import DEFAULT_CACHE_ENABLED, DEFAULT_URL_SIGNATURE_ENABLED from qr_code.qrcode.serve import make_qr_code_url from qr_code.qrcode.utils import QRCodeOptions @validate_call(config=PYDANTIC_CONFIG) def make_qr(data: Any, qr_code_options: QRCodeOptions, force_text: bool = True): """Creates a QR code that encodes the given `data` with the given `qr_code_options`. :param str data: The data to encode :param qr_code_options: Options to create and serialize the QR code. :param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode. :rtype: segno.QRCode """ # WARNING: For compatibility reasons, we still allow to pass __proxy__ class (lazy string). Moreover, it would be # OK to pass anything that has __str__ attribute (e.g. class instance that handles phone numbers). if force_text: return segno.make(str(data), **qr_code_options.kw_make(), mode="byte") return segno.make(data, **qr_code_options.kw_make()) @validate_call(config=PYDANTIC_CONFIG) def make_qr_code_image(data: Any, qr_code_options: QRCodeOptions, force_text: bool = True) -> bytes: """ Creates a bytes object representing a QR code image for the provided `data`. :param str data: The data to encode :param qr_code_options: Options to create and serialize the QR code. :param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode. :rtype: bytes """ qr = make_qr(data, qr_code_options, force_text=force_text) out = io.BytesIO() qr.save(out, **qr_code_options.kw_save()) return out.getvalue() @validate_call(config=PYDANTIC_CONFIG) def make_embedded_qr_code( data: Any, qr_code_options: QRCodeOptions, force_text: bool = True, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, ) -> str: """ Generates a or tag representing the QR code for the given `data`. This tag can be embedded into an HTML document. When `image_format` is SVG and `use_data_uri_for_svg` it True, a base64 encoded image data URI is produced instead of inline SVG path. The `alt_text` argument indicates the value of the alternative text embedded in the `alt` attribute of the returned image tag. When set to `None`, the alternative text is set to the string representation of data. The alternative text is automatically escaped. You may use an empty string to explicitly set an empty alternative text. The `class_names` argument indicates the value of the `class` attribute of the returned image tag. When set to `None` or empty, the class attribute is not set. """ qr = make_qr(data, qr_code_options, force_text=force_text) kw = qr_code_options.kw_save() # Pop the image format from the keywords since qr.png_data_uri / qr.svg_inline # set it automatically kw.pop("kind") if alt_text is None and (use_data_uri_for_svg or qr_code_options.image_format == "png"): if isinstance(data, bytes): alt_text = "" encodings = ["utf-8", "iso-8859-1", "shift-jis"] if qr_code_options.encoding: ei = encodings.index(qr_code_options.encoding) if ei > 0: encodings[ei] = encodings[0] encodings[0] = qr_code_options.encoding for e in encodings: try: alt_text = data.decode(e) break except UnicodeDecodeError: pass elif not isinstance(data, str): alt_text = str(data) else: alt_text = data if class_names: class_attr = f' class="{class_names}"' else: class_attr = "" if qr_code_options.image_format == "png": return mark_safe(f'{escape(alt_text)}') if use_data_uri_for_svg: out = io.BytesIO() qr.save(out, **qr_code_options.kw_save()) svg_path = out.getvalue() svg_b64_data = base64.b64encode(svg_path).decode("utf-8") html = f'{escape(alt_text)}' return mark_safe(html) else: return mark_safe(qr.svg_inline(**kw)) def make_qr_code_with_args( data: Any, qr_code_args: dict, force_text: bool = True, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, ) -> str: options = _options_from_args(qr_code_args) return make_embedded_qr_code( data, options, force_text=force_text, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names ) def make_qr_code_url_with_args(data: Any, qr_code_args: dict, force_text: bool = True) -> str: cache_enabled = qr_code_args.pop("cache_enabled", DEFAULT_CACHE_ENABLED) if not isinstance(cache_enabled, bool): cache_enabled = not cache_enabled == "False" url_signature_enabled = qr_code_args.pop("url_signature_enabled", DEFAULT_URL_SIGNATURE_ENABLED) if not isinstance(url_signature_enabled, bool): url_signature_enabled = not url_signature_enabled == "False" options = _options_from_args(qr_code_args) return make_qr_code_url(data, options, force_text=force_text, cache_enabled=cache_enabled, url_signature_enabled=url_signature_enabled) def _options_from_args(args: Mapping) -> QRCodeOptions: """Returns a QRCodeOptions instance from the provided arguments.""" options = args.get("options") if options: if not isinstance(options, QRCodeOptions): raise TypeError("The options argument must be of type QRCodeOptions.") else: # Convert the string "None" into None kw = {k: v if v != "None" else None for k, v in args.items()} options = QRCodeOptions(**kw) return options django-qr-code-4.1.0/qr_code/qrcode/serve.py000066400000000000000000000165611462661477300207260ustar00rootroot00000000000000import base64 import urllib.parse from collections.abc import Mapping from datetime import datetime from typing import Optional, Any from django.conf import settings from django.contrib.auth.models import AnonymousUser, User from django.core.signing import Signer from django.urls import reverse from django.utils.crypto import get_random_string from django.utils.encoding import force_str from django.utils.safestring import mark_safe from pydantic import validate_call from qr_code.qrcode import constants, PYDANTIC_CONFIG from qr_code.qrcode.utils import QRCodeOptions def _get_default_url_protection_options() -> dict: return { constants.TOKEN_LENGTH: 20, constants.SIGNING_KEY: settings.SECRET_KEY, constants.SIGNING_SALT: "qr_code_url_protection_salt", constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER: False, } def _get_url_protection_settings() -> Optional[Mapping]: if hasattr(settings, "QR_CODE_URL_PROTECTION") and isinstance(settings.QR_CODE_URL_PROTECTION, Mapping): return settings.QR_CODE_URL_PROTECTION return None def _options_allow_external_request(url_protection_options: Mapping, user: User | AnonymousUser | None) -> bool: # Evaluate the callable if required. if callable(url_protection_options[constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER]): allows_external_request = url_protection_options[constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER](user or AnonymousUser()) elif url_protection_options[constants.ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER] is True: allows_external_request = user and user.pk and user.is_authenticated else: allows_external_request = False return allows_external_request def requires_url_protection_token(user: User | AnonymousUser | None = None) -> bool: return not _options_allow_external_request(get_url_protection_options(), user) def allows_external_request_from_user(user: User | AnonymousUser | None = None) -> bool: return _options_allow_external_request(get_url_protection_options(), user) def get_url_protection_options() -> dict: options = _get_default_url_protection_options() settings_options = _get_url_protection_settings() if settings_options is not None: options.update(settings.QR_CODE_URL_PROTECTION) return options def _make_random_token() -> str: url_protection_options = get_url_protection_options() return get_random_string(url_protection_options[constants.TOKEN_LENGTH]) _RANDOM_TOKEN = _make_random_token() def get_qr_url_protection_signed_token(qr_code_options: QRCodeOptions): """Generate a signed token to handle view protection.""" url_protection_options = get_url_protection_options() signer = Signer(key=url_protection_options[constants.SIGNING_KEY], salt=url_protection_options[constants.SIGNING_SALT]) token = signer.sign(get_qr_url_protection_token(qr_code_options, _RANDOM_TOKEN)) return token def get_qr_url_protection_token(qr_code_options, random_token): """ Generate a random token for the QR code image. The token contains image attributes so that a user cannot use a token provided somewhere on a website to generate bigger QR codes. The random_token part ensures that the signed token is not predictable. """ return ".".join( list( map( str, ( qr_code_options.size, qr_code_options.border, qr_code_options.version or "", qr_code_options.image_format, qr_code_options.error_correction, random_token, ), ) ) ) def qr_code_etag(request) -> str: return f'"{request.path}:{request.GET.urlencode()}:version_{constants.QR_CODE_GENERATION_VERSION_DATE.isoformat()}"' def qr_code_last_modified(_request) -> datetime: return constants.QR_CODE_GENERATION_VERSION_DATE @validate_call(config=PYDANTIC_CONFIG) def make_qr_code_url( data: Any, qr_code_options: Optional[QRCodeOptions] = None, force_text: bool = True, cache_enabled: Optional[bool] = None, url_signature_enabled: Optional[bool] = None, ) -> str: """Build an URL to a view that handle serving QR code image from the given parameters. Any invalid argument related to the size or the format of the image is silently converted into the default value for that argument. :param str data: Data to encode into a QR code. :param QRCodeOptions qr_code_options: The rendering options for the QR code. :param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode. :param bool cache_enabled: Allows to skip caching the QR code (when set to *False*) when caching has been enabled. :param bool url_signature_enabled: Tells whether the random token for protecting the URL against external requests is added to the returned URL. It defaults to *True*. """ qr_code_options = QRCodeOptions() if qr_code_options is None else qr_code_options if url_signature_enabled is None: url_signature_enabled = constants.DEFAULT_URL_SIGNATURE_ENABLED if cache_enabled is None: cache_enabled = constants.DEFAULT_CACHE_ENABLED cache_enabled_arg = 1 if cache_enabled else 0 if force_text: encoded_data = str(base64.b64encode(force_str(data).encode("utf-8")), encoding="utf-8") params = dict(text=encoded_data, cache_enabled=cache_enabled_arg) elif isinstance(data, int): params = dict(int=data, cache_enabled=cache_enabled_arg) else: if isinstance(data, str): b64data = base64.b64encode(force_str(data).encode("utf-8")) else: b64data = base64.b64encode(data) encoded_data = str(b64data, encoding="utf-8") params = dict(bytes=encoded_data, cache_enabled=cache_enabled_arg) # Only add non-default values to the params dict if qr_code_options.size != constants.DEFAULT_MODULE_SIZE: params["size"] = qr_code_options.size if qr_code_options.border != constants.DEFAULT_BORDER_SIZE: params["border"] = qr_code_options.border if qr_code_options.version != constants.DEFAULT_VERSION: params["version"] = qr_code_options.version if qr_code_options.image_format != constants.DEFAULT_IMAGE_FORMAT: params["image_format"] = qr_code_options.image_format if qr_code_options.error_correction != constants.DEFAULT_ERROR_CORRECTION: params["error_correction"] = qr_code_options.error_correction if qr_code_options.micro: params["micro"] = 1 if qr_code_options.eci: params["eci"] = 1 if qr_code_options.boost_error: params["boost_error"] = 1 params["encoding"] = qr_code_options.encoding if qr_code_options.encoding else "" params.update(qr_code_options.color_mapping()) path = reverse("qr_code:serve_qr_code_image") if url_signature_enabled: # Generate token to handle view protection. The token is added to the query arguments. It does not replace # existing plain data query arguments in order to allow usage of the URL as an API (without token since external # users cannot generate the signed token!). token = get_qr_url_protection_signed_token(qr_code_options) params["token"] = token url = f"{path}?{urllib.parse.urlencode(params)}" return mark_safe(url) django-qr-code-4.1.0/qr_code/qrcode/utils.py000066400000000000000000001116621462661477300207400ustar00rootroot00000000000000"""Utility classes and functions for configuring and setting up the content and the look of a QR code.""" import datetime import decimal from collections import namedtuple from dataclasses import asdict from datetime import date from decimal import Decimal from enum import Enum from typing import Optional, Any, Union, Sequence, List, Tuple import zoneinfo from django.utils.html import escape from pydantic import validate_call from pydantic.dataclasses import dataclass as pydantic_dataclass from qr_code.qrcode.constants import DEFAULT_MODULE_SIZE, SIZE_DICT, DEFAULT_ERROR_CORRECTION, DEFAULT_IMAGE_FORMAT from segno import helpers class QRCodeOptions: """ Represents the options used to create and draw a QR code. """ @validate_call def __init__( self, size: Union[int, float, str, Decimal, None] = DEFAULT_MODULE_SIZE, border: int = 4, version: Union[int, str, None] = None, image_format: str = "svg", error_correction: str = DEFAULT_ERROR_CORRECTION, encoding: Optional[str] = "utf-8", boost_error: bool = True, micro: bool = False, eci: bool = False, dark_color: Union[tuple, str, bool, None] = "black", light_color: Union[tuple, str, bool, None] = "white", finder_dark_color: Union[tuple, str, bool, None] = False, finder_light_color: Union[tuple, str, bool, None] = False, data_dark_color: Union[tuple, str, bool, None] = False, data_light_color: Union[tuple, str, bool, None] = False, version_dark_color: Union[tuple, str, bool, None] = False, version_light_color: Union[tuple, str, bool, None] = False, format_dark_color: Union[tuple, str, bool, None] = False, format_light_color: Union[tuple, str, bool, None] = False, alignment_dark_color: Union[tuple, str, bool, None] = False, alignment_light_color: Union[tuple, str, bool, None] = False, timing_dark_color: Union[tuple, str, bool, None] = False, timing_light_color: Union[tuple, str, bool, None] = False, separator_color: Union[tuple, str, bool, None] = False, dark_module_color: Union[tuple, str, bool, None] = False, quiet_zone_color: Union[tuple, str, bool, None] = False, ) -> None: """ :param size: The size of the QR code as an integer, float, Decimal or a string. Default is *'m'*. :type: str, int, float or Decimal :param int border: The size of the border (blank space around the code). :param version: The version of the QR code gives the size of the matrix. Default is *None* which mean automatic in order to avoid data overflow. :param version: QR Code version. If the value is ``None`` (default), the minimal version which fits for the input data will be used. Valid values: "M1", "M2", "M3", "M4" (for Micro QR codes) or an integer between 1 and 40 (for QR codes). The `version` parameter is case insensitive. :type version: int, str or None :param str image_format: The graphics format used to render the QR code. It can be either *'svg'* or *'png'*. Default is *'svg'*. :param str error_correction: How much error correction that might be required to read the code. It can be either *'L'*, *'M'*, *'Q'*, or *'H'*. Default is *'M'*. :param bool boost_error: Tells whether the QR code encoding engine tries to increase the error correction level if it does not affect the version. Error correction level is not increased when it impacts the version of the code. :param bool micro: Indicates if a Micro QR Code should be created. Default: False :param encoding: Indicates the encoding in mode "byte". By default `encoding` is ``UTF-8``. When set to ``None``, the implementation tries to use the standard conform ISO/IEC 8859-1 encoding and if it does not fit, it will use UTF-8. Note that no ECI mode indicator is inserted by default (see ``eci``). The `encoding` parameter is case-insensitive. :type encoding: str or None :param bool eci: Indicates if binary data which does not use the default encoding (ISO/IEC 8859-1) should enforce the ECI mode. Since a lot of QR code readers do not support the ECI mode, this feature is disabled by default and the data is encoded in the provided `encoding` using the usual "byte" mode. Set ``eci`` to ``True`` if an ECI header should be inserted into the QR Code. Note that the implementation may not know the ECI designator for the provided `encoding` and may raise an exception if the ECI designator cannot be found. The ECI mode is not supported by Micro QR Codes. :param dark_color: Color of the dark modules (default: black). The color can be provided as ``(R, G, B)`` tuple, as hexadecimal format (``#RGB``, ``#RRGGBB`` ``RRGGBBAA``), or web color name (i.e. ``red``). If alpha transparency is supported (i.e. PNG and SVG), hexadecimal values like #RRGGBBAA are accepted. :param light_color: Color of the light modules (default: transparent). See `color` for valid values. If light is set to ``None`` the light modules will be transparent. :param finder_dark_color: Color of the dark finder modules (default: same as ``dark_color``) :param finder_light_color: Color of the light finder modules (default: same as ``light_color``) :param data_dark_color: Color of the dark data modules (default: same as ``dark_color``) :param data_light_color: Color of the light data modules (default: same as ``light_color``) :param version_dark_color: Color of the dark version modules (default: same as ``dark_color``) :param version_light_color: Color of the light version modules (default: same as ``light_color``) :param format_dark_color: Color of the dark format modules (default: same as ``dark_color``) :param format_light_color: Color of the light format modules (default: same as ``light_color``) :param alignment_dark_color: Color of the dark alignment modules (default: same as ``dark_color``) :param alignment_light_color: Color of the light alignment modules (default: same as ``light_color``) :param timing_dark_color: Color of the dark timing pattern modules (default: same as ``dark_color``) :param timing_light_color: Color of the light timing pattern modules (default: same as ``light_color``) :param separator_color: Color of the separator (default: same as ``light_color``) :param dark_module_color: Color of the dark module (default: same as ``dark_color``) :param quiet_zone_color: Color of the quiet zone modules (default: same as ``light_color``) The *size* parameter gives the size of each module of the QR code matrix. It can be either a positive integer or one of the following letters: * t or T: tiny (value: 6) * s or S: small (value: 12) * m or M: medium (value: 18) * l or L: large (value: 30) * h or H: huge (value: 48) For PNG image format the size unit is in pixels, while the unit is 0.1 mm for SVG format. The *border* parameter controls how many modules thick the border should be (blank space around the code). The default is 4, which is the minimum according to the specs. The *version* parameter is an integer from 1 to 40 that controls the size of the QR code matrix. Set to None to determine this automatically. The smallest, version 1, is a 21 x 21 matrix. The biggest, version 40, is 177 x 177 matrix. The size grows by 4 modules/side. For Micro QR codes, valid values are "M1", "M2", "M3", "M4". There are 4 error correction levels used for QR codes, with each one adding different amounts of "backup" data depending on how much damage the QR code is expected to suffer in its intended environment, and hence how much error correction may be required. The correction level can be configured with the *error_correction* parameter as follow: * l or L: error correction level L – up to 7% damage * m or M: error correction level M – up to 15% damage * q or Q: error correction level Q – up to 25% damage * h or H: error correction level H – up to 30% damage You may enforce the creation of a Micro QR Code with `micro=True`. The `micro` option defaults to `False`. The `encoding` option controls the text encoding used in mode "byte" (used for any general text content). By default `encoding` is ``UTF-8``. When set to ``None``, the implementation (based on Segno) tries to use the standard conform ISO/IEC 8859-1 encoding and if it does not fit, it will use UTF-8. Note that no ECI mode indicator is inserted by default (see `eci` option). The `encoding` parameter is case-insensitive. The `boost_error` indicates whether the QR code encoding engine (Segno) tries to increase the error correction level if it does not affect the version. Error correction level is not increased when it impacts the version of the code. The `eci` option indicates if binary data which does not use the default encoding (ISO/IEC 8859-1) should enforce the ECI mode. Since a lot of QR code readers do not support the ECI mode, this feature is disabled by default and the data is encoded in the provided encoding using the usual “byte” mode. Set eci to `True` if an ECI header should be inserted into the QR Code. Note that the implementation may not know the ECI designator for the provided encoding and may raise an exception if the ECI designator cannot be found. The ECI mode is not supported by Micro QR Codes. :raises: TypeError in case an unknown argument is given. """ self._size = size self._border = int(border) if _can_be_cast_to_int(version): version = int(version) # type: ignore if not 1 <= version <= 40: version = None elif version in ("m1", "m2", "m3", "m4", "M1", "M2", "M3", "M4"): version = version.lower() # type: ignore # Set / change the micro setting otherwise Segno complains about # conflicting parameters micro = True else: version = None self._version = version # if not isinstance(micro, bool): # micro = micro == 'True' self._micro = micro # if not isinstance(eci, bool): # eci = eci == 'True' self._eci = eci try: error = error_correction.lower() self._error_correction = error if error in ("l", "m", "q", "h") else DEFAULT_ERROR_CORRECTION except AttributeError: self._error_correction = DEFAULT_ERROR_CORRECTION self._boost_error = boost_error # Handle encoding self._encoding = None if encoding == "" else encoding try: image_format = image_format.lower() self._image_format = image_format if image_format in ("svg", "png") else DEFAULT_IMAGE_FORMAT except AttributeError: self._image_format = DEFAULT_IMAGE_FORMAT self._colors = dict( dark_color=dark_color, light_color=light_color, finder_dark_color=finder_dark_color, finder_light_color=finder_light_color, data_dark_color=data_dark_color, data_light_color=data_light_color, version_dark_color=version_dark_color, version_light_color=version_light_color, format_dark_color=format_dark_color, format_light_color=format_light_color, alignment_dark_color=alignment_dark_color, alignment_light_color=alignment_light_color, timing_dark_color=timing_dark_color, timing_light_color=timing_light_color, separator_color=separator_color, dark_module_color=dark_module_color, quiet_zone_color=quiet_zone_color, ) def kw_make(self): """Internal method which returns a dict of parameters to create a QR code. :rtype: dict """ return dict( version=self._version, error=self._error_correction, micro=self._micro, eci=self._eci, boost_error=self._boost_error, encoding=self._encoding, ) def kw_save(self): """Internal method which returns a dict of parameters to save a QR code. :rtype: dict """ image_format = self._image_format kw = dict(border=self.border, kind=image_format, scale=self._size_as_number()) # Change the color mapping into the keywords Segno expects # (remove the "_color" suffix from the module names) kw.update({k[:-6]: v for k, v in self.color_mapping().items()}) if image_format == "svg": kw["unit"] = "mm" scale = decimal.Decimal(kw["scale"]) / 10 kw["scale"] = scale return kw def color_mapping(self): """Internal method which returns the color mapping. Only non-default values are returned. :rtype: d """ colors = {k: v for k, v in self._colors.items() if v is not False} return colors def _size_as_number(self) -> Union[int, float, str, Decimal]: """Returns the size as integer value. :rtype: int or float """ size = self._size if _can_be_cast_to_int(size): actual_size = int(size) # type: ignore if actual_size < 1: actual_size = SIZE_DICT[DEFAULT_MODULE_SIZE] elif isinstance(size, (float, Decimal)): actual_size = size # type: ignore if actual_size < Decimal("0.01"): actual_size = SIZE_DICT[DEFAULT_MODULE_SIZE] elif isinstance(size, str): actual_size = SIZE_DICT.get(size.lower(), DEFAULT_MODULE_SIZE) else: actual_size = SIZE_DICT[DEFAULT_MODULE_SIZE] return actual_size @property def size(self): return self._size @property def border(self): return self._border @property def version(self): return self._version @property def image_format(self): return self._image_format @property def error_correction(self): return self._error_correction @property def boost_error(self): return self._boost_error @property def micro(self): return self._micro @property def encoding(self): return self._encoding @property def eci(self): return self._eci def _can_be_cast_to_int(value: Any) -> bool: return isinstance(value, int) or (isinstance(value, str) and value.isdigit()) class EventClass(Enum): PUBLIC = 1 PRIVATE = 2 CONFIDENTIAL = 3 class EventStatus(Enum): TENTATIVE = 1 CONFIRMED = 2 CANCELLED = 3 class EventTransparency(Enum): OPAQUE = 1 TRANSPARENT = 2 @pydantic_dataclass class VEvent: """ Data for representing VEVENT for iCalendar (.ics) event. Only a subset of https://icalendar.org/iCalendar-RFC-5545/3-6-1-event-component.html is supported. Fields meaning: * uid: Event identifier * summary: This property defines a short summary or subject for the calendar event. * start: Start of event * end: End of event * dtstamp: The property indicates the date/time that the instance of the iCalendar object was created. Defaults to current time in UTC. * description: This property provides a more complete description of the calendar component, than that provided by the "SUMMARY" property. * organizer: E-mail of organizer * status: Status of event * location: Location of event * geo: This property specifies information related to the global position of event. The property value specifies latitude and longitude, in that order. Whole degrees of latitude shall be represented by a two-digit decimal number ranging from -90 through 90. The longitude represents the location east or west of the prime meridian as a positive or negative real number, respectively (a decimal number ranging from -180 through 180). * event_class: Either PUBLIC, PRIVATE or CONFIDENTIAL (see `utils.EventClass`). * categories: This property defines the categories for calendar event. * transparency: Tell whether the event can have its Time Transparency set to "TRANSPARENT" in order to prevent blocking of the event in searches for busy time. * url: This property defines a Uniform Resource Locator (URL) associated with the iCalendar object. """ uid: str summary: str start: datetime.datetime end: datetime.datetime dtstamp: Optional[datetime.datetime] = None description: Optional[str] = None organizer: Optional[str] = None status: Optional[EventStatus] = None location: Optional[str] = None geo: Optional[Tuple[float, float]] = None event_class: Optional[EventClass] = None categories: Optional[List[str]] = None transparency: Optional[EventTransparency] = None url: Optional[str] = None def make_qr_code_data(self) -> str: """\ Creates a string encoding the event information. Only a subset of https://icalendar.org/iCalendar-RFC-5545/3-6-1-event-component.html is supported. """ # Inspired form icalendar: https://github.com/collective/icalendar/ def fold_icalendar_line(text, limit=75, fold_sep="\r\n "): """Make a string folded as defined in RFC5545 Lines of text SHOULD NOT be longer than 75 octets, excluding the line break. Long content lines SHOULD be split into a multiple line representations using a line "folding" technique. That is, a long line can be split between any two characters by inserting a CRLF immediately followed by a single linear white-space character (i.e., SPACE or HTAB). """ new_text = "" for line in text.split("\n"): # Use a fast and simple variant for the common case that line is all ASCII. try: line.encode("ascii") except (UnicodeEncodeError, UnicodeDecodeError): ret_chars = [] byte_count = 0 for char in line: char_byte_len = len(char.encode("utf-8")) byte_count += char_byte_len if byte_count >= limit: ret_chars.append(fold_sep) byte_count = char_byte_len ret_chars.append(char) new_text += "".join(ret_chars) else: new_text += fold_sep.join(line[i : i + limit - 1] for i in range(0, len(line), limit - 1)) return new_text # Source form icalendar: https://github.com/collective/icalendar/ def escape_char(text): """Format value according to iCalendar TEXT escaping rules.""" # NOTE: ORDER MATTERS! return ( text.replace(r"\N", "\n") .replace("\\", "\\\\") .replace(";", r"\;") .replace(",", r"\,") .replace("\r\n", r"\n") .replace("\n", r"\n") ) def is_naive_datetime(t) -> bool: return t.tzinfo is None or t.tzinfo.utcoffset(t) is None def get_datetime_str(t) -> str: if is_naive_datetime(t): return t.strftime("%Y%m%dT%H%M%S") else: t_utc = t.astimezone(zoneinfo.ZoneInfo("UTC")) return t_utc.strftime("%Y%m%dT%H%M%SZ") event_str = f"""BEGIN:VCALENDAR PRODID:Django QR Code VERSION:2.0 BEGIN:VEVENT DTSTAMP:{(self.dtstamp or datetime.datetime.utcnow()).astimezone(zoneinfo.ZoneInfo('UTC')).strftime("%Y%m%dT%H%M%SZ")} UID:{self.uid} DTSTART:{get_datetime_str(self.start)} DTEND:{get_datetime_str(self.end)} SUMMARY:{escape_char(self.summary)}""" if self.event_class: event_str += f"\nCLASS:{self.event_class.name}" if self.categories: event_str += "\n" + fold_icalendar_line(f"CATEGORIES:{','.join(map(escape_char, self.categories))}") if self.transparency: event_str += f"\nTRANSP:{self.transparency.name}" if self.description: event_str += "\n" + fold_icalendar_line(f"DESCRIPTION:{escape_char(self.description)}") if self.organizer: event_str += f"\nORGANIZER:MAILTO:{self.organizer}" if self.status: event_str += f"\nSTATUS:{self.status.name}" if self.location: event_str += "\n" + fold_icalendar_line(f"LOCATION:{escape_char(self.location)}") if self.geo: event_str += f"\nGEO:{self.geo[0]};{self.geo[1]}" if self.url: event_str += f"\nURL:{self.url}" event_str += "\nEND:VEVENT\nEND:VCALENDAR" # print(event_str) return event_str @pydantic_dataclass class EpcData: """ Data for representing an European Payments Council Quick Response Code (EPC QR Code) version 002. You must always use the error correction level "M" and utilizes max. version 13 to fulfill the constraints of the EPC QR Code standard. .. note:: Either the ``text`` or ``reference`` must be provided but not both .. note:: Neither the IBAN, BIC, nor remittance reference number or any other information is validated (aside from checks regarding the allowed string lengths). Fields meaning: * name: Name of the recipient. * iban: International Bank Account Number (IBAN) * amount: The amount to transfer. The currency is always Euro, no other currencies are supported. * text: Remittance Information (unstructured) * reference: Remittance Information (structured) * bic: Bank Identifier Code (BIC). Optional, only required for non-EEA countries. * purpose: SEPA purpose code. """ name: str iban: str amount: Union[int, float, decimal.Decimal] text: Optional[str] = None reference: Optional[str] = None bic: Optional[str] = None purpose: Optional[str] = None def make_qr_code_data(self) -> str: """ Validates the input and creates the data for an European Payments Council Quick Response Code (EPC QR Code) version 002. This is a wrapper for :py:func:`segno.helpers._make_epc_qr_data` with no choice for encoding. :rtype: str """ return helpers._make_epc_qr_data(**asdict(self), encoding=1) # type: ignore class ContactDetail: """ Represents the detail of a contact for MeCARD encoding. .. note:: This is a legacy class. Please use :py:class:`MeCard` instead for new projects. Fields meaning: * first_name * last_name * first_name_reading: the sound of the first name. * last_name_reading: the sound of the last name. * tel: the phone number, it can appear multiple times. * tel_av: the video-phone number, it can appear multiple times. * email: the email address, it can appear multiple times. * memo: notes. * birthday: the birth date (Python date). * address: the fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order. * url: homepage URL. * nickname: display name. * org: organization or company name (non-standard,but often recognized, ORG field). """ @validate_call def __init__( self, first_name: Optional[str] = None, last_name: Optional[str] = None, first_name_reading: Optional[str] = None, last_name_reading: Optional[str] = None, tel: Optional[str] = None, tel_av: Optional[str] = None, email: Optional[str] = None, memo: Optional[str] = None, birthday: Optional[date] = None, address: Optional[str] = None, url: Optional[str] = None, nickname: Optional[str] = None, org: Optional[str] = None, ): self.first_name = first_name self.last_name = last_name self.first_name_reading = first_name_reading self.last_name_reading = last_name_reading self.tel = tel self.tel_av = tel_av self.email = email self.memo = memo self.birthday = birthday self.address = address self.url = url self.nickname = nickname self.org = org def make_qr_code_data(self) -> str: """ Make a text for configuring a contact in a phone book. The MeCARD format is used, with an optional, non-standard (but often recognized) ORG field. See this archive of the format specifications: https://web.archive.org/web/20160304025131/https://www.nttdocomo.co.jp/english/service/developer/make/content/barcode/function/application/addressbook/index.html :return: the MeCARD contact description. """ # See this for an archive of the format specifications: # https://web.archive.org/web/20160304025131/https://www.nttdocomo.co.jp/english/service/developer/make/content/barcode/function/application/addressbook/index.html contact_text = "MECARD:" for name_components_pair in ( ("N:%s;", (_escape_mecard_special_chars(self.last_name), _escape_mecard_special_chars(self.first_name))), ("SOUND:%s;", (_escape_mecard_special_chars(self.last_name_reading), _escape_mecard_special_chars(self.first_name_reading))), ): if name_components_pair[1][0] and name_components_pair[1][1]: name = "%s,%s" % name_components_pair[1] else: name = name_components_pair[1][0] or name_components_pair[1][1] or "" if name: contact_text += name_components_pair[0] % name if self.tel: contact_text += "TEL:%s;" % _escape_mecard_special_chars(self.tel) if self.tel_av: contact_text += "TEL-AV:%s;" % _escape_mecard_special_chars(self.tel_av) if self.email: contact_text += "EMAIL:%s;" % _escape_mecard_special_chars(self.email) if self.memo: contact_text += "NOTE:%s;" % _escape_mecard_special_chars(self.memo) if self.birthday: # Format date to YYMMDD. contact_text += "BDAY:%s;" % self.birthday.strftime("%Y%m%d") if self.address: contact_text += "ADR:%s;" % self.address if self.url: contact_text += "URL:%s;" % _escape_mecard_special_chars(self.url) if self.nickname: contact_text += "NICKNAME:%s;" % _escape_mecard_special_chars(self.nickname) # Not standard, but recognized by several readers. if self.org: contact_text += "ORG:%s;" % _escape_mecard_special_chars(self.org) contact_text += ";" return contact_text def escaped_value(self, field_name: str): return _escape_mecard_special_chars(getattr(self, field_name)) @pydantic_dataclass class MeCard: """Represents the detail of a contact for MeCARD encoding. Fields meaning: * name: Name. If it contains a comma, the first part is treated as lastname and the second part is treated as forename. * reading: Designates a text string to be set as the kana name in the phonebook * email: E-mail address. Multiple values are allowed. * phone: Phone number. Multiple values are allowed. * videophone: Phone number for video calls. Multiple values are allowed. * memo: A notice for the contact. * nickname: Nickname. * birthday: Birthday. If a string is provided, it should encode the date as YYYYMMDD value. * url: Homepage. Multiple values are allowed. * pobox: P.O. box (address information). * roomno: Room number (address information). * houseno: House number (address information). * city: City (address information). * prefecture: Prefecture (address information). * zipcode: Zip code (address information). * country: Country (address information). * org: organization or company name (ORG field, non-standard,but often recognized by readers). """ name: str reading: Optional[str] = None email: Union[str, Sequence[str], None] = None phone: Union[str, Sequence[str], None] = None videophone: Union[str, Sequence[str], None] = None memo: Optional[str] = None nickname: Optional[str] = None birthday: Union[str, datetime.date, None] = None url: Union[str, Sequence[str], None] = None pobox: Optional[str] = None roomno: Optional[str] = None houseno: Optional[str] = None city: Optional[str] = None prefecture: Optional[str] = None zipcode: Union[int, str, None] = None country: Optional[str] = None org: Optional[str] = None def make_qr_code_data(self) -> str: """\ Creates a string encoding the contact information as MeCARD. :rtype: str """ kw = asdict(self) if self.zipcode is not None and self.zipcode != "": kw["zipcode"] = str(self.zipcode) org = kw.pop("org") contact_text = helpers.make_mecard_data(**kw) # Not standard, but recognized by several readers. if org: contact_text += f"ORG:{_escape_mecard_special_chars(org)};" return contact_text @pydantic_dataclass class VCard: """Represents the detail of a contact for vCard encoding. Creates a QR code which encodes a `vCard `_ version 3.0. Only a subset of available `vCard 3.0 properties ` is supported. Fields meaning: name: The name. If it contains a semicolon, the first part is treated as lastname and the second part is treated as forename. displayname: Common name. email: E-mail address. Multiple values are allowed. phone: Phone number. Multiple values are allowed. fax: Fax number. Multiple values are allowed. videophone: Phone number for video calls. Multiple values are allowed. memo: A notice for the contact. nickname: Nickname. birthday: Birthday. If a string is provided, it should encode the date as ``YYYY-MM-DD`` value. url: Homepage. Multiple values are allowed. pobox: P.O. box (address information). street: Street address. city: City (address information). region: Region (address information). zipcode: Zip code (address information). country: Country (address information). org: Company / organization name. lat: Latitude. lng: Longitude. source: URL where to obtain the vCard. rev: Revision of the vCard / last modification date. title: Job Title. Multiple values are allowed. photo_uri: Photo URI. Multiple values are allowed. cellphone: Cell phone number. Multiple values are allowed. homephone: Home phone number. Multiple values are allowed. workphone: Work phone number. Multiple values are allowed. """ name: str displayname: Optional[str] = None email: Union[str, Sequence[str], None] = None phone: Union[str, Sequence[str], None] = None fax: Union[str, Sequence[str], None] = None videophone: Union[str, Sequence[str], None] = None memo: Optional[str] = None nickname: Optional[str] = None birthday: Union[str, datetime.date, None] = None url: Union[str, Sequence[str], None] = None pobox: Optional[str] = None street: Optional[str] = None city: Optional[str] = None region: Optional[str] = None zipcode: Union[int, str, None] = None country: Optional[str] = None org: Optional[str] = None lat: Optional[float] = None lng: Optional[float] = None source: Optional[str] = None rev: Union[str, datetime.date, None] = None title: Union[str, Sequence[str], None] = None photo_uri: Union[str, Sequence[str], None] = None cellphone: Union[str, Sequence[str], None] = None homephone: Union[str, Sequence[str], None] = None workphone: Union[str, Sequence[str], None] = None def __post_init__(self): if self.displayname is None: self.displayname = self.name.replace(" ; ", " ").replace("; ", " ").replace(";", " ") def make_qr_code_data(self) -> str: """\ Creates a string encoding the contact information as vCard 3.0. Only a subset of available `vCard 3.0 properties ` is supported. :rtype: str """ kw = asdict(self) kw["zipcode"] = str(self.zipcode) return helpers.make_vcard_data(**kw) @pydantic_dataclass class WifiConfig: """\ Represents a WI-FI configuration. Fields meaning: * ssid: the name of the SSID * authentication: the authentication type for the SSID; can be AUTHENTICATION.wep or AUTHENTICATION.wpa, or AUTHENTICATION.nopass for no password. Or, omit for no password. * password: the password, ignored if "authentication" is 'nopass' (in which case it may be omitted). * hidden: tells whether the SSID is hidden or not; can be True or False. """ AUTHENTICATION = namedtuple("AUTHENTICATION", "nopass WEP WPA")._make(range(3)) # type: ignore AUTHENTICATION_CHOICES = ((AUTHENTICATION.nopass, "nopass"), (AUTHENTICATION.WEP, "WEP"), (AUTHENTICATION.WPA, "WPA")) ssid: str = "" authentication: int = AUTHENTICATION.nopass password: str = "" hidden: bool = False def make_qr_code_data(self) -> str: """ Make a text for configuring a Wi-Fi connexion. The syntax is inspired by the MeCARD format used for contacts. :return: the WI-FI configuration text that can be translated to a QR code. :rtype: str """ wifi_config = "WIFI:" if self.ssid: wifi_config += "S:%s;" % _escape_mecard_special_chars(self.ssid) if self.authentication: wifi_config += "T:%s;" % WifiConfig.AUTHENTICATION_CHOICES[self.authentication][1] if self.password: wifi_config += "P:%s;" % _escape_mecard_special_chars(self.password) if self.hidden: wifi_config += "H:%s;" % str(self.hidden).lower() wifi_config += ";" return wifi_config @pydantic_dataclass class Coordinates: """\ Represents a set of coordinates with an optional altitude. Fields meaning: * latitude: The latitude. * longitude: The longitude. * altitude: The optional altitude. """ latitude: float longitude: float altitude: Optional[Union[int, float]] = None def __str__(self) -> str: if self.altitude: return f"latitude: {self.latitude}, longitude: {self.longitude}, altitude: {self.altitude}" return f"latitude: {self.latitude}, longitude: {self.longitude}" def float_to_str(self, f): return f"{f:.8f}".rstrip("0") def make_geolocation_text(self) -> str: geo = f"geo:{self.float_to_str(self.latitude)},{self.float_to_str(self.longitude)}" if self.altitude: return f"{geo},{self.float_to_str(self.altitude)}" return geo def make_google_maps_text(self) -> str: geo = f"https://maps.google.com/local?q={self.float_to_str(self.latitude)},{self.float_to_str(self.longitude)}" if self.altitude: return f"{geo},{self.float_to_str(self.altitude)}" return geo def make_tel_text(phone_number: Any) -> str: return "tel:%s" % phone_number def make_sms_text(phone_number: Any) -> str: return "sms:%s" % phone_number def make_youtube_text(video_id: str) -> str: return f"https://www.youtube.com/watch/?v={escape(video_id)}" def make_google_play_text(package_id: str) -> str: return f"https://play.google.com/store/apps/details?id={escape(package_id)}" @pydantic_dataclass class Email: """Represents the data of an e-mail. Fields meaning: * to: The email address (recipient). Multiple values are allowed. * cc: The carbon copy recipient. Multiple values are allowed. * bcc: The blind carbon copy recipient. Multiple values are allowed. * subject: The subject. * body: The message body. """ to: Union[str, Sequence[str]] cc: Union[str, Sequence[str], None] = None bcc: Union[str, Sequence[str], None] = None subject: Optional[str] = None body: Optional[str] = None def make_qr_code_data(self) -> str: """\ Creates either a simple "mailto:" URL or complete e-mail message with (blind) carbon copies and a subject and a body. :rtype: str """ return helpers.make_make_email_data(**asdict(self)) @validate_call def _escape_mecard_special_chars(string_to_escape: Optional[str]) -> Optional[str]: if not string_to_escape: return string_to_escape special_chars = ["\\", '"', ";", ",", ":"] for sc in special_chars: string_to_escape = string_to_escape.replace(sc, "\\%s" % sc) return string_to_escape django-qr-code-4.1.0/qr_code/templatetags/000077500000000000000000000000001462661477300204345ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/templatetags/__init__.py000066400000000000000000000000001462661477300225330ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/templatetags/qr_code.py000066400000000000000000000307041462661477300224260ustar00rootroot00000000000000"""Tags for Django template system that help generating QR codes.""" from typing import Optional, Any from django import template from qr_code.qrcode.maker import make_qr_code_with_args, make_qr_code_url_with_args from qr_code.qrcode.utils import ( make_google_play_text, make_tel_text, make_sms_text, make_youtube_text, WifiConfig, ContactDetail, Coordinates, EpcData, VCard, Email, MeCard, VEvent, ) register = template.Library() def _make_app_qr_code_from_obj_or_kwargs( obj_or_kwargs, expected_cls, embedded: bool, qr_code_args: dict, extra_qr_code_args: Optional[dict] = None, force_text: bool = True, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, ) -> str: if isinstance(obj_or_kwargs, expected_cls): obj = obj_or_kwargs else: # For compatibility with existing views and templates, try to build from dict. obj = expected_cls(**obj_or_kwargs) final_args = {**qr_code_args} if extra_qr_code_args: final_args.update(extra_qr_code_args) if embedded: return make_qr_code_with_args( obj.make_qr_code_data(), qr_code_args=final_args, force_text=force_text, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) else: return make_qr_code_url_with_args(obj.make_qr_code_data(), qr_code_args=final_args, force_text=force_text) def _make_google_maps_qr_code( embedded: bool, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: if "coordinates" in kwargs: coordinates = kwargs.pop("coordinates") else: coordinates = Coordinates(kwargs.pop("latitude"), kwargs.pop("longitude")) if embedded: return make_qr_code_with_args( coordinates.make_google_maps_text(), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) else: return make_qr_code_url_with_args( coordinates.make_google_maps_text(), qr_code_args=kwargs, ) def _make_geolocation_qr_code( embedded: bool, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: if "coordinates" in kwargs: coordinates = kwargs.pop("coordinates") else: coordinates = Coordinates(kwargs.pop("latitude"), kwargs.pop("longitude"), kwargs.pop("altitude")) if embedded: return make_qr_code_with_args( coordinates.make_geolocation_text(), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) else: return make_qr_code_url_with_args( coordinates.make_geolocation_text(), qr_code_args=kwargs, ) @register.simple_tag() def qr_from_text( text: str, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( data=text, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names ) @register.simple_tag() def qr_from_data( data: Any, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( data=data, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, force_text=False, ) @register.simple_tag() def qr_for_email( email: str | Email, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: if isinstance(email, str): # Handle simple case where e-mail is simple the electronic address. email = Email(to=email) return _make_app_qr_code_from_obj_or_kwargs( email, Email, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_tel( phone_number: Any, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( make_tel_text(phone_number), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_sms( phone_number: Any, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( make_sms_text(phone_number), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_geolocation(**kwargs) -> str: """Accepts a *'coordinates'* keyword argument or a triplet *'latitude'*, *'longitude'*, and *'altitude'*.""" return _make_geolocation_qr_code(embedded=True, **kwargs) @register.simple_tag() def qr_for_google_maps(**kwargs) -> str: """Accepts a *'coordinates'* keyword argument or a pair *'latitude'* and *'longitude'*.""" return _make_google_maps_qr_code(embedded=True, **kwargs) @register.simple_tag() def qr_for_youtube( video_id: str, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( make_youtube_text(video_id), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_google_play( package_id: str, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return make_qr_code_with_args( make_google_play_text(package_id), qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_contact( contact_detail, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( contact_detail, ContactDetail, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_vcard(vcard, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs) -> str: return _make_app_qr_code_from_obj_or_kwargs( vcard, VCard, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_mecard(mecard, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs) -> str: return _make_app_qr_code_from_obj_or_kwargs( mecard, MeCard, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_wifi( wifi_config, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( wifi_config, WifiConfig, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_for_epc(epc_data, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs) -> str: extra = dict( error_correction="M", boost_error=False, micro=False, encoding="utf-8", ) return _make_app_qr_code_from_obj_or_kwargs( epc_data, EpcData, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, extra_qr_code_args=extra, force_text=False, ) @register.simple_tag() def qr_for_event(event, use_data_uri_for_svg: bool = False, alt_text: None | str = None, class_names: None | str = None, **kwargs) -> str: return _make_app_qr_code_from_obj_or_kwargs( event, VEvent, embedded=True, qr_code_args=kwargs, use_data_uri_for_svg=use_data_uri_for_svg, alt_text=alt_text, class_names=class_names, ) @register.simple_tag() def qr_url_from_text( text: str, **kwargs ) -> str: return make_qr_code_url_with_args( data=text, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_from_data( data: Any, **kwargs ) -> str: return make_qr_code_url_with_args( data=data, qr_code_args=kwargs, force_text=False, ) @register.simple_tag() def qr_url_for_email( email: str | Email, **kwargs ) -> str: if isinstance(email, str): # Handle simple case where e-mail is simple the electronic address. email = Email(to=email) return _make_app_qr_code_from_obj_or_kwargs( email, Email, embedded=False, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_tel( phone_number: Any, **kwargs ) -> str: return make_qr_code_url_with_args( make_tel_text(phone_number), qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_sms( phone_number: Any, **kwargs ) -> str: return make_qr_code_url_with_args( make_sms_text(phone_number), qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_geolocation(**kwargs) -> str: """Accepts a *'coordinates'* keyword argument or a triplet *'latitude'*, *'longitude'*, and *'altitude'*.""" return _make_geolocation_qr_code(embedded=False, **kwargs) @register.simple_tag() def qr_url_for_google_maps(**kwargs) -> str: """Accepts a *'coordinates'* keyword argument or a pair *'latitude'* and *'longitude'*.""" return _make_google_maps_qr_code(embedded=False, **kwargs) @register.simple_tag() def qr_url_for_youtube( video_id: str, **kwargs ) -> str: return make_qr_code_url_with_args( make_youtube_text(video_id), qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_google_play( package_id: str, **kwargs ) -> str: return make_qr_code_url_with_args( make_google_play_text(package_id), qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_contact( contact_detail, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( contact_detail, ContactDetail, embedded=False, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_vcard( vcard, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( vcard, VCard, embedded=False, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_mecard( mecard, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( mecard, MeCard, embedded=False, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_wifi( wifi_config, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( wifi_config, WifiConfig, embedded=False, qr_code_args=kwargs, ) @register.simple_tag() def qr_url_for_epc( epc_data, **kwargs ) -> str: extra = dict( error_correction="M", boost_error=False, micro=False, encoding="utf-8", ) return _make_app_qr_code_from_obj_or_kwargs( epc_data, EpcData, embedded=False, qr_code_args=kwargs, extra_qr_code_args=extra, force_text=False, ) @register.simple_tag() def qr_url_for_event( event, **kwargs ) -> str: return _make_app_qr_code_from_obj_or_kwargs( event, VEvent, embedded=False, qr_code_args=kwargs, ) django-qr-code-4.1.0/qr_code/tests/000077500000000000000000000000001462661477300171045ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/__init__.py000066400000000000000000000024721462661477300212220ustar00rootroot00000000000000import re from django.utils.html import escape def get_base64_png_image_template(alt_text: None | str = None, class_names: None | str = None) -> str: if alt_text is None: alt_text = "Hello World!" template = f'{escape(alt_text)}" def get_base64_svg_image_template(alt_text: None | str = None, class_names: None | str = None) -> str: if alt_text is None: alt_text = "Hello World!" template = f'{escape(alt_text)}" IMAGE_TAG_BASE64_DATA_RE = re.compile(r"data:image/(png|svg\+xml);base64,(?P[\w/+=]+)") TEST_TEXT = "Hello World!" COMPLEX_TEST_TEXT = "/%+¼@#=<>àé" OVERRIDE_CACHES_SETTING = { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", }, "qr-code": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "qr-code-cache", "TIMEOUT": 3600}, } SVG_REF_SUFFIX = ".ref.svg" PNG_REF_SUFFIX = ".ref.png" # Set this flag to True for writing the new version of each reference image in tests/resources while running the tests. REFRESH_REFERENCE_IMAGES = False django-qr-code-4.1.0/qr_code/tests/resources/000077500000000000000000000000001462661477300211165ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_contact.ref.png000066400000000000000000000023511462661477300254030ustar00rootroot00000000000000PNG  IHDRZIDATx\m:Tȑtu0Z$Gvl2X1П}(ƫ-ӎӎ[KqGo<4;[b8/(爺8"-[y|&[71𘧈#FЍTGw n}Dc7zua60,pTB׽zq]ɉ~AELP,2zwގ_G졉8 c{悓*WF j`C~`Iw6b FA1cI-bܩ!dlL[w=Q뻞'`?KMvoC\-/cKE~A lFXZMnV!HXF%D~2=sU ++.6-ѣBjr`}Fos)mԽv5uo]m@ױTHbRl),ڹ0zuR5 >bn*Ak\#~Q` ѳoь=ZJiaw24]d?ufުk#Pc~n\fE*2͗*=uo#d3&9Bjv=^I Ȁ$i8s U̥-vU]8F k&;tɖ=.co8r&d}rDNj4t8sF@e.d䓏{cQcnB}; ev-r!1݁.s{IZ/ةr@`,>,YnGf?=ٲܤ{+|G:'G_{EisF\ogH`>{OFŮ+X1{ϮA.䞊t_\i{˞;oj0μȜnglu^ܦ2;},Or|QzK$EcV܌cZTedjango-qr-code-4.1.0/qr_code/tests/resources/qr_for_email.ref.png000066400000000000000000000004731462661477300250420ustar00rootroot00000000000000PNG  IHDRIDATxX 0 #|_I>*RM)8ăQG !Px+o xffl GU>;[!51Տm 醭 VarڧjgsHrEo}A6ևuHoCV͐ uo-Z %')XөohXx[߶Lڃ72K i 떧̬n{H,--{ iuÆ۹x5Cڧ !p{/ {Z IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_email.ref.svg000066400000000000000000000022521462661477300250520ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_1.ref.png000066400000000000000000000013201462661477300247320ustar00rootroot00000000000000PNG  IHDR>>a`lrVWlGy. ZF /֮tq^W`維ἪGERѠ\CLPX%lpT#$÷_CcuCPrUDK=SX*p4n42_lDMerlg%0*P9pD݌۷'"L_/%\tUUH޾F#{d| :4s_u.6~6ZP{IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_1.ref.svg000066400000000000000000000064321462661477300247560ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_2.ref.png000066400000000000000000000010151462661477300247340ustar00rootroot00000000000000PNG  IHDRPIDATxY0 2WH@O"4$G(FTLE&7}D,H<҈N4%]G::^&Dk֑Yu"B/hR6-)A2$$kܥJ2lm\5u.;- z?Jw ڏ&RReD q$($nڡ[GM|T!ӟr4VPG+K|BB;ݝ.,$B{w(aIGPZf"jBvV2 `WrG7)ZC=XQ}VY!O\KJ&v]:w!=!6VT?>K; q"6 XNViֹ 4G3IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_2.ref.svg000066400000000000000000000045701462661477300247600ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_3.ref.png000066400000000000000000000011661462661477300247440ustar00rootroot00000000000000PNG  IHDR&&w=IDATxZAn#1 'zLk#B6DqQX E:VEU/3L; 2&],jh*Ȋ4dJRʞTNq!Wm;UW#jÐ}p*GDu';ŧBp|f9*Å4}:|DǨdiRZe<#ETM <)ZKs D)6x=v[:4?RgNd]=[6pR1m".{9rjW>ѩsʃdFpPK FYêl;+}'!䜤tJ_$ci\-<9QkƇ!a}#~VjiyGrN@Y^x?C }UWﯱS奔} {G$NIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_epc_3.ref.svg000066400000000000000000000056141462661477300247610ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_1.ref.png000066400000000000000000000025761462661477300253220ustar00rootroot00000000000000PNG  IHDR;rEIDATx\8 LIi%^K |!dDyyU(7E*5~}_5wM<>6Wl%=څ o<V BD!nwQ p5'xAC41xr_L%ө<ɟ19Bt֠ Tz3}'/ae 8NTYsMXHij,&>Yq&]l|~ɩ\6x|6;cX剪JfdE8C~ lZUUV((6>˽x~Oφ])MN +9>OSUlۛ %͟9{PJ :P~#=Q5zFMJZMD94tC9&wrG:e,A-"$b'gmIY R.],s?YIm M:.gfׁ_.;>_js֣ŝ)~YgnpXnk!2:("Ѿ?<론yΫx~%v=>xoNFZx~ ^ zP<ʃ\g {@t~t#django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_2.ref.png000066400000000000000000000025531462661477300253160ustar00rootroot00000000000000PNG  IHDR;r2IDATx\[: %e^R`@D`QE10=sns綫?Wͻ}l\ >ߟx><`a} n omq|sF=E^}^L=BmVxxNwCvGL><H ?m iEv#V-֌U?\^C+eDE>}-%<}ҤDF$ɑr4)ق4{P~߈Ϯ|/3BFƏ_"n3僠 4LFd}2+_x;M(K\;Jv\Moxtii#kAdB¢*< }S䌁rb!7k"J~Z!gȒ/"#&E?DR)Vx&d`6yM|@ٵ!gPn6_=7Őc%GM^{ z/℥'*jRuR|KW-f"zllw#6Ae\ҨTB؜gF\kc\t,+>ї&s K۫G|i thY#]0E9hiV:ߩ&qH Ɇ=û(<>}Ufk$<_fwKڹecɶAxȒqHٗtWYOkK=fiw v҃'< =ve&ps,django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_3.ref.png000066400000000000000000000047401462661477300253170ustar00rootroot00000000000000PNG  IHDR^^MZ6+ IDATx]An1 ̓u?i`l Zf΅,Qm߽azX=?۳~oվ_~X>Ldzׇpfk{cذ:xH,Gcm!6PạyǎkB3GOF^?).Q3Ϸx ?` M&,Oƅ_kz*]f4Q"~U5m"4j(x&^dߠbSȴB& &4݊Ll=XϠRml> [ IGIDu쮅POcFe_m)rdZMT}HPzMT(67E)cF7(yi󜛻ys4iǏ˓0 {Tj~3Ol`5{1XU&ݞgL= 3/ty*"')څf`?BWF1O1U>HMZ6W:I EShlg :L4x"+ĬVOVfsai g(E/uP>yM[J~@ЉRN]'6v:N֥)'%5"Cx^ÔB3Iҝ]~nv SУfOT&ԦyDb3zicoWBfV"T- ၠc؃dʈ.i]V5nvԶHaqmSϷ{ƺ  Jx*6UٔB@NAZnv;_f*hW4{C;yۚḀ={BaY%A瞫â̒iWxF\gGmE f*~=[Ա2CTMӡВF&{ b)Pf8 _Aµm#2VhBsU:dAOwqOצpdVhfBs1JtkZr/\r7s3չ)M IAN|j Q -Y2CIokazX=?7g3^IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_3.ref.svg000066400000000000000000000326631462661477300253370ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_4.ref.png000066400000000000000000000044341462661477300253200ustar00rootroot00000000000000PNG  IHDRFFwIDATx]Kn8 $|u0X90 6xEb~R?O''z]p;zg\3}W돏Izp$/R 3qsP/d @{s>v#JX yrc1 00Ʈ;Ox#) {͙F~75 4Ux>kؕǻ vۜq/V[Nr6U.K;qw癕ة\X kYYZӱKƻם638I*Wmtr]\GƵWh.V|* ʴ9A%G Lk `⾖8he^/?ccW3J E ؕa%q."NDŽ}cWg"ƅ\"X#%$>7aH>]aC^``V NA/=A+t6ŏa*bDq]b9Щ+Fkw**!Ʈ'1A$@H e]LT8B\ls9lJChqC;JhL+DL;2]À=)_cWSqπ3iJcWv-``s!I,T6ыn+;; ToCbaA#tㄘم<0]Ϝ&AJ64z, H%hr6vuMteEk( HU6Pߒr=BtCq%L sj%VxWW'LN1{3~(%z>XljM`K >ܳC$ZrC]v0nGsGQ>gcWXy͇)J0H4JIa`|w`Sl\9R42$!U`}>\8:W.6XA@ EdW<.\Au=1nGj\G&'6xWWAٲg'b[ԈXٝɴ>2آZ C&|3saPL\ j޼ ghR1Q3eͨ80d 16ljRs싷ã}02pľt?NEKhs|۠'Vgb4 w04P$}0dQьqB~SdsԴGyTy~WPxt?쀠@2uiǪ3>)i mq3>Y^3f)n>)BƮNѱS̘ak>S00Y)VMuH{tYݏ)>m"\>B1"9bϮ·4l^l퉡ޢw^sqoJ'=3.,͵Vn~X#zOM7ve5N0-s-MXY9GƮ ;ǯ}xV@KirWqn'3m,Y}fQ3}:\gӗU )P}~XvoM-Gq?ŝ/y[cWV#@47L.! pgtRWY}A$4+B]ϴ~fqw|U/z|G4y.pp+:'\t+NHHBg+S8*p2wW7Dxyys#=)wLȫuL!@gat}.Iy '`3ʍ]i}?_O?O'II,QIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_event_4.ref.svg000066400000000000000000000277371462661477300253460ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_geolocation.ref.png000066400000000000000000000006061462661477300262540ustar00rootroot00000000000000PNG  IHDRzMIDATxA C=WH)iwo#udcE%iu A``W=yT'Bm K\ ^Q ϕRms}뮖=q?Goߊ 2?4+Y-TnRn'%58<4fan b`]uO - "m-CiP ScCٶN :.LʋNL-y|bp-vX~mХ!Ս7|U/5X`w+`g\xaSd>}c yehvo߲I &&`?_Q. _mIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_geolocation.ref.svg000066400000000000000000000030561462661477300262710ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_google_maps.ref.png000066400000000000000000000007131462661477300262440ustar00rootroot00000000000000PNG  IHDRiGeIDATxYm0 2RVH*o6F`\cS8V;{E=K}/z]Wƕ㹵\s'u#^u츋?H!OG/~?8 ?3oPb9gˉ?G0'UR kŜzE ~FZn7 I{6L["cßR".g00oLN6WBEF/ LdDQ"KXXNE`??79iۼ95W*KlsTwԿ; țKIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_google_maps.ref.svg000066400000000000000000000036121462661477300262600ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_google_play.ref.png000066400000000000000000000010341462661477300262460ustar00rootroot00000000000000PNG  IHDRPIDATxYm0 django-qr-code-4.1.0/qr_code/tests/resources/qr_for_mecard.ref.png000066400000000000000000000016461462661477300252110ustar00rootroot00000000000000PNG  IHDRnn"mIDATx[K0 #>R`Hʙ= ;>$g{^z3yi7}}zA(~"s;?+_\2W0<-+LHM+27 ILL+gdi8#BWȠvOBxL~L{;wq4y:] ٹ HgIDj PFE1${yd Đ@W96Au1ͦbz,5!x(Y Ud<%H @ 2j!UJ[͚*TPV5us  \d͡bhك2ܑ'#a6"CܮD&blfBB3J@yr)vY;_YaH1qLcQQ)ҼJJ3̶=+ 2Zr+Logٓ4h",)Hў0UCXzztQt!2f&AS\SkӄYn :MS7AN#!5#9;Ș <Jf-y$6gc6џal `E$Z[hglaaV6lRgJAQ@ U tjFoggTܹjLs)6uhp mYĦVDzÊ)']=-uhPz2=摐bh!tmIb_RRi l:; "@v!'ӎ}Ȝ2uSsp>_l9:k+8Kƫw֙Z&)MiܛXLj%X6oo H p+IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_mecard.ref.svg000066400000000000000000000110371462661477300252170ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_sms.ref.png000066400000000000000000000004771462661477300245610ustar00rootroot00000000000000PNG  IHDRIDATxXA0C|' HۥM>U]Z.6!$cWl> d^ՙ mc/\6w[j̃ VMt[U$7#L l7pZ* ?3o6 a%N'K78P+7Z.y*-,whfvRV1CȦR_1_H/^jucCO*Z!,Vz'V.?\p'磚/kv/קU=p3?ϼmIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_sms.ref.svg000066400000000000000000000021731462661477300245670ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_tel.ref.png000066400000000000000000000005021462661477300245300ustar00rootroot00000000000000PNG  IHDR IDATx 0ѹ] @/D0:EV0쒳x9W21G[!*l 5u,pX:M,تͼF@8Z<}&Xy=RxQ:@v<ꆊx&aSߠ!PH6ʈ,̒5ciiH'ҵ8}K]FȍY#YΆ/b{S/khג)X9 [ZMK}\ .o,׶T7xK'U͏ T%V IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_tel.ref.svg000066400000000000000000000023711462661477300245510ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_vcard_1.ref.png000066400000000000000000000027441462661477300252750ustar00rootroot00000000000000PNG  IHDR9IDATx]A1 ̓u?)@ުi M&;FIJ}ܦ[unխj1ݗlӮ.ǟ?[tF`ax 22 »n# 7OnR#E!ᧀ7Qm@]ÎBu ]7QBK.Ԩ ^9A.xJK#ԡ %TzBGk_B07PPȡ(}k%fmogpSKCT CbvXěnsl]r/,I8k!E+yap-=I CK˻tA )niFљE"d㌀pxUe ;ܔmΜm_D3bH8Mt>OfRk}%>3A3"< OwFۈ)qv2&R w5F\$B1@h<8duʛ941]r~Ed!Uk,JtvFSP#g^Q`dJIlJc fXrJa!l Nsx182Dv!Ola0g3/MPEPD e"y6}-,`l"g3FtHy8tlH Mv qD.d_˜{AakpBJggNfnb96֭K%~3(`MPDt7`+t.c[An4(]^54qbJM1rlvU䧼Pm!p;7~m˙ N〡]5̖le߈nE9%(C[2۬,谴M }W%WæjKp gMq'15BJfPn"#hr["Kdjango-qr-code-4.1.0/qr_code/tests/resources/qr_for_vcard_2.ref.png000066400000000000000000000041521462661477300252710ustar00rootroot00000000000000PNG  IHDR..1r1IDATx]K8 $Ztu0XUg3n Kpdx<֗e2}ߺ~~5ݯ~h~O+~b<2xou>) =Hbz#U#̔"f(HIShcYsHV-lߩ53T f ߯\` Īc_sMUr?F;TJz:~#U6'W׈(+3;HUj1}JUɩGqJ; 4^/L\ӕZgS垟z&VTKwL8rTvTc6`-|Ͳ+,7͞ ~&, - $}9K9-LE%R(ks͂Z ln!h + ({rsIY܌8NeӋR, %\ -eЖ#u oNbr;P7ΖuIG┎W.8W',xN̬~4I8+©u?Oe2}L_\ۖ!B@IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_vcard_2.ref.svg000066400000000000000000000260221462661477300253040ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_wifi.ref.png000066400000000000000000000006001462661477300247010ustar00rootroot00000000000000PNG  IHDRzGIDATxэ! C(S bٿHZ8f{{3F^U mZ]s7hJ@(ZUI=#h{ݣ@KlZ2k$]n3k%)*!f %np  8mdIN*ynlz,*l` ɞW[ڶ [4[B(x'ƥ^vk8'dIXÜu޴1'׶d\t{BZ -hYyYw^->22fBW S slht枠Hf|޿.ç% hIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qr_for_wifi.ref.svg000066400000000000000000000030631462661477300247220ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qr_for_youtube.ref.png000066400000000000000000000007151462661477300254460ustar00rootroot00000000000000PNG  IHDRiGeIDATxY[! p$#qlb_;UǓPcnb۱5c׷?q^[+2% A||_i3=9֙~R ?^[m8+?g?\ C"}O;R'`2͢*p&I.Y'Ig 9CB(~!={+B~>lUJ W,ddjango-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_empty.ref.png000066400000000000000000000011241462661477300307520ustar00rootroot00000000000000PNG  IHDRRR IDATxKn0P, KY @r L9 gkk ,bX,bX,/Pa²ǩxOObXjz?vZs5i*b5:fyhi*biVU^MԬ*WY,jƪ(ruWC,u!W5iMI+WY,.xKX,VzsMY,W=*sb,Pעi*%mVbX>@ViGX,օ\M k],BzDb5*WY,YP*bnYq+[X,֛jȎVmհT|]X,V[꪿x\eX~ZJAAbCVbJbXrAbXj8^ִGX,Z6Q109obXr}kgrbsXXh,ubX,bX,b V.aIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_empty.ref.svg000066400000000000000000000017531462661477300307750ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_error.ref.png000066400000000000000000000011241462661477300307450ustar00rootroot00000000000000PNG  IHDRRR IDATxKn0P, KY @r L9 gkk ,bX,bX,/Pa²ǩxOObXjz?vZs5i*b5:fyhi*biVU^MԬ*WY,jƪ(ruWC,u!W5iMI+WY,.xKX,VzsMY,W=*sb,Pעi*%mVbX>@ViGX,օ\M k],BzDb5*WY,YP*bnYq+[X,֛jȎVmհT|]X,V[꪿x\eX~ZJAAbCVbJbXrAbXj8^ִGX,Z6Q109obXr}kgrbsXXh,ubX,bX,b V.aIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_error.ref.svg000066400000000000000000000017531462661477300307700ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_none.ref.png000066400000000000000000000011241462661477300305530ustar00rootroot00000000000000PNG  IHDRRR IDATxKn0P, KY @r L9 gkk ,bX,bX,/Pa²ǩxOObXjz?vZs5i*b5:fyhi*biVU^MԬ*WY,jƪ(ruWC,u!W5iMI+WY,.xKX,VzsMY,W=*sb,Pעi*%mVbX>@ViGX,օ\M k],BzDb5*WY,YP*bnYq+[X,֛jȎVmհT|]X,V[꪿x\eX~ZJAAbCVbJbXrAbXj8^ִGX,Z6Q109obXr}kgrbsXXh,ubX,bX,b V.aIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_ui_fluid_segment.ref.png000066400000000000000000000011241462661477300331360ustar00rootroot00000000000000PNG  IHDRRR IDATxKn0P, KY @r L9 gkk ,bX,bX,/Pa²ǩxOObXjz?vZs5i*b5:fyhi*biVU^MԬ*WY,jƪ(ruWC,u!W5iMI+WY,.xKX,VzsMY,W=*sb,Pעi*%mVbX>@ViGX,օ\M k],BzDb5*WY,YP*bnYq+[X,֛jȎVmհT|]X,V[꪿x\eX~ZJAAbCVbJbXrAbXj8^ִGX,Z6Q109obXr}kgrbsXXh,ubX,bX,b V.aIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrforemail_embedded_class_ui_fluid_segment.ref.svg000066400000000000000000000017531462661477300331610ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_boost_error_false.ref.png000066400000000000000000000007101462661477300303260ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_boost_error_false.ref.svg000066400000000000000000000017451462661477300303520ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_boost_error_true.ref.png000066400000000000000000000007101462661477300302130ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_boost_error_true.ref.svg000066400000000000000000000017451462661477300302370ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_default.ref.png000066400000000000000000000002471462661477300262460ustar00rootroot00000000000000PNG  IHDR~ZnIDATxc4⃸C+D^! "H|_A(C/}Q _bwU0ᇰ django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_eci_false.ref.png000066400000000000000000000007101462661477300265270ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_eci_false.ref.svg000066400000000000000000000017451462661477300265530ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_eci_true.ref.png000066400000000000000000000011261462661477300264160ustar00rootroot00000000000000PNG  IHDRRR IDATxAN09GsRP qgSR`x^E},&c;kcbX,bX,V1m~ۄ.K^bU+垷-W;mβO^=JX,!WՈRʦi*b[uKYbX5rbZnVBbNj8bxVǓ={Ū:w_Mw+~ٳX,Vil6YX,\͵h Vm۝,u^RE+,z'*bWײl;)jZbX_jej:ĩ\eXw(\eXqZրϔ=bVEX,ָPF.\m;bX\d5F[X,֩\Uz:W~ZZrb88*b}W~a݊b2>y,u*W django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_encoding_iso-8859-1.ref.png000066400000000000000000000007301462661477300300300ustar00rootroot00000000000000PNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_encoding_iso-8859-1.ref.svg000066400000000000000000000016741462661477300300530ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_encoding_utf-8.ref.png000066400000000000000000000007101462661477300274260ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_encoding_utf-8.ref.svg000066400000000000000000000017451462661477300274520ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_h.ref.png000066400000000000000000000011241462661477300305040ustar00rootroot00000000000000PNG  IHDRRR IDATxAn0PT:GHT)؎Cl>RlޢvccX,bX,bX,_ZCɼ_Z,LSbXs5Hiߎ]'[rb\Miiq,u=W25MRVX,{ó.e*br_Ys/\Ӕ*b]0PqUjj=RfٳbXen)jڰXX,VpOۘҶ|g_iWY,kUաKbX\OWϷ^X,V7Wӓ圞lrbj!k 9ְUX,>@Vakk 4^eX^Y[ >@|]X,ֳ>@}{Up,yj WrbjUꍬ,u.B[un,,,W H֢:g*b]չ5C@bޭWpUj_]5[EbX/s5g*b=_bX,bX,b !ImIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_h.ref.svg000066400000000000000000000024531462661477300305250ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_l.ref.png000066400000000000000000000007101462661477300305100ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_l.ref.svg000066400000000000000000000017451462661477300305340ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_m.ref.png000066400000000000000000000007101462661477300305110ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_m.ref.svg000066400000000000000000000017451462661477300305350ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_q.ref.png000066400000000000000000000011241462661477300305150ustar00rootroot00000000000000PNG  IHDRRR IDATxAn0PT:GHT)؎Cl>RlޢvccX,bX,bX,_ZCɼ_Z,LSbXs5Hiߎ]'[rb\Miiq,u=W25MRVX,{ó.e*br_Ys/\Ӕ*b]0PqUjj=RfٳbXen)jڰXX,VpOۘҶ|g_iWY,kUաKbX\OWϷ^X,V7Wӓ圞lrbj!k 9ְUX,>@Vakk 4^eX^Y[ >@|]X,ֳ>@}{Up,yj WrbjUꍬ,u.B[un,,,W H֢:g*b]չ5C@bޭWpUj_]5[EbX/s5g*b=_bX,bX,b !ImIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_error_correction_q.ref.svg000066400000000000000000000024531462661477300305360ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_micro_false.ref.png000066400000000000000000000007301462661477300271020ustar00rootroot00000000000000PNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_micro_false.ref.svg000066400000000000000000000016741462661477300271250ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_micro_true.ref.png000066400000000000000000000005351462661477300267720ustar00rootroot00000000000000PNG  IHDRTc$IDATxA 0`#=RhjLRQJ7+gfMZI$I$I$IekzK"Ie ;+ P*3[9.H2R&/ k{& $0@3FAmdI'@2=0;dLR5 dIF'Lݤ'd>sԑ!'!.>[ 'Ý% \Tad0;d>avÅF@=h@! NNv$OP fO$I$I$I$;wA*wӍIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_micro_true.ref.svg000066400000000000000000000013761462661477300270110ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_0.ref.png000066400000000000000000000007141462661477300257640ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_0.ref.svg000066400000000000000000000016401462661477300257760ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_1.ref.png000066400000000000000000000007101462661477300257610ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_1.ref.svg000066400000000000000000000016321462661477300260000ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_2.ref.png000066400000000000000000000007301462661477300257640ustar00rootroot00000000000000PNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_2.ref.svg000066400000000000000000000015611462661477300260020ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_3.ref.png000066400000000000000000000007341462661477300257710ustar00rootroot00000000000000PNG  IHDR  jZIDATxA0ɫH@5M] |YhE?%x@ @ 1v<] _RkٲV_*3R @K嬣i[ZT_@ RMk3#DZ*J-)uCܬk!Ռz*ʐZbpjus"a/^ŹnQj!bL_R @$|]t]nDZkkVk0HZZGU!V%[KW9DZ1\HZuB )RrsDBy^K@ ZѼUZbxjݽZ/LCD IR|y+`D@ @ CQ(#9IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_3.ref.svg000066400000000000000000000016541462661477300260060ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_4.ref.png000066400000000000000000000007341462661477300257720ustar00rootroot00000000000000PNG  IHDR  jZIDATxA0ɫH@5M] |YhE?%x@ @ 1v<] _RkٲV_*3R @K嬣i[ZT_@ RMk3#DZ*J-)uCܬk!Ռz*ʐZbpjus"a/^ŹnQj!bL_R @$|]t]nDZkkVk0HZZGU!V%[KW9DZ1\HZuB )RrsDBy^K@ ZѼUZbxjݽZ/LCD IR|y+`D@ @ CQ(#9IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_4.ref.svg000066400000000000000000000016541462661477300260070ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_5.ref.png000066400000000000000000000007261462661477300257740ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Qss$ RvU[t575@ @ я'她>O|߫tl٪E~j!~ZutT @ W/B _0k;DB -ϵ"Zk!VCưc\J8<׉@ U}xZt!"1vSF f@ zU+ù\Rn^|g֚{1B ݫF}+a@ VQs-11G!Α{@ twjhB T8g,~j!ՌX[EB ZR8@ w_ŬZ{ҪU̪@ W@ @ @| ./TkIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_5.ref.svg000066400000000000000000000016541462661477300260100ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_6.ref.png000066400000000000000000000013321462661477300257670ustar00rootroot00000000000000PNG  IHDRwRIDATxAn0P#qu*F4vMZim*}1|  BP( BP( BEKulql}+0P($}G89k+-JH~( Mǽzz%/{Br~ B_ݞ)SB?S>CPh}tBd?_9}og+(( MN r?>NB? 5BЬ^=)8N^qB&mk=SECPKbq `\)P(4S?7j:|%? K'OoBмֹf7tP=$? ǽ:K8qKB kMl;fxP(4wN^BL1P(0T?g_ _c\=nBL5'Bjf,û]cÿݨ_B |kJCPh{̟aN( }]_P(%django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_7.ref.png000066400000000000000000000011251462661477300257700ustar00rootroot00000000000000PNG  IHDRRR IDATxAn0Qss$D if ]| ccby[bX,bX,bXiEՏebW#o{K_UruZ*WԸ[zZbX=%bXuZM,J޺*bTjKX,~oÊn p|=bs?CrOp5\eXM0@%WY,iZR4uC^V,u"WW*sz%WiJ==rb\T)e@uK5hWY,~ݭ]5_q,ׯJxVUX,~KUCʖϊbm5ObbXR4byVeUwjbXr?׺_eXzVy _eXuDVbXG~e_eX\M,ubX,bX,b>,?y FIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_7.ref.svg000066400000000000000000000023541462661477300260100ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_8.ref.png000066400000000000000000000020141462661477300257670ustar00rootroot00000000000000PNG  IHDR**EjIDATxA1 PW8Gs>UdCe,+o/e~c]`0 `0 `0 |iyoǿs~E^[g_Y  鹽Ru靟n?(=1 sܟ5^jϭԧ%? pu a0 f UdmE*TkLk&a0 fs6öw:gIO ,qb=KηwaamQ'`C//yMkX`0ح! -]2:`0U3ڞJt#`0%Ckwz`0usn='n(`0̪Y浕S-5-`0+mh="[t a0 fLTصkhs`0`0 `0 `0 `0_cgen'ةOIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_mode_8.ref.svg000066400000000000000000000045251462661477300260130ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_10.ref.png000066400000000000000000000005011462661477300260650ustar00rootroot00000000000000PNG  IHDR""uIDATxA '|_I>ՁHS}*1+Ȃ *T^>*zLT;^d/{^~)"eYezg|_aT+> }Xsb؏1(YqX ao>?G-/ת WZ{d?.g_mdNh7^Kω9e{[ *TT}=P6IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_10.ref.svg000066400000000000000000000015721462661477300261110ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_6.ref.png000066400000000000000000000004021462661477300260120ustar00rootroot00000000000000PNG  IHDRw CIDATxW 0 32WH唃WQ#$TȒM%K{y}ބI|ڧJϳ4&STM>$ML/>TATnO,/#ձ9LF'$1 5d "rWvB ]AذJbh3ūA|&,O$(nl&/OC8oIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_6.ref.svg000066400000000000000000000016401462661477300260320ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_8.ref.png000066400000000000000000000003521462661477300260200ustar00rootroot00000000000000PNG  IHDRҕIDATxX0kL;1Fcl*hœ +bG$79S; ̙<_p,To3JspҾNSV=)Ժ 4߱m?Q(㿜A|3.1?3X|U.cM#3%*󘣵۷6%zjF&IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_8.ref.svg000066400000000000000000000016401462661477300260340ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_huge.ref.png000066400000000000000000000024031462661477300266000ustar00rootroot00000000000000PNG  IHDRppJIDATx1 @t]pJhpc{WkMM `>................................................................................................................................C#Us=*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\S3!^ּ<.............................nK*իwgmƽ-Pgݭ{ggpwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqWg]Sr<.............................nA!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\܃)..............................nnļ>SOgm3$y~WV cuz!y!%πے[&"v_~Xupqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_large.ref.png000066400000000000000000000012531462661477300267440ustar00rootroot00000000000000PNG  IHDRffSrIDATxm0@Q+.h$VD؜&yﰧ/Ð לh4Fh4Fh4Fh4Fh4Fh4Fh?şWr}+Fh4FZ8Bq>kϞJh4Fh{g53yPJᦏơh4Fh5NqVh4FhG7&j4Fh4F{N,7n}Fh4STVhFh4FqbN&Uh4Fh4ڵSimbڰ?qh4Fh4ZgjFh4FqjۍxGh4FhS7Rfj&ơh4Fh6NG׊fGh4Fh|ZSS$ơh4Fh>q'Mh4F:kSiŰ'5Ch4FnkzAnUkˣqh4Fh4Z>84Fh4푍4'K>Fh4F8q;5\5Fh4jAǡh4Fh5ίFh4Fh4Fh4Fh4Fh4Fh4F{4f//1(IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_large.ref.svg000066400000000000000000000016261462661477300267630ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_medium.ref.png000066400000000000000000000007141462661477300271330ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_medium.ref.svg000066400000000000000000000016401462661477300271450ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_small.ref.png000066400000000000000000000005111462661477300267560ustar00rootroot00000000000000PNG  IHDR\\m;IDATxA0 ->2?0M7v  q@F0000000װ4|.wfO7KܨhC*Z$%=EOz nē|HnqggQmnh/Ė n1C37~W=ݘO3X:,n,=ECQ7oh1&IS<Qfcō}rnFZdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_tiny.ref.png000066400000000000000000000004021462661477300266300ustar00rootroot00000000000000PNG  IHDRw CIDATxW 0 32WH唃WQ#$TȒM%K{y}ބI|ڧJϳ4&STM>$ML/>TATnO,/#ձ9LF'$1 5d "rWvB ]AذJbh3ūA|&,O$(nl&/OC8oIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_size_tiny.ref.svg000066400000000000000000000016401462661477300266500ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_2.ref.png000066400000000000000000000011051462661477300265220ustar00rootroot00000000000000PNG  IHDRRR  IDATxA0p=F θ|Y`_MbZ^6ΉbX,bX,b>Jq >eLl} zW񞷿)ڊqsIX,~N!bus.5k7zebujӜaX,փ\{*7$WY,Wk箰X,Vϳn ,&t_*bե}zbոj UjjE>*Uj;Y_eXqfX,bX,bXO Me IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_2.ref.svg000066400000000000000000000023631462661477300265440ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_4.ref.png000066400000000000000000000015611462661477300265320ustar00rootroot00000000000000PNG  IHDR8IDATxA0Pkrs$VW0سy^C.mX Nt:Nt:Nt:K~W?etl q<R!w~Q=:N駳 #T֑_ltlWRX7&:Nt %ĖltlURLȦMt:NMa,a./q&:NɦO^KYNٔg3TRmaR7t:}L6Uq}\JZ&\DuS :LZj[ltlM[[)Mt:NMy;m/w1j;veNOgS鴃HMľFt:}T6mBgHN鳳)#ҝj⩷\DtBk[pC^dNGMy7S{Xc,Ni}ߩޕfS܍ eNfSbpNK:s_ٱNٔ `tKSQN駲] a<ZKIT[N'曞t:>n=tReNOM-K D#8[N05*o+\@&:NΦkp#nMt:NM_@D;w.aN3ݻtzUuzt:NMqa}}!ztl cIgǯ|:)U%t:~2&Nt:Nt:Nt:hQee1IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_4.ref.svg000066400000000000000000000037661462661477300265560ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_default.ref.png000066400000000000000000000007141462661477300300120ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromdata_version_default.ref.svg000066400000000000000000000016401462661477300300240ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_boost_error_false.ref.png000066400000000000000000000007101462661477300304010ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_boost_error_false.ref.svg000066400000000000000000000017451462661477300304250ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_boost_error_true.ref.png000066400000000000000000000007101462661477300302660ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_boost_error_true.ref.svg000066400000000000000000000017451462661477300303120ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_black.ref.png000066400000000000000000000007141462661477300322050ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_black.ref.svg000066400000000000000000000035201462661477300322160ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_blue.ref.png000066400000000000000000000011411462661477300320530ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#IDATxA1@fj)g5BXI NO3oNKs}00000000jʱrwGum.^=? }\<+9MIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_blue.ref.svg000066400000000000000000000035201462661477300320710ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_red.ref.png000066400000000000000000000011411462661477300316760ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdIDATxA1@fj)g5BXI NO3oNKs}00000000jʱrwGum.^=? }\<+9MIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_red.ref.svg000066400000000000000000000035201462661477300317140ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_transparent.ref.png000066400000000000000000000011561462661477300334730ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@fIDATx=0Q;Ҩ)Jǎ T|/100000000000000000000000000000000000|ǰǣf~00000000\j:ҽ:aJx:]G1000000,Q”b``````QcQ:AG]?T%}`}=:2Tz{a!b:Lɝrb``````עx;ulWz<6fZSLJG1000000Qy_ϻ vT^pP*8p{GWwlc.ȧs:aގz9+*tJb){j|XTp}=;}7G1000000,QO0U2PIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_transparent.ref.svg000066400000000000000000000035201462661477300335030ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_white.ref.png000066400000000000000000000007141462661477300322510ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_white.ref.svg000066400000000000000000000016431462661477300322660ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_white_hexa.ref.png000066400000000000000000000007141462661477300332560ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_dark_white_hexa.ref.svg000066400000000000000000000035201462661477300332670ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_black.ref.png000066400000000000000000000007141462661477300323730ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_black.ref.svg000066400000000000000000000035201462661477300324040ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_blue.ref.png000066400000000000000000000011411462661477300322410ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#IDATxA1@fj)g5BXI NO3oNKs}00000000jʱrwGum.^=? }\<+9MIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_blue.ref.svg000066400000000000000000000035201462661477300322570ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_red.ref.png000066400000000000000000000011411462661477300320640ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdIDATxA1@fj)g5BXI NO3oNKs}00000000jʱrwGum.^=? }\<+9MIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_red.ref.svg000066400000000000000000000035201462661477300321020ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_transparent.ref.png000066400000000000000000000011561462661477300336610ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@fIDATx=0Q;Ҩ)Jǎ T|/100000000000000000000000000000000000|ǰǣf~00000000\j:ҽ:aJx:]G1000000,Q”b``````QcQ:AG]?T%}`}=:2Tz{a!b:Lɝrb``````עx;ulWz<6fZSLJG1000000Qy_ϻ vT^pP*8p{GWwlc.ȧs:aގz9+*tJb){j|XTp}=;}7G1000000,QO0U2PIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_transparent.ref.svg000066400000000000000000000035201462661477300336710ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_white.ref.png000066400000000000000000000007141462661477300324370ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_white.ref.svg000066400000000000000000000016431462661477300324540ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_white_hexa.ref.png000066400000000000000000000007141462661477300334440ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_alignment_light_white_hexa.ref.svg000066400000000000000000000035201462661477300334550ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_black.ref.png000066400000000000000000000007141462661477300301470ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_black.ref.svg000066400000000000000000000016431462661477300301640ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_blue.ref.png000066400000000000000000000007361462661477300300260ustar00rootroot00000000000000PNG  IHDR  xPLTE{ܙ,IDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_blue.ref.svg000066400000000000000000000016431462661477300300370ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_black.ref.png000066400000000000000000000007141462661477300315140ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_black.ref.svg000066400000000000000000000036031462661477300315270ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_blue.ref.png000066400000000000000000000011501462661477300313620ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#IDATx1n1@UJ.M75$ Hc/ o*ɓ|-sܾ>q000000000000000000000000000000000000|pSkJn ?;׶(;Zކ:aˎj(u)tzX|&Lc``````ػff^```````XET]QuTTlw?aJN'_9sM:dMB՚h^M(:/ 'e$ok{cG~ۣTW:aɎl(i=```````بF%4{܁b``````Xu߯django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_red.ref.png000066400000000000000000000011501462661477300312050ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdIDATx1n1@UJ.M75$ Hc/ o*ɓ|-sܾ>q000000000000000000000000000000000000|pSkJn ?;׶(;Zކ:aˎj(u)tzX|&Lc``````ػff^```````XET]QuTTlw?aJN'_9sM:dMB՚h^M(:/ 'e$ok{cG~ۣTW:aɎl(i=```````بF%4{܁b``````Xu߯django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_transparent.ref.png000066400000000000000000000011611462661477300327760ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@fIDATx=j1%#nӹQS)gfbT4xl 1hNZu}~00000000\j:ҽ:aJx:]G1000000,Q”b``````QcQ:AG]?T%}`}=:2Tz{a!b:Lɝrb``````עx;ulWz<6fZSLJG1000000Qz_ϻ vT6~g~ך9uüu*VbmT}@G1000000Q~_/8gtT僎b``````QI,eo#c``````X^ Ι0G](E:.#wIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_transparent.ref.svg000066400000000000000000000035201462661477300330120ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_white.ref.png000066400000000000000000000007141462661477300315600ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_white.ref.svg000066400000000000000000000016431462661477300315750ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_white_hexa.ref.png000066400000000000000000000007141462661477300325650ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_module_white_hexa.ref.svg000066400000000000000000000036031462661477300326000ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_red.ref.png000066400000000000000000000007361462661477300276510ustar00rootroot00000000000000PNG  IHDR  xPLTEA4IDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_red.ref.svg000066400000000000000000000016421462661477300276610ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_transparent.ref.png000066400000000000000000000007321462661477300314340ustar00rootroot00000000000000PNG  IHDR  jZtRNSv8IDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_transparent.ref.svg000066400000000000000000000002301462661477300314400ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_white.ref.png000066400000000000000000000003371462661477300302140ustar00rootroot00000000000000PNG  IHDR  xPLTEIDATxA qK$I$I @@ @x-Zk!B @ @x-Zk@x-Zk@x-Zk@x-Zk@-I$I$%]@IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_white.ref.svg000066400000000000000000000016431462661477300302300ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_white_hexa.ref.png000066400000000000000000000003371462661477300312210ustar00rootroot00000000000000PNG  IHDR  xPLTEIDATxA qK$I$I @@ @x-Zk!B @ @x-Zk@x-Zk@x-Zk@x-Zk@-I$I$%]@IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_dark_white_hexa.ref.svg000066400000000000000000000016431462661477300312350ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_black.ref.png000066400000000000000000000007141462661477300311400ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_black.ref.svg000066400000000000000000000036471462661477300311630ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_blue.ref.png000066400000000000000000000012221462661477300310060ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#DIDATxAn0PT)O mh' 5̛JI|a2s C=cJ[ۣmx}10000000<\9j܎]!G]t]b``````;GPS|]b``````8eZ.nY*Q rCAHb`````` 8G1000000>Gj_Q ]樖;/  xijŽ5owoZNEZm'\Q X-s!YMۡKb``````;Gm5*d%G100000057l8wj~_0(UQSlrTm!ygZ DZJQ+YQ rrl*Q rT%GF\l9XTaz B(Q gQϮ+>t=6IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_blue.ref.svg000066400000000000000000000036471462661477300310360ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_red.ref.png000066400000000000000000000012221462661477300306310ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdDIDATxAn0PT)O mh' 5̛JI|a2s C=cJ[ۣmx}10000000<\9j܎]!G]t]b``````;GPS|]b``````8eZ.nY*Q rCAHb`````` 8G1000000>Gj_Q ]樖;/  xijŽ5owoZNEZm'\Q X-s!YMۡKb``````;Gm5*d%G100000057l8wj~_0(UQSlrTm!ygZ DZJQ+YQ rrl*Q rT%GF\l9XTaz B(Q gQϮ+>t=6IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_red.ref.svg000066400000000000000000000036461462661477300306600ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_transparent.ref.png000066400000000000000000000012211462661477300324170ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@f6IDATxݱn P#_ץ%KKa-5༉Ɔ { ?Z_ŬQ|NW=GU(sTg*HQ Smב䨣Ǣ(9b|9}}=)sԑ^```````$GŝbWOGAtQ ) ˹k(as;z9 fSrH9ה:Jb``````7Gj,9p^$G1000000kjQG(Փ ^Co b Trp95YQ rT^Q rT#GP<&QG9Irԩz;9~l9ݕ ^7JIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_transparent.ref.svg000066400000000000000000000030331462661477300324350ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_white.ref.png000066400000000000000000000007141462661477300312040ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_white.ref.svg000066400000000000000000000002251462661477300312140ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_white_hexa.ref.png000066400000000000000000000007141462661477300322110ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_dark_white_hexa.ref.svg000066400000000000000000000036471462661477300322340ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_black.ref.png000066400000000000000000000007141462661477300313260ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_black.ref.svg000066400000000000000000000040271462661477300313420ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_blue.ref.png000066400000000000000000000012411462661477300311750ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#SIDATxݱj0@QS%_%KǓ%ehtȊ:}|{ S},9wG5}~00000000<+Rh[r0vGyK h.wTcb``````dGt*wT#b``````HGUF~oC,Q CvTm-騣œ=? AxGy9=1:uðG|1gM򞕎b``````{Mtc=/b``````#_z<0nG{AƂ|7c``````ZW) u:*z'pz|wL(bi+Sb``````@G5{zΙYG1000000Qt(uԻ^QIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_blue.ref.svg000066400000000000000000000040271462661477300312150ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_red.ref.png000066400000000000000000000012411462661477300310200ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdSIDATxݱj0@QS%_%KǓ%ehtȊ:}|{ S},9wG5}~00000000<+Rh[r0vGyK h.wTcb``````dGt*wT#b``````HGUF~oC,Q CvTm-騣œ=? AxGy9=1:uðG|1gM򞕎b``````{Mtc=/b``````#_z<0nG{AƂ|7c``````ZW) u:*z'pz|wL(bi+Sb``````@G5{zΙYG1000000Qt(uԻ^QIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_red.ref.svg000066400000000000000000000040261462661477300310370ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_transparent.ref.png000066400000000000000000000012361462661477300326130ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@fCIDATxݱn0@QT)K%K%KO}fh"S˕g]tuy6, G*c){b``````PBZ:aʎ|JS:AGЦtʎjĒ&騞z'c``````zFo#u0HG3Kiu^[kXi<΋(;*K6[aIѥ2" ]㦷㲺(;q\o-Q cwԥz]eP#ޏb``````zGP5&django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_white.ref.png000066400000000000000000000007141462661477300313720ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_white.ref.svg000066400000000000000000000016431462661477300314070ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_white_hexa.ref.png000066400000000000000000000007141462661477300323770ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_data_light_white_hexa.ref.svg000066400000000000000000000040271462661477300324130ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_black.ref.png000066400000000000000000000007141462661477300314760ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_black.ref.svg000066400000000000000000000036071462661477300315150ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_blue.ref.png000066400000000000000000000011631462661477300313500ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#%IDATxݻn0Ѩ~]x:<%eh$WR$xB`G)$|==?#U;3swԭ]YGab``````XHY-reGTtL(ulp5^z v̨^```````X"uTTX:aiQ){gg~zb``````Xs}pؔb``````Xך`ytúUo9o uò5^F W:aɎv~T*V8aHɧtúu:Y(\:AGu:jlrb``````XbT=```````ج^z^QG1000000Q? +L?IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_blue.ref.svg000066400000000000000000000036071462661477300313700ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_red.ref.png000066400000000000000000000011631462661477300311730ustar00rootroot00000000000000PNG  IHDR  ? PLTEgd%IDATxݻn0Ѩ~]x:<%eh$WR$xB`G)$|==?#U;3swԭ]YGab``````XHY-reGTtL(ulp5^z v̨^```````X"uTTX:aiQ){gg~zb``````Xs}pؔb``````Xך`ytúUo9o uò5^F W:aɎv~T*V8aHɧtúu:Y(\:AGu:jlrb``````XbT=```````ج^z^QG1000000Q? +L?IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_red.ref.svg000066400000000000000000000036061462661477300312120ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_transparent.ref.png000066400000000000000000000012111462661477300327540ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@f.IDATxݽ!ay?.Mr` lιe@m 1lߟI_UWf׆;jogWQ?snb``````X*-O-Q G>7t !pJ';p ^Ԝ|">C^bUAU˳b``````FGmQz%œ۷w(:*wט{VIJpj5[AY(u;j ]G1000000QW:aɎ,iTN݄VхA>^wsQ :*_Vb``````Q,^:[cQ9s1000000QO(tԫOs?TQSIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_transparent.ref.svg000066400000000000000000000030721462661477300327760ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_white.ref.png000066400000000000000000000003521462661477300315400ustar00rootroot00000000000000PNG  IHDR  jZIDATx 0Jg Nw@ @ @,$*!T @ B B #BBj9'P-P-ZΉ@ T @ T @j!B B ZBBj^-@ @ ;e<nIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_white.ref.svg000066400000000000000000000016431462661477300315570ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_white_hexa.ref.png000066400000000000000000000003521462661477300325450ustar00rootroot00000000000000PNG  IHDR  jZIDATx 0Jg Nw@ @ @,$*!T @ B B #BBj9'P-P-ZΉ@ T @ T @j!B B ZBBj^-@ @ ;e<nIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_dark_white_hexa.ref.svg000066400000000000000000000036071462661477300325660ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_black.ref.png000066400000000000000000000007141462661477300316640ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_black.ref.svg000066400000000000000000000036121462661477300316770ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_blue.ref.png000066400000000000000000000011521462661477300315340ustar00rootroot00000000000000PNG  IHDR  ? PLTE]#IDATxA1@fM7SR(W+hS|sMivw~ޞ~Gҵ:a nMSveG(5B:AG];~Wq>aJ}_F{azQXSwQ!jQ tTr[T ?;uju 6˦tJlOJG1000000QIߌkw uò5yTrJG1000000,Q ^wnsV:AGdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_red.ref.png000066400000000000000000000011521462661477300313570ustar00rootroot00000000000000PNG  IHDR  ? PLTEgdIDATxA1@fM7SR(W+hS|sMivw~ޞ~Gҵ:a nMSveG(5B:AG];~Wq>aJ}_F{azQXSwQ!jQ tTr[T ?;uju 6˦tJlOJG1000000QIߌkw uò5yTrJG1000000,Q ^wnsV:AGdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_transparent.ref.png000066400000000000000000000011661462661477300331530ustar00rootroot00000000000000PNG  IHDR  ? PLTEItRNS@fIDATx10@QqӥQSnH T6|䱲^w {;Uۏpy;rK(;plBuÒL( ! 8GG1000000,Q'}c``````X2+H/& y=aC=Z6۝G1000000,QmQ/~{b``````}|x.Q 3uT4b``````Oz|:y~_/ tÔu)Vqb5<ȧu:aގzb``````Q:AGs=:]`z wԥFdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_white.ref.png000066400000000000000000000007141462661477300317300ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_white.ref.svg000066400000000000000000000016431462661477300317450ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_white_hexa.ref.png000066400000000000000000000007141462661477300327350ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_finder_light_white_hexa.ref.svg000066400000000000000000000036121462661477300327500ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_black.ref.png000066400000000000000000000003371462661477300303360ustar00rootroot00000000000000PNG  IHDR  xPLTEz=IDATxA qK$I$I @@ @x-Zk!B @ @x-Zk@x-Zk@x-Zk@x-Zk@-I$I$%]@IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_black.ref.svg000066400000000000000000000016431462661477300303520ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_blue.ref.png000066400000000000000000000007361462661477300302140ustar00rootroot00000000000000PNG  IHDR  xPLTEeVBIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_blue.ref.svg000066400000000000000000000016431462661477300302250ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_red.ref.png000066400000000000000000000007361462661477300300370ustar00rootroot00000000000000PNG  IHDR  xPLTE"IDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_red.ref.svg000066400000000000000000000016421462661477300300470ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_transparent.ref.png000066400000000000000000000007321462661477300316220ustar00rootroot00000000000000PNG  IHDR  jZtRNSIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_transparent.ref.svg000066400000000000000000000015651462661477300316420ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_white.ref.png000066400000000000000000000007141462661477300304010ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_white.ref.svg000066400000000000000000000016431462661477300304160ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_white_hexa.ref.png000066400000000000000000000007141462661477300314060ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_color_light_white_hexa.ref.svg000066400000000000000000000016431462661477300314230ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_default.ref.png000066400000000000000000000002471462661477300263210ustar00rootroot00000000000000PNG  IHDR~ZnIDATxc4⃸C+D^! "H|_A(C/}Q _bwU0ᇰ django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_eci_false.ref.png000066400000000000000000000007101462661477300266020ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_eci_false.ref.svg000066400000000000000000000017451462661477300266260ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_eci_true.ref.png000066400000000000000000000011261462661477300264710ustar00rootroot00000000000000PNG  IHDRRR IDATxAN09GsRP qgSR`x^E},&c;kcbX,bX,V1m~ۄ.K^bU+垷-W;mβO^=JX,!WՈRʦi*b[uKYbX5rbZnVBbNj8bxVǓ={Ū:w_Mw+~ٳX,Vil6YX,\͵h Vm۝,u^RE+,z'*bWײl;)jZbX_jej:ĩ\eXw(\eXqZրϔ=bVEX,ָPF.\m;bX\d5F[X,֩\Uz:W~ZZrb88*b}W~a݊b2>y,u*W django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_alternative-text.ref.png000066400000000000000000000007141462661477300337110ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_alternative-text.ref.svg000066400000000000000000000017531462661477300337300ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_empty.ref.png000066400000000000000000000007141462661477300315470ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_empty.ref.svg000066400000000000000000000017531462661477300315660ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_none.ref.png000066400000000000000000000007141462661477300313500ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_none.ref.svg000066400000000000000000000017531462661477300313670ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_quotes.ref.png000066400000000000000000000007141462661477300317310ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_alt_text_quotes.ref.svg000066400000000000000000000017531462661477300317500ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_empty.ref.png000066400000000000000000000007141462661477300310300ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_empty.ref.svg000066400000000000000000000017531462661477300310470ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_error.ref.png000066400000000000000000000007141462661477300310230ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_error.ref.svg000066400000000000000000000017531462661477300310420ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_none.ref.png000066400000000000000000000007141462661477300306310ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_none.ref.svg000066400000000000000000000017531462661477300306500ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_ui_fluid_segment.ref.png000066400000000000000000000007141462661477300332140ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_class_ui_fluid_segment.ref.svg000066400000000000000000000017531462661477300332330ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_data_uri_false.ref.svg000066400000000000000000000016401462661477300314610ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_embedded_data_uri_true.ref.svg000066400000000000000000000017531462661477300313530ustar00rootroot00000000000000 qrfromtext_encoding_00e7d4651c49972afb045b47f45e68d0_cp932.ref.png000066400000000000000000000013211462661477300336240ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDRwRIDATx͍0Pk;B"uB"$vg6s ϻ }( BP( BP( B8^`:~3 B0P(Q%"gôoǿK@wBy=VkB|9>P(zPvwuP(.c?~w}~( }L8$? &K~T}:QP($ކ/gTB钿)3<$? yn]BЬ} Poc *P(4oYՃvjBIy: _BЌ5Uط/pA BS%Qǃ_n+=P(=OP(=m/ B5;s iBt5N.5? &fKU{ BSx~'WUQCPhy.P(4Y2~yBtۿꋂBG$hWr/ >#C=.9/P(4]0iSo` 7' B$&o# Mύ BP( BP( BP诠h%UsIENDB`qrfromtext_encoding_00e7d4651c49972afb045b47f45e68d0_cp932.ref.svg000066400000000000000000000031321462661477300336410ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_00e7d4651c49972afb045b47f45e68d0_utf-8.ref.png000066400000000000000000000015461462661477300337400ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR-IDATxA `u=&R!L/ 2Iʶ[|ı%:Nt:Nt:Nt8;qk3{W9t:;2+wm3k,LڑMt:N8)j#$:.Z7-;Nfӻ&* I6t:_dS1ʺZoMt:NMq)Ll: {֛t:>'¨q&:Nɦȹy$jIt:Yt񚸻oL=;N#)ɑ(wҙDz A ʥR|'lXt:}tݴ4.e\@-SDQIt:>*j)|4oG۷lt躩nKQD)Tj{Cc6U&t:y6Rf;^k]mYotl.զtPÞltlzнz^,f&:N].ZvYotlJݝ[BDT|$t:>n*>kMEwuNMy6nxuFFgrO6t:㺩ކxlt:>3ֲys/^͓5dNgS~bN/VڲDyٴu<4Xnt:}z6UTl$t:>8ZMNQIo&:NͦT̻8jDq4alt:Nt:Nt:N߮R>p^ZIENDB`qrfromtext_encoding_00e7d4651c49972afb045b47f45e68d0_utf-8.ref.svg000066400000000000000000000040461462661477300337510ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_2c2535be9e6990722550df36ed4c7af5_shift-jis.ref.png000066400000000000000000000020141462661477300347510ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR**EjIDATxA1 PW8Gs>UdCe,+o/e~c]`0 `0 `0 |iyoǿs~E^[g_Y  鹽Ru靟n?(=1 sܟ5^jϭԧ%? pu a0 f UdmE*TkLk&a0 fs6öw:gIO ,qb=KηwaamQ'`C//yMkX`0ح! -]2:`0U3ڞJt#`0%Ckwz`0usn='n(`0̪Y浕S-5-`0+mh="[t a0 fLTصkhs`0`0 `0 `0 `0_cgen'ةOIENDB`qrfromtext_encoding_2c2535be9e6990722550df36ed4c7af5_shift-jis.ref.svg000066400000000000000000000046401462661477300347730ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_2c2535be9e6990722550df36ed4c7af5_utf-8.ref.png000066400000000000000000000022561462661477300340240ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDRrrLuIDATxMn0P:H>I3ܢ SHWn,-2c+<x<x<x<hı|}3U~|9:nU;x<6oG?Cc<>َٽ~|U>^Yx<|o lo~zfa;?x<޵_C;xr?[Miy<ǻZ .,ץ5<<M0f?|Cx<7'QKQEw{gx<=~]X?x<ތ|/eM8Mt/տ x9>j[HܟfwSx<w|/ݖө3t | Kx{:[?[x<wvXϭoB_B wf[u<㽽~j欿x<7/kʝ]+c~xҵ{|wTڼ/ew{(P7ox_rx7{F8ďox<\a.ӵq{wQe{ kYڵoxon-Mvb]{.Oj=;֪y<ǛM7-g!{x<79=|:L;x<&6}i/[x<o^smKqwYx<"2?x<=wW/{ԛx<rGcj;1?x<^{oӇx: > qrfromtext_encoding_361633153a464830a1fe85dec5efab17_iso-8859-1.ref.png000066400000000000000000000007101462661477300343730ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxA00#yuL44@ /A#&ڦקcM@ @ 8"cʧHiym?@ j-WͶ[ܱU @V5cj!*R-E:Q-Z`5k!pժF:@ bV`Dۨ5>N1ZydMjm8jKut\ @|6*{/B #k>#Zbxif&]@ ϵڑXEr"0תԏj!w垱yT-Z{Dz|sj<Y|cXӹ{@V=DZ{"^j4*{ @ @ bLwm_IENDB`qrfromtext_encoding_361633153a464830a1fe85dec5efab17_iso-8859-1.ref.svg000066400000000000000000000017151462661477300344140ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_361633153a464830a1fe85dec5efab17_utf-8.ref.png000066400000000000000000000007101462661477300337730ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxA00#yuL44@ /A#&ڦקcM@ @ 8"cʧHiym?@ j-WͶ[ܱU @V5cj!*R-E:Q-Z`5k!pժF:@ bV`Dۨ5>N1ZydMjm8jKut\ @|6*{/B #k>#Zbxif&]@ ϵڑXEr"0תԏj!w垱yT-Z{Dz|sj<Y|cXӹ{@V=DZ{"^j4*{ @ @ bLwm_IENDB`qrfromtext_encoding_361633153a464830a1fe85dec5efab17_utf-8.ref.svg000066400000000000000000000017151462661477300340140ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_iso-8859-1.ref.png000066400000000000000000000007301462661477300343130ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_iso-8859-1.ref.svg000066400000000000000000000016741462661477300343360ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_none.ref.png000066400000000000000000000007301462661477300337070ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_none.ref.svg000066400000000000000000000016741462661477300337320ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_utf-8.ref.png000066400000000000000000000007101462661477300337110ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`qrfromtext_encoding_839fa417c5298ac5058c549879e1e9f9_utf-8.ref.svg000066400000000000000000000017451462661477300337350ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_88be82f1da06ef7b28c615b1d3288f9a_iso-8859-1.ref.png000066400000000000000000000015461462661477300345650ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR-IDATxK0Pֳ, Re=>E΀UŕrZ)t:Nt:Nt:Nu{ݝǝ/;z4rt:wy6=̚It{Y-G6t:l"nJڂldNeG)dN6Iaw^TRNCBJjͶ<Mt:N:UM.%t:'je)CNi;){[ltzߺ)/ٔmEN=ްNtVIq&:Nbm0|* )D^uSn[MN_gL^Bu(D>Tzg>xVԚR%}zt:N]7mQh粉N_e+Kkm ItO6t:C6ŐI)7t:c6I{6-oZfr^t:9#9ը"t:NMEgukŮntiiGȈxnKzt:>*Z;jt:7bUt5u\Dtls_B":Nwֹͦ[HRqgu~NӇMٺUK Dh4_NoR7t:g6lʻù^:NΦxtjS2N郳)H qrfromtext_encoding_88be82f1da06ef7b28c615b1d3288f9a_utf-8.ref.png000066400000000000000000000015461462661477300341650ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR-IDATxK0Pֳ, Re=>E΀UŕrZ)t:Nt:Nt:Nu{ݝǝ/;z4rt:wy6=̚It{Y-G6t:l"nJڂldNeG)dN6Iaw^TRNCBJjͶ<Mt:N:UM.%t:'je)CNi;){[ltzߺ)/ٔmEN=ްNtVIq&:Nbm0|* )D^uSn[MN_gL^Bu(D>Tzg>xVԚR%}zt:N]7mQh粉N_e+Kkm ItO6t:C6ŐI)7t:c6I{6-oZfr^t:9#9ը"t:NMEgukŮntiiGȈxnKzt:>*Z;jt:7bUt5u\Dtls_B":Nwֹͦ[HRqgu~NӇMٺUK Dh4_NoR7t:g6lʻù^:NΦxtjS2N郳)H qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_iso-8859-1.ref.png000066400000000000000000000007141462661477300343500ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_iso-8859-1.ref.svg000066400000000000000000000017531462661477300343670ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_none.ref.png000066400000000000000000000007141462661477300337440ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_none.ref.svg000066400000000000000000000017531462661477300337630ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_utf-8.ref.png000066400000000000000000000007141462661477300337500ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resourcesPNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`qrfromtext_encoding_ed076287532e86365e841e92bfc50d8c_utf-8.ref.svg000066400000000000000000000017531462661477300337670ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_h.ref.png000066400000000000000000000011241462661477300305570ustar00rootroot00000000000000PNG  IHDRRR IDATxAn0PT:GHT)؎Cl>RlޢvccX,bX,bX,_ZCɼ_Z,LSbXs5Hiߎ]'[rb\Miiq,u=W25MRVX,{ó.e*br_Ys/\Ӕ*b]0PqUjj=RfٳbXen)jڰXX,VpOۘҶ|g_iWY,kUաKbX\OWϷ^X,V7Wӓ圞lrbj!k 9ְUX,>@Vakk 4^eX^Y[ >@|]X,ֳ>@}{Up,yj WrbjUꍬ,u.B[un,,,W H֢:g*b]չ5C@bޭWpUj_]5[EbX/s5g*b=_bX,bX,b !ImIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_h.ref.svg000066400000000000000000000024531462661477300306000ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_l.ref.png000066400000000000000000000007101462661477300305630ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_l.ref.svg000066400000000000000000000017451462661477300306070ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_m.ref.png000066400000000000000000000007101462661477300305640ustar00rootroot00000000000000PNG  IHDR  jZIDATxAn0@Q #=***J+` .-˧ @ @ ur1/y>Kx!ZO5j=ەfB U}T {ZaZ"Y:j!B ?W+ε&]Z"O::"YoD Þ8kִ{nOG DjWXj's-Z Ux{FB YZsױ@ V1{6 ۰4@$VB@ ?!դi @Ix$>lT @ VwK7*m|"Qq6@dֱ M's-Z/~4쵪'DZi/,{-1Z@ @ I2,0KIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_m.ref.svg000066400000000000000000000017451462661477300306100ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_q.ref.png000066400000000000000000000011241462661477300305700ustar00rootroot00000000000000PNG  IHDRRR IDATxAn0PT:GHT)؎Cl>RlޢvccX,bX,bX,_ZCɼ_Z,LSbXs5Hiߎ]'[rb\Miiq,u=W25MRVX,{ó.e*br_Ys/\Ӕ*b]0PqUjj=RfٳbXen)jڰXX,VpOۘҶ|g_iWY,kUաKbX\OWϷ^X,V7Wӓ圞lrbj!k 9ְUX,>@Vakk 4^eX^Y[ >@|]X,ֳ>@}{Up,yj WrbjUꍬ,u.B[un,,,W H֢:g*b]չ5C@bޭWpUj_]5[EbX/s5g*b=_bX,bX,b !ImIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_error_correction_q.ref.svg000066400000000000000000000024531462661477300306110ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_micro_false.ref.png000066400000000000000000000007301462661477300271550ustar00rootroot00000000000000PNG  IHDR  jZIDATx0PkD.X%#y_3fB @ @ G~Gu>>5'}߫JH-Rz^GZK-/潎2jy_SraR @ Zz\zF@ IѾ) @ Z521=xwB åVNϓ:D1r5}O@ HֻLʺRk!R+sFUIv?@ @ C6@Ha EIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_micro_false.ref.svg000066400000000000000000000016741462661477300272000ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_micro_true.ref.png000066400000000000000000000005351462661477300270450ustar00rootroot00000000000000PNG  IHDRTc$IDATxA 0`#=RhjLRQJ7+gfMZI$I$I$IekzK"Ie ;+ P*3[9.H2R&/ k{& $0@3FAmdI'@2=0;dLR5 dIF'Lݤ'd>sԑ!'!.>[ 'Ý% \Tad0;d>avÅF@=h@! NNv$OP fO$I$I$I$;wA*wӍIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_micro_true.ref.svg000066400000000000000000000013761462661477300270640ustar00rootroot00000000000000 django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_1.2.ref.svg000066400000000000000000000016411462661477300262410ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_10.ref.png000066400000000000000000000005011462661477300261400ustar00rootroot00000000000000PNG  IHDR""uIDATxA '|_I>ՁHS}*1+Ȃ *T^>*zLT;^d/{^~)"eYezg|_aT+> }Xsb؏1(YqX ao>?G-/ת WZ{d?.g_mdNh7^Kω9e{[ *TT}=P6IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_10.ref.svg000066400000000000000000000015721462661477300261640ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_2.1.ref.png000066400000000000000000000002711462661477300262240ustar00rootroot00000000000000PNG  IHDR::wIDATxڭ1 1 E+}]pbPk @)Uf+,xMȯQ% v_d\V=FYƧ'Ͳcj\sr Y<NY=~^ IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_2.1.ref.svg000066400000000000000000000020371462661477300262410ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_6.ref.png000066400000000000000000000004021462661477300260650ustar00rootroot00000000000000PNG  IHDRw CIDATxW 0 32WH唃WQ#$TȒM%K{y}ބI|ڧJϳ4&STM>$ML/>TATnO,/#ձ9LF'$1 5d "rWvB ]AذJbh3ūA|&,O$(nl&/OC8oIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_6.ref.svg000066400000000000000000000016401462661477300261050ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_8.ref.png000066400000000000000000000003521462661477300260730ustar00rootroot00000000000000PNG  IHDRҕIDATxX0kL;1Fcl*hœ +bG$79S; ̙<_p,To3JspҾNSV=)Ժ 4߱m?Q(㿜A|3.1?3X|U.cM#3%*󘣵۷6%zjF&IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_8.ref.svg000066400000000000000000000016401462661477300261070ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_huge.ref.png000066400000000000000000000024031462661477300266530ustar00rootroot00000000000000PNG  IHDRppJIDATx1 @t]pJhpc{WkMM `>................................................................................................................................C#Us=*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\S3!^ּ<.............................nK*իwgmƽ-Pgݭ{ggpwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqWg]Sr<.............................nA!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\܃)..............................nnļ>SOgm3$y~WV cuz!y!%πے[&"v_~Xupqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_large.ref.png000066400000000000000000000012531462661477300270170ustar00rootroot00000000000000PNG  IHDRffSrIDATxm0@Q+.h$VD؜&yﰧ/Ð לh4Fh4Fh4Fh4Fh4Fh4Fh?şWr}+Fh4FZ8Bq>kϞJh4Fh{g53yPJᦏơh4Fh5NqVh4FhG7&j4Fh4F{N,7n}Fh4STVhFh4FqbN&Uh4Fh4ڵSimbڰ?qh4Fh4ZgjFh4FqjۍxGh4FhS7Rfj&ơh4Fh6NG׊fGh4Fh|ZSS$ơh4Fh>q'Mh4F:kSiŰ'5Ch4FnkzAnUkˣqh4Fh4Z>84Fh4푍4'K>Fh4F8q;5\5Fh4jAǡh4Fh5ίFh4Fh4Fh4Fh4Fh4Fh4F{4f//1(IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_large.ref.svg000066400000000000000000000016261462661477300270360ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_medium.ref.png000066400000000000000000000007141462661477300272060ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_medium.ref.svg000066400000000000000000000016401462661477300272200ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_small.ref.png000066400000000000000000000005111462661477300270310ustar00rootroot00000000000000PNG  IHDR\\m;IDATxA0 ->2?0M7v  q@F0000000װ4|.wfO7KܨhC*Z$%=EOz nē|HnqggQmnh/Ė n1C37~W=ݘO3X:,n,=ECQ7oh1&IS<Qfcō}rnFZdjango-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_tiny.ref.png000066400000000000000000000004021462661477300267030ustar00rootroot00000000000000PNG  IHDRw CIDATxW 0 32WH唃WQ#$TȒM%K{y}ބI|ڧJϳ4&STM>$ML/>TATnO,/#ձ9LF'$1 5d "rWvB ]AذJbh3ūA|&,O$(nl&/OC8oIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_size_tiny.ref.svg000066400000000000000000000016401462661477300267230ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_2.ref.png000066400000000000000000000011051462661477300265750ustar00rootroot00000000000000PNG  IHDRRR  IDATxA0p=F θ|Y`_MbZ^6ΉbX,bX,b>Jq >eLl} zW񞷿)ڊqsIX,~N!bus.5k7zebujӜaX,փ\{*7$WY,Wk箰X,Vϳn ,&t_*bե}zbոj UjjE>*Uj;Y_eXqfX,bX,bXO Me IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_2.ref.svg000066400000000000000000000023631462661477300266170ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_4.ref.png000066400000000000000000000015611462661477300266050ustar00rootroot00000000000000PNG  IHDR8IDATxA0Pkrs$VW0سy^C.mX Nt:Nt:Nt:K~W?etl q<R!w~Q=:N駳 #T֑_ltlWRX7&:Nt %ĖltlURLȦMt:NMa,a./q&:NɦO^KYNٔg3TRmaR7t:}L6Uq}\JZ&\DuS :LZj[ltlM[[)Mt:NMy;m/w1j;veNOgS鴃HMľFt:}T6mBgHN鳳)#ҝj⩷\DtBk[pC^dNGMy7S{Xc,Ni}ߩޕfS܍ eNfSbpNK:s_ٱNٔ `tKSQN駲] a<ZKIT[N'曞t:>n=tReNOM-K D#8[N05*o+\@&:NΦkp#nMt:NM_@D;w.aN3ݻtzUuzt:NMqa}}!ztl cIgǯ|:)U%t:~2&Nt:Nt:Nt:hQee1IENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_4.ref.svg000066400000000000000000000037661462661477300266310ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_default.ref.png000066400000000000000000000007141462661477300300650ustar00rootroot00000000000000PNG  IHDR  jZIDATxKj0@QQ/ Kֵ$/ R>n)d89AIQҴ;JB @ @ L>mJo_5[jhfެZb^su4싮c2LDj]3@ >d]m8;\ @DV33DZk N1mxbѳ!8gT @V{M/7@ &W?C\+r=@ ToLB 1? @ @ >\7%gIENDB`django-qr-code-4.1.0/qr_code/tests/resources/qrfromtext_version_default.ref.svg000066400000000000000000000016401462661477300300770ustar00rootroot00000000000000django-qr-code-4.1.0/qr_code/tests/test_embedded_options.py000066400000000000000000000233071462661477300240260ustar00rootroot00000000000000import base64 from django.test import SimpleTestCase from qr_code.qrcode.maker import make_embedded_qr_code from qr_code.qrcode.utils import QRCodeOptions from qr_code.templatetags.qr_code import qr_from_text, qr_for_email from qr_code.tests import ( TEST_TEXT, REFRESH_REFERENCE_IMAGES, IMAGE_TAG_BASE64_DATA_RE, get_base64_png_image_template, get_base64_svg_image_template, ) from qr_code.tests.utils import ( write_png_content_to_file, get_png_content_from_file_name, write_svg_content_to_file, get_svg_content_from_file_name, ) TEST_ALT_TEXTS = [None, "", "alternative text", "quotes test: ', \""] TEST_ALT_TEXT_NAMES = ["none", "empty", "alternative-text", "quotes"] TEST_CLASS_NAMES = [None, "", "error", "ui fluid segment"] class TestQREmbeddedImageResult(SimpleTestCase): """ Ensures that produced QR codes in PNG format coincide with verified references. The tests cover direct call to tag function, rendering of tag, and direct call to qr_code API. """ def setUp(self): self.maxDiff = None def test_embedded_alt_text_png(self): base_ref_file_name = "qrfromtext_embedded_alt_text" for i in range(len(TEST_ALT_TEXTS)): alt_text = TEST_ALT_TEXTS[i] alt_text_name = TEST_ALT_TEXT_NAMES[i] print("Testing PNG with alt text: %s" % alt_text_name) result_file_name = f"{base_ref_file_name}_{alt_text_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(image_format="png"), alt_text=alt_text) qr2 = qr_from_text(TEST_TEXT, image_format="png", alt_text=alt_text) qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(image_format="png"), alt_text=alt_text) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template(alt_text) % result) def test_embedded_classes_png(self): for i in range(len(TEST_CLASS_NAMES)): class_names = TEST_CLASS_NAMES[i] class_name = "none" if class_names is None else "empty" if class_names == "" else class_names.replace(" ", "_") print("Testing PNG with classes: %s" % class_name) base_ref_file_name = "qrfromtext_embedded_class" result_file_name = f"{base_ref_file_name}_{class_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(image_format="png"), class_names=class_names) qr2 = qr_from_text(TEST_TEXT, image_format="png", class_names=class_names) qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(image_format="png"), class_names=class_names) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template(class_names=class_names) % result) base_ref_file_name = "qrforemail_embedded_class" test_mail = "test@domain.com" result_file_name = f"{base_ref_file_name}_{class_name}" qr1 = make_embedded_qr_code(f"mailto:{test_mail}", QRCodeOptions(image_format="png"), class_names=class_names) qr2 = qr_for_email(test_mail, image_format="png", class_names=class_names) qr3 = qr_for_email(test_mail, options=QRCodeOptions(image_format="png"), class_names=class_names) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template(class_names=class_names, alt_text="mailto:test@domain.com") % result) def test_embedded_alt_text_svg(self): base_ref_file_name = "qrfromtext_embedded_alt_text" for i in range(len(TEST_ALT_TEXTS)): alt_text = TEST_ALT_TEXTS[i] alt_text_name = TEST_ALT_TEXT_NAMES[i] print("Testing SVG with alt text: %s" % alt_text_name) result_file_name = f"{base_ref_file_name}_{alt_text_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(image_format="svg"), alt_text=alt_text, use_data_uri_for_svg=True) qr2 = qr_from_text(TEST_TEXT, image_format="svg", alt_text=alt_text, use_data_uri_for_svg=True) qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(image_format="svg"), alt_text=alt_text, use_data_uri_for_svg=True) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_svg_content_to_file(result_file_name, base64.b64decode(source_image_data).decode("utf-8")) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_svg_image_template(alt_text) % base64.b64encode(result.encode("utf-8")).decode("utf-8")) def test_embedded_classes_svg(self): base_ref_file_name = "qrfromtext_embedded_class" for i in range(len(TEST_CLASS_NAMES)): class_names = TEST_CLASS_NAMES[i] class_name = "none" if class_names is None else "empty" if class_names == "" else class_names.replace(" ", "_") print("Testing SVG with classes: %s" % class_name) result_file_name = f"{base_ref_file_name}_{class_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(image_format="svg"), class_names=class_names, use_data_uri_for_svg=True) qr2 = qr_from_text(TEST_TEXT, image_format="svg", class_names=class_names, use_data_uri_for_svg=True) qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(image_format="svg"), class_names=class_names, use_data_uri_for_svg=True) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_svg_content_to_file(result_file_name, base64.b64decode(source_image_data).decode("utf-8")) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual( qr1, get_base64_svg_image_template(class_names=class_names) % base64.b64encode(result.encode("utf-8")).decode("utf-8") ) base_ref_file_name = "qrforemail_embedded_class" test_mail = "test@domain.com" result_file_name = f"{base_ref_file_name}_{class_name}" qr1 = make_embedded_qr_code(f"mailto:{test_mail}", QRCodeOptions(image_format="png"), class_names=class_names) qr2 = qr_for_email(test_mail, image_format="png", class_names=class_names) qr3 = qr_for_email(test_mail, options=QRCodeOptions(image_format="png"), class_names=class_names) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template(alt_text="mailto:test@domain.com", class_names=class_names) % result) def test_embedded_data_uri_svg(self): base_ref_file_name = "qrfromtext_embedded_data_uri" for use_data_uri_for_svg in [True, False]: alt_text_name = str(use_data_uri_for_svg).lower() print("Testing SVG with data URI: %s" % alt_text_name) result_file_name = f"{base_ref_file_name}_{alt_text_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(image_format="svg"), use_data_uri_for_svg=use_data_uri_for_svg) qr2 = qr_from_text(TEST_TEXT, image_format="svg", use_data_uri_for_svg=use_data_uri_for_svg) qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(image_format="svg"), use_data_uri_for_svg=use_data_uri_for_svg) if REFRESH_REFERENCE_IMAGES: if use_data_uri_for_svg: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_svg_content_to_file(result_file_name, base64.b64decode(source_image_data).decode("utf-8")) else: write_svg_content_to_file(result_file_name, qr1) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) if use_data_uri_for_svg: self.assertEqual(qr1, get_base64_svg_image_template() % base64.b64encode(result.encode("utf-8")).decode("utf-8")) else: self.assertEqual(qr1, result) django-qr-code-4.1.0/qr_code/tests/test_issues.py000066400000000000000000000014371462661477300220350ustar00rootroot00000000000000from django.test import SimpleTestCase from qr_code.qrcode.maker import make_embedded_qr_code from qr_code.qrcode.serve import make_qr_code_url from qr_code.qrcode.utils import QRCodeOptions class TestIssues(SimpleTestCase): def test_reverse_lazy_url(self): from django.urls import reverse, reverse_lazy options = QRCodeOptions(image_format="svg", size=1) url1 = make_qr_code_url(reverse("qr_code:serve_qr_code_image"), options) url2 = make_qr_code_url(reverse_lazy("qr_code:serve_qr_code_image"), options) self.assertEqual(url1, url2) svg1 = make_embedded_qr_code(reverse("qr_code:serve_qr_code_image"), options) svg2 = make_embedded_qr_code(reverse_lazy("qr_code:serve_qr_code_image"), options) self.assertEqual(svg1, svg2) django-qr-code-4.1.0/qr_code/tests/test_qr_for_apps.py000066400000000000000000000406221462661477300230340ustar00rootroot00000000000000"""Tests for qr_code application.""" import base64 import datetime from dataclasses import asdict from datetime import date import zoneinfo from django.template import Template, Context from django.test import SimpleTestCase from django.utils.safestring import mark_safe from qr_code.qrcode.utils import ( ContactDetail, VCard, MeCard, WifiConfig, Coordinates, EpcData, VEvent, EventClass, EventTransparency, EventStatus, ) from qr_code.tests import REFRESH_REFERENCE_IMAGES, IMAGE_TAG_BASE64_DATA_RE from qr_code.tests.utils import ( write_svg_content_to_file, get_svg_content_from_file_name, minimal_svg, get_png_content_from_file_name, write_png_content_to_file, ) US_EASTERN_TZ = zoneinfo.ZoneInfo("America/New_York") EUROPE_ZURICH_TZ = zoneinfo.ZoneInfo("Europe/Zurich") TEST_EVENT1 = VEvent( uid="django-qr-code-test-id-1", summary="Vacations", start=datetime.datetime(2022, 7, 6, hour=8, minute=30, tzinfo=US_EASTERN_TZ), end=datetime.datetime(2022, 7, 17, hour=12, tzinfo=US_EASTERN_TZ), location="New-York", categories=["holidays"], event_class=EventClass.PUBLIC, transparency=EventTransparency.TRANSPARENT, dtstamp=datetime.datetime(2022, 6, 25, hour=17, minute=30, tzinfo=datetime.timezone.utc), ) TEST_EVENT2 = VEvent( uid="django-qr-code-test-id-2", summary="Café avec Marcel!", start=datetime.datetime(2022, 6, 27, hour=8, minute=15, tzinfo=EUROPE_ZURICH_TZ), end=datetime.datetime(2022, 6, 27, hour=9, tzinfo=EUROPE_ZURICH_TZ), categories=["PERSO,FRIENDS"], event_class=EventClass.PRIVATE, dtstamp=datetime.datetime(2022, 6, 25, hour=17, minute=30, tzinfo=datetime.timezone.utc), ) TEST_EVENT3 = VEvent( uid="django-qr-code-test-id-3", summary="Vacations", start=datetime.datetime(2022, 8, 6, hour=8, minute=30, tzinfo=US_EASTERN_TZ), end=datetime.datetime(2022, 8, 17, hour=12, tzinfo=US_EASTERN_TZ), location="New-York", categories=["holidays", "PERSONAL", "FAMILY_STUFF", "FUN AT HOME", "SOME_VERY_LONG_CATEGORY_NAME_THAT_REQUIRES_LINE_FOLDING"], status=EventStatus.TENTATIVE, organizer="foo@bar.com", url="https://bar.com", description="""Meeting to provide technical review for "Phoenix" design. Happy Face Conference Room. Phoenix design team MUST attend this meeting. RSVP to team leader.""", dtstamp=datetime.datetime(2022, 6, 25, hour=17, minute=30, tzinfo=datetime.timezone.utc), ) TEST_EVENT4 = VEvent( uid="django-qr-code-test-id-4", summary="Concert", start=datetime.datetime(2022, 8, 6, hour=19, minute=30), end=datetime.datetime(2022, 8, 6, hour=23), location="Delémont, Salle St-Georges", geo=(47.3661640157025, 7.346173125268345), status=EventStatus.CONFIRMED, description="""Meeting to provide technical review for "Phoenix" design. Happy Face Conference Room. Phoenix design team MUST attend this meeting. RSVP to team leader. Add some diacritics for fun: éàüî""", dtstamp=datetime.datetime(2022, 6, 25, hour=17, minute=30, tzinfo=datetime.timezone.utc), ) TEST_CONTACT_DETAIL = dict( first_name="Jérémy Sébastien Ninõ", last_name="Érard", first_name_reading="jAAn", last_name_reading="dOH", tel="+41769998877", email="j.doe@company.com", url="http://www.company.com", birthday=date(year=1985, month=10, day=2), address="Cras des Fourches 987, 2800 Delémont, Jura, Switzerland", memo="Development Manager", org="Company Ltd", ) TEST_MECARD_CONTACT = MeCard( name="Ninõ,Jérémy Sébastien", phone="+41769998877", email="j.doe@company.com", url="http://www.company.com", birthday=date(year=1985, month=10, day=2), memo="Development Manager", org="Company Ltd", ) TEST_VCARD_CONTACT = VCard( name="Ninõ;Jérémy Sébastien", phone="+41769998877", email="j.doe@company.com", url="http://www.company.com", birthday=date(year=1985, month=10, day=2), street="Cras des Fourches 987", city="Delémont", zipcode=2800, region="Jura", country="Switzerland", memo="Development Manager", org="Company Ltd", ) TEST_VCARD_CONTACT2 = VCard( name="Ninõ;Jérémy Sébastien", phone="+41769998877", email="j.doe@company.com", url="http://www.company.com", birthday=date(year=1985, month=10, day=2), street="Cras des Fourches 987", city="Delémont", zipcode=2800, region="Jura", country="Switzerland", memo="Development Manager", org="Company Ltd", photo_uri="http://www.company.com/profile/12", cellphone=["+41769998877", "+41769998878"], homephone="+41321112233", workphone="+41329992233", ) TEST_WIFI_CONFIG = dict(ssid="my-wifi", authentication=WifiConfig.AUTHENTICATION.WPA, password="wifi-password") TEST_EPC_QR_1 = dict( name="Wikimedia Foerdergesellschaft", iban="DE33100205000001194700", amount=20, text="To Wikipedia, From Gérard Boéchat" ) TEST_EPC_QR_2 = dict(name="Wikimedia Foerdergesellschaft", iban="DE33100205000001194700", amount=50.0, reference="12983020") class TestContactDetail(SimpleTestCase): def test_make_qr_code_text_with_contact_detail(self): data = dict(**TEST_CONTACT_DETAIL) c1 = ContactDetail(**data) data["nickname"] = "buddy" c2 = ContactDetail(**data) data["last_name"] = "O'Hara;,:" data["tel_av"] = "n/a" c3 = ContactDetail(**data) del data["last_name"] c4 = ContactDetail(**data) self.assertEqual( c1.make_qr_code_data(), r"MECARD:N:Érard,Jérémy Sébastien Ninõ;SOUND:dOH,jAAn;TEL:+41769998877;EMAIL:j.doe@company.com;NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;ORG:Company Ltd;;", ) self.assertEqual( c2.make_qr_code_data(), r"MECARD:N:Érard,Jérémy Sébastien Ninõ;SOUND:dOH,jAAn;TEL:+41769998877;EMAIL:j.doe@company.com;NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;", ) self.assertEqual( c3.make_qr_code_data(), r"MECARD:N:O'Hara\;\,\:,Jérémy Sébastien Ninõ;SOUND:dOH,jAAn;TEL:+41769998877;TEL-AV:n/a;EMAIL:j.doe@company.com;NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;", ) self.assertEqual( c4.make_qr_code_data(), r"MECARD:N:Jérémy Sébastien Ninõ;SOUND:dOH,jAAn;TEL:+41769998877;TEL-AV:n/a;EMAIL:j.doe@company.com;NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;", ) def test_make_qr_code_text_with_mecard(self): data = asdict(TEST_MECARD_CONTACT) c1 = MeCard(**data) data["nickname"] = "buddy" c2 = MeCard(**data) self.assertEqual( c1.make_qr_code_data(), r"MECARD:N:Ninõ,Jérémy Sébastien;TEL:+41769998877;EMAIL:j.doe@company.com;BDAY:19851002;URL:http\://www.company.com;MEMO:Development Manager;;ORG:Company Ltd;", ) self.assertEqual( c2.make_qr_code_data(), r"MECARD:N:Ninõ,Jérémy Sébastien;TEL:+41769998877;EMAIL:j.doe@company.com;NICKNAME:buddy;BDAY:19851002;URL:http\://www.company.com;MEMO:Development Manager;;ORG:Company Ltd;", ) def test_make_qr_code_text_with_vcard(self): data = asdict(TEST_VCARD_CONTACT) c1 = VCard(**data) data["nickname"] = "buddy" c2 = VCard(**data) self.assertEqual( c1.make_qr_code_data(), """BEGIN:VCARD\r VERSION:3.0\r N:Ninõ;Jérémy Sébastien\r FN:Ninõ Jérémy Sébastien\r ORG:Company Ltd\r EMAIL:j.doe@company.com\r TEL:+41769998877\r URL:http://www.company.com\r ADR:;;Cras des Fourches 987;Delémont;Jura;2800;Switzerland\r BDAY:1985-10-02\r NOTE:Development Manager\r END:VCARD\r """, ) self.assertEqual( c2.make_qr_code_data(), """BEGIN:VCARD\r VERSION:3.0\r N:Ninõ;Jérémy Sébastien\r FN:Ninõ Jérémy Sébastien\r ORG:Company Ltd\r EMAIL:j.doe@company.com\r TEL:+41769998877\r URL:http://www.company.com\r NICKNAME:buddy\r ADR:;;Cras des Fourches 987;Delémont;Jura;2800;Switzerland\r BDAY:1985-10-02\r NOTE:Development Manager\r END:VCARD\r """, ) class TestWifiConfig(SimpleTestCase): def test_make_qr_code_text(self): wifi1 = WifiConfig(**TEST_WIFI_CONFIG) wifi2 = WifiConfig(hidden=True, **TEST_WIFI_CONFIG) self.assertEqual(wifi1.make_qr_code_data(), "WIFI:S:my-wifi;T:WPA;P:wifi-password;;") self.assertEqual(wifi2.make_qr_code_data(), "WIFI:S:my-wifi;T:WPA;P:wifi-password;H:true;;") class TestCoordinates(SimpleTestCase): def test_coordinates(self): c1 = Coordinates(latitude=586000.32, longitude=250954.19) c2 = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) self.assertEqual(c1.__str__(), "latitude: 586000.32, longitude: 250954.19") self.assertEqual(c2.__str__(), "latitude: 586000.32, longitude: 250954.19, altitude: 500") class TestQRForApplications(SimpleTestCase): @staticmethod def _make_test_data(tag_pattern, ref_file_name, tag_args, template_context=dict()): tag_content = tag_pattern for key, value in tag_args.items(): if isinstance(value, str): tag_content += f' {key}="{value}"' else: tag_content += f" {key}={value}" return dict(source="{% " + tag_content + " %}", ref_file_name=ref_file_name, template_context=template_context) @staticmethod def _make_tests_data(embedded=True, image_format="svg"): contact_detail1 = dict(**TEST_CONTACT_DETAIL) contact_detail2 = ContactDetail(**contact_detail1) wifi_config1 = dict(**TEST_WIFI_CONFIG) wifi_config2 = WifiConfig(**wifi_config1) epc_data1 = dict(**TEST_EPC_QR_1) epc_data2 = EpcData(**epc_data1) epc_data3 = dict(**TEST_EPC_QR_2) google_maps_coordinates = Coordinates(latitude=586000.32, longitude=250954.19) geolocation_coordinates = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) tag_prefix = "qr_for_" if embedded else "qr_url_for_" tag_args = dict(image_format=image_format) if image_format == "png": tag_args["size"] = "t" if not embedded: # Deactivate cache for URL. tag_args["cache_enabled"] = False raw_data = ( ("email", '"john.doe@domain.com"', None, None), ("tel", ' "+41769998877"', None, None), ("sms", ' "+41769998877"', None, None), ("geolocation", "latitude=586000.32 longitude=250954.19 altitude=500", None, None), ("geolocation", "coordinates=coordinates", {"coordinates": geolocation_coordinates}, None), ("google_maps", "latitude=586000.32 longitude=250954.19", None, None), ("google_maps", "coordinates=coordinates", {"coordinates": google_maps_coordinates}, None), ("wifi", "wifi_config", {"wifi_config": wifi_config1}, None), ("wifi", "wifi_config", {"wifi_config": wifi_config2}, None), ("wifi", "wifi_config=wifi_config", {"wifi_config": wifi_config2}, None), ("epc", "epc_data", {"epc_data": epc_data1}, 1), ("epc", "epc_data", {"epc_data": epc_data2}, 1), ("epc", "epc_data=epc_data", {"epc_data": epc_data2}, 1), ("epc", "epc_data", {"epc_data": epc_data3}, 2), ("contact", "contact_detail", {"contact_detail": contact_detail1}, None), ("contact", "contact_detail", {"contact_detail": contact_detail2}, None), ("contact", "contact_detail=contact_detail", {"contact_detail": contact_detail2}, None), ("mecard", "mecard=mecard", {"mecard": TEST_MECARD_CONTACT}, None), ("mecard", "mecard", {"mecard": TEST_MECARD_CONTACT}, None), ("vcard", "vcard=vcard", {"vcard": TEST_VCARD_CONTACT}, 1), ("vcard", "vcard", {"vcard": TEST_VCARD_CONTACT}, 1), ("vcard", "vcard", {"vcard": TEST_VCARD_CONTACT2}, 2), ("event", "event", {"event": TEST_EVENT1}, 1), ("event", "event", {"event": TEST_EVENT2}, 2), ("event", "event", {"event": TEST_EVENT3}, 3), ("event", "event", {"event": TEST_EVENT4}, 4), ("youtube", '"J9go2nj6b3M"', None, None), ("youtube", "video_id", {"video_id": "J9go2nj6b3M"}, None), ("google_play", '"ch.admin.meteoswiss"', None, None), ) tests_data = [] for tag_base_name, tag_data, template_context, number in raw_data: ref_file_name = "qr_for_%s" % tag_base_name if number is not None: ref_file_name = f"{ref_file_name}_{number}" test_data = TestQRForApplications._make_test_data( tag_pattern=f"{tag_prefix}{tag_base_name} {tag_data}", ref_file_name=ref_file_name, tag_args=tag_args, template_context=template_context, ) tests_data.append(test_data) return tests_data @staticmethod def _get_rendered_template(template_source, template_context): html_source = mark_safe("{% load qr_code %}" + template_source) template = Template(html_source) context = Context() if template_context: context.update(template_context) return template.render(context).strip() def test_demo_samples_embedded_in_svg_format(self): tests_data = self._make_tests_data(embedded=True) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) source_image_data = TestQRForApplications._get_rendered_template(test_data["source"], test_data.get("template_context")) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_demo_samples_embedded_in_png_format(self): tests_data = self._make_tests_data(embedded=True, image_format="png") for test_data in tests_data: print("Testing template: %s" % test_data["source"]) source_image_data = TestQRForApplications._get_rendered_template(test_data["source"], test_data.get("template_context")) match = IMAGE_TAG_BASE64_DATA_RE.search(source_image_data) source_image_data = match.group("data") source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_demo_sample_urls_in_svg_format(self): tests_data = self._make_tests_data(embedded=False) for test_data in tests_data: source_image_data = self._check_url_for_test_data(test_data).content.decode("utf-8") if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_demo_sample_urls_in_png_format(self): tests_data = self._make_tests_data(embedded=False, image_format="png") for test_data in tests_data: source_image_data = self._check_url_for_test_data(test_data).content if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def _check_url_for_test_data(self, test_data): print("Testing template: %s" % test_data["source"]) source_image_url = TestQRForApplications._get_rendered_template(test_data["source"], test_data.get("template_context")) response = self.client.get(source_image_url) self.assertEqual(response.status_code, 200) return response django-qr-code-4.1.0/qr_code/tests/test_qr_from_data.py000066400000000000000000001503621462661477300231620ustar00rootroot00000000000000"""Tests for qr_code application.""" import base64 import re from itertools import product from django.conf import settings from django.contrib.auth.models import AnonymousUser, User from django.core.cache import caches from django.template import Template, Context from django.test import SimpleTestCase, override_settings from django.utils.safestring import mark_safe from django.utils.html import escape from qr_code.qrcode.maker import make_embedded_qr_code from qr_code.qrcode.constants import ERROR_CORRECTION_DICT from qr_code.qrcode.serve import make_qr_code_url, allows_external_request_from_user from qr_code.qrcode.utils import QRCodeOptions from qr_code.templatetags.qr_code import qr_from_data, qr_url_from_data from qr_code.tests import ( REFRESH_REFERENCE_IMAGES, TEST_TEXT, OVERRIDE_CACHES_SETTING, COMPLEX_TEST_TEXT, get_base64_png_image_template, IMAGE_TAG_BASE64_DATA_RE, ) from qr_code.tests.utils import ( write_svg_content_to_file, write_png_content_to_file, get_svg_content_from_file_name, get_png_content_from_file_name, get_urls_without_token_for_comparison, minimal_svg, ) COMPLEX_TEST_TEXT_AS_ISO_8859_1 = COMPLEX_TEST_TEXT.encode("iso-8859-1") COMPLEX_TEST_TEXT_AS_UTF_8 = COMPLEX_TEST_TEXT.encode("utf-8") TEST_TEXT_AS_UTF_8 = TEST_TEXT.encode("utf-8") class TestQRUrlFromDataResult(SimpleTestCase): """ Ensures that serving images representing QR codes works as expected (with or without caching, and with or without protection against external requests). """ default_ref_base_file_name = "qrfromdata_default" def setUp(self): self.maxDiff = None @staticmethod def _get_reference_result_for_default_svg(): return get_svg_content_from_file_name(TestQRUrlFromDataResult.default_ref_base_file_name) @staticmethod def _get_reference_result_for_default_png(): return get_png_content_from_file_name(TestQRUrlFromDataResult.default_ref_base_file_name) def test_svg_url(self): is_first = True users = [None, AnonymousUser(), User(username="test")] for url_options in product([True, False, None], [True, False, None], users): cache_enabled = url_options[0] url_signature_enabled = url_options[1] user = url_options[2] print(f"\t - cache_enabled={cache_enabled}, url_signature_enabled={url_signature_enabled}, user={user}") url_options_kwargs = dict() url0 = make_qr_code_url( TEST_TEXT_AS_UTF_8, QRCodeOptions(size=1), **url_options_kwargs, force_text=False, cache_enabled=cache_enabled, url_signature_enabled=url_signature_enabled, ) if cache_enabled is not None: url_options_kwargs["cache_enabled"] = cache_enabled url1 = make_qr_code_url( TEST_TEXT_AS_UTF_8, QRCodeOptions(size=1), **url_options_kwargs, force_text=False, url_signature_enabled=url_signature_enabled, ) if url_signature_enabled is not None: url_options_kwargs["url_signature_enabled"] = url_signature_enabled url2 = qr_url_from_data(TEST_TEXT_AS_UTF_8, size=1, **url_options_kwargs) url3 = qr_url_from_data(TEST_TEXT_AS_UTF_8, image_format="svg", size=1, **url_options_kwargs) url4 = qr_url_from_data(TEST_TEXT_AS_UTF_8, image_format="SVG", size=1, **url_options_kwargs) url5 = qr_url_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(image_format="SVG", size=1), **url_options_kwargs) # Using an invalid image format should fall back to SVG. url6 = qr_url_from_data(TEST_TEXT_AS_UTF_8, image_format="invalid-format-name", size=1, **url_options_kwargs) url = url1 if url_signature_enabled is not False: urls = get_urls_without_token_for_comparison(url0, url1, url2, url3, url4, url5, url6) else: urls = [url0, url1, url2, url3, url4, url5, url6] self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) expected_status_code = 200 if url_signature_enabled is False and not allows_external_request_from_user(user): expected_status_code = 403 self.assertEqual(response.status_code, expected_status_code) image_data = response.content.decode("utf-8") if expected_status_code == 200: if is_first and REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(TestQRUrlFromDataResult.default_ref_base_file_name, image_data) is_first = False self.assertEqual(image_data, TestQRUrlFromDataResult._get_reference_result_for_default_svg()) def test_png_url(self): is_first = True for url_options in product([True, False, None], [True, False, None]): cache_enabled = url_options[0] url_signature_enabled = url_options[1] url_options_kwargs = dict() if cache_enabled is not None: url_options_kwargs["cache_enabled"] = cache_enabled if url_signature_enabled is not None: url_options_kwargs["url_signature_enabled"] = url_signature_enabled url1 = make_qr_code_url(TEST_TEXT_AS_UTF_8, QRCodeOptions(image_format="png", size=1), **url_options_kwargs, force_text=False) url2 = qr_url_from_data(TEST_TEXT_AS_UTF_8, image_format="png", size=1, **url_options_kwargs) url3 = qr_url_from_data(TEST_TEXT_AS_UTF_8, image_format="PNG", size=1, **url_options_kwargs) url4 = qr_url_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(image_format="PNG", size=1), **url_options_kwargs) url = url1 if url_signature_enabled is not False: urls = get_urls_without_token_for_comparison(url1, url2, url3, url4) else: urls = [url1, url2, url3, url4] self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) response = self.client.get(url) print(f"\t - cache_enabled={cache_enabled}, url_signature_enabled={url_signature_enabled}") expected_status_code = 200 if url_signature_enabled is False and not allows_external_request_from_user(None): expected_status_code = 403 self.assertEqual(response.status_code, expected_status_code) if expected_status_code == 200: if is_first and REFRESH_REFERENCE_IMAGES: write_png_content_to_file(TestQRUrlFromDataResult.default_ref_base_file_name, response.content) is_first = False self.assertEqual(response.content, TestQRUrlFromDataResult._get_reference_result_for_default_png()) @override_settings(CACHES=OVERRIDE_CACHES_SETTING, QR_CODE_CACHE_ALIAS=None) def test_svg_with_cache_but_no_alias(self): self.test_svg_url() @override_settings(CACHES=OVERRIDE_CACHES_SETTING) def test_png_with_cache(self): self.test_png_url() @override_settings(CACHES=OVERRIDE_CACHES_SETTING, QR_CODE_CACHE_ALIAS=None) def test_png_with_cache_but_no_alias(self): self.test_png_url() @override_settings( QR_CODE_URL_PROTECTION=dict( TOKEN_LENGTH=30, SIGNING_KEY="my-secret-signing-key", SIGNING_SALT="my-signing-salt", ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=True, ) ) def test_url_with_protection_settings_1(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=False, cache_enabled=False)) # Registered users can access the URL externally, but since we are not logged in, we must expect an HTTP 403. self.assertEqual(response.status_code, 403) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=False)) def test_url_with_protection_settings_2(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 403) response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=lambda user: False)) def test_url_with_protection_settings_3(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 403) response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=lambda user: True)) def test_url_with_protection_settings_4(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() # The callable for ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER always return True, even for anonymous user. # Therefore, we must expect an HTTP 200. # We test with different values of url_signature_enabled. response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, cache_enabled=False)) self.assertEqual(response.status_code, 200) response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) response = self.client.get(make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 200) def test_url_with_invalid_signature_token(self): valid_url_with_signature_token = make_qr_code_url(TEST_TEXT_AS_UTF_8, force_text=False) url_with_invalid_signature_token = valid_url_with_signature_token.replace("token=", "token=some-front-padding") response = self.client.get(url_with_invalid_signature_token) self.assertEqual(response.status_code, 403) def test_url_with_wrong_signature_token(self): valid_url_with_signature_token_for_size_10 = make_qr_code_url(TEST_TEXT_AS_UTF_8, QRCodeOptions(size=10), force_text=False) valid_url_with_signature_token_for_size_8 = make_qr_code_url(TEST_TEXT_AS_UTF_8, QRCodeOptions(size=8), force_text=False) token_regex = re.compile(r"token=([^&]+)") match = token_regex.search(valid_url_with_signature_token_for_size_8) size_8_token_value = match.group(1) match = token_regex.search(valid_url_with_signature_token_for_size_10) size_10_token_value = match.group(1) url_with_invalid_signature_token = valid_url_with_signature_token_for_size_10.replace(size_10_token_value, size_8_token_value) response = self.client.get(url_with_invalid_signature_token) self.assertEqual(response.status_code, 403) def test_svg_error_correction(self): base_file_name = "qrfromdata_error_correction" for correction_level in ERROR_CORRECTION_DICT: print("Testing SVG URL with error correction: %s" % correction_level) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(error_correction=correction_level), force_text=False, cache_enabled=False ) url2 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, cache_enabled=False) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, image_format="svg", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, image_format="SVG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(error_correction=correction_level, image_format="SVG"), cache_enabled=False, ) # Using an invalid image format should fall back to SVG. url6 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, image_format="invalid-format-name", cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{correction_level.lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_error_correction(self): base_file_name = "qrfromdata_error_correction" for correction_level in ERROR_CORRECTION_DICT: print("Testing PNG URL with error correction: %s" % correction_level) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(error_correction=correction_level, image_format="png"), force_text=False, cache_enabled=False, ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(error_correction=correction_level, image_format="PNG"), force_text=False, cache_enabled=False, ) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, image_format="png", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, error_correction=correction_level, image_format="PNG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(error_correction=correction_level, image_format="PNG"), cache_enabled=False, ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{correction_level.lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_eci(self): base_file_name = "qrfromdata_eci" for eci in [False, True]: print("Testing SVG URL with ECI: %s" % eci) url1 = make_qr_code_url(COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(eci=eci), force_text=False, cache_enabled=False) url2 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, cache_enabled=False) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, image_format="svg", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, image_format="SVG", cache_enabled=False) url5 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(eci=eci, image_format="SVG"), cache_enabled=False) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, image_format="invalid-format-name", cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(eci).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_eci(self): base_file_name = "qrfromdata_eci" for eci in [False, True]: print("Testing PNG URL with ECI: %s" % eci) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(eci=eci, image_format="png"), force_text=False, cache_enabled=False ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(eci=eci, image_format="PNG"), force_text=False, cache_enabled=False ) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, image_format="png", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, eci=eci, image_format="PNG", cache_enabled=False) url5 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(eci=eci, image_format="PNG"), cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(eci).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_micro(self): base_file_name = "qrfromdata_micro" for micro in [False, True]: print("Testing SVG URL with micro: %s" % micro) url1 = make_qr_code_url(COMPLEX_TEST_TEXT_AS_ISO_8859_1, QRCodeOptions(micro=micro), force_text=False, cache_enabled=False) url2 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, cache_enabled=False) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, image_format="svg", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, image_format="SVG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_ISO_8859_1, options=QRCodeOptions(micro=micro, image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, image_format="invalid-format-name", cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(micro).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_micro(self): base_file_name = "qrfromdata_micro" for micro in [False, True]: print("Testing PNG URL with micro: %s" % micro) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_ISO_8859_1, QRCodeOptions(micro=micro, image_format="png"), force_text=False, cache_enabled=False ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_ISO_8859_1, QRCodeOptions(micro=micro, image_format="PNG"), force_text=False, cache_enabled=False ) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, image_format="png", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_ISO_8859_1, micro=micro, image_format="PNG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_ISO_8859_1, options=QRCodeOptions(micro=micro, image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(micro).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_boost_error(self): base_file_name = "qrfromdata_boost_error" for boost_error in [False, True]: print("Testing SVG URL with boost_error: %s" % boost_error) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(boost_error=boost_error), force_text=False, cache_enabled=False ) url2 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, cache_enabled=False) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, image_format="svg", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, image_format="SVG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(boost_error=boost_error, image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, image_format="invalid-format-name", cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(boost_error).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_boost_error(self): base_file_name = "qrfromdata_boost_error" for boost_error in [False, True]: print("Testing PNG URL with boost_error: %s" % boost_error) url1 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(boost_error=boost_error, image_format="png"), force_text=False, cache_enabled=False, ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT_AS_UTF_8, QRCodeOptions(boost_error=boost_error, image_format="PNG"), force_text=False, cache_enabled=False, ) url3 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, image_format="png", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT_AS_UTF_8, boost_error=boost_error, image_format="PNG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT_AS_UTF_8, options=QRCodeOptions(boost_error=boost_error, image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(boost_error).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_encoding(self): base_file_name = "qrfromdata_encoding" for encoding in ["utf-8", "iso-8859-1"]: print("Testing SVG URL with encoding: %s" % encoding) url1 = make_qr_code_url( COMPLEX_TEST_TEXT.encode(encoding), QRCodeOptions(encoding=encoding), force_text=False, cache_enabled=False ) url2 = qr_url_from_data(COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, cache_enabled=False) url3 = qr_url_from_data(COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, image_format="svg", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, image_format="SVG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT.encode(encoding), options=QRCodeOptions(encoding=encoding, image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_data( COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, image_format="invalid-format-name", cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(encoding).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_encoding(self): base_file_name = "qrfromdata_encoding" for encoding in ["utf-8", "iso-8859-1"]: print("Testing PNG URL with encoding: %s" % encoding) url1 = make_qr_code_url( COMPLEX_TEST_TEXT.encode(encoding), QRCodeOptions(encoding=encoding, image_format="png"), force_text=False, cache_enabled=False, ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT.encode(encoding), QRCodeOptions(encoding=encoding, image_format="PNG"), force_text=False, cache_enabled=False, ) url3 = qr_url_from_data(COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, image_format="png", cache_enabled=False) url4 = qr_url_from_data(COMPLEX_TEST_TEXT.encode(encoding), encoding=encoding, image_format="PNG", cache_enabled=False) url5 = qr_url_from_data( COMPLEX_TEST_TEXT.encode(encoding), options=QRCodeOptions(encoding=encoding, image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(encoding).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) class TestQRFromDataSvgResult(SimpleTestCase): """ Ensures that produced QR codes in SVG format coincide with verified references. The tests cover direct call to tag function, rendering of tag, and direct call to qr_code API. """ def setUp(self): self.maxDiff = None def test_size(self): base_ref_file_name = "qrfromdata_size" sizes = ["t", "T", "s", "S", None, -1, 0, "m", "M", "l", "L", "h", "H", "6", 6, "8", 8, "10", 10] size_names = ["tiny"] * 2 + ["small"] * 2 + ["medium"] * 5 + ["large"] * 2 + ["huge"] * 2 + ["6"] * 2 + ["8"] * 2 + ["10"] * 2 for i in range(len(sizes)): size = sizes[i] print("Testing SVG with size %s" % size) size_name = size_names[i] qr1 = make_embedded_qr_code(TEST_TEXT_AS_UTF_8, QRCodeOptions(size=size), force_text=False) qr2 = qr_from_data(TEST_TEXT_AS_UTF_8, size=size) qr3 = qr_from_data(TEST_TEXT_AS_UTF_8, size=size, image_format="svg") qr4 = qr_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(size=size, image_format="svg")) qr5 = qr_from_data(TEST_TEXT_AS_UTF_8, size=size, image_format="invalid-format-name") result_file_name = f"{base_ref_file_name}_{size_name}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(result_file_name, qr1) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, qr5) self.assertEqual(qr1, result) def test_version(self): base_file_name = "qrfromdata_version" versions = [None, -1, 0, 41, "-1", "0", "41", "blabla", 1, "1", 2, "2", 4, "4"] version_names = ["default"] * 10 + ["2", "2", "4", "4"] for i in range(len(versions)): version = versions[i] print("Testing SVG with version %s" % version) version_name = version_names[i] qr1 = make_embedded_qr_code(TEST_TEXT_AS_UTF_8, QRCodeOptions(version=version), force_text=False) qr2 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version) qr3 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version, image_format="svg") qr4 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version, image_format="SVG") qr5 = qr_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(version=version, image_format="SVG")) qr6 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version, image_format="invalid-format-name") result_file_name = f"{base_file_name}_{version_name}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(result_file_name, qr1) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, qr5) self.assertEqual(qr1, qr6) self.assertEqual(qr1, result) def test_error_correction(self): file_base_name = "qrfromdata_error_correction" tests_data = [] for correction_level in ERROR_CORRECTION_DICT.keys(): ref_file_name = f"{file_base_name}_{correction_level}" tests_data.append( dict( source=f'{{% qr_from_data data image_format="svg" error_correction="{correction_level}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_eci(self): file_base_name = "qrfromdata_eci" tests_data = [] for eci in [False, True]: ref_file_name = f"{file_base_name}_{eci}" tests_data.append(dict(source=f'{{% qr_from_data data image_format="svg" eci={eci} %}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_micro(self): file_base_name = "qrfromdata_micro" tests_data = [] for micro in [False, True]: ref_file_name = f"{file_base_name}_{micro}" tests_data.append( dict( source=f'{{% qr_from_data data image_format="svg" micro={micro} encoding="iso-8859-1" %}}', ref_file_name=ref_file_name.lower(), ) ) tests_data.append( dict( source=f'{{% qr_from_data data image_format="svg" micro={micro} encoding=None %}}', ref_file_name=ref_file_name.lower() ) ) tests_data.append( dict( source=f'{{% qr_from_data data image_format="svg" micro={micro} encoding="utf-8" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_ISO_8859_1)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_boost_error(self): file_base_name = "qrfromdata_boost_error" tests_data = [] for boost_error in [False, True]: ref_file_name = f"{file_base_name}_{boost_error}" tests_data.append( dict(source=f'{{% qr_from_data data image_format="svg" boost_error={boost_error} %}}', ref_file_name=ref_file_name.lower()) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_encoding(self): file_base_name = "qrfromdata_encoding" tests_data = [] for encoding in ["utf-8", "iso-8859-1"]: ref_file_name = f"{file_base_name}_{encoding}" tests_data.append( dict( encoding=encoding, source=f'{{% qr_from_data data image_format="svg" encoding="{encoding}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) data = COMPLEX_TEST_TEXT.encode(encoding=test_data["encoding"]) context = Context(dict(data=data)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_mode(self): file_base_name = "qrfromdata_mode" tests_data = [] data_for_mode = [ TEST_TEXT_AS_UTF_8, COMPLEX_TEST_TEXT_AS_UTF_8, COMPLEX_TEST_TEXT_AS_ISO_8859_1, 123, "123", "ABCD1234", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "義務教育諸学校教科用図書検定基準".encode("cp932"), "ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?".encode("shift-jis"), ] encodings = ["utf-8", "utf-8", "iso-8859-1", None, None, None, None, None, "shift-jis"] for mode_index in range(len(data_for_mode)): ref_file_name = f"{file_base_name}_{mode_index}" tests_data.append(dict(source=f'{{% qr_from_data data image_format="svg" %}}', ref_file_name=ref_file_name.lower())) for i, test_data in enumerate(tests_data): print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=data_for_mode[i], encoding=encodings[i])) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) class TestQRFromDataPngResult(SimpleTestCase): """ Ensures that produced QR codes in PNG format coincide with verified references. The tests cover direct call to tag function, rendering of tag, and direct call to qr_code API. """ def setUp(self): self.maxDiff = None def test_size(self): base_ref_file_name = "qrfromdata_size" sizes = ["t", "T", "s", "S", None, -1, 0, "m", "M", "l", "L", "h", "H", "6", 6, "8", 8, "10", 10] size_names = ["tiny"] * 2 + ["small"] * 2 + ["medium"] * 5 + ["large"] * 2 + ["huge"] * 2 + ["6"] * 2 + ["8"] * 2 + ["10"] * 2 for i in range(len(sizes)): size = sizes[i] print("Testing PNG with size %s" % size) size_name = size_names[i] result_file_name = f"{base_ref_file_name}_{size_name}" qr1 = make_embedded_qr_code(TEST_TEXT_AS_UTF_8, QRCodeOptions(size=size, image_format="png"), force_text=False) qr2 = qr_from_data(TEST_TEXT_AS_UTF_8, size=size, image_format="png") qr3 = qr_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(size=size, image_format="png"), force_text=False) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template() % result) def test_version(self): base_file_name = "qrfromdata_version" versions = [None, -1, 0, 41, "-1", "0", "41", "blabla", 1, "1", 2, "2", 4, "4"] version_names = ["default"] * 10 + ["2", "2", "4", "4"] for i in range(len(versions)): version = versions[i] print("Testing PNG with version %s" % version) version_name = version_names[i] qr1 = make_embedded_qr_code(TEST_TEXT_AS_UTF_8, QRCodeOptions(version=version, image_format="png"), force_text=False) qr2 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version, image_format="png") qr3 = qr_from_data(TEST_TEXT_AS_UTF_8, version=version, image_format="PNG") qr4 = qr_from_data(TEST_TEXT_AS_UTF_8, options=QRCodeOptions(version=version, image_format="PNG")) result_file_name = f"{base_file_name}_{version_name}" if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, get_base64_png_image_template() % result) def test_error_correction(self): file_base_name = "qrfromdata_error_correction" tests_data = [] for correction_level in ERROR_CORRECTION_DICT.keys(): ref_file_name = f"{file_base_name}_{correction_level}" tests_data.append( dict( source=f'{{% qr_from_data data image_format="png" error_correction="{correction_level}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_eci(self): file_base_name = "qrfromdata_eci" tests_data = [] for eci in [False, True]: ref_file_name = f"{file_base_name}_{eci}" tests_data.append(dict(source=f'{{% qr_from_data data image_format="png" eci={eci} %}}', ref_file_name=ref_file_name.lower())) # tests_data.append(dict(source=f'{{% qr_from_data "{COMPLEX_TEST_TEXT_AS_UTF_8}" image_format="png" eci="{eci}" %}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_micro(self): file_base_name = "qrfromdata_micro" tests_data = [] for micro in [False, True]: ref_file_name = f"{file_base_name}_{micro}" tests_data.append( dict(source=f'{{% qr_from_data data image_format="png" micro={micro}%}}', ref_file_name=ref_file_name.lower()) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_ISO_8859_1)) source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_boost_error(self): file_base_name = "qrfromdata_boost_error" tests_data = [] for boost_error in [False, True]: ref_file_name = f"{file_base_name}_{boost_error}" tests_data.append( dict(source=f'{{% qr_from_data data image_format="png" boost_error={boost_error}%}}', ref_file_name=ref_file_name.lower()) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT_AS_UTF_8)) source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_encoding(self): file_base_name = "qrfromdata_encoding" tests_data = [] for encoding in ["utf-8", "iso-8859-1"]: ref_file_name = f"{file_base_name}_{encoding}" tests_data.append( dict( encoding=encoding, source=f'{{% qr_from_data data image_format="png" encoding="{encoding}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) data = COMPLEX_TEST_TEXT.encode(encoding=test_data["encoding"]) context = Context(dict(data=data)) source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_mode(self): file_base_name = "qrfromdata_mode" tests_data = [] data_for_mode = [ TEST_TEXT_AS_UTF_8, COMPLEX_TEST_TEXT_AS_UTF_8, COMPLEX_TEST_TEXT_AS_ISO_8859_1, 123, "123", "ABCD1234", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "義務教育諸学校教科用図書検定基準".encode("cp932"), "ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?".encode("shift-jis"), ] encodings = ["utf-8", "utf-8", "iso-8859-1", None, None, None, None, None, "shift-jis"] for mode_index in range(len(data_for_mode)): ref_file_name = f"{file_base_name}_{mode_index}" tests_data.append( dict(source=f'{{% qr_from_data data image_format="png" encoding=encoding %}}', ref_file_name=ref_file_name.lower()) ) for i, test_data in enumerate(tests_data): print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=data_for_mode[i], encoding=encodings[i])) source_image = template.render(context).strip() source_image_data = source_image[32 : source_image.index('" alt="')] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) django-qr-code-4.1.0/qr_code/tests/test_qr_from_text.py000066400000000000000000001735251462661477300232430ustar00rootroot00000000000000"""Tests for qr_code application.""" import base64 import hashlib import re from decimal import Decimal from itertools import product from django.conf import settings from django.contrib.auth.models import AnonymousUser, User from django.core.cache import caches from django.template import Template, Context from django.test import SimpleTestCase, override_settings from django.utils.safestring import mark_safe from django.utils.html import escape from qr_code.qrcode.maker import make_embedded_qr_code from qr_code.qrcode.constants import ERROR_CORRECTION_DICT from qr_code.qrcode.serve import make_qr_code_url, allows_external_request_from_user from qr_code.qrcode.utils import QRCodeOptions from qr_code.templatetags.qr_code import qr_from_text, qr_url_from_text from qr_code.tests import ( REFRESH_REFERENCE_IMAGES, TEST_TEXT, OVERRIDE_CACHES_SETTING, COMPLEX_TEST_TEXT, get_base64_png_image_template, IMAGE_TAG_BASE64_DATA_RE, ) from qr_code.tests.utils import ( write_svg_content_to_file, write_png_content_to_file, get_svg_content_from_file_name, get_png_content_from_file_name, get_urls_without_token_for_comparison, minimal_svg, ) class TestQRUrlFromTextResult(SimpleTestCase): """ Ensures that serving images representing QR codes works as expected (with or without caching, and with or without protection against external requests). """ default_ref_base_file_name = "qrfromtext_default" def setUp(self): self.maxDiff = None @staticmethod def _get_reference_result_for_default_svg(): return get_svg_content_from_file_name(TestQRUrlFromTextResult.default_ref_base_file_name) @staticmethod def _get_reference_result_for_default_png(): return get_png_content_from_file_name(TestQRUrlFromTextResult.default_ref_base_file_name) def test_svg_url(self): is_first = True users = [None, AnonymousUser(), User(username="test")] for url_options in product([True, False, None], [True, False, None], users): cache_enabled = url_options[0] url_signature_enabled = url_options[1] user = url_options[2] print(f"\t - cache_enabled={cache_enabled}, url_signature_enabled={url_signature_enabled}, user={user}") url_options_kwargs = dict() url0 = make_qr_code_url( TEST_TEXT, QRCodeOptions(size=1), **dict(**url_options_kwargs, cache_enabled=cache_enabled, url_signature_enabled=url_signature_enabled), ) if cache_enabled is not None: url_options_kwargs["cache_enabled"] = cache_enabled url1 = make_qr_code_url( TEST_TEXT, QRCodeOptions(size=1), **dict(**url_options_kwargs, url_signature_enabled=url_signature_enabled) ) if url_signature_enabled is not None: url_options_kwargs["url_signature_enabled"] = url_signature_enabled url2 = qr_url_from_text(TEST_TEXT, size=1, **url_options_kwargs) url3 = qr_url_from_text(TEST_TEXT, image_format="svg", size=1, **url_options_kwargs) url4 = qr_url_from_text(TEST_TEXT, image_format="SVG", size=1, **url_options_kwargs) url5 = qr_url_from_text(TEST_TEXT, options=QRCodeOptions(image_format="SVG", size=1), **url_options_kwargs) # Using an invalid image format should fall back to SVG. url6 = qr_url_from_text(TEST_TEXT, image_format="invalid-format-name", size=1, **url_options_kwargs) url = url1 if url_signature_enabled is not False: urls = get_urls_without_token_for_comparison(url0, url1, url2, url3, url4, url5, url6) else: urls = [url0, url1, url2, url3, url4, url5, url6] self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) expected_status_code = 200 if url_signature_enabled is False and not allows_external_request_from_user(user): expected_status_code = 403 self.assertEqual(response.status_code, expected_status_code) image_data = response.content.decode("utf-8") if expected_status_code == 200: if is_first and REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(TestQRUrlFromTextResult.default_ref_base_file_name, image_data) is_first = False self.assertEqual(image_data, TestQRUrlFromTextResult._get_reference_result_for_default_svg()) def test_png_url(self): is_first = True for url_options in product([True, False, None], [True, False, None]): cache_enabled = url_options[0] url_signature_enabled = url_options[1] url_options_kwargs = dict() if cache_enabled is not None: url_options_kwargs["cache_enabled"] = cache_enabled if url_signature_enabled is not None: url_options_kwargs["url_signature_enabled"] = url_signature_enabled url1 = make_qr_code_url(TEST_TEXT, QRCodeOptions(image_format="png", size=1), **url_options_kwargs) url2 = qr_url_from_text(TEST_TEXT, image_format="png", size=1, **url_options_kwargs) url3 = qr_url_from_text(TEST_TEXT, image_format="PNG", size=1, **url_options_kwargs) url4 = qr_url_from_text(TEST_TEXT, options=QRCodeOptions(image_format="PNG", size=1), **url_options_kwargs) url = url1 if url_signature_enabled is not False: urls = get_urls_without_token_for_comparison(url1, url2, url3, url4) else: urls = [url1, url2, url3, url4] self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) response = self.client.get(url) print(f"\t - cache_enabled={cache_enabled}, url_signature_enabled={url_signature_enabled}") expected_status_code = 200 if url_signature_enabled is False and not allows_external_request_from_user(None): expected_status_code = 403 self.assertEqual(response.status_code, expected_status_code) if expected_status_code == 200: if is_first and REFRESH_REFERENCE_IMAGES: write_png_content_to_file(TestQRUrlFromTextResult.default_ref_base_file_name, response.content) is_first = False self.assertEqual(response.content, TestQRUrlFromTextResult._get_reference_result_for_default_png()) @override_settings(CACHES=OVERRIDE_CACHES_SETTING, QR_CODE_CACHE_ALIAS=None) def test_svg_with_cache_but_no_alias(self): self.test_svg_url() @override_settings(CACHES=OVERRIDE_CACHES_SETTING) def test_png_with_cache(self): self.test_png_url() @override_settings(CACHES=OVERRIDE_CACHES_SETTING, QR_CODE_CACHE_ALIAS=None) def test_png_with_cache_but_no_alias(self): self.test_png_url() @override_settings( QR_CODE_URL_PROTECTION=dict( TOKEN_LENGTH=30, SIGNING_KEY="my-secret-signing-key", SIGNING_SALT="my-signing-salt", ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=True, ) ) def test_url_with_protection_settings_1(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=False, cache_enabled=False)) # Registered users can access the URL externally, but since we are not logged in, we must expect an HTTP 403. self.assertEqual(response.status_code, 403) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=False)) def test_url_with_protection_settings_2(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 403) response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=lambda user: False)) def test_url_with_protection_settings_3(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 403) response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) @override_settings(QR_CODE_URL_PROTECTION=dict(ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER=lambda user: True)) def test_url_with_protection_settings_4(self): # We need to clear cache every time we change the QR_CODE_URL_PROTECTION to avoid incidence between tests. caches[settings.QR_CODE_CACHE_ALIAS].clear() self.test_svg_url() self.test_png_url() # The callable for ALLOWS_EXTERNAL_REQUESTS_FOR_REGISTERED_USER always return True, even for anonymous user. # Therefore, we must expect an HTTP 200. # We test with different values of url_signature_enabled. response = self.client.get(make_qr_code_url(TEST_TEXT, cache_enabled=False)) self.assertEqual(response.status_code, 200) response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=True, cache_enabled=False)) self.assertEqual(response.status_code, 200) response = self.client.get(make_qr_code_url(TEST_TEXT, url_signature_enabled=False, cache_enabled=False)) self.assertEqual(response.status_code, 200) def test_url_with_invalid_signature_token(self): valid_url_with_signature_token = make_qr_code_url(TEST_TEXT) url_with_invalid_signature_token = valid_url_with_signature_token.replace("token=", "token=some-front-padding") response = self.client.get(url_with_invalid_signature_token) self.assertEqual(response.status_code, 403) def test_url_with_wrong_signature_token(self): valid_url_with_signature_token_for_size_10 = make_qr_code_url(TEST_TEXT, QRCodeOptions(size=10)) valid_url_with_signature_token_for_size_8 = make_qr_code_url(TEST_TEXT, QRCodeOptions(size=8)) token_regex = re.compile(r"token=([^&]+)") match = token_regex.search(valid_url_with_signature_token_for_size_8) size_8_token_value = match.group(1) match = token_regex.search(valid_url_with_signature_token_for_size_10) size_10_token_value = match.group(1) url_with_invalid_signature_token = valid_url_with_signature_token_for_size_10.replace(size_10_token_value, size_8_token_value) response = self.client.get(url_with_invalid_signature_token) self.assertEqual(response.status_code, 403) def test_svg_error_correction(self): base_file_name = "qrfromtext_error_correction" for correction_level in ERROR_CORRECTION_DICT: print("Testing SVG URL with error correction: %s" % correction_level) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(error_correction=correction_level), cache_enabled=False) url2 = qr_url_from_text(COMPLEX_TEST_TEXT, error_correction=correction_level, cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, error_correction=correction_level, image_format="svg", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, error_correction=correction_level, image_format="SVG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(error_correction=correction_level, image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_text( COMPLEX_TEST_TEXT, error_correction=correction_level, image_format="invalid-format-name", cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{correction_level.lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_error_correction(self): base_file_name = "qrfromtext_error_correction" for correction_level in ERROR_CORRECTION_DICT: print("Testing PNG URL with error correction: %s" % correction_level) url1 = make_qr_code_url( COMPLEX_TEST_TEXT, QRCodeOptions(error_correction=correction_level, image_format="png"), cache_enabled=False ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT, QRCodeOptions(error_correction=correction_level, image_format="PNG"), cache_enabled=False ) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, error_correction=correction_level, image_format="png", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, error_correction=correction_level, image_format="PNG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(error_correction=correction_level, image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{correction_level.lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_eci(self): base_file_name = "qrfromtext_eci" for eci in [False, True]: print("Testing SVG URL with ECI: %s" % eci) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(eci=eci), cache_enabled=False) url2 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, image_format="svg", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, image_format="SVG", cache_enabled=False) url5 = qr_url_from_text(COMPLEX_TEST_TEXT, options=QRCodeOptions(eci=eci, image_format="SVG"), cache_enabled=False) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, image_format="invalid-format-name", cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(eci).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_eci(self): base_file_name = "qrfromtext_eci" for eci in [False, True]: print("Testing PNG URL with ECI: %s" % eci) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(eci=eci, image_format="png"), cache_enabled=False) url2 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(eci=eci, image_format="PNG"), cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, image_format="png", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, eci=eci, image_format="PNG", cache_enabled=False) url5 = qr_url_from_text(COMPLEX_TEST_TEXT, options=QRCodeOptions(eci=eci, image_format="PNG"), cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(eci).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_micro(self): base_file_name = "qrfromtext_micro" for micro in [False, True]: print("Testing SVG URL with micro: %s" % micro) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(micro=micro, encoding="iso-8859-1"), cache_enabled=False) url2 = qr_url_from_text(COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", image_format="svg", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", image_format="SVG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(micro=micro, encoding="iso-8859-1", image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_text( COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", image_format="invalid-format-name", cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(micro).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_micro(self): base_file_name = "qrfromtext_micro" for micro in [False, True]: print("Testing PNG URL with micro: %s" % micro) url1 = make_qr_code_url( COMPLEX_TEST_TEXT, QRCodeOptions(micro=micro, encoding="iso-8859-1", image_format="png"), cache_enabled=False ) url2 = make_qr_code_url( COMPLEX_TEST_TEXT, QRCodeOptions(micro=micro, encoding="iso-8859-1", image_format="PNG"), cache_enabled=False ) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", image_format="png", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, micro=micro, encoding="iso-8859-1", image_format="PNG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(micro=micro, encoding="iso-8859-1", image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(micro).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_boost_error(self): base_file_name = "qrfromtext_boost_error" for boost_error in [False, True]: print("Testing SVG URL with boost_error: %s" % boost_error) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(boost_error=boost_error), cache_enabled=False) url2 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, image_format="svg", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, image_format="SVG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(boost_error=boost_error, image_format="SVG"), cache_enabled=False ) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, image_format="invalid-format-name", cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") ref_file_name = f"{base_file_name}_{str(boost_error).lower()}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_png_boost_error(self): base_file_name = "qrfromtext_boost_error" for boost_error in [False, True]: print("Testing PNG URL with boost_error: %s" % boost_error) url1 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(boost_error=boost_error, image_format="png"), cache_enabled=False) url2 = make_qr_code_url(COMPLEX_TEST_TEXT, QRCodeOptions(boost_error=boost_error, image_format="PNG"), cache_enabled=False) url3 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, image_format="png", cache_enabled=False) url4 = qr_url_from_text(COMPLEX_TEST_TEXT, boost_error=boost_error, image_format="PNG", cache_enabled=False) url5 = qr_url_from_text( COMPLEX_TEST_TEXT, options=QRCodeOptions(boost_error=boost_error, image_format="PNG"), cache_enabled=False ) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content ref_file_name = f"{base_file_name}_{str(boost_error).lower()}" if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) def test_svg_encoding(self): file_base_name = "qrfromtext_encoding" data_for_encoding = [ (TEST_TEXT, "utf-8"), (TEST_TEXT, "iso-8859-1"), (TEST_TEXT, None), (COMPLEX_TEST_TEXT, "utf-8"), (COMPLEX_TEST_TEXT, "iso-8859-1"), (COMPLEX_TEST_TEXT, None), ("ABCD1234", "utf-8"), ("ABCD1234", "iso-8859-1"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "utf-8"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "iso-8859-1"), ("義務教育諸学校教科用図書検定基準", "utf-8"), ("義務教育諸学校教科用図書検定基準", "cp932"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "utf-8"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "shift-jis"), ] for text, encoding in data_for_encoding: text_id = hashlib.md5(text.encode("utf-8")).hexdigest() ref_file_name = f"{file_base_name}_{text_id}_{str(encoding).lower()}" print(f"Testing SVG URL with encoding {encoding}' for text '{text}' ({text_id})") url1 = make_qr_code_url(text, QRCodeOptions(encoding=encoding), cache_enabled=False) url2 = qr_url_from_text(text, encoding=encoding, cache_enabled=False) url3 = qr_url_from_text(text, encoding=encoding, image_format="svg", cache_enabled=False) url4 = qr_url_from_text(text, encoding=encoding, image_format="SVG", cache_enabled=False) url5 = qr_url_from_text(text, options=QRCodeOptions(encoding=encoding, image_format="SVG"), cache_enabled=False) # Using an invalid image format should fallback to SVG. url6 = qr_url_from_text(text, encoding=encoding, image_format="invalid-format-name", cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5, url6) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) self.assertEqual(urls[0], urls[5]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content.decode("utf-8") if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(ref_file_name, source_image_data) ref_image_data = get_svg_content_from_file_name(ref_file_name) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_png_encoding(self): file_base_name = "qrfromtext_encoding" data_for_encoding = [ (TEST_TEXT, "utf-8"), (TEST_TEXT, "iso-8859-1"), (TEST_TEXT, None), (COMPLEX_TEST_TEXT, "utf-8"), (COMPLEX_TEST_TEXT, "iso-8859-1"), (COMPLEX_TEST_TEXT, None), ("ABCD1234", "utf-8"), ("ABCD1234", "iso-8859-1"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "utf-8"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "iso-8859-1"), ("義務教育諸学校教科用図書検定基準", "utf-8"), ("義務教育諸学校教科用図書検定基準", "cp932"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "utf-8"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "shift-jis"), ] for text, encoding in data_for_encoding: text_id = hashlib.md5(text.encode("utf-8")).hexdigest() ref_file_name = f"{file_base_name}_{text_id}_{str(encoding).lower()}" print(f"Testing PNG URL with encoding {encoding}' for text '{text}' ({text_id})") url1 = make_qr_code_url(text, QRCodeOptions(encoding=encoding, image_format="png"), cache_enabled=False) url2 = make_qr_code_url(text, QRCodeOptions(encoding=encoding, image_format="PNG"), cache_enabled=False) url3 = qr_url_from_text(text, encoding=encoding, image_format="png", cache_enabled=False) url4 = qr_url_from_text(text, encoding=encoding, image_format="PNG", cache_enabled=False) url5 = qr_url_from_text(text, options=QRCodeOptions(encoding=encoding, image_format="PNG"), cache_enabled=False) url = url1 urls = get_urls_without_token_for_comparison(url1, url2, url3, url4, url5) self.assertEqual(urls[0], urls[1]) self.assertEqual(urls[0], urls[2]) self.assertEqual(urls[0], urls[3]) self.assertEqual(urls[0], urls[4]) response = self.client.get(url) self.assertEqual(response.status_code, 200) source_image_data = response.content if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(ref_file_name, source_image_data) ref_image_data = get_png_content_from_file_name(ref_file_name) self.assertEqual(source_image_data, ref_image_data) class TestQRFromTextSvgResult(SimpleTestCase): """ Ensures that produced QR codes in SVG format coincide with verified references. The tests cover direct call to tag function, rendering of tag, and direct call to qr_code API. """ def setUp(self): self.maxDiff = None def test_size(self): base_ref_file_name = "qrfromtext_size" sizes = ["t", "T", "s", "S", None, -1, 0, "m", "M", "l", "L", "h", "H", "6", 6, "8", 8, "10", 10, 2.1, Decimal("1.2")] size_names = ( ["tiny"] * 2 + ["small"] * 2 + ["medium"] * 5 + ["large"] * 2 + ["huge"] * 2 + ["6"] * 2 + ["8"] * 2 + ["10"] * 2 + ["2.1"] + ["1.2"] ) for i in range(len(sizes)): size = sizes[i] print("Testing SVG with size %s" % size) size_name = size_names[i] qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(size=size)) qr2 = qr_from_text(TEST_TEXT, size=size) qr3 = qr_from_text(TEST_TEXT, size=size, image_format="svg") qr4 = qr_from_text(TEST_TEXT, options=QRCodeOptions(size=size, image_format="svg")) qr5 = qr_from_text(TEST_TEXT, size=size, image_format="invalid-format-name") result_file_name = f"{base_ref_file_name}_{size_name}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(result_file_name, qr1) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, qr5) self.assertEqual(qr1, result) def test_version(self): base_file_name = "qrfromtext_version" versions = [None, -1, 0, 41, "-1", "0", "41", "blabla", 1, "1", 2, "2", 4, "4"] version_names = ["default"] * 10 + ["2", "2", "4", "4"] for i in range(len(versions)): version = versions[i] print("Testing SVG with version %s" % version) version_name = version_names[i] qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(version=version)) qr2 = qr_from_text(TEST_TEXT, version=version) qr3 = qr_from_text(TEST_TEXT, version=version, image_format="svg") qr4 = qr_from_text(TEST_TEXT, version=version, image_format="SVG") qr5 = qr_from_text(TEST_TEXT, options=QRCodeOptions(version=version, image_format="SVG")) qr6 = qr_from_text(TEST_TEXT, version=version, image_format="invalid-format-name") result_file_name = f"{base_file_name}_{version_name}" if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(result_file_name, qr1) result = get_svg_content_from_file_name(result_file_name) self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, qr5) self.assertEqual(qr1, qr6) self.assertEqual(qr1, result) def test_error_correction(self): file_base_name = "qrfromtext_error_correction" tests_data = [] for correction_level in ERROR_CORRECTION_DICT.keys(): ref_file_name = f"{file_base_name}_{correction_level}" tests_data.append( dict( source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="svg" error_correction="{correction_level}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_eci(self): file_base_name = "qrfromtext_eci" tests_data = [] for eci in [False, True]: ref_file_name = f"{file_base_name}_{eci}" tests_data.append( dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="svg" eci={eci} %}}', ref_file_name=ref_file_name.lower()) ) # tests_data.append(dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="svg" eci="{eci}" %}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_micro(self): file_base_name = "qrfromtext_micro" tests_data = [] for micro in [False, True]: ref_file_name = f"{file_base_name}_{micro}" tests_data.append( dict( source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="svg" encoding="iso-8859-1" micro={micro} %}}', ref_file_name=ref_file_name.lower(), ) ) # tests_data.append(dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="svg" micro="{micro}" %}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_boost_error(self): file_base_name = "qrfromtext_boost_error" tests_data = [] for boost_error in [False, True]: ref_file_name = f"{file_base_name}_{boost_error}" tests_data.append( dict(source=f'{{% qr_from_text data image_format="svg" boost_error={boost_error} %}}', ref_file_name=ref_file_name.lower()) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT)) source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_encoding(self): file_base_name = "qrfromtext_encoding" tests_data = [] data_for_encoding = [ (TEST_TEXT, "utf-8"), (TEST_TEXT, "iso-8859-1"), (TEST_TEXT, None), (COMPLEX_TEST_TEXT, "utf-8"), (COMPLEX_TEST_TEXT, "iso-8859-1"), (COMPLEX_TEST_TEXT, None), ("ABCD1234", "utf-8"), ("ABCD1234", "iso-8859-1"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "utf-8"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "iso-8859-1"), ("義務教育諸学校教科用図書検定基準", "utf-8"), ("義務教育諸学校教科用図書検定基準", "cp932"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "utf-8"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "shift-jis"), ] for text, encoding in data_for_encoding: text_id = hashlib.md5(text.encode("utf-8")).hexdigest() ref_file_name = f"{file_base_name}_{text_id}_{str(encoding).lower()}" tests_data.append( dict( source=f'{{% qr_from_text "{text}" image_format="svg" encoding="{encoding}" %}}', text=text, ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image_data = template.render(context) if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_svg_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(minimal_svg(source_image_data), minimal_svg(ref_image_data)) def test_colors(self): def run_tests(): if REFRESH_REFERENCE_IMAGES: write_svg_content_to_file(result_file_name, qr1) self.assertEqual(minimal_svg(qr1), minimal_svg(qr2)) self.assertEqual(minimal_svg(qr1), minimal_svg(qr3)) ref_image_data = minimal_svg(get_svg_content_from_file_name(result_file_name)) self.assertEqual(minimal_svg(qr1), ref_image_data) base_ref_file_name = "qrfromtext_color" colors = ["#000", "#000000", "black", "#fff", "#FFFFFF", "white", "red", "blue", None] color_names = ["black"] * 2 + ["black"] + ["white_hexa"] * 2 + ["white"] + ["red", "blue", "transparent"] for i in range(len(colors)): color = colors[i] color_name = color_names[i] print("Testing SVG with dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_dark_{color_name}" # Set light color to pink to avoid black on black or white on white. qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(dark_color=color, light_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, dark_color=color, light_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(dark_color=color, light_color="pink", image_format="svg")) run_tests() print("Testing SVG with light color %s" % color_name) result_file_name = f"{base_ref_file_name}_light_{color_name}" # Set dark color to pink to avoid black on black or white on white. qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(light_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, light_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(light_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with data_dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_data_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(data_dark_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, data_dark_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(data_dark_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with data light color %s" % color_name) result_file_name = f"{base_ref_file_name}_data_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(data_light_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, data_light_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(data_light_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with finder dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_finder_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(finder_dark_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, finder_dark_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(finder_dark_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with finder light color %s" % color_name) result_file_name = f"{base_ref_file_name}_finder_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(finder_light_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, finder_light_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(finder_light_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with dark module color %s" % color_name) result_file_name = f"{base_ref_file_name}_dark_module_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(dark_module_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, dark_module_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(dark_module_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with alignment dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_alignment_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(alignment_dark_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, alignment_dark_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(alignment_dark_color=color, dark_color="pink", image_format="svg")) run_tests() print("Testing SVG with alignment light color %s" % color_name) result_file_name = f"{base_ref_file_name}_alignment_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(alignment_light_color=color, dark_color="pink", image_format="svg")) qr2 = qr_from_text(TEST_TEXT, alignment_light_color=color, dark_color="pink", image_format="svg") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(alignment_light_color=color, dark_color="pink", image_format="svg")) run_tests() class TestQRFromTextPngResult(SimpleTestCase): """ Ensures that produced QR codes in PNG format coincide with verified references. The tests cover direct call to tag function, rendering of tag, and direct call to qr_code API. """ def setUp(self): self.maxDiff = None def test_size(self): base_ref_file_name = "qrfromtext_size" sizes = ["t", "T", "s", "S", None, -1, 0, "m", "M", "l", "L", "h", "H", "6", 6, "8", 8, "10", 10, 2.1] size_names = ( ["tiny"] * 2 + ["small"] * 2 + ["medium"] * 5 + ["large"] * 2 + ["huge"] * 2 + ["6"] * 2 + ["8"] * 2 + ["10"] * 2 + ["2.1"] ) for i in range(len(sizes)): size = sizes[i] print("Testing PNG with size %s" % size) size_name = size_names[i] result_file_name = f"{base_ref_file_name}_{size_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(size=size, image_format="png")) qr2 = qr_from_text(TEST_TEXT, size=size, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(size=size, image_format="png")) if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template() % result) def test_version(self): base_file_name = "qrfromtext_version" versions = [None, -1, 0, 41, "-1", "0", "41", "blabla", 1, "1", 2, "2", 4, "4"] version_names = ["default"] * 10 + ["2", "2", "4", "4"] for i in range(len(versions)): version = versions[i] print("Testing PNG with version %s" % version) version_name = version_names[i] qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(version=version, image_format="png")) qr2 = qr_from_text(TEST_TEXT, version=version, image_format="png") qr3 = qr_from_text(TEST_TEXT, version=version, image_format="PNG") qr4 = qr_from_text(TEST_TEXT, options=QRCodeOptions(version=version, image_format="PNG")) result_file_name = f"{base_file_name}_{version_name}" if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, qr4) self.assertEqual(qr1, get_base64_png_image_template() % result) def test_error_correction(self): file_base_name = "qrfromtext_error_correction" tests_data = [] for correction_level in ERROR_CORRECTION_DICT.keys(): ref_file_name = f"{file_base_name}_{correction_level}" tests_data.append( dict( source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" error_correction="{correction_level}" %}}', ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_eci(self): file_base_name = "qrfromtext_eci" tests_data = [] for eci in [False, True]: ref_file_name = f"{file_base_name}_{eci}" tests_data.append( dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" eci={eci} %}}', ref_file_name=ref_file_name.lower()) ) # tests_data.append(dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" eci="{eci}" %}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_micro(self): file_base_name = "qrfromtext_micro" tests_data = [] for micro in [False, True]: ref_file_name = f"{file_base_name}_{micro}" tests_data.append( dict( source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" encoding=None micro={micro}%}}', ref_file_name=ref_file_name.lower(), ) ) tests_data.append( dict( source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" encoding="iso-8859-1" micro={micro}%}}', ref_file_name=ref_file_name.lower(), ) ) # tests_data.append(dict(source=f'{{% qr_from_text "{COMPLEX_TEST_TEXT}" image_format="png" micro="{micro}"%}}', ref_file_name=ref_file_name.lower())) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_boost_error(self): file_base_name = "qrfromtext_boost_error" tests_data = [] for boost_error in [False, True]: ref_file_name = f"{file_base_name}_{boost_error}" tests_data.append( dict(source=f'{{% qr_from_text data image_format="png" boost_error={boost_error} %}}', ref_file_name=ref_file_name.lower()) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context(dict(data=COMPLEX_TEST_TEXT)) source_image = template.render(context).strip() # template = Template(html_source.replace('qr_from_text', 'qr_url_from_text')) # url = template.render(context).strip() # response = self.client.get(url) # new_image = base64.b64encode(response.content) source_image_data = source_image[32 : -len('" alt="%s"' % escape(COMPLEX_TEST_TEXT))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_encoding(self): file_base_name = "qrfromtext_encoding" tests_data = [] data_for_encoding = [ (TEST_TEXT, "utf-8"), (TEST_TEXT, "iso-8859-1"), (TEST_TEXT, None), (COMPLEX_TEST_TEXT, "utf-8"), (COMPLEX_TEST_TEXT, "iso-8859-1"), (COMPLEX_TEST_TEXT, None), ("ABCD1234", "utf-8"), ("ABCD1234", "iso-8859-1"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "utf-8"), ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", "iso-8859-1"), ("義務教育諸学校教科用図書検定基準", "utf-8"), ("義務教育諸学校教科用図書検定基準", "cp932"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "utf-8"), ("ウェブサイトにおける文字コードの割合、UTF-8が90%超え。Shift_JISやEUC-JPは?", "shift-jis"), ] for text, encoding in data_for_encoding: text_id = hashlib.md5(text.encode("utf-8")).hexdigest() ref_file_name = f"{file_base_name}_{text_id}_{str(encoding).lower()}" tests_data.append( dict( source=f'{{% qr_from_text "{text}" image_format="png" encoding="{encoding}" %}}', text=text, ref_file_name=ref_file_name.lower(), ) ) for test_data in tests_data: print("Testing template: %s" % test_data["source"]) text = test_data["text"] html_source = mark_safe("{% load qr_code %}" + test_data["source"]) template = Template(html_source) context = Context() source_image = template.render(context).strip() source_image_data = source_image[32 : -len('" alt="%s"' % escape(text))] source_image_data = base64.b64decode(source_image_data) if REFRESH_REFERENCE_IMAGES: write_png_content_to_file(test_data["ref_file_name"], source_image_data) ref_image_data = get_png_content_from_file_name(test_data["ref_file_name"]) self.assertEqual(source_image_data, ref_image_data) def test_colors(self): def run_tests(): if REFRESH_REFERENCE_IMAGES: match = IMAGE_TAG_BASE64_DATA_RE.search(qr1) source_image_data = match.group("data") write_png_content_to_file(result_file_name, base64.b64decode(source_image_data)) result = base64.b64encode(get_png_content_from_file_name(result_file_name)).decode("utf-8") self.assertEqual(qr1, qr2) self.assertEqual(qr1, qr3) self.assertEqual(qr1, get_base64_png_image_template() % result) base_ref_file_name = "qrfromtext_color" colors = ["#000", "#000000", "black", "#fff", "#FFFFFF", "white", "red", "blue", None] color_names = ["black"] * 2 + ["black"] + ["white_hexa"] * 2 + ["white"] + ["red", "blue", "transparent"] for i in range(len(colors)): color = colors[i] color_name = color_names[i] print("Testing PNG with dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(dark_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, dark_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(dark_color=color, image_format="png")) run_tests() print("Testing PNG with light color %s" % color_name) result_file_name = f"{base_ref_file_name}_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(light_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, light_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(light_color=color, image_format="png")) run_tests() print("Testing PNG with data_dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_data_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(data_dark_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, data_dark_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(data_dark_color=color, image_format="png")) run_tests() print("Testing PNG with data light color %s" % color_name) result_file_name = f"{base_ref_file_name}_data_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(data_light_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, data_light_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(data_light_color=color, image_format="png")) run_tests() print("Testing PNG with finder dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_finder_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(finder_dark_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, finder_dark_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(finder_dark_color=color, image_format="png")) run_tests() print("Testing PNG with finder light color %s" % color_name) result_file_name = f"{base_ref_file_name}_finder_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(finder_light_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, finder_light_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(finder_light_color=color, image_format="png")) run_tests() print("Testing PNG with dark module color %s" % color_name) result_file_name = f"{base_ref_file_name}_dark_module_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(dark_module_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, dark_module_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(dark_module_color=color, image_format="png")) run_tests() print("Testing PNG with alignment dark color %s" % color_name) result_file_name = f"{base_ref_file_name}_alignment_dark_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(alignment_dark_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, alignment_dark_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(alignment_dark_color=color, image_format="png")) run_tests() print("Testing PNG with alignment light color %s" % color_name) result_file_name = f"{base_ref_file_name}_alignment_light_{color_name}" qr1 = make_embedded_qr_code(TEST_TEXT, QRCodeOptions(alignment_light_color=color, image_format="png")) qr2 = qr_from_text(TEST_TEXT, alignment_light_color=color, image_format="png") qr3 = qr_from_text(TEST_TEXT, options=QRCodeOptions(alignment_light_color=color, image_format="png")) run_tests() django-qr-code-4.1.0/qr_code/tests/tests.py000066400000000000000000000060271462661477300206250ustar00rootroot00000000000000"""Tests for qr_code application.""" import os from decimal import Decimal from django.test import SimpleTestCase from pydantic import ValidationError from qr_code.qrcode.constants import ( DEFAULT_IMAGE_FORMAT, DEFAULT_MODULE_SIZE, DEFAULT_ERROR_CORRECTION, DEFAULT_VERSION, DEFAULT_ECI, DEFAULT_BOOST_ERROR, DEFAULT_ENCODING, ) from qr_code.qrcode.serve import make_qr_code_url from qr_code.qrcode.utils import QRCodeOptions from qr_code.tests import TEST_TEXT, PNG_REF_SUFFIX, SVG_REF_SUFFIX from qr_code.tests.utils import write_svg_content_to_file, get_resources_path, write_png_content_to_file class TestApps(SimpleTestCase): def test_apps_attributes(self): from qr_code.apps import QrCodeConfig self.assertEqual(QrCodeConfig.name, "qr_code") self.assertEqual(QrCodeConfig.verbose_name, "Django QR Code") class TestQRCodeOptions(SimpleTestCase): def test_qr_code_options(self): with self.assertRaises((TypeError, ValidationError)): QRCodeOptions(foo="bar") options = QRCodeOptions() self.assertEqual(options.border, 4) self.assertEqual(options.size, DEFAULT_MODULE_SIZE) self.assertEqual(options.image_format, DEFAULT_IMAGE_FORMAT) self.assertEqual(options.version, DEFAULT_VERSION) self.assertEqual(options.error_correction, DEFAULT_ERROR_CORRECTION) self.assertEqual(options.eci, DEFAULT_ECI) self.assertEqual(options.boost_error, DEFAULT_BOOST_ERROR) self.assertEqual(options.encoding.lower(), DEFAULT_ENCODING) options = QRCodeOptions(image_format="invalid-image-format") self.assertEqual(options.image_format, DEFAULT_IMAGE_FORMAT) def test_kw_save(self): options = QRCodeOptions(border=0, image_format="png", size=13) self.assertDictEqual(options.kw_save(), {"border": 0, "dark": "black", "kind": "png", "light": "white", "scale": 13}) options = QRCodeOptions(border=0, image_format="svg", size=13) self.assertDictEqual( options.kw_save(), {"border": 0, "dark": "black", "kind": "svg", "light": "white", "scale": Decimal("1.3"), "unit": "mm"} ) class TestWriteResourceData(SimpleTestCase): resource_file_base_name = "TestWriteResourceData" def test_write_svg(self): response = self.client.get(make_qr_code_url(TEST_TEXT)) image_data = response.content.decode("utf-8") write_svg_content_to_file(TestWriteResourceData.resource_file_base_name, image_data) file_path_to_remove = os.path.join(get_resources_path(), TestWriteResourceData.resource_file_base_name + SVG_REF_SUFFIX) os.remove(file_path_to_remove) def test_write_png(self): response = self.client.get(make_qr_code_url(TEST_TEXT)) image_data = response.content write_png_content_to_file(TestWriteResourceData.resource_file_base_name, image_data) file_path_to_remove = os.path.join(get_resources_path(), TestWriteResourceData.resource_file_base_name + PNG_REF_SUFFIX) os.remove(file_path_to_remove) django-qr-code-4.1.0/qr_code/tests/utils.py000066400000000000000000000030011462661477300206100ustar00rootroot00000000000000import os import re from qr_code.tests import PNG_REF_SUFFIX, SVG_REF_SUFFIX def get_urls_without_token_for_comparison(*urls): token_regex = re.compile(r"&?token=[^&]+") simplified_urls = list(map(lambda x: token_regex.sub("", x), urls)) simplified_urls = list(map(lambda x: x.replace("?&", "?"), simplified_urls)) return simplified_urls def get_resources_path(): tests_dir = os.path.dirname(os.path.abspath(__file__)) return os.path.join(tests_dir, "resources") def minimal_svg(s): """Returns the SVG document without the XML declaration and SVG namespace declaration :rtype: str """ return s.replace('\n', "").replace('xmlns="http://www.w3.org/2000/svg" ', "").strip() def get_svg_content_from_file_name(base_file_name): with open(os.path.join(get_resources_path(), base_file_name + SVG_REF_SUFFIX), encoding="utf-8") as file: return file.read() def get_png_content_from_file_name(base_file_name): with open(os.path.join(get_resources_path(), base_file_name + PNG_REF_SUFFIX), "rb") as file: return file.read() def write_svg_content_to_file(base_file_name, image_content): with open(os.path.join(get_resources_path(), base_file_name + SVG_REF_SUFFIX), "wt", encoding="utf-8") as file: file.write(image_content) def write_png_content_to_file(base_file_name, image_content): with open(os.path.join(get_resources_path(), base_file_name + PNG_REF_SUFFIX), "wb") as file: file.write(image_content) django-qr-code-4.1.0/qr_code/urls.py000066400000000000000000000004361462661477300173040ustar00rootroot00000000000000from django.conf import settings from django.urls import path from qr_code import views app_name = "qr_code" urlpatterns = [ path( getattr(settings, "SERVE_QR_CODE_IMAGE_PATH", "images/serve-qr-code-image/"), views.serve_qr_code_image, name="serve_qr_code_image" ) ] django-qr-code-4.1.0/qr_code/views.py000066400000000000000000000137531462661477300174620ustar00rootroot00000000000000import base64 import binascii import functools from django.conf import settings from django.core.exceptions import PermissionDenied, SuspiciousOperation from django.core.signing import BadSignature, Signer from django.http import HttpResponse from django.views.decorators.cache import cache_page from django.views.decorators.http import condition from qr_code.qrcode import constants from qr_code.qrcode.maker import make_qr_code_image from qr_code.qrcode.utils import QRCodeOptions from qr_code.qrcode.serve import ( get_url_protection_options, get_qr_url_protection_token, qr_code_etag, qr_code_last_modified, allows_external_request_from_user, ) def cache_qr_code(): """ Decorator that caches the requested page if a settings named 'QR_CODE_CACHE_ALIAS' exists and is not empty or None. """ def decorator(view_func): @functools.wraps(view_func) def _wrapped_view(request, *view_args, **view_kwargs): cache_enabled = int(request.GET.get("cache_enabled", 1)) == 1 if cache_enabled and hasattr(settings, "QR_CODE_CACHE_ALIAS") and settings.QR_CODE_CACHE_ALIAS: # We found a cache alias for storing the generate qr code and cache is enabled, use it to cache the # page. timeout = settings.CACHES[settings.QR_CODE_CACHE_ALIAS]["TIMEOUT"] key_prefix = "token={}.user_pk={}".format( request.GET.get("url_signature_enabled") or constants.DEFAULT_URL_SIGNATURE_ENABLED, request.user.pk, ) response = cache_page(timeout, cache=settings.QR_CODE_CACHE_ALIAS, key_prefix=key_prefix)(view_func)( request, *view_args, **view_kwargs ) else: # No cache alias for storing the generated qr code, call the view as is. response = (view_func)(request, *view_args, **view_kwargs) return response return _wrapped_view return decorator @condition(etag_func=qr_code_etag, last_modified_func=qr_code_last_modified) @cache_qr_code() def serve_qr_code_image(request) -> HttpResponse: """Serve an image that represents the requested QR code. IMPORTANT NOTE: Each boolean option mentioned below (value True/False) must be passed as `