ircbot: force lowercase IrcChannel channel name
This commit is contained in:
parent
d9c39d3db9
commit
f513b241d2
20
dr_botzo/ircbot/migrations/0013_auto_20150917_2255.py
Normal file
20
dr_botzo/ircbot/migrations/0013_auto_20150917_2255.py
Normal 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),
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user