Fixed bug that allowed addcom to set the same alias to two different channels.

/Griatch
This commit is contained in:
Griatch 2009-09-28 17:08:18 +00:00
parent 35676b7660
commit 6d45c98b8e

View file

@ -39,11 +39,22 @@ def cmd_addcom(command):
else:
chan_name = command_argument.strip()
chan_alias = chan_name
membership = source_object.channel_membership_set.filter(channel__name__iexact=chan_name)
try:
chan = CommChannel.objects.get(name__iexact=chan_name)
s = ""
s = ""
#if we happened to have this alias already defined on another channel, make
#sure to tell us.
aliasmatch = [cmatch.channel.name for cmatch in
source_object.channel_membership_set.filter(user_alias=chan_alias)
if cmatch.channel.name != chan_name]
if aliasmatch:
s = "The alias '%s' is already in use (for channel '%s')." % (chan_alias, aliasmatch[0])
source_object.emit_to(s)
return
if membership:
#we are already members of this channel. Set a different alias.
# Note: To this without requiring a the user to logout then login again,