1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/peeringdb_server/management/commands/pdb_deskpro_publish.py
Matt Griswold 16285c13f3 Support 202010 (#868)
* Add migrations for 463_745_775

* Black format the migration

* Bump up django_peeringdb version

* api require django-peeringdb 2.3.0.1 and later

* Set timezone to utc throughout sponsorship notifications

* Add government net type to existing migrtion

* Remove ixlan from peers at this exchange point

* Add new migration

* add backward migrtion

* Search on user__username not user object

* Black those changes

* Fix local erro bug

* Add test and fix speed update for deleted netixlan

* Handle attribute error

* Change language in email to reflect we don't email after x days

* Comment out EnvironmentSetting in django admin

* Disable the followup ticket and modify tests to correct deskproticket assertions

* exclude ixf tickets from deskpro publishing

* Add failing mock deskpro api and write a test with it

* Add anchor tags to notify-ixf-add

* a tags for conflict insert

* a tags for consolidated

* a tags modify

* a tags protocol conflict

* a tags remote changes

* a tags for remove

* a tags for resolved

* a tags source error

* Add target blank

* Add comment

* fix unhandled deskpro api errors

* Add mail attachment

* Remove strip_tags

* readd some strip_tags

* add explicit order for fields in admin control panel #861

* revert pretty_speed change

* Coerce is_rs_peer and operational to bool

* black formatted

* pipfile relock

Co-authored-by: Elliot Frank <elliot@20c.com>
Co-authored-by: Stefan Pratter <stefan@20c.com>
2020-11-03 18:26:15 -06:00

52 lines
1.6 KiB
Python

#!/usr/bin/env python
import datetime
from django.core.management.base import BaseCommand
from django.conf import settings
from peeringdb_server import models
from peeringdb_server.deskpro import APIClient, APIError
class Command(BaseCommand):
help = "Process deskpro ticket queue"
def add_arguments(self, parser):
pass
def log(self, msg):
print(msg)
def handle(self, *args, **options):
client = APIClient(settings.DESKPRO_URL, settings.DESKPRO_KEY)
self.log(f"DESKPRO: {settings.DESKPRO_URL}")
# Per issue #858 we want to ignore the IX-F tickets
ticket_qs = (
models.DeskProTicket.objects.filter(published__isnull=True)
.exclude(subject__icontains="[IX-F]")
.order_by("created")
)
if not ticket_qs.count():
self.log("No tickets in queue")
return
for ticket in ticket_qs[:10]:
self.log(f"Posting to Deskpro: #{ticket.id}")
try:
client.create_ticket(ticket)
ticket.published = datetime.datetime.now().replace(tzinfo=models.UTC())
ticket.save()
except APIError as exc:
self.log(
"!!!! Could not create ticket #{} - error data has been attached to ticket body.".format(
ticket.id
)
)
ticket.published = datetime.datetime.now().replace(tzinfo=models.UTC())
ticket.subject = f"[FAILED] {ticket.subject}"
ticket.body = f"{ticket.body}\nAPI Delivery Error: {exc.data}"
ticket.save()