Skip to main content

A django app to create and manage handle-pids

Project description

=============================
acdh-django-handle
=============================

.. image:: https://badge.fury.io/py/acdh-django-handle.svg
:target: https://badge.fury.io/py/acdh-django-handle

.. image:: https://travis-ci.org/acdh-oeaw/acdh-django-handle.svg?branch=master
:target: https://travis-ci.org/acdh-oeaw/acdh-django-handle

.. image:: https://codecov.io/gh/acdh-oeaw/acdh-django-handle/branch/master/graph/badge.svg
:target: https://codecov.io/gh/acdh-oeaw/acdh-django-handle

A django app to create and manage handle-pids.

Documentation
-------------

The full documentation is at https://acdh-django-handle.readthedocs.io.

Quickstart
----------

Install acdh-django-handle::

pip install acdh-django-handle

Add it to your `INSTALLED_APPS`:

.. code-block:: python

INSTALLED_APPS = (
...
'handle',
...
)

Provide a handle-config dict:

.. code-block:: python

HANDLE = {
'resolver': "http://hdl.handle.net",
'user': "your handle-provider user",
'pw': "your handle-provider password",
'url': "base url to your handle-provider api",
'app_base_url': "the base url of your application"
}

example:

.. code-block:: python

HANDLE = {
'resolver': "http://hdl.handle.net",
'user': "user11.1234567-01",
'pw': "password1234",
'url': "http://pid.gwdg.de/handles/11.1234567-01/",
'app_base_url': "https://myproject.com"
}

The value of `app_base_url` will be concaneted with the value of the `get_absolute_url` method of the model instance you want to register a handle for.

And run

python manage.py migrate handle


Create/register handle-pids
----

The package provides a management command to bulk create/register handle-pids. For this you'll have to
* add a `GenericRelation` property to the model class you would like register handles for
* and make sure you have a `get_absolute_url` method defined

.. code-block:: python

from django.contrib.contenttypes.fields import GenericRelation

...

class Example(models.Model):
name = models.CharField(
max_length=255, blank=True,
)
...
pid = GenericRelation(Pid, blank=True, null=True, related_query_name="get_pid")
...
def get_absolute_url(self):
return reverse('example_detail', kwargs={'pk': self.id})

To register/create handle-pids run:

python manage.py crate_handles example

In case your GenericRelation property is named something else than `pid` you need to pass in the name as second argument, e.g:

python manage.py crate_handles example --pid=<name>

Handle-Pids will only be crated for objects which do not have a handle-pid yet.


Features
--------

* Provides a `Pid` class which stores
* a handle-pid
* creation and modification date
* a generic relation to any other class of your django project.
* an overidden save-method which will register/create a handle-pid on save in case you didn't provide a handle-pid

* Provides a `handle.utils.create_handle` function to register/create a new handle-pid

* Register/Create handle-pid for any objects in your project via admin-interface.

* Provides a management command to bulk create/register handle-pids for all instances of a model-class in your project.


Credits
-------

Tools used in rendering this package:

* Cookiecutter_
* `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.1.0 (2018-06-28)
++++++++++++++++++

* First release on PyPI.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acdh-django-handle-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acdh_django_handle-0.1.0-py2.py3-none-any.whl (10.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file acdh-django-handle-0.1.0.tar.gz.

File metadata

File hashes

Hashes for acdh-django-handle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f068cf0cd88981520d3461178e5ba07366bbb1f44583b14b062c8063cb17e09
MD5 87ae7d18e048fbefc526a9a397abdbc5
BLAKE2b-256 c82633bf62c3061500bf829bfaac74ea2ef3e12a10a6e34624365bc1eaa029a8

See more details on using hashes here.

File details

Details for the file acdh_django_handle-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for acdh_django_handle-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c521bab9613c4e179975c9bb73573b723bbc41c39bbc9c77d579704871f050c2
MD5 b94670b101e4235e041abe3498c87647
BLAKE2b-256 13bbfd3aefd080bd1b696231b262059fcdbff84f01ba79ee6e33fc1614b3a85d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page