Skip to main content

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.

Metadata

Release files for dit-activity-stream 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dit-activity-stream 0.2.5
File Size Uploaded
dit_activity_stream-0.2.5.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dit-activity-stream 0.2.5
File Interpreter ABI Platform
dit_activity_stream-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / dit_activity_stream-0.2.5.tar.gz

Download URL dit_activity_stream-0.2.5.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0fc6d77e9b2eed7231ad9749d808e606566b2e5210b45ff95e364d02ed1fb97a
BLAKE2b-256 checksum
How to use checksums
a7702087517218622aa7b90ee7cc00b07d1d4e54e3a2584375d4a282c6b2e8c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/24.5.0

Release files / dit_activity_stream-0.2.5-py3-none-any.whl

Download URL dit_activity_stream-0.2.5-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d3c00c155ee3967480fd27040930d2d88e70af42725881f7005e80cd61b5c13
BLAKE2b-256 checksum
How to use checksums
b153b22928f6fff4b674bdeff82d3f2478d5a716254b1a88152f7c6b8f0b8d6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/24.5.0

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page