fix case sensitive irc channel uniqueness check

This commit is contained in:
Thomas Steen Rasmussen 2019-01-19 14:22:30 +01:00
parent 1b9566ee02
commit b4698f3fdc

View file

@ -147,15 +147,15 @@ class Team(CampRelatedModel):
if self.private_irc_channel_name == settings.IRCBOT_PUBLIC_CHANNEL or self.private_irc_channel_name == settings.IRCBOT_VOLUNTEER_CHANNEL:
raise ValidationError('The private IRC channel name is reserved')
# make sure public_irc_channel_name is unique
# make sure public_irc_channel_name is not in use as public or private irc channel for another team, case insensitive
if self.public_irc_channel_name:
if Team.objects.filter(private_irc_channel_name__iexact=self.public_irc_channel_name).exclude(pk=self.pk).exists():
raise ValidationError('The public IRC channel name is already in use!')
if Team.objects.filter(private_irc_channel_name__iexact=self.public_irc_channel_name).exclude(pk=self.pk).exists() or Team.objects.filter(public_irc_channel_name__iexact=self.public_irc_channel_name).exclude(pk=self.pk).exists():
raise ValidationError('The public IRC channel name is already in use on another team!')
# make sure private_irc_channel_name is unique
# make sure private_irc_channel_name is not in use as public or private irc channel for another team, case insensitive
if self.private_irc_channel_name:
if Team.objects.filter(public_irc_channel_name__iexact=self.private_irc_channel_name).exclude(pk=self.pk).exists():
raise ValidationError('The private IRC channel name is already in use!')
if Team.objects.filter(private_irc_channel_name__iexact=self.private_irc_channel_name).exclude(pk=self.pk).exists() or Team.objects.filter(public_irc_channel_name__iexact=self.private_irc_channel_name).exclude(pk=self.pk).exists():
raise ValidationError('The private IRC channel name is already in use on another team!')
@property
def memberships(self):