Kawaz¶

All your games are belong to us.
札幌ゲーム製作者コミュニティ Kawaz のポータルサイトの開発ドキュメントです。 開発・実行は Python 3.5 と Django 1.10 で行われています。
Kawaz をローカルにインストールする¶
Kawaz は GitHub 上で開発されているので 下記のようにローカルにチェックアウトしてください。
$ git clone https://github.com/kawazrepos/Kawaz3rd
また、上記URLではコミット権限を得られないため、開発メンバーに了承を得たコミット権のある方は 下記のように git アドレスを用いてください。
$ git clone git@github.com:kawazrepos/Kawaz3rd
次に開発に必要なサブモジュールとパッケージをインストールします。 この作業は依存するサブモジュールやパッケージの更新・追加などが発生した場合に毎回行う必要があります。 過去に動いていたのに動かなくなった場合は大抵下記の作業を行うと動くようになります
$ git submodule update --init --recursive
$ pip install -r config/requirements.txt
$ pip install -r config/requirements-test.txt
$ pip install -r config/requirements-docs.txt
テストを実行する¶
Kawaz はテスト駆動開発により開発が進められています。 変更を加えた場合は下記の手順に従って必ずテストが通ることを確認してください。
クリーンな環境でテストを実行する場合¶
どの環境においてもテストが成功することを保証するためにクリーンな環境でテストを実行することを強くおすすめします。
その際は tox を用いて下記のように行えば自動的にクリーンな環境でのテストが実行できます(事前に pip install tox
で _tox を開発環境にインストールしておいてください)。
$ tox -c config/tox.ini
開発中に簡易的にテストを実行する場合¶
開発時は多くの変更を加えるため上記 tox を利用したテストは時間がかかり面倒なことが多いと思います。 その場合は下記のように現在の環境でテストを行うと比較的高速にテストを実行することができます。
$ python manage.py test kawaz # この場合すべての kawaz テストを実行します
$ python manage.py test kawaz.core.personas # この場合 kawaz.core.personas のテストのみを実行します
ただし開発環境によりインストールされているパッケージ等に差異があるため リモートにプッシュする前に tox を利用したクリーンなテストを最低一度は実行することを強くおすすめします
開発サーバーを実行する¶
デザインやクライアントサイドコードの動作確認などを行う場合は開発用サーバーにて Kawaz を起動する必要があります。 このサーバーを起動するためには
- データベースの初期化
- 翻訳メッセージの初期化
の手順を事前に行う必要があるので、下記のようにこれらの初期化を行なってください。
$ python manage.py init_database # データベースの初期化
$ python manage.py compilemessages # 翻訳メッセージの初期化
なおこの初期化は対象部分(データベース・翻訳メッセージ)に変更を加えた際はその都度実行する必要があります。
これらの初期化が終わっている場合は下記のように honcho を利用してサーバーを起動することができます。
$ honcho start -f config/Procfile.dev
上記コマンドにより http://localhost:8000/ に開発用サーバーが http://localhost:35729/ に LiveReload 用サーバーが実行されます。 なお LiveReload 拡張が入った Google Chrome を利用するとファイル更新時に自動でブラウザの更新が呼ばれるためオススメです。
本番用サーバーを実行する¶
WIP
開発用サーバーを実行する際は下記の手順を踏んでください
src/kawaz/local_settings.py
を作成して下記の項目に関して設定を行う- 管理者のメールアドレス
- キャッシュ関係の設定
- データベースの設定
- メール(送信用)の設定
SECRET_KEY
の設定- Google Calendar ID の設定
- その他(加筆求む)
- データが存在していない場合は
python manage.py init_database
にてデータベースの初期化を行う。 データが存在している場合は全データのロストにつながるため実行禁止 python manage.py compilemessages
にて翻訳メッセージのコンパイルを行う。 この作業は翻訳メッセージに変更が合った場合に毎度行う必要があるpython manage.py collectstatic
にて静的ファイルをpublic/static
以下に集める。 この作業は静的ファイルに変更が合った場合に毎度行う必要があるpython manage.py compress
にて CoffeeScript/JavaScript/CSS/Less の圧縮を行う。 この作業は上記ファイルに変更が合った場合に毎度行う必要がある
ドキュメントファイルを更新する¶
全てのドキュメントは docs
フォルダ内に reStructuredText で書かれ Sphinx によりドキュメント化が行われている。
このドキュメントには
- 上記のような手順書
- ディレクトリ構成の説明や思想説明
- APIドキュメント
が含まれ、develop
ブランチにプッシュすると自動的に KawazDevelopmentDocumentation に公開されます。
APIドキュメント以外の更新は適当にディレクトリ分割を行なって各自追加してください。 APIドキュメントの追加を行う場合は下記コマンドにて差分を追加できるので利用して下さい。 なおAPIドキュメントファイルを直接更新することは禁止します(変更したい場合はソースコードのコメントを修正してください)。
$ sphinx-apidoc -o docs/api src -f
ローカルでドキュメントをコンパイルする¶
ローカルでドキュメントをコンパイルする場合は下記コマンドにより docs/_build/html/index.html
(ほか多数)が作成されます。
$ (cd docs; make html)
また Windows の場合は
$ (cd docs; make.bat html)
でコンパイルできる(はずです)
ドキュメント¶
kawaz Package¶
local_settings.sample
Module¶
pre_settings
Module¶
urls
Module¶
wsgi
Module¶
Subpackages¶
api Package¶
filters
Module¶
mixins
Module¶
-
class
kawaz.api.mixins.
ReadModelMixin
[source]¶ Bases:
object
A mixin for reading model objects.
It add get_queryset_for_read method and override get_queryset method.
-
class
kawaz.api.mixins.
WriteModelMixin
[source]¶ Bases:
object
A mixin for writing model objects.
It add get_queryset_for_write method and override get_queryset method.
-
class
kawaz.api.mixins.
CreateModelMixin
[source]¶ Bases:
rest_framework.mixins.CreateModelMixin
Create model instance and automatically save author
urls
Module¶
views
Module¶
-
class
kawaz.api.views.
KawazGenericViewSet
(**kwargs)[source]¶ Bases:
rest_framework.viewsets.GenericViewSet
Kawaz で使用する API が通常行う設定を事前に行った GenericViewSet 下記に上げる設定が行われている
- レスポンスをデフォルトでJSONで返すように指定
- 権限チェックに DjangoModelPermissions と DjangoObjectPermissions を指定
- フィルターバックエンドに DjangoFilterBackend と KawazObjectPermissionFilterBackend を指定
- 注意:
- KawazObjectPermissionFilterBackend は全てのオブジェクトの権限をループ で検索するバックエンドのため大量のオブジェクトに対して実行すると実働 時間がかかる可能性が存在する
-
filter_backends
= (<class 'rest_framework.filters.DjangoFilterBackend'>, <class 'kawaz.api.filters.KawazObjectPermissionFilterBackend'>)¶
-
permission_classes
= (<class 'rest_framework.permissions.DjangoObjectPermissions'>, <class 'rest_framework.permissions.DjangoModelPermissions'>)¶
-
renderer_classes
= (<class 'rest_framework.renderers.JSONRenderer'>,)¶
-
class
kawaz.api.views.
KawazModelViewSet
(**kwargs)[source]¶ Bases:
kawaz.api.mixins.CreateModelMixin
,rest_framework.mixins.RetrieveModelMixin
,rest_framework.mixins.UpdateModelMixin
,rest_framework.mixins.DestroyModelMixin
,rest_framework.mixins.ListModelMixin
,kawaz.api.views.KawazGenericViewSet
KawazGenericViewSet をベースとした読み書き用APIのViewSet retrieve, list に加え create, destroy, update, partial_update を提供
-
class
kawaz.api.views.
KawazReadOnlyModelViewSet
(**kwargs)[source]¶ Bases:
rest_framework.mixins.RetrieveModelMixin
,rest_framework.mixins.ListModelMixin
,kawaz.api.views.KawazGenericViewSet
KawazGenericViewSet をベースとした読み込み専用APIのViewSet retrieve, list のみを提供
apps Package¶
apps
Package¶
Subpackages¶
announcements Package¶
activity
Module¶admin
Module¶forms
Module¶models
Module¶-
class
kawaz.apps.announcements.models.
Announcement
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
スタッフがメンバーに告知する際に使用するモデル
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Announcement.
MultipleObjectsReturned
¶ Bases:
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.
-
Announcement.
body
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Announcement.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Announcement.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Announcement.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Announcement.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Announcement.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
last_modifier
¶ 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.
-
Announcement.
last_modifier_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
objects
= <kawaz.apps.announcements.models.AnnouncementManager object>¶
-
Announcement.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Announcement.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.announcements.models.
AnnouncementManager
[source]¶ Bases:
django.db.models.manager.Manager
,kawaz.core.publishments.models.PublishmentManagerMixin
-
draft
(user)[source]¶ 下書き状態のAnnouncementインスタンスを含むクエリを返す。
ユーザーがスタッフの場合は全ての下書きインスタンスを含むもの、それ以外 の場合は空のクエリを返す
Parameters: user (User instance) – DjangoのUserモデル Returns: 指定されたユーザーに対して公開されているAnnouncementインスタンスを 含むQuerySet
-
published
(user)[source]¶ 指定されたユーザーに対して公開されているAnnouncementインスタンスを含む クエリを返す。
公開状態は指定されたユーザの所属によって変化する。 ユーザーが認証ユーザかつ[seele, nerv, chidlren]のいずれかに属している 場合は公開状態が public もしくは protected のものを、それ以外の場合 は公開状態が public になっているものだけを含む。
Parameters: user (User instance) – DjangoのUserモデル Returns: 指定されたユーザーに対して公開されているAnnouncementインスタンスを 含むQuerySet
-
perms
Module¶urls
Module¶views
Module¶0001_initial
Module¶-
class
kawaz.apps.announcements.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__')]¶
-
operations
= [<CreateModel name='Announcement', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Announcements', 'permissions': (('view_announcement', 'Can view the announcement'),), 'ordering': ('-created_at',), 'verbose_name': 'Announcement'}, fields=[('id', <django.db.models.fields.AutoField>), ('pub_state', <django.db.models.fields.CharField>), ('title', <django.db.models.fields.CharField>), ('body', <django.db.models.fields.TextField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('author', <django.db.models.fields.related.ForeignKey>), ('last_modifier', <django.db.models.fields.related.ForeignKey>)]>]¶
-
announcements_tags
Module¶任意の<lookup>によりフィルタされた Announcement のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_announcements as <variable> %} {% get_announcements <lookup> as <variable> %}
- Lookup: (Default: published)
- published: ユーザーに対して公開された Announcement を返す draft: ユーザーが編集可能な下書き Announcement を返す
Examples
公開された Announcement のクエリを取得し、最新5件のみを描画
{% get_announcements as announcements %} {% for announcement in announcements|slice:”:5” %}
{{ announcement }}{% endfor %}
下書き記事を取得
{% get_announcements ‘draft’ as draft_announcements %}
get_announcementsで得られるQSのうち、作成日が1週間以内の物のみに絞り込む
attachments Package¶
admin
Module¶-
class
kawaz.apps.attachments.admin.
MaterialAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('filename', 'slug', 'author_nickname', 'created_at')¶
-
media
¶
-
readonly_fields
= ('slug', 'author', 'ip_address', 'created_at')¶
-
search_fields
= ('author__username', 'author__nickname')¶
-
models
Module¶-
class
kawaz.apps.attachments.models.
Material
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
添付素材用のモデルです
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Material.
MultipleObjectsReturned
¶ Bases:
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.
-
Material.
content_file
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
Material.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Material.
ext
¶ アップされたファイルから拡張子を返します 拡張子は小文字になります。2つ以上拡張子がついている場合は最後の物のみが返却されます。
hoge.mp3 -> mp3 hoge.tar.gz -> gz hoge.WAV -> wav README ->
-
Material.
filename
¶ ファイル名を返します
-
Material.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Material.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Material.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Material.
ip_address
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Material.
is_audio
¶ 音声ファイルかどうかを返します
-
Material.
is_image
¶ 画像ファイルかどうかを返します
-
Material.
is_movie
¶ 動画ファイルかどうかを返します
-
Material.
is_pdf
¶ PDFかどうかを返します
-
Material.
mimetype
¶ Mimetypeを返します
-
Material.
objects
= <django.db.models.manager.Manager object>¶
-
Material.
slug
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
urls
Module¶views
Module¶api
Package¶serializers
Module¶-
class
kawaz.apps.attachments.api.serializers.
MaterialSerializer
(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]¶ Bases:
rest_framework.serializers.ModelSerializer
views
Module¶-
class
kawaz.apps.attachments.api.views.
MaterialViewSet
(**kwargs)[source]¶ Bases:
kawaz.api.mixins.CreateModelMixin
,kawaz.api.views.KawazGenericViewSet
-
lookup_field
= 'slug'¶
-
lookup_url_kwarg
= 'slug'¶
-
model
¶ alias of
Material
-
parser_classes
= (<class 'rest_framework.parsers.FormParser'>, <class 'rest_framework.parsers.MultiPartParser'>)¶
-
queryset
¶
-
serializer_class
¶ alias of
MaterialSerializer
-
suffix
= None¶
-
0001_initial
Module¶-
class
kawaz.apps.attachments.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__')]¶
-
operations
= [<CreateModel name='Material', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Materials', 'verbose_name': 'Material', 'ordering': ('created_at',)}, fields=[('id', <django.db.models.fields.AutoField>), ('content_file', <django.db.models.fields.files.FileField>), ('slug', <django.db.models.fields.SlugField>), ('ip_address', <django.db.models.fields.IPAddressField>), ('created_at', <django.db.models.fields.DateTimeField>), ('author', <django.db.models.fields.related.ForeignKey>)]>]¶
-
templatetags
Package¶attachments
Module¶{attachments:47c833254e45532d850cc40a0b8ec8b055b27c71}的なタグをparseします
- Usage
- {{ <value>|parse_attachments }}
blogs Package¶
activity
Module¶admin
Module¶-
class
kawaz.apps.blogs.admin.
EntryAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('title', 'author_nickname', 'get_pub_state_display', 'star_count', 'created_at', 'updated_at')¶
-
media
¶
-
search_fields
= ('title', 'body', 'author__username', 'author__nickname', 'category__label')¶
-
forms
Module¶models
Module¶-
class
kawaz.apps.blogs.models.
Category
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
ブログが所属するカテゴリーモデル
カテゴリーは各ユーザーがそれぞれ所有するもので、自身のブログの整理に利用する 目的で存在する。
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Category.
MultipleObjectsReturned
¶ Bases:
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.
-
Category.
entries
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Category.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
objects
= <django.db.models.manager.Manager object>¶
-
exception
-
class
kawaz.apps.blogs.models.
Entry
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
ブログ記事モデル
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Entry.
MultipleObjectsReturned
¶ Bases:
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.
-
Entry.
body
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
category
¶ 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.
-
Entry.
category_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Entry.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Entry.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Entry.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Entry.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Entry.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
objects
= <kawaz.apps.blogs.models.EntryManager object>¶
-
Entry.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
published_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
published_at_date
¶ 公開日
-
Entry.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Entry.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.blogs.models.
EntryManager
[source]¶ Bases:
django.db.models.manager.Manager
,kawaz.core.publishments.models.PublishmentManagerMixin
urls
Module¶views
Module¶api
Package¶serializers
Module¶views
Module¶-
class
kawaz.apps.blogs.api.views.
CategoryViewSet
(**kwargs)[source]¶ Bases:
kawaz.api.mixins.CreateModelMixin
,kawaz.api.views.KawazGenericViewSet
ブログカテゴリを作成するためのAPIエンドポイント
-
model
¶ alias of
Category
-
queryset
¶
-
serializer_class
¶ alias of
CategorySerializer
-
suffix
= None¶
-
0001_initial
Module¶-
class
kawaz.apps.blogs.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__')]¶
-
operations
= [<CreateModel name='Category', bases=(<class 'django.db.models.base.Model'>,), options={}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('author', <django.db.models.fields.related.ForeignKey>)]>, <CreateModel name='Entry', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Entries', 'permissions': (('view_entry', 'Can view the entry'),), 'verbose_name': 'Entry', 'ordering': ('-updated_at', 'title')}, fields=[('id', <django.db.models.fields.AutoField>), ('pub_state', <django.db.models.fields.CharField>), ('title', <django.db.models.fields.CharField>), ('body', <django.db.models.fields.TextField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('publish_at', <django.db.models.fields.DateTimeField>), ('author', <django.db.models.fields.related.ForeignKey>), ('category', <django.db.models.fields.related.ForeignKey>)]>, <AlterUniqueTogether unique_together={('author', 'label')}, name='category'>]¶
-
0002_auto_20141123_0104
Module¶blogs_tags
Module¶ブログ記事カテゴリ一覧を取り出します <user>を渡した場合は、そのユーザーが持っているカテゴリのみを取り出します
- Syntax:
- {% get_categories as categories %} {% get_categories <user> as categories %}
任意の<lookup>によりフィルタされた Entry のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_entries as <variable> %} {% get_entries <lookup> as <variable> %}
- Lookup: (Default: published)
- published: ユーザーに対して公開された Entry を返す draft: ユーザーが編集可能な下書き Entry を返す
Examples
公開された Entry のクエリを取得し、最新5件のみを描画
{% get_entries as entries %} {% for entry in entries|slice:”:5” %}
{{ entry }}{% endfor %}
下書き記事を取得
{% get_entries ‘draft’ as draft_entries %}
あるユーザーの書いたpublishedなエントリーを返します
- Syntax:
- {% get_published_entries_of <user> as <variable> %}
events Package¶
activity
Module¶admin
Module¶-
class
kawaz.apps.events.admin.
EventAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('title', 'organizer_name', 'get_pub_state_display', 'period_start', 'number_of_attendees', 'created_at', 'updated_at')¶
-
media
¶
-
search_fields
= ('title', 'body', 'organizer__username', 'organizer__nickname', 'category__label', 'place')¶
-
filters
Module¶forms
Module¶gcal
Module¶Google Calendar 連携用 Backend kawaz.core.google.calendar に依存し settings.GOOGLE_CALENDAR_BACKEND で指定 されている
models
Module¶-
class
kawaz.apps.events.models.
Category
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
イベントの大カテゴリ 運営が設置したものをユーザーが選ぶ
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Category.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Category.
events
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Category.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
objects
= <django.db.models.manager.Manager object>¶
-
Category.
order
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.events.models.
Event
(id, pub_state, title, body, period_start, period_end, place, number_restriction, attendance_deadline, organizer, category, created_at, updated_at)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Event.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Event.
active_attendees
¶
-
Event.
attendance_deadline
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
attendees
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Event.
body
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
category
¶ 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.
-
Event.
category_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
clean
()[source]¶ 下記のルールに従ってValidationする 1. イベント終了時間は開始時間より遅い必要がある(時間は逆行できない) 2. 過去のイベントは作成できない(スネーク!タイムパラドックスだ!) 3. 7日以上にまたがるイベントは作成できない 4. 開始時間が指定されているが終了時間が指定されていないイベントは
作成できない(一生イベントに参加とかは物理的に不可能)- 参加者制限が0人のイベントは作成できない
- 参加締め切りは未来でなければいけない
-
Event.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Event.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Event.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Event.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Event.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Event.
googlecalendarbridge
¶ Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
place.restaurant
is aReverseOneToOneDescriptor
instance.
-
Event.
humanized_period
¶ 開催日時をいい感じで描画します
- Output:
- 5月10日(月) 13:00 ~ 19:00 2013年9月21(土) 13:00 ~ 19:00 6月11日(月) 13:00 ~ 6月12日(火) 10:00 未定 6月11日(月) 13:00 ~ 終了日時未定
-
Event.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
number_restriction
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
objects
= <kawaz.apps.events.models.EventManager object>¶
-
Event.
organizer
¶ 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.
-
Event.
organizer_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
period_end
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
period_start
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
place
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
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.
-
Event.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Event.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.events.models.
EventManager
[source]¶ Bases:
django.db.models.manager.Manager
,kawaz.core.publishments.models.PublishmentManagerMixin
-
active
(user)[source]¶ 指定されたユーザーに公開されたイベントの中で、まだ終わっていない or イベントの終了時期が指定されていないかつ、作成日から30日日以内のイベントを含むクエリを返す
-
perms
Module¶urls
Module¶views
Module¶0001_initial
Module¶-
class
kawaz.apps.events.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__')]¶
-
operations
= [<CreateModel name='Category', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Label', 'verbose_name': 'Label', 'ordering': ('order',)}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('order', <django.db.models.fields.PositiveSmallIntegerField>)]>, <CreateModel name='Event', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Events', 'permissions': (('attend_event', 'Can attend the event'), ('quit_event', 'Can quit the event'), ('view_event', 'Can view the event')), 'verbose_name': 'Event', 'ordering': ('period_start', 'period_end', '-created_at', '-updated_at', 'title', '-pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('pub_state', <django.db.models.fields.CharField>), ('title', <django.db.models.fields.CharField>), ('body', <django.db.models.fields.TextField>), ('period_start', <django.db.models.fields.DateTimeField>), ('period_end', <django.db.models.fields.DateTimeField>), ('place', <django.db.models.fields.CharField>), ('number_restriction', <django.db.models.fields.PositiveIntegerField>), ('attendance_deadline', <django.db.models.fields.DateTimeField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('attendees', <django.db.models.fields.related.ManyToManyField>), ('category', <django.db.models.fields.related.ForeignKey>), ('organizer', <django.db.models.fields.related.ForeignKey>)]>]¶
-
events_tags
Module¶Bases:
object
任意の<lookup>によりフィルタされた Event のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_events as <variable> %} {% get_events <lookup> as <variable> %}
- Lookup: (Default: published)
- published: ユーザーに対して公開された Event を返す draft: ユーザーが編集可能な下書き Event を返す active: ユーザーが閲覧可能な非終了 Event を返す attendable: ユーザーが参加可能な Event を返す
Examples
公開された Event のクエリを取得し、最新5件のみを描画
{% get_events as events %} {% for event in events|slice:”:5” %}
{{ event }}{% endfor %}
下書き記事を取得
{% get_events ‘draft’ as draft_events %}
Eventの月間アーカイブを取得する
- Usage:
- get_monthly_archive as <variable>
<variable> には Archive の各インスタンスがリストとして保存される。 また Archive は下記に上げるアトリビュートを持っている
- date (Date): アーカイブ対象のDateオブジェクト
- object_list (QuerySet): アーカイブ対象のEventsを格納したQuerySet
- count (int): アーカイブ対象のイベント数
- url (str): アーカイブのURL
したがって下記のようにアーカイブリストを描画できる
{% get_monthly_archives as archives %} {% for archive in archives %}
- <p><a href=”{{ archive.url }}”>
- {{ archive.date }}({{ archive.count }})
</a></p>
{% endfor %}
kfm Package¶
parser
Module¶-
kawaz.apps.kfm.parser.
parse_kfm
(value)[source]¶ Kawaz Flavored Markdown のパースを行いHTMLを返す
kfm は下記の機能を提供する
- GitHub Flavored Markdown (2014) と等価の Markdown 機能 - Multiple underscores in words - URL autolinking - Strikethrough - Fenced code blocks - Syntax highlighting - Tables
- 脚注シンタックスの追加
- Cuddled Lists (パラグラフ直下でもリスト記法が有効)
- YouTube URL のプレイヤー展開
- ニコニコ動画URLのプレイヤー展開
- @username のユーザーリンク展開 (Kawaz ユーザー)
- {attachment: <slug>} の添付展開
autolink
Module¶mention
Module¶nicovideo
Module¶strikethrough
Module¶utils
Module¶-
kawaz.apps.kfm.extras.utils.
is_quoated
(text, s, e, quotes=('"', "'", '`'))[source]¶ 指定された文字列の特定部分がクオート文字で囲まれているか調べる
Ref: https://gist.github.com/lambdalisue/f2c9ab121883e48d3c2f
Examples
>>> # 0123456789012345678901234 >>> text = '''N'Y'N'Y'N"Y"N"Y'Y'Y"N"Y"N''' >>> # N >>> assert is_quoated(text, 0, 1) is False >>> # N' >>> assert is_quoated(text, 0, 2) is False >>> # N'Y >>> assert is_quoated(text, 0, 3) is False >>> # N'Y' >>> assert is_quoated(text, 0, 4) is False >>> # ' >>> assert is_quoated(text, 1, 2) is False >>> # 'Y >>> assert is_quoated(text, 1, 3) is False >>> # 'Y' >>> assert is_quoated(text, 1, 4) is False >>> # 'Y'N >>> assert is_quoated(text, 1, 5) is False >>> # Y >>> assert is_quoated(text, 2, 3) is True >>> # Y' >>> assert is_quoated(text, 2, 4) is False >>> # Y'N >>> assert is_quoated(text, 2, 5) is False >>> # Y'N' >>> assert is_quoated(text, 2, 6) is True >>> # Y'N'Y >>> assert is_quoated(text, 2, 7) is True >>> # Y'N'Y' >>> assert is_quoated(text, 2, 8) is False
youtube
Module¶-
kawaz.apps.kfm.extras.youtube.
parse_youtube_urls
(value, responsive=False, width=None, height=None)[source]¶ 指定された文字列に含まれる YouTube URL をプレイヤーに変換 ただしURLがシングル・ダブルクオーテーションマークで囲まれていた場合は 変換を行わない
変換にはテンプレートシステムが使用され kfm/parsers/youtube.html なおコンテキストとして下記の値がテンプレートに渡される
- video_id: YouTube Video ID
- responsive: レスポンシブデザインで描画すべきか否か
- width: 横幅(responsiveには渡されない)
- height: 縦幅(responsiveには渡されない)
Parameters: - responsive (bool) – bootstrapのレスポンシブデザインに対応させる http://getbootstrap.com/components/#responsive-embed これが指定された場合下記 width/height の指定は無視される
- width (int or None) – 横幅 (px) 指定されない場合は DEFAULT_WIDTH が使用される
- height (int or None) – 縦幅 (px) 指定されない場合は width に対して アスペクト比が 16:9 に成るように自動指定される
kfm
Module¶Bases:
django.template.base.Node
テンプレートフォルダに存在する Kawaz Flavored Markdown ファイルを読み込み レンダリングするテンプレートタグ
Usage:
{% include_kfm “markdown/about.md” %}
ブロックで囲まれたテキストを Kawaz Flavored Markdown として HTML展開するタグ
- Usage:
- {% kfm %} Kawaz Flavored Markdown {% endkfm %}
指定されたテキストを Kawaz Flavored Markdown として HTML 展開するフィルタ
- Usage:
- {{ object.body | kfm }}
youtube
Module¶指定されたテキスト内に存在するYouTube URLを展開するフィルタ
- Usage:
- {{ object.body | youtube }} {{ object.body | youtube:’responsive’ }} # レスポンシブデザイン {{ object.body | youtube:‘1600’ }} # 横幅指定(16:9) {{ object.body | youtube:‘1600,900’ }} # 縦横幅指定
test_parse
Module¶test_autolink
Module¶test_mention
Module¶test_nicovideo
Module¶test_strikethrough
Module¶products Package¶
activity
Module¶-
class
kawaz.apps.products.activity.
ProductActivityMediator
[source]¶ Bases:
activities.mediator.ActivityMediator
-
notifiers
= ('twitter_kawaz_info', 'twitter_kawaz_official')¶
-
admin
Module¶-
class
kawaz.apps.products.admin.
CategoryAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
media
¶
-
-
class
kawaz.apps.products.admin.
PackageReleaseAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('label', 'platform', 'version', 'downloads')¶
-
media
¶
-
readonly_fields
= ('downloads',)¶
-
search_fields
= ('title', 'description')¶
-
-
class
kawaz.apps.products.admin.
PlatformAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
media
¶
-
-
class
kawaz.apps.products.admin.
ProductAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('title', 'last_modifier_nickname', 'get_display_mode_display', 'published_at', 'created_at', 'updated_at')¶
-
media
¶
-
filters
Module¶forms
Module¶models
Module¶-
class
kawaz.apps.products.models.
AbstractRelease
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
リリース形態のアブストラクトモデル
-
AbstractRelease.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
AbstractRelease.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
AbstractRelease.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
AbstractRelease.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
AbstractRelease.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
AbstractRelease.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
AbstractRelease.
platform
¶ 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.
-
AbstractRelease.
platform_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
AbstractRelease.
product
¶ 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.
-
AbstractRelease.
product_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
AbstractRelease.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
AbstractRelease.
version
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
-
class
kawaz.apps.products.models.
Category
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
プロダクトが所属するカテゴリーを表すモデル
e.g. ACT, STG, ADV など
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Category.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Category.
description
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
objects
= <django.db.models.manager.Manager object>¶
-
Category.
order
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
product_set
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
-
class
kawaz.apps.products.models.
PackageRelease
(*args, **kwargs)[source]¶ Bases:
kawaz.apps.products.models.AbstractRelease
ファイル添付形式でのリリースモデル
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
PackageRelease.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
PackageRelease.
downloads
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PackageRelease.
file_content
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
PackageRelease.
filename
¶ ファイル名を返します
-
PackageRelease.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
PackageRelease.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
PackageRelease.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
PackageRelease.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
PackageRelease.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PackageRelease.
mimetype
¶ Mimetypeを返します
-
PackageRelease.
objects
= <django.db.models.manager.Manager object>¶
-
PackageRelease.
platform
¶ 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.
-
PackageRelease.
product
¶ 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.
-
exception
-
class
kawaz.apps.products.models.
Platform
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
プロダクトがサポートしているプラットフォームを表すモデル
e.g. Windows, Mac, Browser, iOS, PS Vita など
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Platform.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Platform.
icon
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
Platform.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Platform.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Platform.
objects
= <django.db.models.manager.Manager object>¶
-
Platform.
order
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Platform.
packagerelease_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Platform.
products
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Platform.
urlrelease_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
-
class
kawaz.apps.products.models.
Product
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
完成したプロダクトを表すモデル
メンバーであれば誰でも作成・管理可能
-
DISPLAY_MODES
= (('featured', 'Fetured: Displayed in the curled cell and the tiled cell on the top page'), ('tiled', 'Tiled: Displayed in the tiled cell on the top page'), ('normal', 'Normal: Displayed only in tiled cell on the detailed page'))¶
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Product.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Product.
administrators
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Product.
advertisement_image
¶ Enhanced ImageFileDescriptor
Just like the ImageFileDescriptor, but for ThumbnailField. The only difference is removing previous Image and Thumbnails from storage when the value has changed.
-
Product.
categories
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Product.
contact_info
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
description
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
display_mode
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
get_display_mode_display
(*moreargs, **morekwargs)¶
-
Product.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Product.
get_next_by_published_at
(*moreargs, **morekwargs)¶
-
Product.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Product.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Product.
get_previous_by_published_at
(*moreargs, **morekwargs)¶
-
Product.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Product.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
last_modifier
¶ 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.
-
Product.
last_modifier_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
objects
= <django.db.models.manager.Manager object>¶
-
Product.
packagereleases
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Product.
platforms
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Product.
project
¶ Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
restaurant.place
is aForwardOneToOneDescriptor
instance.
-
Product.
project_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
published_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
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.
-
Product.
screenshots
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Product.
slug
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
thumbnail
¶ Enhanced ImageFileDescriptor
Just like the ImageFileDescriptor, but for ThumbnailField. The only difference is removing previous Image and Thumbnails from storage when the value has changed.
-
Product.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
trailer
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Product.
urlreleases
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
-
class
kawaz.apps.products.models.
Screenshot
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
プロダクトのスクリーンショットモデル
プロダクト管理者は何枚でもプロダクトに関連付けることが出来る
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Screenshot.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Screenshot.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Screenshot.
image
¶ Enhanced ImageFileDescriptor
Just like the ImageFileDescriptor, but for ThumbnailField. The only difference is removing previous Image and Thumbnails from storage when the value has changed.
-
Screenshot.
objects
= <django.db.models.manager.Manager object>¶
-
Screenshot.
product
¶ 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.
-
Screenshot.
product_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.products.models.
URLRelease
(*args, **kwargs)[source]¶ Bases:
kawaz.apps.products.models.AbstractRelease
URL指定形式でのリリースモデル。主に外部ホスティングでのリリース用
e.g. iTunes App Store, Google Play, Vector など
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
URLRelease.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
URLRelease.
PLAY_NOW_PLATFORM_LABELS
= ['ブラウザ']¶
-
URLRelease.
app_id
¶ そのリリースがiOSアプリかAndroidアプリだった場合は、そのアプリのAppIDを取得して返します そうではない場合、空白文字を返します
-
URLRelease.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
URLRelease.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
URLRelease.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
URLRelease.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
URLRelease.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
URLRelease.
is_appstore
¶ App Store の URL か否か
-
URLRelease.
is_googleplay
¶ Google Play の URL か否か
-
URLRelease.
objects
= <django.db.models.manager.Manager object>¶
-
URLRelease.
pageview
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
URLRelease.
platform
¶ 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.
-
URLRelease.
product
¶ 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.
-
URLRelease.
url
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.products.models.
UnsavedForeignKey
(to, on_delete=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, to_field=None, db_constraint=True, **kwargs)[source]¶ Bases:
django.db.models.fields.related.ForeignKey
-
allow_unsaved_instance_assignment
= True¶
-
perms
Module¶urls
Module¶views
Module¶0001_initial
Module¶-
class
kawaz.apps.products.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__'), ('projects', '0001_initial')]¶
-
operations
= [<CreateModel name='Category', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Categories', 'verbose_name': 'Category', 'ordering': ('order', 'pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('description', <django.db.models.fields.CharField>), ('order', <django.db.models.fields.PositiveSmallIntegerField>)]>, <CreateModel name='PackageRelease', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Package releases', 'verbose_name': 'Package release', 'abstract': False, 'ordering': ('platform__pk', 'product__pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('version', <django.db.models.fields.CharField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('file_content', <django.db.models.fields.files.FileField>), ('downloads', <django.db.models.fields.PositiveIntegerField>)]>, <CreateModel name='Platform', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Platforms', 'verbose_name': 'Platform', 'ordering': ('order', 'pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('icon', <django.db.models.fields.files.ImageField>), ('order', <django.db.models.fields.PositiveSmallIntegerField>)]>, <CreateModel name='Product', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Products', 'permissions': (('join_product', 'Can join to the product'), ('quit_product', 'Can quit from the product')), 'verbose_name': 'Product', 'ordering': ('display_mode', '-publish_at')}, fields=[('id', <django.db.models.fields.AutoField>), ('title', <django.db.models.fields.CharField>), ('slug', <django.db.models.fields.SlugField>), ('thumbnail', <thumbnailfield.fields.ThumbnailField>), ('description', <django.db.models.fields.TextField>), ('advertisement_image', <thumbnailfield.fields.ThumbnailField>), ('trailer', <django.db.models.fields.URLField>), ('publish_at', <django.db.models.fields.DateField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('display_mode', <django.db.models.fields.CharField>), ('administrators', <django.db.models.fields.related.ManyToManyField>), ('categories', <django.db.models.fields.related.ManyToManyField>), ('last_modifier', <django.db.models.fields.related.ForeignKey>), ('platforms', <django.db.models.fields.related.ManyToManyField>), ('project', <django.db.models.fields.related.OneToOneField>)]>, <CreateModel name='Screenshot', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Screen shots', 'verbose_name': 'Screen shot', 'ordering': ('pk',)}, fields=[('id', <django.db.models.fields.AutoField>), ('image', <thumbnailfield.fields.ThumbnailField>), ('product', <django.db.models.fields.related.ForeignKey>)]>, <CreateModel name='URLRelease', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'URL releases', 'verbose_name': 'URL release', 'abstract': False, 'ordering': ('platform__pk', 'product__pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('version', <django.db.models.fields.CharField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('url', <django.db.models.fields.URLField>), ('pageview', <django.db.models.fields.PositiveIntegerField>), ('platform', <django.db.models.fields.related.ForeignKey>), ('product', <django.db.models.fields.related.ForeignKey>)]>, <AddField preserve_default=True, name='platform', field=<django.db.models.fields.related.ForeignKey>, model_name='packagerelease'>, <AddField preserve_default=True, name='product', field=<django.db.models.fields.related.ForeignKey>, model_name='packagerelease'>]¶
-
0002_auto_20141115_1411
Module¶-
class
kawaz.apps.products.migrations.0002_auto_20141115_1411.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('products', '0001_initial')]¶
-
operations
= [<AddField preserve_default=True, name='contact_info', field=<django.db.models.fields.CharField>, model_name='product'>, <AlterField preserve_default=True, name='version', field=<django.db.models.fields.CharField>, model_name='packagerelease'>, <AlterField preserve_default=True, name='version', field=<django.db.models.fields.CharField>, model_name='urlrelease'>]¶
-
0003_auto_20141123_0104
Module¶-
class
kawaz.apps.products.migrations.0003_auto_20141123_0104.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('products', '0002_auto_20141115_1411')]¶
-
operations
= [<AlterModelOptions name='product', options={'verbose_name_plural': 'Products', 'permissions': (('join_product', 'Can join to the product'), ('quit_product', 'Can quit from the product')), 'ordering': ('display_mode', '-published_at'), 'verbose_name': 'Product'}>, <RenameField new_name='published_at', old_name='publish_at', model_name='product'>, <AlterField preserve_default=True, name='contact_info', field=<django.db.models.fields.CharField>, model_name='product'>]¶
-
products_tags
Module¶全てのCategory一覧を取り出します。
- Syntax:
- {% get_categories as <variable> %}
全てのPlatform一覧を取り出します。
- Syntax:
- {% get_platforms as <variable> %}
任意の<lookup>によりフィルタされた Product のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_products as <variable> %} {% get_products <lookup> as <variable> %}
- Lookup: (Default: mixed)
- mixed: display_mode が featured/tiled な Product を返す normal: display_mode が normal な Product を返す featured: display_mode が featured な Product を返す tiled: display_mode が tiled な Product を返す
Examples
display_mode が featured/tiled な Product のクエリを取得し、最新 5件のみを描画
{% get_products as products %} {% for product in products|slice:”:5” %}
{{ product }}{% endfor %}
display_mode が normal な Product を取得
{% get_products ‘normal’ as normal_products %}
任意のカテゴリに所属するProductを返却します
- categories:
- CategoryのQuerySet
Example
{% load products_tag %} {% get_product_by_category <categories> as <variable> %}
任意のプロダクトの関連プロダクトを取り出します。 渡されたプロダクトと同じカテゴリに所属している物全てから、自身を抜いた QuerySetを返します
- Syntax:
- {% get_relative <product> as <variable> %}
プロダクト用のTwitterカードを埋め込むテンプレートタグ 通常はhead内に書く
- Syntax:
- {% render_twitter_card product %}
- Template:
products/components/twitter_card.htmlが使用される。 このテンプレートは以下のコンテキストを受け取れる
product: 描画対象のProductオブジェクト apps: Productの所属するURLReleaseのうち、iOSアプリ、Androidアプリのもののみが含まれたリスト
このような仕様になっているのは、appsがある場合のみTwitterカードのApp Cardを利用することが想定されているためである
projects Package¶
projects
Package¶activity
Module¶admin
Module¶-
class
kawaz.apps.projects.admin.
CategoryAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
media
¶
-
-
class
kawaz.apps.projects.admin.
ProjectAdmin
(model, admin_site)[source]¶ Bases:
django.contrib.admin.options.ModelAdmin
-
list_display
= ('title', 'get_status_display', 'administrator_nickname', 'created_at', 'updated_at', 'is_legacy')¶
-
media
¶
-
search_fields
= ('title', 'body', 'administrator__username', 'administrator__nickname', 'category__label')¶
-
forms
Module¶models
Module¶-
class
kawaz.apps.projects.models.
Category
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
プロジェクトが所属するカテゴリモデル
スタッフが作成し、メンバーがプロジェクト作成・編集時に利用する
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Category.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Category.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Category.
objects
= <django.db.models.manager.Manager object>¶
-
Category.
projects
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
-
class
kawaz.apps.projects.models.
Project
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
現在進行形で作成しているプロジェクトを示すモデル
メンバーであれば自由に作成可能で所有者および参加者が編集権限を持つ また削除権限は所有者のみが持ち、所有権限の委託は未だ作成されていない。
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Project.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Project.
STATUS
= (('planning', 'Planning'), ('active', 'Active'), ('paused', 'Suspended'), ('eternal', 'Eternaled'), ('done', 'Released'))¶
-
Project.
active_members
¶
-
Project.
administrator
¶ 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.
-
Project.
administrator_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
body
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
category
¶ 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.
-
Project.
category_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
get_huge_icon
()¶
-
Project.
get_large_icon
()¶
-
Project.
get_middle_icon
()¶
-
Project.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Project.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Project.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Project.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Project.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Project.
get_small_icon
()¶
-
Project.
get_status_display
(*moreargs, **morekwargs)¶
-
Project.
icon
¶ Enhanced ImageFileDescriptor
Just like the ImageFileDescriptor, but for ThumbnailField. The only difference is removing previous Image and Thumbnails from storage when the value has changed.
-
Project.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
is_legacy
¶ 企画中か活動中、かつ180日以上更新されていない場合、Trueが返ります
-
Project.
last_modifier
¶ 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.
-
Project.
last_modifier_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
members
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Project.
objects
= <kawaz.apps.projects.models.ProjectManager object>¶
-
Project.
product
¶ Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
place.restaurant
is aReverseOneToOneDescriptor
instance.
-
Project.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
repository
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
slug
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
status
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
tracker
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Project.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.apps.projects.models.
ProjectManager
[source]¶ Bases:
django.db.models.manager.Manager
,kawaz.core.publishments.models.PublishmentManagerMixin
-
archived
(user)[source]¶ 指定されたユーザーがー閲覧可能なプロジェクトのうち アーカイブ化されたプロジェクトのクエリを返す 以下のようなプロジェクトがアーカイブである
状態がpaused, eternaled, doneのいずれかである 状態がplanningかつ、created_atから90日以上経過している
-
perms
Module¶urls
Module¶views
Module¶0001_initial
Module¶-
class
kawaz.apps.projects.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__')]¶
-
operations
= [<CreateModel name='Category', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Categories', 'verbose_name': 'Category', 'ordering': ('label',)}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>)]>, <CreateModel name='Project', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Projects', 'permissions': (('join_project', 'Can join to the project'), ('quit_project', 'Can quit from the project'), ('view_project', 'Can view the project')), 'verbose_name': 'Project', 'ordering': ('status', '-updated_at', 'title')}, fields=[('id', <django.db.models.fields.AutoField>), ('pub_state', <django.db.models.fields.CharField>), ('status', <django.db.models.fields.CharField>), ('title', <django.db.models.fields.CharField>), ('slug', <django.db.models.fields.SlugField>), ('body', <django.db.models.fields.TextField>), ('icon', <thumbnailfield.fields.ThumbnailField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('tracker', <django.db.models.fields.URLField>), ('repository', <django.db.models.fields.URLField>), ('administrator', <django.db.models.fields.related.ForeignKey>), ('category', <django.db.models.fields.related.ForeignKey>), ('last_modifier', <django.db.models.fields.related.ForeignKey>), ('members', <django.db.models.fields.related.ManyToManyField>)]>]¶
-
projects_tags
Module¶任意の<lookup>によりフィルタされた Project のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_projects as <variable> %} {% get_projects <lookup> as <variable> %}
- Lookup: (Default: published)
published: ユーザーに対して公開された Project を返す draft: ユーザーが編集可能な下書き Project を返す active: ユーザーが閲覧可能なactiveな Project を返す recently_planned: ユーザーが閲覧可能な直近90日以内に作られた企画中な Project を返す archived: 以下の条件を満たすプロジェクトを返す
状態が一時停止中、エターナった、完成済み、もしくは 企画中であるが、作成から90日以上経過している
Examples
公開された Project のクエリを取得し、最新5件のみを描画
{% get_projects as projects %} {% for project in projects|slice:”:5” %}
{{ project }}{% endfor %}
下書き記事を取得
{% get_projects ‘draft’ as draft_projects %}
userがメンバーに含まれているプロジェクト一覧を返します
- Syntax:
- {% get_published_joined_projects_of user %}
stars Package¶
admin
Module¶models
Module¶-
class
kawaz.apps.stars.models.
Star
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
はてなスター的なモデル。主にJavaScriptで処理を行う
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Star.
MultipleObjectsReturned
¶ Bases:
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
[source]¶ Bases:
django.db.models.manager.Manager
-
add_to_object
(obj, author, quote='')[source]¶ 指定されたオブジェクトに新たにスターを作成
Parameters: - 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
[source]¶ Bases:
permission.logics.base.PermissionLogic
-
has_perm
(user_obj, perm, obj=None)[source]¶ 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¶api
Package¶serializers
Module¶-
class
kawaz.apps.stars.api.serializers.
StarSerializer
(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]¶ Bases:
rest_framework.serializers.ModelSerializer
views
Module¶-
class
kawaz.apps.stars.api.views.
StarViewSet
(**kwargs)[source]¶ Bases:
kawaz.api.mixins.CreateModelMixin
,rest_framework.mixins.DestroyModelMixin
,rest_framework.mixins.ListModelMixin
,kawaz.api.views.KawazGenericViewSet
-
filter_fields
= ('content_type', 'object_id')¶
-
model
¶ alias of
Star
-
queryset
¶
-
serializer_class
¶ alias of
StarSerializer
-
suffix
= None¶
-
0001_initial
Module¶-
class
kawaz.apps.stars.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('personas', '__first__'), ('contenttypes', '0001_initial')]¶
-
operations
= [<CreateModel name='Star', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Stars', 'permissions': (('view_star', 'Can view the Star'),), 'verbose_name': 'Star', 'ordering': ('created_at',)}, fields=[('id', <django.db.models.fields.AutoField>), ('object_id', <django.db.models.fields.PositiveIntegerField>), ('quote', <django.db.models.fields.CharField>), ('created_at', <django.db.models.fields.DateTimeField>), ('author', <django.db.models.fields.related.ForeignKey>), ('content_type', <django.db.models.fields.related.ForeignKey>)]>]¶
-
stars_tags
Module¶任意の<object>に対するStarのエンドポイントURLを取得し、指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_star_endpoint <object> as <variable> %}
Examples
あるオブジェクトに対するendpointを取得し、フォームを生成する
{% get_star_endpoint object as endpoint %} <form action=”{{ endpoint }}” method=”POST”>
<input type=”submit”></form>
任意の<object>についた Star のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_stars <object> as <variable> %}
Examples
公開された Star のクエリを取得し、最新5件のみを描画
{% get_stars object as stars %} {% for star in stars|slice:”:5” %}
{{ star }}{% endfor %}
factories
Module¶models
Module¶-
class
kawaz.apps.stars.tests.models.
StarTestArticle
(id, pub_state, author, title)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
StarTestArticle.
MultipleObjectsReturned
¶ Bases:
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.
-
StarTestArticle.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
StarTestArticle.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
StarTestArticle.
objects
= <django.db.models.manager.Manager object>¶
-
StarTestArticle.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
StarTestArticle.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
test_api
Module¶test_models
Module¶test_perms
Module¶test_templatetags
Module¶core Package¶
Subpackages¶
activities Package¶
urls
Module¶views
Module¶hatenablog
Package¶activity
Module¶admin
Module¶conf
Module¶models
Module¶-
class
kawaz.core.activities.hatenablog.models.
HatenablogEntry
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
はてなブログで運営されているKawaz広報ブログの各エントリーを表すモデル
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
HatenablogEntry.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
HatenablogEntry.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
HatenablogEntry.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
HatenablogEntry.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
HatenablogEntry.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
HatenablogEntry.
md5
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
HatenablogEntry.
objects
= <django.db.models.manager.Manager object>¶
-
HatenablogEntry.
thumbnail
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
HatenablogEntry.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
HatenablogEntry.
url
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
scraper
Module¶fetch_hatenablog_entries
Module¶0001_initial
Module¶-
class
kawaz.core.activities.hatenablog.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= []¶
-
operations
= [<CreateModel name='HatenablogEntry', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Hatenablog entries', 'verbose_name': 'Hatenablog entry', 'ordering': ('-created_at',)}, fields=[('id', <django.db.models.fields.AutoField>), ('title', <django.db.models.fields.CharField>), ('url', <django.db.models.fields.URLField>), ('thumbnail', <django.db.models.fields.files.ImageField>), ('md5', <django.db.models.fields.CharField>), ('created_at', <django.db.models.fields.DateTimeField>)]>]¶
-
activities_hatenablog_tag
Module¶Hatenablog 更新情報を指定された <variable> に格納
- Syntax:
- {% get_hatenablog_entries as <variable> %}
Example
最近更新された Hatenablog の記事を5つ描画
{% get_hatenablog_entries as entries %} {% for entry in entries|slice:”:5” %}
{{ entry }}{% endfor %}
comments Package¶
activity
Module¶forms
Module¶models
Module¶perms
Module¶-
class
kawaz.core.comments.perms.
CommentPermissionLogic
[source]¶ Bases:
permission.logics.base.PermissionLogic
-
has_perm
(user_obj, perm, obj=None)[source]¶ コメントのパーミッションを処理する
- Model permission:
- add: メンバーであれば True change: 誰も持たない delete: 誰も持たない can_moderate: メンバーであればTrue
- Object permission:
change: 誰も持たない delete: 誰も持たない can_moderate: 以下のいずれかの条件を満たす
- ネルフ権限以上がある
- コメントの作者が自分である
- 指定されたコメントがリンクしているオブジェクトの編集権限を持っている
- Notice:
- django_comments.can_moderateはdjango_comments.Commentが持つパーミッションであり commentのis_removedフラグを変更する権限である
-
tests
Package¶factories
Module¶models
Module¶-
class
kawaz.core.comments.tests.models.
CommentTestArticle
(id, text, author)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
CommentTestArticle.
MultipleObjectsReturned
¶ Bases:
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.
-
CommentTestArticle.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
CommentTestArticle.
objects
= <django.db.models.manager.Manager object>¶
-
CommentTestArticle.
text
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
test_activity
Module¶test_perms
Module¶test_views
Module¶db Package¶
decorators
Module¶-
kawaz.core.db.decorators.
validate_on_save
(klass)[source]¶ モデル保存時にバリデーションを走らせるためのクラスデコレータ
このデコレータが指定されたモデルを保存した場合、自動的に
full_clean()
が呼び出されバリデーションが走る- Usage:
>>> from django.db import models >>> from django.core.exceptions import ValidationError >>> @validation_on_save >>> class Entry(models.Model): ... def clean(self): ... raise ValidationError
models
Module¶models
Module¶-
class
kawaz.core.db.tests.models.
EvenNumberContainer
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
A test model which does not allow to store odd number
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
EvenNumberContainer.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
EvenNumberContainer.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
EvenNumberContainer.
number
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
EvenNumberContainer.
objects
= <django.db.models.manager.Manager object>¶
-
exception
forms Package¶
forms
Package¶fields
Module¶helpers
Module¶-
class
kawaz.core.forms.helpers.
Bootstrap3HorizontalFormHelper
(*args, **kwargs)[source]¶ Bases:
crispy_forms.helper.FormHelper
Bootstrap3のHorizontalFormを利用するためのHelperです
-
class
kawaz.core.forms.helpers.
Bootstrap3InlineFormHelper
(*args, **kwargs)[source]¶ Bases:
crispy_forms.helper.FormHelper
Bootstrap3のInlineFormを利用するためのHelperです
-
class
kawaz.core.forms.helpers.
HorizontalBareFormHelper
(*args, **kwargs)[source]¶ Bases:
kawaz.core.forms.helpers.Bootstrap3HorizontalFormHelper
HorizontalFormHelperの<form>タグでwrapされていない版です 主にget_form_helperテンプレートタグからの利用を想定しています form_tag = False
-
form_tag
= False¶
-
-
class
kawaz.core.forms.helpers.
InlineBareFormHelper
(*args, **kwargs)[source]¶ Bases:
kawaz.core.forms.helpers.Bootstrap3InlineFormHelper
InlineFormHelperの<form>タグでwrapされていない版です 主にget_form_helperテンプレートタグからの利用を想定しています form_tag = False
-
form_tag
= False¶
-
mixins
Module¶-
class
kawaz.core.forms.mixins.
Bootstrap3HorizontalFormHelperMixin
(*args, **kwargs)[source]¶ Bases:
kawaz.core.forms.mixins.FormHelperMixinBase
django-crispy-formsを使って、bootstrap3対応のHorizontalFormを作成するMixinです。
Usage:
- class ArticleForm(BootstrapHorizontalFormMixin, ModelForm):
- model = Article
-
helper_class
¶ alias of
Bootstrap3HorizontalFormHelper
-
class
kawaz.core.forms.mixins.
Bootstrap3InlineFormHelperMixin
(*args, **kwargs)[source]¶ Bases:
kawaz.core.forms.mixins.FormHelperMixinBase
django-crispy-formsを使って、bootstrap3対応のInlineFormを作成するMixinです。
-
helper_class
¶ alias of
Bootstrap3InlineFormHelper
-
widgets
Module¶templatetags
Package¶form_helper
Module¶<type>に応じたFormHelperを返します。 もし、該当する<type>が見つからない場合は、TemplateSyntaxErrorを投げます。
- Syntax:
- {% get_form_helper as <variable> %} {% get_form_helper <type> as <variable> %}
- Type: (Default: horizontal)
- horizontal: Bootstrap3のHorizontal Formを描画するHelper inline: Bootstrap3Inline Formを描画するHelper bare: horizontalを描画し、formタグに囲まれていないHelper
Examples
任意のFormに対してHorizontalFormHelperを適応する {% load crispy_form_tags %} {% load form_helper %}
{% get_form_helper “horizontal” as helper %} {% crispy form helper %}
management Package¶
management
Package¶Kawaz 用 manage.py 拡張モジュール
init_database
Module¶Kawaz開発用にデータベースの初期化等を行うコマンド
-
class
kawaz.core.management.management.commands.init_database.
Command
(stdout=None, stderr=None, no_color=False)[source]¶ Bases:
django.core.management.base.BaseCommand
-
help
= 'Command to initialize database. It will overwrite the existing data in database thus Run this command WITH CLOSE ATTENTION.'¶
-
personas Package¶
personas
Package¶承認システム用カスタムユーザApp
filters
Module¶perms
Module¶-
class
kawaz.core.personas.perms.
AdamPermissionLogic
(any_permission=False, add_permission=False, change_permission=False, delete_permission=False)[source]¶ Bases:
kawaz.core.personas.perms.BaseRolePermissionLogic
Permission logic class to allow permissions to over `Adam`(superuser) role user
-
role_names
= ['adam']¶
-
-
class
kawaz.core.personas.perms.
BaseRolePermissionLogic
(any_permission=False, add_permission=False, change_permission=False, delete_permission=False)[source]¶ Bases:
permission.logics.base.PermissionLogic
Permission logic class for role based permission system It is checked by user_obj.role
-
has_perm
(user_obj, perm, obj=None)[source]¶ Check if user have permission (of object) It is determined from the user_obj.role.
If no object is specified, if any_permission is True it returns
True
. if else returnsFalse
.If an object is specified, it will return
True
if the user’s role is contained inrole_names
.Parameters: - 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
Returns: Wheter the specified user have specified permission (of specified object).
Return type: boolean
-
role_names
= []¶
-
-
class
kawaz.core.personas.perms.
ChildrenPermissionLogic
(any_permission=False, add_permission=False, change_permission=False, delete_permission=False)[source]¶ Bases:
kawaz.core.personas.perms.BaseRolePermissionLogic
Permission logic class to allow permissions to over Children role user.
-
role_names
= ['adam', 'seele', 'nerv', 'children']¶
-
-
class
kawaz.core.personas.perms.
KawazAuthorPermissionLogic
(field_name=None, any_permission=None, change_permission=None, delete_permission=None)[source]¶ Bases:
permission.logics.author.AuthorPermissionLogic
Kawaz用AuthorPermissionLogic
Kawazの仕様では、willeがauthorになることは現段階ではない。 通常のAuthorPermissionLogicを利用すると、willeであっても ログインユーザーであればモデルパーミッションがTrueになり 使い勝手が悪い そのため、wille以下の場合はFalseが返るようにした
-
role_names
= ['adam', 'seele', 'nerv', 'children']¶
-
-
class
kawaz.core.personas.perms.
NervPermissionLogic
(any_permission=False, add_permission=False, change_permission=False, delete_permission=False)[source]¶ Bases:
kawaz.core.personas.perms.BaseRolePermissionLogic
Permission logic class to allow permissions to over `Nerv`(staff) role user
-
role_names
= ['adam', 'seele', 'nerv']¶
-
-
class
kawaz.core.personas.perms.
PersonaPermissionLogic
[source]¶ Bases:
permission.logics.base.PermissionLogic
Permission logics which check the user’s role and return corresponding permission
-
class
kawaz.core.personas.perms.
SeelePermissionLogic
(any_permission=False, add_permission=False, change_permission=False, delete_permission=False)[source]¶ Bases:
kawaz.core.personas.perms.BaseRolePermissionLogic
Permission logic class to allow permissions to over Seele role user.
-
role_names
= ['adam', 'seele']¶
-
urls
Module¶activities
Package¶persona
Module¶-
class
kawaz.core.personas.activities.persona.
PersonaActivityMediator
[source]¶ Bases:
kawaz.core.personas.activities.persona.PersonaActivityMediatorBase
Note
Personaは3つのMediatorからさまざまなイベントが発行される activated: Profileの作成(ユーザーのアクティベート時にプロフィールが
作成されるため、プロフィールが生成されたときをアクティベート されたと判定している)profile_updated: プロフィールの更新 comment_added: コメントの追加 account_added: アカウントの追加
updatedイベントは初回更新時の前回との差分がないとき、`last_login`カラム が更新されるだけでも通知されてしまう問題があり対処が面倒なので、ユーザ の更新は一切通知されない仕様にする
profile
Module¶-
class
kawaz.core.personas.activities.profile.
AccountActivityMediator
[source]¶ Bases:
kawaz.core.personas.activities.persona.PersonaActivityMediatorBase
-
class
kawaz.core.personas.activities.profile.
ProfileActivityMediator
[source]¶ Bases:
kawaz.core.personas.activities.persona.PersonaActivityMediatorBase
api
Package¶0001_initial
Module¶-
class
kawaz.core.personas.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('auth', '0001_initial')]¶
-
operations
= [<CreateModel name='Persona', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Personas', 'permissions': (('activate_persona', 'Can activate/deactivate the persona'), ('assign_role_persona', 'Can assign the role to the persona')), 'verbose_name': 'Persona', 'ordering': ('username',)}, fields=[('id', <django.db.models.fields.AutoField>), ('password', <django.db.models.fields.CharField>), ('last_login', <django.db.models.fields.DateTimeField>), ('username', <django.db.models.fields.CharField>), ('first_name', <django.db.models.fields.CharField>), ('last_name', <django.db.models.fields.CharField>), ('email', <django.db.models.fields.EmailField>), ('is_active', <django.db.models.fields.BooleanField>), ('date_joined', <django.db.models.fields.DateTimeField>), ('nickname', <django.db.models.fields.CharField>), ('quotes', <django.db.models.fields.CharField>), ('avatar', <thumbnailfield.fields.ThumbnailField>), ('gender', <django.db.models.fields.CharField>), ('role', <django.db.models.fields.CharField>)]>, <CreateModel name='Account', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Accounts', 'permissions': (('view_account', 'Can view the account'),), 'verbose_name': 'Account'}, fields=[('id', <django.db.models.fields.AutoField>), ('pub_state', <django.db.models.fields.CharField>), ('username', <django.db.models.fields.CharField>)]>, <CreateModel name='Profile', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Profiles', 'permissions': (('view_profile', 'Can view the profile'),), 'verbose_name': 'Profile', 'ordering': ('user__nickname',)}, fields=[('pub_state', <django.db.models.fields.CharField>), ('birthday', <django.db.models.fields.DateField>), ('place', <django.db.models.fields.CharField>), ('url', <django.db.models.fields.URLField>), ('remarks', <django.db.models.fields.TextField>), ('user', <django.db.models.fields.related.OneToOneField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>)]>, <CreateModel name='Service', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Services', 'verbose_name': 'Service', 'ordering': ('pk',)}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('icon', <django.db.models.fields.files.ImageField>), ('url_pattern', <django.db.models.fields.CharField>)]>, <CreateModel name='Skill', bases=(<class 'django.db.models.base.Model'>,), options={'verbose_name_plural': 'Skills', 'verbose_name': 'Skill', 'ordering': ('order', 'pk')}, fields=[('id', <django.db.models.fields.AutoField>), ('label', <django.db.models.fields.CharField>), ('description', <django.db.models.fields.CharField>), ('order', <django.db.models.fields.IntegerField>)]>, <AddField preserve_default=True, name='skills', field=<django.db.models.fields.related.ManyToManyField>, model_name='profile'>, <AddField preserve_default=True, name='profile', field=<django.db.models.fields.related.ForeignKey>, model_name='account'>, <AddField preserve_default=True, name='service', field=<django.db.models.fields.related.ForeignKey>, model_name='account'>, <AlterUniqueTogether unique_together={('service', 'username')}, name='account'>, <AddField preserve_default=True, name='groups', field=<django.db.models.fields.related.ManyToManyField>, model_name='persona'>, <AddField preserve_default=True, name='user_permissions', field=<django.db.models.fields.related.ManyToManyField>, model_name='persona'>]¶
-
models
Package¶persona
Module¶-
class
kawaz.core.personas.models.persona.
ActivePersonaManager
[source]¶ Bases:
kawaz.core.personas.models.persona.PersonaManager
アクティブユーザーのみを取り出すManager
-
class
kawaz.core.personas.models.persona.
Persona
(*args, **kwargs)[source]¶ Bases:
django.contrib.auth.models.AbstractUser
Kawazで利用する認証用カスタムユーザーモデル
このユーザーモデルはDjangoデフォルトのモデルと異なり`is_staff`と `is_superuser`の値をDB上に保持しない。代わりにこれらの値は`role`の値から 自動的に決定され、プロパティとして提供される
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
Persona.
GENDER_TYPES
= (('man', 'Man'), ('woman', 'Woman'), ('unknown', 'Unknown'))¶
-
exception
Persona.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Persona.
ROLE_TYPES
= (('adam', 'Adam'), ('seele', 'Seele'), ('nerv', 'Nerv'), ('children', 'Children'), ('wille', 'Wille'))¶
-
Persona.
actives
= <kawaz.core.personas.models.persona.ActivePersonaManager object>¶
-
Persona.
avatar
¶ Enhanced ImageFileDescriptor
Just like the ImageFileDescriptor, but for ThumbnailField. The only difference is removing previous Image and Thumbnails from storage when the value has changed.
-
Persona.
blog_categories
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
blog_entries
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
comment_comments
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
comment_flags
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
commenttestarticle_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
created_announcements
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
events_attend
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
events_owned
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
gender
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Persona.
get_gender_display
(*moreargs, **morekwargs)¶
-
Persona.
get_grayscale_avatar
()¶
-
Persona.
get_huge_avatar
()¶
-
Persona.
get_large_avatar
()¶
-
Persona.
get_middle_avatar
()¶
-
Persona.
get_next_by_date_joined
(*moreargs, **morekwargs)¶
-
Persona.
get_previous_by_date_joined
(*moreargs, **morekwargs)¶
-
Persona.
get_role_display
(*moreargs, **morekwargs)¶
-
Persona.
get_small_avatar
()¶
-
Persona.
groups
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Persona.
is_member
¶
-
Persona.
is_staff
¶
-
Persona.
is_superuser
¶
-
Persona.
last_modified_announcements
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
last_modified_products
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
last_modified_projects
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
logentry_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
material_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
nickname
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Persona.
objects
= <kawaz.core.personas.models.persona.PersonaManager object>¶
-
Persona.
product_set
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
projects_joined
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
projects_owned
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
quotes
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Persona.
registration_profile
¶ Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
place.restaurant
is aReverseOneToOneDescriptor
instance.
-
Persona.
role
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Persona.
save
(*args, **kwargs)¶
-
Persona.
star_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
startestarticle_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Persona.
user_permissions
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
-
class
kawaz.core.personas.models.persona.
PersonaBase
(class_name, bases, namespace)[source]¶ Bases:
django.db.models.base.ModelBase
AbstractUser`から継承されたために自動作成される`is_staff`や`is_superuser フィールドを強制的に削除するためのメタクラス
`Persona`モデルは`role`フィールドを持ち、その値により`is_staff`や `is_superuser`の値を決定するためDB上にこれらの値を保持する必要性がない。
-
class
kawaz.core.personas.models.persona.
PersonaManager
[source]¶ Bases:
django.contrib.auth.base_user.BaseUserManager
Persona用カスタムマネージャ
PersonaモデルはDjangoがデフォルトで利用する is_staff や is_superuser を DBレベルで廃止しているため、このカスタムが必要
PersonaManagerでは`role`によりユーザーとスーパーユーザを区別しているため create_superuser`で作成されたユーザーは`role`が‘adam’になり、その他の 場合は‘wille’`となる。
profile
Module¶-
class
kawaz.core.personas.models.profile.
Account
(id, profile, service, pub_state, username)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Account.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Account.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Account.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Account.
objects
= <django.db.models.manager.Manager object>¶
-
Account.
profile
¶ 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.
-
Account.
profile_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Account.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Account.
service
¶ 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.
-
Account.
service_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Account.
url
¶
-
Account.
username
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.core.personas.models.profile.
Profile
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
It is the model which indicates profiles of each users
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Profile.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Profile.
PUB_STATES
= (('public', 'Public'), ('protected', 'Internal'))¶
-
Profile.
accounts
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Profile.
birthday
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
created_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
get_next_by_created_at
(*moreargs, **morekwargs)¶
-
Profile.
get_next_by_updated_at
(*moreargs, **morekwargs)¶
-
Profile.
get_previous_by_created_at
(*moreargs, **morekwargs)¶
-
Profile.
get_previous_by_updated_at
(*moreargs, **morekwargs)¶
-
Profile.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
Profile.
objects
= <kawaz.core.personas.models.profile.ProfileManager object>¶
-
Profile.
place
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
remarks
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
skills
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Profile.
updated_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
url
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Profile.
user
¶ Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
restaurant.place
is aForwardOneToOneDescriptor
instance.
-
Profile.
user_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.core.personas.models.profile.
ProfileManager
[source]¶ Bases:
django.db.models.manager.Manager
-
class
kawaz.core.personas.models.profile.
Service
(id, label, icon, url_pattern)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Service.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Service.
accounts
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
Service.
active_accounts
¶
-
Service.
icon
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
Service.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Service.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Service.
objects
= <django.db.models.manager.Manager object>¶
-
Service.
url_pattern
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
kawaz.core.personas.models.profile.
Skill
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
It is the model which indicates what users can
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
Skill.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
Skill.
description
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Skill.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Skill.
label
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Skill.
objects
= <django.db.models.manager.Manager object>¶
-
Skill.
order
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
Skill.
users
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
templatetags
Package¶profiles_tags
Module¶現在のログインユーザーのプロフィールを取り出すテンプレートタグ セキュリティの観点から、任意のユーザーのプロフィール情報を取り出すことはできず、 必ずログインユーザーの物が返される もし、ログインユーザーがプロフィールを持っていなかったり(wille)、 渡されたユーザーが非ログインユーザーだった場合は`None`を返す
Example
{% load profiles_tags %} {% get_my_profile as profile %} {{ profile.remarks }}
特定のユーザーのプロフィールを取り出すテンプレートタグ セッションに含まれる現在のログインユーザーを取得し、 対象プロフィールの閲覧権限がある場合のみ取得できる パーミッションがない場合は`None`を返す
Example
{% load profiles_tags %} {% get_profile user as profile %} {{ profile.remarks }}
models
Module¶-
class
kawaz.core.personas.tests.models.
PersonaTestArticle
(id, pub_state, title, author)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
PersonaTestArticle.
MultipleObjectsReturned
¶ Bases:
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.
-
PersonaTestArticle.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
PersonaTestArticle.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PersonaTestArticle.
objects
= <django.db.models.manager.Manager object>¶
-
PersonaTestArticle.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PersonaTestArticle.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
test_activity
Module¶test_mails
Module¶test_templatetags
Module¶utils
Module¶publishments Package¶
publishments
Package¶lookups
Module¶-
kawaz.core.publishments.lookups.
draft_lookup
(user_obj, author_field_name='author', field_name='pub_state')[source]¶ 指定されたユーザーが編集可能な下書きオブジェクトをフィルタするための Qオブジェクトを返す
ユーザーがメンバーであれば、自身が保有する下書き状態のオブジェクトを返し それ以外であれば何も返さない。なおユーザーがsuperuserの場合は存在する あらゆる下書き状態のオブジェクトを返す(superuserはあらゆる権限を持つため 全ての下書き記事の編集権限を持つ)
Parameters: - user_obj (obj) – Userモデルインスタンス(or AnonymousUser)
- author_field_name (str) – 所有者を指定しているフィールド名
(デフォルト:
'author'
) - field_name (str) – 公開状態を指定しているフィールド名
(デフォルト:
'pub_state'
)
Returns: Qオブジェクトインスタンス
-
kawaz.core.publishments.lookups.
published_lookup
(user_obj, field_name='pub_state')[source]¶ 指定されたユーザーが閲覧可能な公開オブジェクトをフィルタするための Qオブジェクトを返す
ユーザーがメンバーであれば、publicおよびprotected指定のオブジェクトを返し それ以外であればpublic指定のオブジェクトを返す
Parameters: - user_obj (obj) – Userモデルインスタンス(or AnonymousUser)
- field_name (str) – 公開状態を指定しているフィールド名
(デフォルト:
'pub_state'
)
Returns: Qオブジェクトインスタンス
models
Module¶-
class
kawaz.core.publishments.models.
PublishmentManagerMixin
[source]¶ Bases:
object
A model manager mixin for
AbstractPublishmentModel
model.-
published
(user)[source]¶ 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.
Return a queryset which include the objects related to the specified user, namely an union of the
published
anddraft
queryset.
-
perms
Module¶-
class
kawaz.core.publishments.perms.
PublishmentPermissionLogic
(author_field_name='author', pub_state_field_name='pub_state')[source]¶ Bases:
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)[source]¶ Check if user have view permission (of object) based on the
pub_state
andauthor
of the instance.If no object is specified, it always return
True
.If an object is specified, it will return
True
when thepub_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
Parameters: - 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
Returns: Wheter the specified user have specified permission (of specified object).
Return type: boolean
-
tests
Package¶models
Module¶-
class
kawaz.core.publishments.tests.models.
PublishmentTestArticle
(id, pub_state, author, title)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
PublishmentTestArticle.
MultipleObjectsReturned
¶ Bases:
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.
-
PublishmentTestArticle.
get_pub_state_display
(*moreargs, **morekwargs)¶
-
PublishmentTestArticle.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PublishmentTestArticle.
objects
= <django.db.models.manager.Manager object>¶
-
PublishmentTestArticle.
pub_state
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
PublishmentTestArticle.
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
test_lookups
Module¶test_perms
Module¶-
class
kawaz.core.publishments.tests.test_perms.
PublishmentPermissionLogicTestCase
(methodName='runTest')[source]¶ Bases:
django.test.testcases.TestCase
-
test_view_permission_with_draft
()[source]¶ Nobody except the author and adam can see the draft model
-
registrations Package¶
registrations
Package¶backends
Module¶forms
Module¶-
class
kawaz.core.registrations.forms.
KawazRegistrationForm
(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]¶ Bases:
registration.forms.RegistrationFormTermsOfService
-
base_fields
= OrderedDict([('username', <django.forms.fields.RegexField object>), ('email1', <django.forms.fields.EmailField object>), ('email2', <django.forms.fields.EmailField object>), ('tos', <django.forms.fields.BooleanField object>)])¶
-
declared_fields
= OrderedDict([('username', <django.forms.fields.RegexField object>), ('email1', <django.forms.fields.EmailField object>), ('email2', <django.forms.fields.EmailField object>), ('tos', <django.forms.fields.BooleanField object>)])¶
-
media
¶
-
models
Module¶-
class
kawaz.core.registrations.models.
RegistrationSupplement
(id, registration_profile, place, skill, remarks)[source]¶ Bases:
registration.supplements.base.RegistrationSupplementBase
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
RegistrationSupplement.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
RegistrationSupplement.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
RegistrationSupplement.
objects
= <django.db.models.manager.Manager object>¶
-
RegistrationSupplement.
place
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
RegistrationSupplement.
registration_profile
¶ Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
restaurant.place
is aForwardOneToOneDescriptor
instance.
-
RegistrationSupplement.
remarks
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
RegistrationSupplement.
skill
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
perms
Module¶urls
Module¶0001_initial
Module¶-
class
kawaz.core.registrations.migrations.0001_initial.
Migration
(name, app_label)[source]¶ Bases:
django.db.migrations.migration.Migration
-
dependencies
= [('registration', '__first__')]¶
-
operations
= [<CreateModel name='RegistrationSupplement', bases=(<class 'django.db.models.base.Model'>,), options={'abstract': False}, fields=[('id', <django.db.models.fields.AutoField>), ('place', <django.db.models.fields.CharField>), ('skill', <django.db.models.fields.TextField>), ('remarks', <django.db.models.fields.TextField>), ('registration_profile', <django.db.models.fields.related.OneToOneField>)]>]¶
-
tests
Package¶factories
Module¶test_emails
Module¶test_perms
Module¶test_signals
Module¶test_views
Module¶templatetags Package¶
templatetags
Package¶expr
Module¶Bases:
django.template.base.Node
テンプレート内でPythonの機能を実行し描画 or 変数代入するタグ
- Syntax:
- {% expr <expression> (as <variable) %}
Example
{# 2 を描画 #} {% expr 1 + 1 %} {# 10 を foo に代入 #} {% expr 1 + 9 as foo %} {# foo を使って掛け算し描画 #} {% expr foo * 100 %}
strip_newlines
Module¶指定されたテキストから改行文字を取り除くテンプレートフィルタ
- Usage:
- {{ object.body | strip_newlines }} {{ object.body | strip_newlines:’ ‘ }} # 半角スペースに置換
utils
Module¶現在のURLのregexを渡して、一致していた場合は’active’を返します そうでない場合は空白文字を返します param pattern 現在のURLの正規表現パターン
また、GETパラメーターが与えられている場合、keyの昇順に連結されたURLで判定します /members/kawaz_tan/?a=1&b=2&c=3
Example
{% load utils %} <div class=”{% active ‘/members/.+’ %}”</div>
例えば、このように記述しておくと、bootstrapのタブなど、「特定のページにいるときだけactiveクラスを付加したい」 という需要に対応できます
現在のSiteオブジェクトを取得します
datetimeオブジェクトを受け取り、曜日に応じてCSSクラス名を返します
- Param
- date [datetime]
- Return [string]
- 土曜日 saturday 日曜日 sunday その他 weekday
- Example
- {% load utils %} <div class=”{% get_week_day date”>{{ date }}</div>
tests
Package¶test_builtin
Module¶Bases:
django.test.testcases.TestCase
kfmがbuilt in template-filter化されている
test_expr
Module¶Bases:
django.test.testcases.TestCase
expr タグを利用して計算結果を代入可能
test_strip_newlines
Module¶Bases:
django.test.testcases.TestCase
strip_newlinesフィルタで改行文字の置換が可能
test_utils
Module¶Bases:
django.test.testcases.TestCase
activeタグのpatternが現在のURLとマッチしたとき、activeの文字を返す
activeタグはGETパラメータの値も含む
activeタグのpatternが現在のURLとマッチしないとき、空白文字を返す
Bases:
django.test.testcases.TestCase
get_current_siteで現在のSiteを返す
Bases:
django.test.testcases.TestCase
get_week_dayで土曜だったときにsaturdayを返す
get_week_dayで日曜だったときにsundayを返す
get_week_dayで平日だったときにweekdayを返す
tests Package¶
runner
Module¶-
class
kawaz.core.tests.runner.
KawazDiscoverRunner
(pattern=None, top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_mode=False, debug_sql=False, parallel=0, tags=None, exclude_tags=None, **kwargs)[source]¶
-
class
kawaz.core.tests.runner.
MediaRootTestSuiteRunner
(pattern=None, top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_mode=False, debug_sql=False, parallel=0, tags=None, exclude_tags=None, **kwargs)[source]¶ Bases:
kawaz.core.tests.runner.TempMediaMixin
,django.test.runner.DiscoverRunner
Local test suite runner.
-
class
kawaz.core.tests.runner.
TempMediaMixin
[source]¶ Bases:
object
Mixin to create MEDIA_ROOT in temp and tear down when complete. cf. http://www.caktusgroup.com/blog/2013/06/26/media-root-and-django-tests/
utils Package¶
utils
Package¶models
Module¶permission
Module¶-
kawaz.core.utils.permission.
check_object_permission
(user_obj, codename, obj)[source]¶ 指定ユーザが省略形パーミッションを指定オブジェクトに対して持つか調べる
Parameters: - user_obj (user instance) – 対象ユーザインスタンス
- codename (str) – 省略形パーミッション(例: ‘add’)
- obj (model instance) – 対象モデルインスタンス
Returns: - 指定されたパーミッションが存在する場合は`True`/`False`を
返し、存在しない場合は`None`を返す
Return type: bool or None
-
kawaz.core.utils.permission.
filter_with_perm
(user_obj, qs, codename)[source]¶ 指定された省略形パーミッションを持つオブジェクトをフィルタリング
Parameters: - user_obj (user instance) – 対象ユーザインスタンス
- qs (obj) – QuerySetのインスタンスもしくはオブジェクトリスト
- codename (str) – 省略形パーミッション(例: ‘add’)もしくは パーミッションの完全名
- Notice:
- `qs`にオブジェクトリストを渡す場合は`codename`はパーミッションの完全名 である必要がある。 また、この関数は全てのオブジェクトをいてレートするイテレータを返すため 結果をリスト化する際に全てのオブジェクトを評価する。 このためオブジェクト数が多い場合は計算時間がかかるので注意。
Returns: フィルタしたオブジェクトイテレータ Return type: iterator
views Package¶
delete
Module¶-
class
kawaz.core.views.delete.
DeleteSuccessMessageMixin
[source]¶ Bases:
object
削除時に、削除通知を出すMixin SuccessMessageMixinはDeleteViewには使えないので、自前で実装している
Ref : http://stackoverflow.com/questions/24822509/success-message-in-deleteview-not-shown
- Usage:
- class EntryDeleteView(DeleteSuccessMessageMixin, DeleteView):
- success_message = ‘Entry successfully deleted.’
-
success_message
= ''¶
preview
Module¶-
class
kawaz.core.views.preview.
SingleObjectPreviewViewMixin
[source]¶ Bases:
object
プレビューを行うためのViewを作るMixin
SingleObjectMixin と共に使用することが前提で、SingleObjectMixin にて定義 される get_object(queryset=None) メソッドを上書きする。 上記上書きされたメソッドは POST にて渡されたパラメータを元に仮想モデル インスタンスを生成し返すため、このMixinが適用されたビューはモデルの保存 などを行わずしてテンプレートにてモデルインスタンスのように扱うことが可能
Note
実際に返されるオブジェクトは辞書であるためテンプレート以外では動かない
RESTの原則的にはGETで行うのがふさわしいが、GETだと、長い本文を送信したときに 413エラーを送出してしまうため、POSTで行っている
tests
Package¶models
Module¶-
kawaz.core.views.tests.models.
Article
¶
-
class
kawaz.core.views.tests.models.
SingleObjectPreviewViewMixinTestArticle
(id, foo, bar)[source]¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
SingleObjectPreviewViewMixinTestArticle.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
SingleObjectPreviewViewMixinTestArticle.
bar
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
SingleObjectPreviewViewMixinTestArticle.
foo
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
SingleObjectPreviewViewMixinTestArticle.
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
SingleObjectPreviewViewMixinTestArticle.
objects
= <django.db.models.manager.Manager object>¶
-
exception
test_preview
Module¶test_roughpages
Module¶