Kawaz

Build status Coverage Requirements Status

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 を起動する必要があります。 このサーバーを起動するためには

  1. データベースの初期化
  2. 翻訳メッセージの初期化

の手順を事前に行う必要があるので、下記のようにこれらの初期化を行なってください。

$ 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

開発用サーバーを実行する際は下記の手順を踏んでください

  1. src/kawaz/local_settings.py を作成して下記の項目に関して設定を行う
    • 管理者のメールアドレス
    • キャッシュ関係の設定
    • データベースの設定
    • メール(送信用)の設定
    • SECRET_KEY の設定
    • Google Calendar ID の設定
    • その他(加筆求む)
  2. データが存在していない場合は python manage.py init_database にてデータベースの初期化を行う。 データが存在している場合は全データのロストにつながるため実行禁止
  3. python manage.py compilemessages にて翻訳メッセージのコンパイルを行う。 この作業は翻訳メッセージに変更が合った場合に毎度行う必要がある
  4. python manage.py collectstatic にて静的ファイルを public/static 以下に集める。 この作業は静的ファイルに変更が合った場合に毎度行う必要がある
  5. python manage.py compress にて CoffeeScript/JavaScript/CSS/Less の圧縮を行う。 この作業は上記ファイルに変更が合った場合に毎度行う必要がある

ドキュメントファイルを更新する

全てのドキュメントは docs フォルダ内に reStructuredText で書かれ Sphinx によりドキュメント化が行われている。 このドキュメントには

  1. 上記のような手順書
  2. ディレクトリ構成の説明や思想説明
  3. 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

kawaz Package

local_settings.sample Module

pre_settings Module

settings Module

kawaz.settings.show_debug_toolbar(request)[source]

urls Module

wsgi Module

Subpackages

api Package

filters Module
class kawaz.api.filters.KawazObjectPermissionFilterBackend[source]

Bases: rest_framework.filters.BaseFilterBackend

A filter backend that limits results to those where the requesting user has read object level permissions.

filter_queryset(request, queryset, view)[source]
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.

get_queryset()[source]
get_queryset_for_read()[source]

Return a queryset for reading.

If the object manager have published method, this execute the method with self.request.user, otherwise it simply return all.

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.

get_queryset()[source]
get_queryset_for_write()[source]

Return a queryset for writing.

If the object manager have related method, this execute the method with self.request.user, otherwise it simply return all.

class kawaz.api.mixins.CreateModelMixin[source]

Bases: rest_framework.mixins.CreateModelMixin

Create model instance and automatically save author

get_extra_fields()[source]
perform_create(serializer)[source]
class kawaz.api.mixins.ListModelMixin[source]

Bases: object

List a queryset.

list(request, *args, **kwargs)[source]
class kawaz.api.mixins.RetrieveModelMixin[source]

Bases: object

Retrieve a model instance.

retrieve(request, *args, **kwargs)[source]
class kawaz.api.mixins.UpdateModelMixin[source]

Bases: object

Update a model instance.

partial_update(request, *args, **kwargs)[source]
perform_update(serializer)[source]
update(request, *args, **kwargs)[source]
class kawaz.api.mixins.DestroyModelMixin[source]

Bases: object

Destroy a model instance.

destroy(request, *args, **kwargs)[source]
perform_destroy(instance)[source]
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
class kawaz.apps.announcements.activity.AnnouncementActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
notifiers = ('twitter_kawaz_info', 'twitter_kawaz_official')
prepare_context(activity, context, typename=None)[source]
admin Module
class kawaz.apps.announcements.admin.AnnouncementAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

media
search_fields = ('title', 'body', 'author__username', 'author__nickname')
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

Announcement.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Announcement.author_id

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_absolute_url()[source]
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 a ForwardManyToOneDescriptor 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.

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
class kawaz.apps.announcements.perms.AnnouncementPermissionLogic[source]

Bases: permission.logics.base.PermissionLogic

Announcementの権限クラス

スタッフユーザーはあらゆる権限を持ち、それ以外は記事の状態とメンバーか否か により閲覧権限が変わる

has_perm(user_obj, perm, obj=None)[source]
urls Module
views Module
Subpackages
migrations Package
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>)]>]
templatetags Package
announcements_tags Module
kawaz.apps.announcements.templatetags.announcements_tags.get_announcements(context, lookup='published')[source]

任意の<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 %}

kawaz.apps.announcements.templatetags.announcements_tags.get_recent_announcements(context, lookup='published')[source]

get_announcementsで得られるQSのうち、作成日が1週間以内の物のみに絞り込む

tests Package
factories Module
test_activity Module
test_models Module
test_perms Module
test_templatetags Module
test_views Module
attachments Package
admin Module
class kawaz.apps.attachments.admin.MaterialAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

author_nickname(obj)[source]
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

Material.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Material.author_id

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_absolute_url()[source]
Material.get_attachment_tag()[source]
Material.get_next_by_created_at(*moreargs, **morekwargs)
Material.get_previous_by_created_at(*moreargs, **morekwargs)
Material.get_thumbnail_display()[source]
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.save(*args, **kwargs)[source]
Material.slug

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

urls Module
views Module
class kawaz.apps.attachments.views.MaterialDetailView(**kwargs)[source]

Bases: django.views.generic.detail.BaseDetailView

get(request, *args, **kwargs)[source]
model

alias of Material

slug_field = 'slug'
Subpackages
api Package
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

class Meta[source]

Bases: object

fields = ('content_file', 'author', 'slug', 'ip_address', 'tag')
model

alias of Material

MaterialSerializer.create(validated_data)[source]
views Module
class kawaz.apps.attachments.api.views.MaterialViewSet(**kwargs)[source]

