edc-search


Nameedc-search JSON
Version 0.3.11 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-search
SummarySimple edc-search forms and view mixins for the clinicedc/edc
upload_time2024-02-13 17:44:53
maintainer
docs_urlNone
authorErik van Widenfelt
requires_python>=3.10
licenseGPL license, see LICENSE
keywords django edc search clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |coverage|

edc-search
----------

Add a slug field to models using the model mixin ``SearchSlugModelMixin``. Specify the fields and/or properties to include in the ``slug`` in ``search_slug_fields``:


.. code-block:: python

    class TestModel(SearchSlugModelMixin, models.Model):

        search_slug_fields = ['f1', 'f2', 'f3']

        f1 = models.CharField(max_length=25, null=True)
        f2 = models.DateTimeField(null=True)
        f3 = models.IntegerField(null=True)
        f4 = models.CharField(max_length=25, null=True)

Fields in the ``search_slug_fields`` are converted to string in the slug:

.. code-block:: python

    >>> obj = TestModel.objects.create(f1='run rabbit run!', f2=get_utcnow(), f3=12345)
    >>> obj.slug
    'run-rabbit-run!|2017-06-02 19:08:32.163520+00:00|12345'

Fields not listed are not included:

.. code-block:: python

    >>> obj = TestModel.objects.create(f1='slug me', f4='don\'t slug me')
    >>> obj.slug
    'slug-me||'

``Null`` fields are converted to ``''``:

.. code-block:: python

    >>> obj = TestModel.objects.create()
    >>> obj.slug
    '||'

You can use dotted syntax:

.. code-block:: python

    class TestModel(SearchSlugModelMixin, models.Model):

        search_slug_fields = ['f1', 'name.first', 'name.last']

        f1 = models.CharField(max_length=25, null=True)

        def name(self):
            return FullName(first='Gore', last='Vidal')

    >>> obj = TestModel.objects.create()
    >>> obj.slug
    '|Gore|Vidal'


.. |pypi| image:: https://img.shields.io/pypi/v/edc-search.svg
    :target: https://pypi.python.org/pypi/edc-search

.. |actions| image:: https://github.com/clinicedc/edc-search/workflows/build/badge.svg?branch=develop
  :target: https://github.com/clinicedc/edc-search/actions?query=workflow:build

.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-search/badge.svg?branch=develop
    :target: https://coveralls.io/github/clinicedc/edc-search?branch=develop

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-search",
    "name": "edc-search",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "django Edc search,clinicedc,clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/87/12/b8f42d8117633001ea818b73960c1c648f5f34ca7d46a937acb319f5d967/edc-search-0.3.11.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |coverage|\n\nedc-search\n----------\n\nAdd a slug field to models using the model mixin ``SearchSlugModelMixin``. Specify the fields and/or properties to include in the ``slug`` in ``search_slug_fields``:\n\n\n.. code-block:: python\n\n    class TestModel(SearchSlugModelMixin, models.Model):\n\n        search_slug_fields = ['f1', 'f2', 'f3']\n\n        f1 = models.CharField(max_length=25, null=True)\n        f2 = models.DateTimeField(null=True)\n        f3 = models.IntegerField(null=True)\n        f4 = models.CharField(max_length=25, null=True)\n\nFields in the ``search_slug_fields`` are converted to string in the slug:\n\n.. code-block:: python\n\n    >>> obj = TestModel.objects.create(f1='run rabbit run!', f2=get_utcnow(), f3=12345)\n    >>> obj.slug\n    'run-rabbit-run!|2017-06-02 19:08:32.163520+00:00|12345'\n\nFields not listed are not included:\n\n.. code-block:: python\n\n    >>> obj = TestModel.objects.create(f1='slug me', f4='don\\'t slug me')\n    >>> obj.slug\n    'slug-me||'\n\n``Null`` fields are converted to ``''``:\n\n.. code-block:: python\n\n    >>> obj = TestModel.objects.create()\n    >>> obj.slug\n    '||'\n\nYou can use dotted syntax:\n\n.. code-block:: python\n\n    class TestModel(SearchSlugModelMixin, models.Model):\n\n        search_slug_fields = ['f1', 'name.first', 'name.last']\n\n        f1 = models.CharField(max_length=25, null=True)\n\n        def name(self):\n            return FullName(first='Gore', last='Vidal')\n\n    >>> obj = TestModel.objects.create()\n    >>> obj.slug\n    '|Gore|Vidal'\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-search.svg\n    :target: https://pypi.python.org/pypi/edc-search\n\n.. |actions| image:: https://github.com/clinicedc/edc-search/workflows/build/badge.svg?branch=develop\n  :target: https://github.com/clinicedc/edc-search/actions?query=workflow:build\n\n.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/edc-search/badge.svg?branch=develop\n    :target: https://coveralls.io/github/clinicedc/edc-search?branch=develop\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Simple edc-search forms and view mixins for the clinicedc/edc",
    "version": "0.3.11",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-search"
    },
    "split_keywords": [
        "django edc search",
        "clinicedc",
        "clinical trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33f34895a2572b25b456996bef0e88adf6dcbd3926202deef13b10659fe55bb4",
                "md5": "fa58f2dbaccb0d0cb1d410ccdbed0863",
                "sha256": "08386e4e56556b665f7f66bdf8c60c9371cdd4005df4fec80bebe06596b90557"
            },
            "downloads": -1,
            "filename": "edc_search-0.3.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa58f2dbaccb0d0cb1d410ccdbed0863",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 25742,
            "upload_time": "2024-02-13T17:44:51",
            "upload_time_iso_8601": "2024-02-13T17:44:51.041403Z",
            "url": "https://files.pythonhosted.org/packages/33/f3/4895a2572b25b456996bef0e88adf6dcbd3926202deef13b10659fe55bb4/edc_search-0.3.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8712b8f42d8117633001ea818b73960c1c648f5f34ca7d46a937acb319f5d967",
                "md5": "4076eec4329909b4968c71d91b844edd",
                "sha256": "c4ee4fc3f6c234c0fa31fd2ee579adb128306d9c78d101977a73ea5631ec9682"
            },
            "downloads": -1,
            "filename": "edc-search-0.3.11.tar.gz",
            "has_sig": false,
            "md5_digest": "4076eec4329909b4968c71d91b844edd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 28143,
            "upload_time": "2024-02-13T17:44:53",
            "upload_time_iso_8601": "2024-02-13T17:44:53.001696Z",
            "url": "https://files.pythonhosted.org/packages/87/12/b8f42d8117633001ea818b73960c1c648f5f34ca7d46a937acb319f5d967/edc-search-0.3.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 17:44:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-search",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "edc-search"
}
        
Elapsed time: 0.32337s