-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
336 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
charset = utf-8 | ||
end_of_line = lf | ||
max_line_length = 88 | ||
|
||
[*.{json,yml,yaml,js,jsx,vue,toml}] | ||
indent_size = 2 | ||
|
||
[*.{html,htm,svg,xml}] | ||
indent_size = 2 | ||
max_line_length = 120 | ||
|
||
[*.{css,scss}] | ||
indent_size = 2 | ||
|
||
[LICENSE] | ||
insert_final_newline = false | ||
|
||
[*.{md,markdown}] | ||
indent_size = 2 | ||
max_line_length = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github: | ||
- amureki | ||
- codingjoe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: pip | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
reviewers: | ||
- herrbenesch | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
reviewers: | ||
- herrbenesch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
|
||
dist: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- run: python -m pip install --upgrade pip build wheel twine | ||
- run: python -m build --sdist --wheel | ||
- run: python -m twine check dist/* | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
path: dist/* | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
lint-command: | ||
- bandit -r . -x ./tests | ||
- black --check --diff . | ||
- flake8 . | ||
- isort --check-only --diff . | ||
- pydocstyle . | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
cache: 'pip' | ||
cache-dependency-path: 'linter-requirements.txt' | ||
- run: python -m pip install -r linter-requirements.txt | ||
- run: ${{ matrix.lint-command }} | ||
|
||
pytest: | ||
needs: | ||
- lint | ||
strategy: | ||
matrix: | ||
os: | ||
- "ubuntu-latest" | ||
python-version: | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
django-version: | ||
- "3.2" # LTS | ||
- "4.1" | ||
- "4.2" # LTS | ||
extras: | ||
- "test" | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: python -m pip install .[${{ matrix.extras }}] | ||
- run: python -m pip install django~=${{ matrix.django-version }}.0 | ||
- run: python -m pytest | ||
- uses: codecov/codecov-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
|
||
PyPi: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- run: python -m pip install --upgrade pip build wheel twine | ||
- run: python -m build --sdist --wheel | ||
- run: python -m twine upload dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
# django-citext | ||
PostgreSQL CITEXT integration for Django | ||
# Django CITEXT | ||
|
||
PostgreSQL CITEXT integration for Django. | ||
|
||
[![PyPi Version](https://img.shields.io/pypi/v/citext.svg)](https://pypi.python.org/pypi/citext/) | ||
[![Test Coverage](https://codecov.io/gh/voiio/citext/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/citext) | ||
[![GitHub License](https://img.shields.io/github/license/voiio/citext)](https://raw.githubusercontent.com/voiio/citext/master/LICENSE) | ||
|
||
## Setup | ||
|
||
```ShellSession | ||
python3 -m pip install django-citext | ||
``` | ||
|
||
```python | ||
# settings.py | ||
INSTALLED_APPS = [ | ||
'citext', | ||
# ... | ||
] | ||
``` | ||
|
||
## Usage | ||
|
||
```python | ||
# myapp/models.py | ||
from django.db import models | ||
from citext import CITextField, CIEmailField | ||
|
||
|
||
class MyModel(models.Model): | ||
name = CITextField() | ||
email = CIEmailField(unique=True) | ||
``` | ||
|
||
```python | ||
# myapp/views.py | ||
from django.http import HttpResponse, HttpResponseNotFound | ||
|
||
from . import models | ||
|
||
|
||
def my_view(request, email): | ||
try: | ||
my_model = models.MyModel.objects.get(email=email) | ||
except models.MyModel.DoesNotExist: | ||
return HttpResponseNotFound() | ||
return HttpResponse(my_model.name) | ||
``` | ||
|
||
## Credits | ||
|
||
Project is based on the Django's own CITEXT implementation, | ||
which was removed in Django 5.0. Big thanks to the Django contributors | ||
for their excellent work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""PostgreSQL CITEXT integration for Django.""" | ||
|
||
from . import _version | ||
from .fields import * # noqa | ||
|
||
__version__ = _version.version | ||
VERSION = _version.version_tuple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.db.models import CharField, EmailField, TextField | ||
from django.test.utils import ignore_warnings | ||
from django.utils.deprecation import RemovedInDjango51Warning | ||
|
||
__all__ = ["CICharField", "CIEmailField", "CIText", "CITextField"] | ||
|
||
|
||
# RemovedInDjango51Warning. | ||
class CIText: | ||
def get_internal_type(self): | ||
return "CI" + super().get_internal_type() | ||
|
||
def db_type(self, connection): | ||
return "citext" | ||
|
||
|
||
class CICharField(CIText, CharField): | ||
|
||
|
||
def __init__(self, *args, **kwargs): | ||
with ignore_warnings(category=RemovedInDjango51Warning): | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class CIEmailField(CIText, EmailField): | ||
|
||
def __init__(self, *args, **kwargs): | ||
with ignore_warnings(category=RemovedInDjango51Warning): | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class CITextField(CIText, TextField): | ||
|
||
def __init__(self, *args, **kwargs): | ||
with ignore_warnings(category=RemovedInDjango51Warning): | ||
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib.postgres.operations import CreateExtension | ||
|
||
|
||
class CITextExtension(CreateExtension): | ||
def __init__(self): | ||
self.name = "citext" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bandit==1.7.5 | ||
black==23.7.0 | ||
flake8==6.0.0 | ||
isort==5.12.0 | ||
pydocstyle[toml]==6.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
[build-system] | ||
requires = ["flit_core>=3.2", "flit_scm", "wheel"] | ||
build-backend = "flit_scm:buildapi" | ||
|
||
[project] | ||
name = "citext" | ||
authors = [ | ||
{ name = "Rust Saiargaliev", email = "fly.amureki@gmail.com" }, | ||
{ name = "Johannes Maron", email = "johannes@maron.family" }, | ||
{ name = "Jörg Benesch", email = "benesch.joerg@gmail.com" } | ||
] | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
keywords = ["PostgreSQL", "Django", "CITEXT", "Case Insensitive", "postgres"] | ||
dynamic = ["version", "description"] | ||
classifiers = [ | ||
"Development Status :: 1 - Planning", | ||
"Programming Language :: Python", | ||
"Environment :: Web Environment", | ||
"License :: OSI Approved :: BSD License", | ||
"Intended Audience :: Developers", | ||
"Operating System :: OS Independent", | ||
"Topic :: Software Development", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Database", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Framework :: Django", | ||
"Framework :: Django :: 3.2", | ||
"Framework :: Django :: 4.1", | ||
"Framework :: Django :: 4.2", | ||
] | ||
requires-python = ">=3.10" | ||
dependencies = ["django", "psycopg"] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest", | ||
"pytest-cov", | ||
"pytest-django", | ||
"psycopg[binary]", | ||
] | ||
|
||
[project.urls] | ||
Project-URL = "https://github.com/voiio/citext" | ||
Changelog = "https://github.com/voiio/citext/releases" | ||
|
||
[tool.flit.module] | ||
name = "citext" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "citext/_version.py" | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
addopts = "--cov --tb=short -rxs" | ||
testpaths = ["tests"] | ||
DJANGO_SETTINGS_MODULE = "tests.testapp.settings" | ||
|
||
[tool.coverage.run] | ||
source = ["citext"] | ||
omit = ["citext/buildapi.py"] | ||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
|
||
[tool.isort] | ||
atomic = true | ||
line_length = 88 | ||
known_first_party = "citext, tests" | ||
include_trailing_comma = true | ||
default_section = "THIRDPARTY" | ||
combine_as_imports = true | ||
|
||
[tool.pydocstyle] | ||
add_ignore = "D1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length=88 | ||
select = C,E,F,W,B,B950 | ||
ignore = E203, E501, W503, E731 |