Bases: kawaz.api.mixins.CreateModelMixin, kawaz.api.views.KawazGenericViewSet

author_field_name = 'author'
get_extra_fields()[source]
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
migrations Package
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
templatetags Package
attachments Module
kawaz.apps.attachments.templatetags.attachments.parse_attachments(value)[source]

{attachments:47c833254e45532d850cc40a0b8ec8b055b27c71}的なタグをparseします

Usage
{{ <value>|parse_attachments }}
tests Package
tests Package
factories Module
test_api Module
test_models Module
test_perms Module
test_templatetags Module
test_views Module
utils Package
utils Package
thumbnails Module
kawaz.apps.attachments.utils.thumbnails.get_thumbnail_html(material)[source]

渡したmaterialのファイルタイプに応じてサムネイル用のHTMLを返します

Param
Material material
blogs Package
activity Module
class kawaz.apps.blogs.activity.EntryActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
prepare_context(activity, context, typename=None)[source]
admin Module
class kawaz.apps.blogs.admin.EntryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

author_nickname(obj)[source]
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')
star_count(obj)[source]
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

Category.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Category.author_id

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 a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Category.get_absolute_url()[source]
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>
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

Entry.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Entry.author_id

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 a ForwardManyToOneDescriptor 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.clean()[source]
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_absolute_url()[source]
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.save(*args, **kwargs)[source]
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.

class kawaz.apps.blogs.models.EntryManager[source]

Bases: django.db.models.manager.Manager, kawaz.core.publishments.models.PublishmentManagerMixin

urls Module
views Module
Subpackages
api Package
api Package
serializers Module
class kawaz.apps.blogs.api.serializers.CategorySerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

ブログカテゴリ用のAPIシリアライザ

class Meta[source]

Bases: object

fields = ('id', 'author', 'label')
model

alias of Category

CategorySerializer.create(validated_data)[source]
views Module
class kawaz.apps.blogs.api.views.CategoryViewSet(**kwargs)[source]

Bases: kawaz.api.mixins.CreateModelMixin, kawaz.api.views.KawazGenericViewSet

ブログカテゴリを作成するためのAPIエンドポイント

author_field_name = 'author'
model

alias of Category

queryset
serializer_class

alias of CategorySerializer

suffix = None
migrations Package
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
class kawaz.apps.blogs.migrations.0002_auto_20141123_0104.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

dependencies = [('blogs', '0001_initial')]
operations = [<RenameField new_name='published_at', old_name='publish_at', model_name='entry'>]
templatetags Package
blogs_tags Module
kawaz.apps.blogs.templatetags.blogs_tags.get_categories(author=None)[source]

ブログ記事カテゴリ一覧を取り出します <user>を渡した場合は、そのユーザーが持っているカテゴリのみを取り出します

Syntax:
{% get_categories as categories %} {% get_categories <user> as categories %}
kawaz.apps.blogs.templatetags.blogs_tags.get_entries(context, lookup='published')[source]

任意の<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 %}

kawaz.apps.blogs.templatetags.blogs_tags.get_published_entries_of(context, author)[source]

あるユーザーの書いたpublishedなエントリーを返します

Syntax:
{% get_published_entries_of <user> as <variable> %}
tests Package
tests Package
factories Module
test_activity Module
test_api Module
test_forms Module
test_models Module
test_perms Module
test_templatetags Module
Subpackages
views Package
views Package
test_crud Module
test_date Module
events Package
activity Module
class kawaz.apps.events.activity.EventActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
m2m_fields = ('attendees',)
prepare_context(activity, context, typename=None)[source]
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
number_of_attendees(obj)[source]
organizer_name(obj)[source]
save_model(request, obj, form, change)[source]
search_fields = ('title', 'body', 'organizer__username', 'organizer__nickname', 'category__label', 'place')
class kawaz.apps.events.admin.EventCategoryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('label', 'number_of_events')
media
number_of_events(obj)[source]
filters Module
forms Module
gcal Module

Google Calendar 連携用 Backend kawaz.core.google.calendar に依存し settings.GOOGLE_CALENDAR_BACKEND で指定 されている

class kawaz.apps.events.gcal.KawazGoogleCalendarBackend[source]

Bases: google_calendar.backend.Backend

is_valid(event, raise_exception=False)[source]

Kawaz3のEventモデルインスタンスが、Google Calendar API Version3の Bodyパラメーターと適合しているかをチェックします

translate(event)[source]

Kawaz3のEventモデルをGoogle Calendar API Version3のBodyパラメーターに変換します

Params:
event [Event] Eventモデルインスタンス
Returns:[dict] パラメーター
kawaz.apps.events.gcal.get_base_url()[source]
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 a ReverseManyToOneDescriptor 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.

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.attend(user)[source]

指定されたユーザーをこのイベントに参加させる

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 and topping.pizzas are ManyToManyDescriptor 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 a ForwardManyToOneDescriptor 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. 開始時間が指定されているが終了時間が指定されていないイベントは

作成できない(一生イベントに参加とかは物理的に不可能)
  1. 参加者制限が0人のイベントは作成できない
  2. 参加締め切りは未来でなければいけない
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_absolute_url()[source]
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 a ReverseOneToOneDescriptor 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.is_active()[source]

イベントが終了していないか否か

Event.is_attendee(user)[source]

参加者か否か

Event.is_over_deadline()[source]

参加締め切りを超えているか否か

Event.is_over_restriction()[source]

人数制限を超えているか否か

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 a ForwardManyToOneDescriptor 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.quit(user)[source]

指定されたユーザーをこのイベントから退会させる

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.

