add irc messages when new event- or speakerproposals are created
This commit is contained in:
parent
c02598bfde
commit
f4a2f6cea6
|
@ -11,6 +11,7 @@ from django.contrib import messages
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
@ -22,6 +23,7 @@ from django.db.models.signals import post_save
|
||||||
|
|
||||||
from utils.models import CreatedUpdatedModel, CampRelatedModel
|
from utils.models import CreatedUpdatedModel, CampRelatedModel
|
||||||
from .email import add_new_speakerproposal_email, add_new_eventproposal_email
|
from .email import add_new_speakerproposal_email, add_new_eventproposal_email
|
||||||
|
from ircbot.models import OutgoingIrcMessage
|
||||||
logger = logging.getLogger("bornhack.%s" % __name__)
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,18 +277,36 @@ class EventProposal(UserSubmittedModel):
|
||||||
|
|
||||||
@receiver(post_save, sender=EventProposal)
|
@receiver(post_save, sender=EventProposal)
|
||||||
@receiver(post_save, sender=SpeakerProposal)
|
@receiver(post_save, sender=SpeakerProposal)
|
||||||
def notify_content_team(sender, created, instance, **kwargs):
|
def notify_proposals(sender, created, instance, **kwargs):
|
||||||
|
target = settings.IRCBOT_CHANNELS['orga'] if 'orga' in settings.IRCBOT_CHANNELS else settings.IRCBOT_CHANNELS['default']
|
||||||
|
|
||||||
if created and isinstance(instance, SpeakerProposal):
|
if created and isinstance(instance, SpeakerProposal):
|
||||||
if not add_new_speakerproposal_email(instance):
|
if not add_new_speakerproposal_email(instance):
|
||||||
logger.error(
|
logger.error(
|
||||||
'Error adding speaker proposal email to outgoing queue for {}'.format(instance)
|
'Error adding speaker proposal email to outgoing queue for {}'.format(instance)
|
||||||
)
|
)
|
||||||
|
OutgoingIrcMessage.objects.create(
|
||||||
|
target=target,
|
||||||
|
message="New speaker proposal: {} (https://bornhack.dk/admin/program/speakerproposal/{}/change/)".format(
|
||||||
|
instance.name,
|
||||||
|
instance.uuid
|
||||||
|
),
|
||||||
|
timeout=timezone.now()+timedelta(minutes=10)
|
||||||
|
)
|
||||||
|
|
||||||
if created and isinstance(instance, EventProposal):
|
if created and isinstance(instance, EventProposal):
|
||||||
if not add_new_eventproposal_email(instance):
|
if not add_new_eventproposal_email(instance):
|
||||||
logger.error(
|
logger.error(
|
||||||
'Error adding event proposal email to outgoing queue for {}'.format(instance)
|
'Error adding event proposal email to outgoing queue for {}'.format(instance)
|
||||||
)
|
)
|
||||||
|
OutgoingIrcMessage.objects.create(
|
||||||
|
target=target,
|
||||||
|
message="New event proposal: {} (https://bornhack.dk/admin/program/eventproposal/{{ proposal.uuid }}/change/)".format(
|
||||||
|
instance.title,
|
||||||
|
instance.uuid
|
||||||
|
),
|
||||||
|
timeout=timezone.now()+timedelta(minutes=10)
|
||||||
|
)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue