publishments Package

publishments Package

lookups Module

kawaz.core.publishments.lookups.draft_lookup(user_obj, author_field_name='author', field_name='pub_state')[ソース]

指定されたユーザーが編集可能な下書きオブジェクトをフィルタするための Qオブジェクトを返す

ユーザーがメンバーであれば、自身が保有する下書き状態のオブジェクトを返し それ以外であれば何も返さない。なおユーザーがsuperuserの場合は存在する あらゆる下書き状態のオブジェクトを返す(superuserはあらゆる権限を持つため 全ての下書き記事の編集権限を持つ)

パラメタ:
  • user_obj (obj) – Userモデルインスタンス(or AnonymousUser)
  • author_field_name (str) – 所有者を指定しているフィールド名 (デフォルト: 'author'
  • field_name (str) – 公開状態を指定しているフィールド名 (デフォルト: 'pub_state'
戻り値:

Qオブジェクトインスタンス

kawaz.core.publishments.lookups.published_lookup(user_obj, field_name='pub_state')[ソース]

指定されたユーザーが閲覧可能な公開オブジェクトをフィルタするための Qオブジェクトを返す

ユーザーがメンバーであれば、publicおよびprotected指定のオブジェクトを返し それ以外であればpublic指定のオブジェクトを返す

パラメタ:
  • user_obj (obj) – Userモデルインスタンス(or AnonymousUser)
  • field_name (str) – 公開状態を指定しているフィールド名 (デフォルト: 'pub_state'
戻り値:

Qオブジェクトインスタンス

models Module

class kawaz.core.publishments.models.PublishmentManagerMixin[ソース]

ベースクラス: object

A model manager mixin for AbstractPublishmentModel model.

author_field_name = 'author'
draft(user)[ソース]

Return a queryset which include the draft objects of the specified user.

published(user)[ソース]

Return a queryset which include the objects published to the specified user.

A queryset which include public/protected objects would be returend if the specified user is the member of Kawaz, otherwise it only include the public objects.

related(user)[ソース]

Return a queryset which include the objects related to the specified user, namely an union of the published and draft queryset.

perms Module

class kawaz.core.publishments.perms.PublishmentPermissionLogic(author_field_name='author', pub_state_field_name='pub_state')[ソース]

ベースクラス: permission.logics.base.PermissionLogic

Permission logic of AbstractPublishmentModel subclass. This permission logic handle the ‘view’ permission based on the publishment status

has_perm(user_obj, perm, obj=None)[ソース]

Check if user have view permission (of object) based on the pub_state and author of the instance.

If no object is specified, it always return True.

If an object is specified, it will return True when the pub_state of the instance is:

  • ‘public’ | Anyone can see this obj
  • ‘protected’ | Seele, Nerv, Children can see this obj
  • ‘draft’ | Nobody but the obj author can see this obj
パラメタ:
  • user_obj (django user model instance) – A django user model instance which be checked
  • perm (string) – app_label.codename formatted permission string
  • obj (None or django model instance) – None or django model instance for object permission
戻り値:

Wheter the specified user have specified permission (of specified object).

戻り値の型:

boolean