class kawaz.apps.events.models.EventManager[source]

Bases: django.db.models.manager.Manager, kawaz.core.publishments.models.PublishmentManagerMixin

active(user)[source]

指定されたユーザーに公開されたイベントの中で、まだ終わっていない or イベントの終了時期が指定されていないかつ、作成日から30日日以内のイベントを含むクエリを返す

attendable(user)[source]

指定されたユーザーに公開されたイベントの中で、参加可能なイベントを 含むクエリを返す

author_field_name = 'organizer'
kawaz.apps.events.models.join_organizer(**kwargs)[source]

作成者を自動的に参加させるシグナルレシーバ

perms Module
class kawaz.apps.events.perms.EventPermissionLogic[source]

Bases: permission.logics.base.PermissionLogic

Permission logic of Event model which for

  • events.add_event
  • events.change_event
  • events.delete_event
  • events.attend_event
  • events.quit_event
has_perm(user_obj, perm, obj=None)[source]

Check if user have a specified event permissions (of obj)

urls Module
views Module
Subpackages
migrations Package
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>)]>]
templatetags Package
events_tags Module
class kawaz.apps.events.templatetags.events_tags.Archive(date, object_list, count, url)[source]

Bases: object

kawaz.apps.events.templatetags.events_tags.get_events(context, lookup='published')[source]

任意の<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 %}

kawaz.apps.events.templatetags.events_tags.get_monthly_archives(context)[source]

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 %}

tests Package
factories Module
test_activity Module
test_models Module
test_perms Module
test_templatetags Module
test_views Module
utils Module
utils Package
utils Package
ical Module
kawaz.apps.events.utils.ical.generate_ical(object)[source]
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>} の添付展開
Subpackages
extras Package
mention Module
kawaz.apps.kfm.extras.mention.parse_mentions(value)[source]

指定された文字列から @username という部分を探しリンク文字列に変換

nicovideo Module
kawaz.apps.kfm.extras.nicovideo.parse_nicovideo_urls(value)[source]

指定された文字列に含まれる ニコニコ動画 URL をプレイヤーに変換 ただしURLがシングル・ダブルクオーテーションマークで囲まれていた場合は 変換を行わない

変換にはテンプレートシステムが使用され kfm/parsers/nicovideo.html なおコンテキストとして下記の値がテンプレートに渡される

  • video_id: ニコニコ動画 ID
strikethrough Module
kawaz.apps.kfm.extras.strikethrough.parse_strikethroughs(value)[source]

~~で囲まれた部分を<del>展開する

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 に成るように自動指定される
templatetags Package
kfm Module
class kawaz.apps.kfm.templatetags.kfm.KFMNode(nodelist)[source]

Bases: django.template.base.Node

render(context)[source]
kawaz.apps.kfm.templatetags.kfm.do_include_kfm(parser, token)[source]

テンプレートフォルダに存在する Kawaz Flavored Markdown ファイルを読み込み レンダリングするテンプレートタグ

Usage:

{% include_kfm “markdown/about.md” %}
kawaz.apps.kfm.templatetags.kfm.do_kfm(parser, token)[source]

ブロックで囲まれたテキストを Kawaz Flavored Markdown として HTML展開するタグ

Usage:
{% kfm %} Kawaz Flavored Markdown {% endkfm %}
kawaz.apps.kfm.templatetags.kfm.filter_kfm(value)[source]

指定されたテキストを Kawaz Flavored Markdown として HTML 展開するフィルタ

Usage:
{{ object.body | kfm }}
youtube Module
kawaz.apps.kfm.templatetags.youtube.filter_youtube(value, size=None)[source]

指定されたテキスト内に存在するYouTube URLを展開するフィルタ

Usage:
{{ object.body | youtube }} {{ object.body | youtube:’responsive’ }} # レスポンシブデザイン {{ object.body | youtube:‘1600’ }} # 横幅指定(16:9) {{ object.body | youtube:‘1600,900’ }} # 縦横幅指定
tests Package
test_parse Module
Subpackages
test_extras Package
test_mention Module
test_nicovideo Module
class kawaz.apps.kfm.tests.test_extras.test_nicovideo.ParseNicoVideoURLsTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_parse_nicovideo_urls()[source]

ニコニコ動画のURLは展開される

test_parse_nicovideo_urls_double_quoated()[source]

ダブルクォートされたニコニコ動画URLは展開されない

test_parse_nicovideo_urls_fenced()[source]

フェンス化されたニコニコ動画URLは展開されない

test_parse_nicovideo_urls_multiple()[source]

複数のニコニコ動画URLも正しく展開される

test_parse_nicovideo_urls_single_quoated()[source]

シングルクォートされたニコニコ動画URLは展開されない

test_strikethrough Module
class kawaz.apps.kfm.tests.test_extras.test_strikethrough.ParseStrikethroughsTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_parse_strikethroughs()[source]

打ち消し構文が正しく変換される

test_parse_strikethroughs_double_quoted()[source]

ダブルクォートされた打ち消し構文は変換されない

test_parse_strikethroughs_fenced()[source]

フェンス化された打ち消し構文は変換されない

test_parse_strikethroughs_multiple()[source]

複数の打ち消し構文が正しく変換される

test_parse_strikethroughs_single_quoted()[source]

シングルクォートされた打ち消し構文は変換されない

test_youtube Module
class kawaz.apps.kfm.tests.test_extras.test_youtube.ParseYouTubeURLsTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_parse_shorten_youtube_urls()[source]

短縮されたYouTubeのURLは展開される

test_parse_youtube_urls()[source]

YouTubeのURLは展開される

