ircbot: force lowercase IrcChannel channel name

This commit is contained in:
Brian S. Stephan 2015-09-17 22:55:25 -05:00
parent d9c39d3db9
commit f513b241d2
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import ircbot.models
class Migration(migrations.Migration):
dependencies = [
('ircbot', '0012_ircchannel_markov_learn_from_channel'),
]
operations = [
migrations.AlterField(
model_name='ircchannel',
name='name',
field=ircbot.models.LowerCaseCharField(unique=True, max_length=200),
),
]

View File

@ -13,6 +13,14 @@ from django.utils import timezone
log = logging.getLogger('ircbot.models')
class LowerCaseCharField(models.CharField):
def get_prep_value(self, value):
value = super(LowerCaseCharField, self).get_prep_value(value)
if value is not None:
value = value.lower()
return value
class Alias(models.Model):
"""Allow for aliasing of arbitrary regexes to normal supported commands."""
@ -58,7 +66,7 @@ class IrcChannel(models.Model):
"""Track channel settings."""
name = models.CharField(max_length=200, unique=True)
name = LowerCaseCharField(max_length=200, unique=True)
autojoin = models.BooleanField(default=False)
topic_msg = models.TextField(default='', blank=True)