Skip to main content

stapel-reviews

CI coverage pypi downloads python license llms.txt

Target-generic reviews and ratings for the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.

A generic review core — Review (author + rating + body about an opaque target) and Response (the target owner's reply) — driven entirely by a per-target-type policy registry. The module ships knowing nothing about what gets reviewed: a host registers its target types (a seller, a listing, a driver, a course), each with a policy, and answers the domain questions — "may this author review?", "who owns this target?" — through comm Function callbacks, so the module never imports a host model.

Install

pip install stapel-reviews
INSTALLED_APPS = [
    # ...
    "stapel_reviews",
]

# urls.py
path("reviews/", include("stapel_reviews.urls"))

Concepts

  • Target — opaque: target_type (a key the host registered) + target_key (an opaque host string — a UUID, a slug, a composite). No FK to any host model; the module is domain-blind.
  • Policy — per target type: who may review (can_review comm callback), pre/post moderation, one-review-per-author, whether owner responses are allowed (allow_response), who may moderate/respond (can_moderate comm callback).
  • Aggregate — the module owns avg/count over published reviews per target, and emits a generic fact carrying it on every visibility change, so a host catalog maintains its own rating projection (§10) without calling back.
STAPEL_REVIEWS = {
    "TARGET_TYPES": {
        "seller": {
            "can_review": "marketplace.buyer_of_seller",   # host comm Function
            "can_moderate": "marketplace.is_seller_owner",
            "moderation": "post",
            "one_per_author": True,
            "allow_response": True,
        },
        "listing": {"moderation": "pre"},
    },
}
from stapel_reviews import services

review = services.create_review(
    target_type="seller", target_key="s-42", author=user, rating=5, body="great",
)
services.moderate_review(review, actor=owner, action="hide", reason="spam")
services.respond(review, author=owner, body="thanks for the feedback")
agg = services.aggregate("seller", "s-42")   # Aggregate(avg=..., count=...)

Settings

All configuration lives in the STAPEL_REVIEWS namespace (dict setting, flat setting, or env var — resolved lazily):

Key Default Meaning
TARGET_TYPES {} The target-type registry {type: policy}, merged over the (empty) built-ins; None removes a type
MODERATION_DEFAULT "post" Default moderation mode (post/pre) for types that don't override it
RESPONSES True Whether owner responses are allowed by default
RATING_MIN 1 Inclusive minimum rating
RATING_MAX 5 Inclusive maximum rating

comm surface

Kind Name Contract
Emit reviews.review.published A review became visible — carries {aggregate: {avg, count}} for the host projection
Emit reviews.review.hidden A review left the visible set — carries the updated aggregate
Function reviews.aggregate {target_type, target_key} -> {avg, count}
Callback (host) policy can_review {author_id, target_type, target_key} -> bool — the host answers
Callback (host) policy can_moderate {actor_id, target_type, target_key} -> bool — the host answers

Extension points

See MODULE.md — the agent-facing map of every fork-free seam (the TARGET_TYPES registry and its policy callbacks, the projection emits, the aggregate Function, serializer seams, settings).

Development

pip install -e . && pip install pytest pytest-django ruff
./setup-hooks.sh
pytest tests/

License

MIT

Download files

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

Source Distribution

stapel_reviews-0.1.8.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

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

stapel_reviews-0.1.8-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file stapel_reviews-0.1.8.tar.gz.

File metadata

  • Download URL: stapel_reviews-0.1.8.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for stapel_reviews-0.1.8.tar.gz
Algorithm Hash digest
SHA256 184fc61938a6839e7a514e6e6e5873463de4463cf2ef9ffe23b40d895c6d211c
MD5 75ffac82339e6a9a5798348b9e52d25c
BLAKE2b-256 4a95f0c0fca449c146bbd504d39eb40628118c77c6d94b9598cac0278e3d564d

See more details on using hashes here.

Provenance

The following attestation bundles were made for stapel_reviews-0.1.8.tar.gz:

Publisher: publish.yml on usestapel/stapel-reviews

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stapel_reviews-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: stapel_reviews-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for stapel_reviews-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5d07348a99c53d724438e799b69bc0cf4850640cb5110087a05d01700c5c44c3
MD5 02356ad02a675f0bee1fa113cc92485f
BLAKE2b-256 8fcf11bb79b26e3ffbe9f9e72e9de84350fdb67ab7cc798e375d3d3df6c753d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for stapel_reviews-0.1.8-py3-none-any.whl:

Publisher: publish.yml on usestapel/stapel-reviews

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

This release

0.1.8 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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