test_parse_youtube_urls_double_quoated()[source]

ダブルクォートされたYouTubeURLは展開されない

test_parse_youtube_urls_fenced()[source]

フェンス化されたYouTubeURLは展開されない

test_parse_youtube_urls_height()[source]

YouTubeのURLは展開される (Height指定)

test_parse_youtube_urls_multiple()[source]

複数のYouTubeURLも正しく展開される

test_parse_youtube_urls_responsive()[source]

YouTubeのURLはレスポンシブ展開される

test_parse_youtube_urls_single_quoated()[source]

シングルクォートされたYouTubeURLは展開されない

test_parse_youtube_urls_width()[source]

YouTubeのURLは展開される (Width指定)

test_templatetags Package
test_youtube Module
class kawaz.apps.kfm.tests.test_templatetags.test_youtube.YouTubeTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_youtube(parse_youtube_urls)[source]

フィルタによりYouTube展開コードが呼び出される

test_youtube_responsive(parse_youtube_urls)[source]

フィルタによりYouTube展開コードが呼び出される (responsive)

test_youtube_width(parse_youtube_urls)[source]

フィルタによりYouTube展開コードが呼び出される (width)

test_youtube_width_and_height(parse_youtube_urls)[source]

フィルタによりYouTube展開コードが呼び出される (width/height)

products Package
activity Module
class kawaz.apps.products.activity.ProductActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
notifiers = ('twitter_kawaz_info', 'twitter_kawaz_official')
prepare_context(activity, context, typename=None)[source]
class kawaz.apps.products.activity.ReleaseActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
class kawaz.apps.products.activity.ScreenshotActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
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

last_modifier_nickname(obj)[source]
list_display = ('title', 'last_modifier_nickname', 'get_display_mode_display', 'published_at', 'created_at', 'updated_at')
media
class kawaz.apps.products.admin.ScreenshotAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

media
class kawaz.apps.products.admin.URLReleaseAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('label', 'platform', 'version', 'url', 'pageview')
media
readonly_fields = ('pageview',)
filters Module
forms Module
models Module
class kawaz.apps.products.models.AbstractRelease(*args, **kwargs)[source]

Bases: django.db.models.base.Model

リリース形態のアブストラクトモデル

class Meta[source]

Bases: object

abstract = False
ordering = ('platform__pk', 'product__pk')
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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor instances.

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.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_absolute_url()[source]
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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor instance.

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 a ReverseManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 a ReverseManyToOneDescriptor 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.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 and topping.pizzas are ManyToManyDescriptor 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 and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Product.clean()[source]
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_absolute_url()[source]
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.join(user)[source]

指定されたユーザーを管理者にする

ユーザーに参加権限がない場合は PermissionDenied を投げる

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 a ForwardManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 a ForwardOneToOneDescriptor 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.quit(user)[source]

指定されたユーザーを管理者から外す

ユーザーに脱退権限がない場合は PermissionDenied を投げる

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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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.

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_absolute_url()[source]
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.is_play_now()[source]
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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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.

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
class kawaz.apps.products.perms.ProductPermissionLogic[source]

Bases: permission.logics.base.PermissionLogic

allowed_permissions = ('products.add_product', 'products.change_product', 'products.delete_product', 'products.join_product', 'products.quit_product')
has_perm(user_obj, perm, obj=None)[source]
urls Module
views Module
Subpackages
migrations Package
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'>]
templatetags Package
products_tags Module
kawaz.apps.products.templatetags.products_tags.get_categories()[source]

全てのCategory一覧を取り出します。

Syntax:
{% get_categories as <variable> %}
kawaz.apps.products.templatetags.products_tags.get_platforms()[source]

全てのPlatform一覧を取り出します。

Syntax:
{% get_platforms as <variable> %}
kawaz.apps.products.templatetags.products_tags.get_products(lookup='mixed')[source]

任意の<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 %}

kawaz.apps.products.templatetags.products_tags.get_products_by_categories(categories)[source]

任意のカテゴリに所属するProductを返却します

categories:
CategoryのQuerySet

Example

{% load products_tag %} {% get_product_by_category <categories> as <variable> %}

kawaz.apps.products.templatetags.products_tags.get_relative(product)[source]

任意のプロダクトの関連プロダクトを取り出します。 渡されたプロダクトと同じカテゴリに所属している物全てから、自身を抜いた QuerySetを返します

Syntax:
{% get_relative <product> as <variable> %}
kawaz.apps.products.templatetags.products_tags.render_twitter_card(context, product)[source]

プロダクト用のTwitterカードを埋め込むテンプレートタグ 通常はhead内に書く

Syntax:
{% render_twitter_card product %}
Template:

products/components/twitter_card.htmlが使用される。 このテンプレートは以下のコンテキストを受け取れる

product: 描画対象のProductオブジェクト apps: Productの所属するURLReleaseのうち、iOSアプリ、Androidアプリのもののみが含まれたリスト

このような仕様になっているのは、appsがある場合のみTwitterカードのApp Cardを利用することが想定されているためである

tests Package
tests Package
factories Module
test_activity Module
test_models Module
test_perms Module
test_templatetags Module
test_views Module
projects Package
projects Package
activity Module
class kawaz.apps.projects.activity.ProjectActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
m2m_fields = ('members',)
prepare_context(activity, context, typename=None)[source]
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

static administrator_nickname(obj)[source]
static is_legacy(obj)[source]
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 a ReverseManyToOneDescriptor 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.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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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_absolute_url()[source]
Project.get_default_icon(size)[source]

デフォルトアイコンを返します

Project.get_huge_icon()
Project.get_icon(size)[source]

