From 2ecda214ce51eaa2470072bf868fcd3c74596895 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Wed, 1 Feb 2017 01:09:21 +0100 Subject: [PATCH] small fixes to ircbot --- src/ircbot/irc3module.py | 3 ++- src/ircbot/models.py | 1 + src/utils/models.py | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ircbot/irc3module.py b/src/ircbot/irc3module.py index 93f1e4d9..a2f512b5 100644 --- a/src/ircbot/irc3module.py +++ b/src/ircbot/irc3module.py @@ -1,6 +1,7 @@ import irc3 from ircbot.models import OutgoingIrcMessage from django.conf import settings +from django.utils import timezone @irc3.plugin @@ -73,7 +74,7 @@ class Plugin(object): the target channel. Messages are skipped if the bot is not in the channel. """ print("inside get_outgoing_messages()") - for msg in OutgoingIrcMessage.objects.filter(processed=False).order_by('created_date'): + for msg in OutgoingIrcMessage.objects.filter(processed=False).order_by('created'): # if this message expired mark it as expired and processed without doing anything if msg.timeout < timezone.now(): # this message is expired diff --git a/src/ircbot/models.py b/src/ircbot/models.py index 3fdc4ecb..ae422fc8 100644 --- a/src/ircbot/models.py +++ b/src/ircbot/models.py @@ -1,6 +1,7 @@ from django.core.exceptions import ValidationError from utils.models import UUIDModel, CreatedUpdatedModel from django.db import models +from django.utils import timezone class OutgoingIrcMessage(CreatedUpdatedModel): diff --git a/src/utils/models.py b/src/utils/models.py index a292aa54..9448ff01 100644 --- a/src/utils/models.py +++ b/src/utils/models.py @@ -11,7 +11,12 @@ class CleanedModel(models.Model): try: # call this models full_clean() method before saving, # which in turn calls .clean_fields(), .clean() and .validate_unique() - self.full_clean() + #self.full_clean() + # for some reason self.full_clean() appears to call self.clean() before self.clean_fields() + # which is not supposed to happen. Call them manually one by one instead. + self.clean_fields() + self.clean() + self.validate_unique() except ValidationError as e: message = "Got ValidationError while saving: %s" % e if hasattr(self, 'request'):