Skip to main content

DIT Activity Stream

Project description

DIT Activity Stream

Installation

Read the Django Hawk installation documentation.

Add the package to your urls.py file.

from django.urls import include, path

urlpatterns = [
    ...
    path("dit-activity-stream/", include("dit_activity_stream.urls")),
    ...
]

How to implement?

Write your custom client, here is an example client for returning all users:

from typing import Any, Dict

from django.contrib.auth import get_user_model
from django.db.models import QuerySet
from django.http import HttpRequest

from dit_activity_stream.client import ActivityStreamClient

User = get_user_model()


class ActivityStreamUserClient(ActivityStreamClient):
    object_uuid_field: str = "user_id"
    object_last_modified_field: str = "last_modified"

    def get_queryset(self, request: HttpRequest) -> QuerySet:
        return User.objects.all()

    def render_object(self, object: User) -> Dict:
        return {
            "id": object.id,
            "username": object.username,
            "first_name": object.first_name,
            "last_name": object.last_name,
        }

Where the following attributes:

  • object_uuid_field is a field on the Object that is a Unique Identifier for the object.
    • This will be output in the URL GET parameter so it should be a UUID.
  • object_last_modified_field us a field on the Object that holds a datetime value of when the object was last modified.
    • This will be output in the URL GET parameter.

Set DIT_ACTIVITY_STREAM_CLIENT_CLASS in your django settings file:

DIT_ACTIVITY_STREAM_CLIENT_CLASS = "package.client.ActivityStreamUserClient"

Pushing to PyPI

Running make build will build the package into the dist/ directory. Running make push-pypi-test will push the built package to Test PyPI. Running make push-pypi will push the built package to PyPI.

Setting up poetry for pushing to PyPI

First you will need to add the test pypy repository to your poetry config:

poetry config repositories.test-pypi https://test.pypi.org/legacy/

Then go to https://test.pypi.org/manage/account/token/ and generate a token.

Then add it to your poetry config:

poetry config pypi-token.test-pypi XXXXXXXX

Then you also need to go to https://pypi.org/manage/account/token/ to generate a token for the real PyPI.

Then add it to your poetry config:

poetry config pypi-token.pypi XXXXXXXX

Now the make commands should work as expected.

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

dit_activity_stream-0.2.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

dit_activity_stream-0.2.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file dit_activity_stream-0.2.3.tar.gz.

File metadata

  • Download URL: dit_activity_stream-0.2.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Darwin/23.2.0

File hashes

Hashes for dit_activity_stream-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ef8b9cbe2e3054354017221dbaa80f952acf5518865a63c02642efd226c30d08
MD5 211da66ee7cb8266cab18574f340a122
BLAKE2b-256 5f5f9ed0f2ce1616622d6166fec645a21d19b2ebcb5895428869ce1c6e7e63dd

See more details on using hashes here.

File details

Details for the file dit_activity_stream-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for dit_activity_stream-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7509e32f095ac200b502ea6238081594ae357697d5ce7220530d79dc1b721977
MD5 000e5ccb2c9acf9b21c4e4b402e8f25f
BLAKE2b-256 c7b7746ea906b1c3992c35e6bc75218ef8f88e1869530c5175d5714a4add609c

See more details on using hashes here.

Supported by

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