From 6c70c689f230d39499c43cb5b1c94f86d55aad64 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Thu, 12 Jul 2012 17:46:16 +0000 Subject: move fetching of admin email addresses to the glue library so it can be used by rpkigui-rcynic as well svn path=/trunk/; revision=4598 --- rpkid/rpki/gui/app/glue.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'rpkid/rpki/gui/app/glue.py') diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py index 577f9c7b..66d4c368 100644 --- a/rpkid/rpki/gui/app/glue.py +++ b/rpkid/rpki/gui/app/glue.py @@ -121,9 +121,31 @@ def config_from_template(dest, a): else: print >>f, r, + def str_to_resource_range(prefix): try: r = resource_range_ipv4.parse_str(prefix) except BadIPResource: r = resource_range_ipv6.parse_str(prefix) return r + + +def get_email_list(conf): + """Return a list of the contact emails for this user. + + Contact emails are extract from any ghostbuster requests, and if there are + none, returns the default email for the web portal account. + + """ + notify_emails = [] + qs = models.GhostbusterRequest.objects.filter(issuer=conf) + for gbr in qs: + if gbr.email_address: + notify_emails.append(gbr.email_address) + + if len(notify_emails) == 0: + # fall back to the email address registered for this user + user = User.objects.get(username=conf.handle) + notify_emails.append(user.email) + + return notify_emails -- cgit v1.2.3