Fix a really obscure bug with adding default channels. Had a string substitution that didn't match up and wasn't throwing an exception (for some weird reason).

Also add CommChannelMembershipAdmin.
This commit is contained in:
Greg Taylor 2009-06-04 04:03:16 +00:00
parent d29c6340fc
commit ddfd479ba9
4 changed files with 25 additions and 10 deletions

View file

@ -1,10 +1,14 @@
from django.contrib import admin
from src.channels.models import CommChannel, CommChannelMessage
from src.channels.models import CommChannel, CommChannelMessage, CommChannelMembership
class CommChannelAdmin(admin.ModelAdmin):
list_display = ('name', 'ansi_name', 'owner', 'description', 'is_joined_by_default')
admin.site.register(CommChannel, CommChannelAdmin)
class CommChannelMembershipAdmin(admin.ModelAdmin):
list_display = ('channel', 'listener', 'user_alias', 'is_listening')
admin.site.register(CommChannelMembership, CommChannelMembershipAdmin)
class CommChannelMessageAdmin(admin.ModelAdmin):
list_display = ('channel', 'date_sent', 'message')
admin.site.register(CommChannelMessage, CommChannelMessageAdmin)

View file

@ -119,7 +119,8 @@ def plr_has_channel(session, cname, alias_search=False, return_muted=False):
def plr_set_channel_listening(session, alias, listening):
"""
Enables or disables listening on a particular channel.
Enables or disables listening on a particular channel based on the
user's channel alias.
session: (SessionProtocol) A reference to the player session.
alias: (str) The channel alias.

View file

@ -366,8 +366,12 @@ class ObjectManager(models.Manager):
# Activate the player's session and set them loose.
command.session.login(user)
print 'Registration: %s' % (command.session, user_object.get_name())
logger.log_infomsg('Registration: %s' % user_object.get_name())
user_object.emit_to("Welcome to %s, %s.\n\r" % (
ConfigValue.objects.get_configvalue('site_name'),
user_object.get_name(show_dbref=False)))
# Add the user to all of the CommChannel objects that are flagged
# is_joined_by_default.
command.session.add_default_channels()

View file

@ -8,11 +8,11 @@ from datetime import datetime
from twisted.conch.telnet import StatefulTelnetProtocol
from django.contrib.auth.models import User
from django.conf import settings
from src.objects.models import Object
from src.channels.models import CommChannel
from src.config.models import ConnectScreen, ConfigValue
from util import functions_general
import src.comsys
from src.objects.models import Object
from src.channels.models import CommChannel, CommChannelMembership
from src.config.models import ConnectScreen, ConfigValue
from src import comsys
import cmdhandler
import logger
import session_mgr
@ -177,7 +177,7 @@ class SessionProtocol(StatefulTelnetProtocol):
self.cemit_info('Logged in: %s' % self)
# Update their account's last login time.
user.last_login = datetime.now()
user.last_login = datetime.now()
user.save()
# In case the account and the object get out of sync, fix it.
@ -199,8 +199,14 @@ class SessionProtocol(StatefulTelnetProtocol):
"""
# Add the default channels.
for chan in CommChannel.objects.filter(is_joined_by_default=True):
logger.log_infomsg("ADDING BY DEFAULT %s" % chan)
chan_alias = chan.get_default_chan_alias()
src.comsys.plr_set_channel(self, chan_alias, chan.name, True)
membership = CommChannelMembership(channel=chan,
listener=self.get_pobject(),
user_alias=chan_alias)
membership.save()
comsys.plr_set_channel_listening(self, chan_alias, True)
def __str__(self):
"""
@ -218,5 +224,5 @@ class SessionProtocol(StatefulTelnetProtocol):
Channel emits info to the appropriate info channel. By default, this
is MUDConnections.
"""
src.comsys.send_cmessage(settings.COMMCHAN_MUD_CONNECTIONS,
comsys.send_cmessage(settings.COMMCHAN_MUD_CONNECTIONS,
'Session: %s' % message)