From 17e811133adc73431912312bbeb48fbaa7fc170b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Sat, 13 May 2023 18:47:44 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ .isort.cfg | 2 ++ LICENSE | 9 +++++++++ README.md | 3 +++ __init__.py | 0 setup.py | 17 +++++++++++++++++ src/ktools/django/db/models/fields/__init__.py | 11 +++++++++++ 7 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100644 .isort.cfg create mode 100644 LICENSE create mode 100644 README.md create mode 100644 __init__.py create mode 100644 setup.py create mode 100644 src/ktools/django/db/models/fields/__init__.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e533df8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +py_ktools.egg-info diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..79a6550 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +multi_line_output=4 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2e45d4c --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT+NIGGER License + +Copyright (c) <2023> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice, this permission notice and the word "NIGGER" shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1562e5e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Ktools + +This module contains boilerplate for python projects, mostly based on django. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9ceb4d2 --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +from pathlib import Path + +from setuptools import setup + +setup( + name='py-ktools', + version='1.0.0', + # packages=['ktools'], + install_requires=['typing_extensions~=4.4'], + author='László Károlyi', + author_email='laszlo@karolyi.hu', + description='Boilerplate tools for python based projects.', + long_description=Path(__file__).parent.joinpath('README.md').read_text(), + long_description_content_type='text/markdown', + keywords='python django boilerplate', + url='http://gitea.ksol.io/karolyi/py-ktools', + license='MIT+NIGGER') diff --git a/src/ktools/django/db/models/fields/__init__.py b/src/ktools/django/db/models/fields/__init__.py new file mode 100644 index 0000000..3cbdb52 --- /dev/null +++ b/src/ktools/django/db/models/fields/__init__.py @@ -0,0 +1,11 @@ +from django.db.models.fields import ( + AutoFieldMeta, AutoFieldMixin, PositiveIntegerField) + + +class PositiveAutoField( + AutoFieldMixin, PositiveIntegerField, metaclass=AutoFieldMeta): + def get_internal_type(self): + return "PositiveAutoField" + + def rel_db_type(self, connection): + return PositiveIntegerField().db_type(connection=connection)