stars Package

admin Module

class kawaz.apps.stars.admin.StarAdmin(model, admin_site)[ソース]

ベースクラス: django.contrib.admin.options.ModelAdmin

media

models Module

class kawaz.apps.stars.models.Star(*args, **kwargs)[ソース]

ベースクラス: django.db.models.base.Model

はてなスター的なモデル。主にJavaScriptで処理を行う

exception DoesNotExist

ベースクラス: django.core.exceptions.ObjectDoesNotExist

exception Star.MultipleObjectsReturned

ベースクラス: django.core.exceptions.MultipleObjectsReturned

Star.author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

Star.author_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

Star.content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

Star.content_type_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.get_next_by_created_at(*moreargs, **morekwargs)
Star.get_previous_by_created_at(*moreargs, **morekwargs)
Star.id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.object_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.objects = <kawaz.apps.stars.models.StarManager object>
Star.quote

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Star.save(force_insert=False, force_update=False, using=None, update_fields=None)

Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

Star.tooltip_text

ツールチップに表示させる内容を取り出します

Example

井の中かわず 井の中かわず「ゲーム作りました」

class kawaz.apps.stars.models.StarManager[ソース]

ベースクラス: django.db.models.manager.Manager

add_to_object(obj, author, quote='')[ソース]

指定されたオブジェクトに新たにスターを作成

パラメータ:
  • obj (model instance) – 付加対象のモデルインスタンス
  • author (user instance) – スター付加を行うユーザー
  • quote (str) – 引用文字列(デフォルト: ‘’
Notice:

`author`を指定するが、実際に`author`がstarを対象オブジェクトに 付加可能かどうかのテストは行わない。 このテストを行う場合は下記のように権限テストを行う必要がある

>>> author.has_perm('stars.add_star', obj=obj)
cleanup_object(obj)[ソース]

指定されたオブジェクトに付加されている全てのスターを削除

パラメータ:obj (model instance) – 削除対象のモデルインスタンス
get_for_object(obj)[ソース]
get_queryset()[ソース]
published(user_obj)[ソース]
remove_from_object(obj, star)[ソース]

指定されたオブジェクトから指定されたスターを削除

パラメータ:
  • obj (model instance) – 削除対象のモデルインスタンス
  • star (star instance) – 削除対象のスターインスタンス
Raises:

ObjectDoesNotExist – 指定されたスターがオブジェクトに関連付けられて 居ない場合に発生

class kawaz.apps.stars.models.StarQuerySet(model=None, query=None, using=None, hints=None)[ソース]

ベースクラス: django.db.models.query.QuerySet

get_for_object(obj)[ソース]

指定されたオブジェクトに関係するスターを含むクエリを返す

パラメータ:obj (model instance) – 検索対象のモデルインスタンス
published(user_obj)[ソース]

指定されたユーザーが閲覧可能なスターを含むクエリを返す

パラメータ:user_obj (user instance) – 対象ユーザーインスタンス
戻り値:queryset

perms Module

class kawaz.apps.stars.perms.StarPermissionLogic[ソース]

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

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

Starのパーミッションを処理する

Model permission:
add: メンバーであれば True change: 誰も持たない delete: メンバーであれば True view: 全員 True
Object permission:
add: メンバーかつ指定されたオブジェクトの閲覧権限があれば True
詳細は後記

change: 誰も持たない delete: メンバーかつ指定されたスターがリンクしている

オブジェクトの閲覧権限があれば True もしくは指定されたスターがリンクしているオブジェクトの 編集権限があれば True
view: 指定されたスターがリンクしているオブジェクトの閲覧権限
があれば True
Notice:
通常 add 権限は Model permission のみが存在するが、Star の場合は `has_perm`に付加対象オブジェクトを渡すことで付加対象オブジェクト に対する付加権限を調べることが可能

views Module