渡したサイズのアイコンURLを返します 未設定の場合や、見つからない場合はデフォルトアイコンを返します

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.is_member(user)[source]

指定されたユーザーがこのプロジェクトに参加しているか否か

Project.join(user)[source]

指定されたユーザーを参加させる

ユーザーに参加権限がない場合は PermissionDenied を投げる

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 a ForwardManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 a ReverseOneToOneDescriptor 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.quit(user)[source]

指定されたユーザーを退会させる

ユーザーに退会権限がない場合は PermissionDenied を投げる

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.

class kawaz.apps.projects.models.ProjectManager[source]

Bases: django.db.models.manager.Manager, kawaz.core.publishments.models.PublishmentManagerMixin

active(user)[source]

指定されたユーザーが閲覧可能なプロジェクトのうち、活動中のもののみ を含むクエリを返す

archived(user)[source]

指定されたユーザーがー閲覧可能なプロジェクトのうち アーカイブ化されたプロジェクトのクエリを返す 以下のようなプロジェクトがアーカイブである

状態がpaused, eternaled, doneのいずれかである 状態がplanningかつ、created_atから90日以上経過している

author_field_name = 'administrator'
recently_planned(user)[source]

指定されたユーザーがー閲覧可能なプロジェクトのうち 最近企画されたプロジェクトのクエリを返す 状態がplanningかつ、created_atが90日未満である

kawaz.apps.projects.models.join_administrator(**kwargs)[source]

プロジェクト作成時に自動的に管理者をプロジェクトに参加させるシグナル処理

perms Module
class kawaz.apps.projects.perms.ProjectPermissionLogic[source]

Bases: permission.logics.base.PermissionLogic

has_perm(user_obj, perm, obj=None)[source]

Check if user have a specified project permissions (of obj)

urls Module
views Module
Subpackages
migrations Package
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>)]>]
templatetags Package
projects_tags Module
kawaz.apps.projects.templatetags.projects_tags.get_projects(context, lookup='published')[source]

任意の<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 %}

kawaz.apps.projects.templatetags.projects_tags.get_published_joined_projects_of(context, user)[source]

userがメンバーに含まれているプロジェクト一覧を返します

Syntax:
{% get_published_joined_projects_of user %}
tests Package
tests Package
factories Module
test_activity Module
test_models Module
test_perms Module
test_templatetags Module
test_views Module
stars Package
admin Module
class kawaz.apps.stars.admin.StarAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

media
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

Star.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Star.author_id

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

Star.content_object

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

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

Star.content_type

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

Star.content_type_id

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

Star.created_at

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

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

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

Star.object_id

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

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

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

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

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

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

Star.tooltip_text

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

Example

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

class kawaz.apps.stars.models.StarManager[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)
cleanup_object(obj)[source]

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

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

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

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

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

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

Bases: django.db.models.query.QuerySet

get_for_object(obj)[source]

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

Parameters:obj (model instance) – 検索対象のモデルインスタンス
published(user_obj)[source]

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

Parameters:user_obj (user instance) – 対象ユーザーインスタンス
Returns:queryset
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
Subpackages
api Package
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

class Meta[source]

Bases: object

fields = ('id', 'content_type', 'object_id', 'author', 'quote', 'html', 'tooltip')
model

alias of Star

StarSerializer.create(validated_data)[source]
StarSerializer.get_html(obj)[source]
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

author_field_name = 'author'
filter_fields = ('content_type', 'object_id')
model

alias of Star

queryset
serializer_class

alias of StarSerializer

suffix = None
migrations Package
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>)]>]
0002_test Module
class kawaz.apps.stars.migrations.0002_test.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

dependencies = [('personas', '__first__'), ('stars', '0001_initial')]
operations = []
templatetags Package
stars_tags Module
kawaz.apps.stars.templatetags.stars_tags.get_star_endpoint(context, object)[source]

任意の<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>

kawaz.apps.stars.templatetags.stars_tags.get_stars(object)[source]

任意の<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 %}

tests Package
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

StarTestArticle.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

StarTestArticle.author_id

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.

test_api Module
test_models Module
test_perms Module
test_templatetags Module

core Package

Subpackages
activities Package
urls Module
views Module
class kawaz.core.activities.views.ActivityListView(**kwargs)[source]

Bases: django.views.generic.list.ListView

get_queryset()[source]
model

alias of Activity

paginate_by = 10
Subpackages
hatenablog Package
hatenablog Package
activity Module
class kawaz.core.activities.hatenablog.activity.HatenablogEntryActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
notifiers = ('twitter_kawaz_info', 'twitter_kawaz_official')
admin Module
class kawaz.core.activities.hatenablog.admin.HatenablogEntryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

media
conf Module
class kawaz.core.activities.hatenablog.conf.ActivitiesHatenablogAppConf(**kwargs)[source]

Bases: appconf.base.AppConf

FEED_URL = 'http://kawazinfo.hateblo.jp/rss'
class Meta[source]

Bases: object

prefix = 'activities_hatenablog'
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_absolute_url()[source]
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.

scraper Module
class kawaz.core.activities.hatenablog.scraper.HatenablogFeedScraper(url=None, verbose=False)[source]

Bases: object

fetch()[source]
Subpackages
management Package
Subpackages
commands Package
fetch_hatenablog_entries Module
class kawaz.core.activities.hatenablog.management.commands.fetch_hatenablog_entries.Command(stdout=None, stderr=None, no_color=False)[source]

Bases: django.core.management.base.BaseCommand

