stars Package¶
admin
Module¶
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
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 aForwardManyToOneDescriptor
instance.
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
andobject_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 aForwardManyToOneDescriptor
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
井の中かわず 井の中かわず「ゲーム作りました」
-
exception
-
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)
-
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`に付加対象オブジェクトを渡すことで付加対象オブジェクト に対する付加権限を調べることが可能
-