ircbot: tie bot users to django auth user, part 2
rename BotAdmin to BotUser other stuff will check whether or not they're an "admin", which will actually be standard django permissions
This commit is contained in:
parent
123acbbd8d
commit
df17e68456
@ -10,14 +10,14 @@ from django.contrib import admin
|
||||
from django.shortcuts import render
|
||||
|
||||
from ircbot.forms import PrivmsgForm
|
||||
from ircbot.models import Alias, BotAdmin, IrcChannel, IrcPlugin
|
||||
from ircbot.models import Alias, BotUser, IrcChannel, IrcPlugin
|
||||
|
||||
|
||||
log = logging.getLogger('ircbot.admin')
|
||||
|
||||
|
||||
admin.site.register(Alias)
|
||||
admin.site.register(BotAdmin)
|
||||
admin.site.register(BotUser)
|
||||
admin.site.register(IrcChannel)
|
||||
admin.site.register(IrcPlugin)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import logging
|
||||
|
||||
import irc.client
|
||||
|
||||
from ircbot.models import BotAdmin
|
||||
from ircbot.models import BotUser
|
||||
|
||||
|
||||
log = logging.getLogger('ircbot.lib')
|
||||
@ -48,9 +48,9 @@ def is_admin(source):
|
||||
"""Check if the provided event source is a bot admin."""
|
||||
|
||||
try:
|
||||
bot_user = BotAdmin.objects.get(nickmask=source)
|
||||
bot_user = BotUser.objects.get(nickmask=source)
|
||||
log.debug("found bot user {0:s}".format(bot_user))
|
||||
except BotAdmin.DoesNotExist:
|
||||
except BotUser.DoesNotExist:
|
||||
log.debug("could not find bot user for {0:s}".format(source))
|
||||
return False
|
||||
|
||||
|
18
dr_botzo/ircbot/migrations/0010_auto_20150620_0930.py
Normal file
18
dr_botzo/ircbot/migrations/0010_auto_20150620_0930.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ircbot', '0009_botadmin_user'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='BotAdmin',
|
||||
new_name='BotUser',
|
||||
),
|
||||
]
|
@ -36,9 +36,9 @@ class Alias(models.Model):
|
||||
return command
|
||||
|
||||
|
||||
class BotAdmin(models.Model):
|
||||
class BotUser(models.Model):
|
||||
|
||||
"""Configure admins, which can do things through the bot that others can't."""
|
||||
"""Configure bot users, which can do things through the bot and standard Django auth."""
|
||||
|
||||
nickmask = models.CharField(max_length=200, unique=True)
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
|
Loading…
Reference in New Issue
Block a user