Converted the comm system folder to use Google style doc strings, as per #709.

This commit is contained in:
Griatch 2015-05-16 11:03:17 +02:00
parent e84db3df54
commit e37079aa5b
5 changed files with 512 additions and 201 deletions

View file

@ -1,7 +1,7 @@
#
# This sets up how models are displayed
# in the web admin interface.
#
"""
This defines how Comm models are displayed in the web admin interface.
"""
from django.contrib import admin
from evennia.comms.models import ChannelDB
@ -9,14 +9,26 @@ from evennia.typeclasses.admin import AttributeInline, TagInline
class ChannelAttributeInline(AttributeInline):
"""
Inline display of Channel Attribute - experimental
"""
model = ChannelDB.db_attributes.through
class ChannelTagInline(TagInline):
"""
Inline display of Channel Tags - experimental
"""
model = ChannelDB.db_tags.through
class MsgAdmin(admin.ModelAdmin):
"""
Defines display for Msg objects
"""
list_display = ('id', 'db_date_sent', 'db_sender', 'db_receivers',
'db_channels', 'db_message', 'db_lock_storage')
list_display_links = ("id",)
@ -30,6 +42,10 @@ class MsgAdmin(admin.ModelAdmin):
class ChannelAdmin(admin.ModelAdmin):
"""
Defines display for Channel objects
"""
inlines = [ChannelTagInline, ChannelAttributeInline]
list_display = ('id', 'db_key', 'db_lock_storage', "subscriptions")
list_display_links = ("id", 'db_key')
@ -43,7 +59,13 @@ class ChannelAdmin(admin.ModelAdmin):
)
def subscriptions(self, obj):
"Helper method to get subs from a channel"
"""
Helper method to get subs from a channel.
Args:
obj (Channel): The channel to get subs from.
"""
return ", ".join([str(sub) for sub in obj.db_subscriptions.all()])
admin.site.register(ChannelDB, ChannelAdmin)