adhocracy_core.sheets.rate module

Rate sheet.

interface IRate[source]

Extends: adhocracy_core.interfaces.IPredicateSheet, adhocracy_core.interfaces.ISheetReferenceAutoUpdateMarker

Marker interface for the rate sheet.

interface IRateable[source]

Extends: adhocracy_core.interfaces.ISheet, adhocracy_core.interfaces.ISheetReferenceAutoUpdateMarker

Marker interface for resources that can be rated.

class RateableRateValidator(context)[source]

Bases: object

Validator for rates about IRateable.

The following values are allowed:

  • 1: pro
  • 0: neutral
  • -1: contra

Initialize self.

validate(rate: int) → bool[source]

Validate the rate.

helpful_error_message() → str[source]

Return error message.

interface ILikeable[source]

Extends: adhocracy_core.sheets.rate.IRateable

IRateable subclass that restricts the set of allowed values.

class LikeableRateValidator(context)[source]

Bases: adhocracy_core.sheets.rate.RateableRateValidator

Validator for rates about ILikeable.

The following values are allowed:

  • 1: like
  • 0: neutral/no vote

Initialize self.

interface ICanRate[source]

Extends: adhocracy_core.interfaces.ISheet

Marker interface for resources that can rate.

interface RateSubjectReference[source]

Extends: adhocracy_core.interfaces.SheetToSheet

Reference from rate to rater.

interface RateObjectReference[source]

Extends: adhocracy_core.interfaces.SheetToSheet

Reference from rate to rated resource.

class RateSchema(*arg, **kw)[source]

Bases: adhocracy_core.schema.MappingSchema

Rate sheet data structure.

preparer = <colander.deferred object>
validator = <colander.deferred object>[source]
create_validate_subject(request: <InterfaceClass pyramid.interfaces.IRequest>) → <built-in function callable>[source]

Create validator to ensure value[‘subject’] is current user.

create_validate_is_unique(context, request: <InterfaceClass pyramid.interfaces.IRequest>) → <built-in function callable>[source]

Create validatator to ensure rate version is unique.

Older rate versions with the same subject and object may occur. If they belong to a different rate item an error is thrown.

create_validate_rate_value(registry: pyramid.registry.Registry) → <built-in function callable>[source]

Create validator to validate value[‘rate’].

Ask the validator registered for object whether rate is valid. In this way, IRateable subclasses can modify the range of allowed ratings by registering their own IRateValidator adapter.

class CanRateSchema(*arg, **kw)[source]

Bases: adhocracy_core.schema.MappingSchema

CanRate sheet data structure.

class RateableSchema(*arg, **kw)[source]

Bases: adhocracy_core.schema.MappingSchema

Commentable sheet data structure.

post_pool: Pool to post new adhocracy_sample.resource.IRate.

includeme(config)[source]

Register sheets, adapters and index views.