add_arguments(parser)[source]
handle(*args, **options)[source]
help = 'Command to fetch entries in Hatenablog. It will ignore duplicated entries.'
migrations Package
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>)]>]
templatetags Package
activities_hatenablog_tag Module
kawaz.core.activities.hatenablog.templatetags.activities_hatenablog_tag.get_hatenablog_entries()[source]

Hatenablog 更新情報を指定された <variable> に格納

Syntax:
{% get_hatenablog_entries as <variable> %}

Example

最近更新された Hatenablog の記事を5つ描画

{% get_hatenablog_entries as entries %} {% for entry in entries|slice:”:5” %}

{{ entry }}

{% endfor %}

tests Package
factories Module
test_activity Module
test_models Module
test_scraper Module
class kawaz.core.activities.hatenablog.tests.test_scraper.HatenablogFeedScraperTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_scraper_can_fetch_entries()[source]
test_scraper_does_not_fetch_duplicate()[source]
kawaz.core.activities.hatenablog.tests.test_scraper.get(url, **kwargs)[source]
test_templatetags Module
tests Package
tests Package
factories Module
test_views Module
testcases Module
comments Package
comments Package
kawaz.core.comments.get_form()[source]
kawaz.core.comments.get_model()[source]
activity Module
class kawaz.core.comments.activity.CommentActivityMediator[source]

Bases: activities.mediator.ActivityMediator

alter(instance, activity, **kwargs)[source]
translate_snapshot(snapshot)[source]
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フラグを変更する権限である
Subpackages
tests Package
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

CommentTestArticle.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

CommentTestArticle.author_id

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.

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
Subpackages
tests Package
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.clean()[source]
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>
test_decorators Module
class kawaz.core.db.tests.test_decorators.ValidationOnSaveDecoratorTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_non_validate_on_save()[source]

full_clean method should not be called without validate_on_save decorator

test_validate_on_save()[source]

full_clean method should be called with validate_on_save decorator

test_validate_on_save_disabled()[source]

full_clean method should not be called with VALIDATE_ON_SAVE_DISABLE

files Package
files Package
storages Module
class kawaz.core.files.storages.OverwriteStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None)[source]

Bases: django.core.files.storage.FileSystemStorage

get_available_name(name, max_length=None)[source]
filters Package
filters Package
widgets Module
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です

Ref:
http://django-crispy-forms.readthedocs.org/en/latest/crispy_tag_forms.html#bootstrap3-horizontal-forms
class kawaz.core.forms.helpers.Bootstrap3InlineFormHelper(*args, **kwargs)[source]

Bases: crispy_forms.helper.FormHelper

Bootstrap3のInlineFormを利用するためのHelperです

Ref:
http://django-crispy-forms.readthedocs.org/en/latest/crispy_tag_forms.html#bootstrap3-inline-forms
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

class kawaz.core.forms.mixins.FormHelperMixinBase(*args, **kwargs)[source]

Bases: object

form_tag = True
get_additional_objects()[source]
get_helper()[source]
helper_class = None
widgets Module
Subpackages
templatetags Package
templatetags Package
form_helper Module
kawaz.core.forms.templatetags.form_helper.get_form_helper(type='horizontal')[source]

<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 %}

tests Package
tests Package
test_templatetags Module
class kawaz.core.forms.tests.test_templatetags.GetFormHelperTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_get_helper_horizontal()[source]

get_helper horizontalでBootstrap3HorizontalFormHelperを取り出せる

test_get_helper_horizontal_bare()[source]

get_helper bareでHorizontalBareFormHelperを取り出せる

test_get_helper_inline_bare()[source]

get_helper inline_bareでInlineBareFormHelperを取り出せる

test_get_helper_unknown()[source]

get_helperに存在しないtypeを渡したとき、TemplateSyntaxErrorが返る

management Package
management Package

Kawaz 用 manage.py 拡張モジュール

Subpackages
management Package
Subpackages
commands Package
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

add_arguments(parser)[source]
handle(*args, **options)[source]
help = 'Command to initialize database. It will overwrite the existing data in database thus Run this command WITH CLOSE ATTENTION.'
start_livereload Module
class kawaz.core.management.management.commands.start_livereload.Command(stdout=None, stderr=None, no_color=False)[source]

Bases: django.core.management.base.BaseCommand

handle(*args, **options)[source]
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 returns False.

If an object is specified, it will return True if the user’s role is contained in role_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が返るようにした

has_perm(user_obj, perm, obj=None)[source]
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

has_perm(user_obj, perm, obj=None)[source]
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
Subpackages
activities Package
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`カラム が更新されるだけでも通知されてしまう問題があり対処が面倒なので、ユーザ の更新は一切通知されない仕様にする

alter(instance, activity, **kwargs)[source]
prepare_context(activity, context, typename=None)[source]
class kawaz.core.personas.activities.persona.PersonaActivityMediatorBase[source]

Bases: activities.mediator.ActivityMediator

serialize_snapshot(snapshot)[source]
profile Module
class kawaz.core.personas.activities.profile.AccountActivityMediator[source]

Bases: kawaz.core.personas.activities.persona.PersonaActivityMediatorBase

alter(instance, activity, **kwargs)[source]
class kawaz.core.personas.activities.profile.ProfileActivityMediator[source]

Bases: kawaz.core.personas.activities.persona.PersonaActivityMediatorBase

alter(instance, activity, **kwargs)[source]
admin Package
admin Package
persona Module
profile Module
api Package
api Package
serializers Module
class kawaz.core.personas.api.serializers.PersonaSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'nickname', 'quotes', 'small_avatar', 'middle_avatar', 'large_avatar', 'huge_avatar', 'gender', 'role')
model

alias of Persona

forms Package
forms Package
persona Module
profile Module
migrations 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'>]
0002_test Module
class kawaz.core.personas.migrations.0002_test.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

dependencies = [('personas', '__first__'), ('personas', '0001_initial')]
operations = []
models Package
models Package
persona Module
class kawaz.core.personas.models.persona.ActivePersonaManager[source]

Bases: kawaz.core.personas.models.persona.PersonaManager

アクティブユーザーのみを取り出すManager

get_queryset()[source]
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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Persona.clean_fields(exclude=None, **kwargs)[source]
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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 a ReverseManyToOneDescriptor 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_absolute_url()[source]
Persona.get_avatar(size)[source]

渡したサイズのアバターURLを返します 未設定の場合や、見つからない場合はデフォルトアバターを返します

Persona.get_default_avatar(size)[source]

デフォルトアバターを返します

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 and topping.pizzas are ManyToManyDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 and topping.pizzas are ManyToManyDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseOneToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

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_staffis_superuser を DBレベルで廃止しているため、このカスタムが必要

PersonaManagerでは`role`によりユーザーとスーパーユーザを区別しているため create_superuser`で作成されたユーザーは`role`が‘adam’になり、その他の 場合は‘wille’`となる。

create_superuser(username, email, password, **extra_fields)[source]
create_user(username, email=None, password=None, **extra_fields)[source]
retired()[source]
kawaz.core.personas.models.persona.invite_to_slack(user, profile, request, **kwargs)[source]
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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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.

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 a ReverseManyToOneDescriptor 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_absolute_url()[source]
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 and topping.pizzas are ManyToManyDescriptor 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 a ForwardOneToOneDescriptor 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.

class kawaz.core.personas.models.profile.ProfileManager[source]

Bases: django.db.models.manager.Manager

active()[source]

Returns the QuerySet which contains all active profiles

published(user)[source]

Return the QuerySet which contains all active viewable profiles by passed user.

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 a ReverseManyToOneDescriptor 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.get_absolute_url()[source]
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.

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 and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

templatetags Package
templatetags Package
profiles_tags Module
kawaz.core.personas.templatetags.profiles_tags.get_my_profile(context)[source]

現在のログインユーザーのプロフィールを取り出すテンプレートタグ セキュリティの観点から、任意のユーザーのプロフィール情報を取り出すことはできず、 必ずログインユーザーの物が返される もし、ログインユーザーがプロフィールを持っていなかったり(wille)、 渡されたユーザーが非ログインユーザーだった場合は`None`を返す

Example

{% load profiles_tags %} {% get_my_profile as profile %} {{ profile.remarks }}

kawaz.core.personas.templatetags.profiles_tags.get_profile(context, user)[source]

特定のユーザーのプロフィールを取り出すテンプレートタグ セッションに含まれる現在のログインユーザーを取得し、 対象プロフィールの閲覧権限がある場合のみ取得できる パーミッションがない場合は`None`を返す

Example

{% load profiles_tags %} {% get_profile user as profile %} {{ profile.remarks }}

tests Package
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

PersonaTestArticle.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

PersonaTestArticle.author_id

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.

test_activity Module
test_mails Module
class kawaz.core.personas.tests.test_mails.PersonaPasswordResetMailTemplateTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_email_parse()[source]

registration/password_reset_email.htmlを正しくparseできる

test_email_subject_parse()[source]

registration/password_reset_email_subject.txtを正しくparseできる

test_templatetags Module
utils Module
Subpackages
factories Package
factories Package
persona Module
profile Module
test_models Package
test_models Package
test_persona Module
test_profile Module
test_perms Package
test_perms Package
test_persona Module
test_profile Module
test_views Package
test_persona Module
test_profile Module
views Package
views Package
persona Module
profile 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.

author_field_name = 'author'
draft(user)[source]

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

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.

related(user)[source]

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

perms Module
class kawaz.core.publishments.perms.PublishmentPermissionLogic(author_field_name='author', pub_state_field_name='pub_state')[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 and author of the instance.

If no object is specified, it always return True.

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

  • ‘public’ | Anyone can see this obj
  • ‘protected’ | Seele, Nerv, Children can see this obj
  • ‘draft’ | Nobody but the obj author can see this obj
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

Subpackages
migrations Package
0001_test Module
class kawaz.core.publishments.migrations.0001_test.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

dependencies = [('personas', '__first__')]
operations = []
tests Package
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

PublishmentTestArticle.author

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

In the example:

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

child.parent is a ForwardManyToOneDescriptor instance.

PublishmentTestArticle.author_id

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.

test_lookups Module
test_perms Module
class kawaz.core.publishments.tests.test_perms.PublishmentPermissionLogicTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_view_permission_with_draft()[source]

Nobody except the author and adam can see the draft model

test_view_permission_with_protected()[source]

Authenticated user except wille can see the protected model

test_view_permission_with_public()[source]

Anyone can see the public model

test_view_permission_without_obj()[source]

Anyone have a potential to see the model

registrations Package
registrations Package
backends Module
class kawaz.core.registrations.backends.KawazRegistrationBackend[source]

Bases: registration.backends.default.DefaultRegistrationBackend

get_registration_form_class()[source]
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 a ForwardOneToOneDescriptor 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.

kawaz.core.registrations.models.setup_for_participation(sender, user, password, is_generated, request, **kwargs)[source]
perms Module
class kawaz.core.registrations.perms.RegistrationProfilePermissionLogic[source]

Bases: permission.logics.base.PermissionLogic

has_perm(user_obj, perm, obj=None)[source]
urls Module
Subpackages
migrations Package
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
tests Package
factories Module
test_emails Module
class kawaz.core.registrations.tests.test_emails.RegistrationMailTemplateTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_acceptance_parse()[source]

registration/acceptance_email.txtを正しくparseできる

test_acceptance_subject_parse()[source]

registration/acceptance_email_subject.txtを正しくparseできる

test_notification_parse()[source]

registration/notification_email.txtを正しくparseできる

test_notification_subject_parse()[source]

registration/notification_email_subject.txtを正しくparseできる

test_registration_parse()[source]

registration/registration_email.txtを正しくparseできる

test_registration_subject_parse()[source]

registration/registration_email_subject.txtを正しくparseできる

test_rejection_parse()[source]

registration/rejection_email.txtを正しくparseできる

test_rejection_subject_parse()[source]

registration/rejection_email_subject.txtを正しくparseできる

test_perms Module
test_signals Module
class kawaz.core.registrations.tests.test_signals.RegistrationActivatedTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_activated_user_should_be_children()[source]

新規会員登録が承認されたユーザーのactivationが行われたとき、 signalを受けて権限をwilleからchildrenに変更する

test_profile_should_be_created_on_activation()[source]

新規会員登録が承認されたとき、profileが生成される

test_views Module
templatetags Package
templatetags Package
Subpackages
templatetags Package
expr Module
class kawaz.core.templatetags.templatetags.expr.ExprNode(expression, variable=None)[source]

Bases: django.template.base.Node

render(context)[source]
kawaz.core.templatetags.templatetags.expr.do_expr(parser, token)[source]

テンプレート内で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
kawaz.core.templatetags.templatetags.strip_newlines.strip_newlines(value, repl='')[source]

指定されたテキストから改行文字を取り除くテンプレートフィルタ

Usage:
{{ object.body | strip_newlines }} {{ object.body | strip_newlines:’ ‘ }} # 半角スペースに置換
utils Module
kawaz.core.templatetags.templatetags.utils.active(context, pattern)[source]

現在の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クラスを付加したい」 という需要に対応できます

kawaz.core.templatetags.templatetags.utils.get_current_site()[source]

現在のSiteオブジェクトを取得します

kawaz.core.templatetags.templatetags.utils.get_week_day(date)[source]

datetimeオブジェクトを受け取り、曜日に応じてCSSクラス名を返します

Param
date [datetime]
Return [string]
土曜日 saturday 日曜日 sunday その他 weekday
Example
{% load utils %} <div class=”{% get_week_day date”>{{ date }}</div>
tests Package
tests Package
test_builtin Module
class kawaz.core.templatetags.tests.test_builtin.CustomBuiltInTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_kfm()[source]

kfmがbuilt in template-filter化されている

test_expr Module
class kawaz.core.templatetags.tests.test_expr.ExprTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_expr_render()[source]

expr タグを利用して計算結果を代入可能

test_strip_newlines Module
class kawaz.core.templatetags.tests.test_strip_newlines.StripNewlinesTemplateFilterTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_strip_newlines()[source]

strip_newlinesフィルタで改行文字の置換が可能

test_utils Module
class kawaz.core.templatetags.tests.test_utils.ActiveTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_active()[source]

activeタグのpatternが現在のURLとマッチしたとき、activeの文字を返す

test_active_contains_get_parameter()[source]

activeタグはGETパラメータの値も含む

test_active_with_not_matched_pattern()[source]

activeタグのpatternが現在のURLとマッチしないとき、空白文字を返す

class kawaz.core.templatetags.tests.test_utils.GetCurrentSiteTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_get_current_site()[source]

get_current_siteで現在のSiteを返す

class kawaz.core.templatetags.tests.test_utils.GetWeekDayTemplateTagTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_saturday()[source]

get_week_dayで土曜だったときにsaturdayを返す

test_sunday()[source]

get_week_dayで日曜だったときにsundayを返す

test_weekday()[source]

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]

Bases: kawaz.core.tests.runner.MediaRootTestSuiteRunner

setup_test_environment()[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/

setup_test_environment()[source]

Create temp directory and update MEDIA_ROOT and default storage.

teardown_test_environment()[source]

Delete temp storage.

Subpackages
testcases Package
testcases Package
permissions Module
views Module
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
kawaz.core.utils.permission.get_full_permission_name(codename, obj)[source]

省略形パーミッションとオブジェクトからパーミッションの完全名を取得

Parameters:
  • codename (str) – 省略形パーミッション(例: ‘add’
  • obj (model instance) – 対象モデルインスタンス
Returns:

パーミッションの完全名(例: ‘auth.add_user’

Return type:

str

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.’
delete(request, *args, **kwargs)[source]
get_success_message()[source]
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で行っている

get_object(queryset=None)[source]

POSTで渡された値を元に仮想オブジェクトを構築し返す

post(request, *args, **kwargs)[source]
Subpackages
tests Package
tests Package
models Module
kawaz.core.views.tests.models.Article

alias of SingleObjectPreviewViewMixinTestArticle

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>
kawaz.core.views.tests.models.alias(name)[source]

Define alias name of the class

test_preview Module
class kawaz.core.views.tests.test_preview.KawazSingleObjectPreviewViewMixinTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_get_object_with_get_queryset()[source]

Modelに存在しないアトリビュートは削除される (get_queryset)

test_get_object_with_model()[source]

Modelに存在しないアトリビュートは削除される (model)

test_get_object_with_queryset()[source]

Modelに存在しないアトリビュートは削除される (queryset)

test_has_get_object_method()[source]

get_objectメソッドを所有する

test_roughpages Module
test_statics Module
class kawaz.core.views.tests.test_statics.ErrorPageTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_render_404()[source]

本番環境でカスタム404ページが描画できる

Indices and tables