Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from mail to RT for admin operations #491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions appliance_catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from django.views.generic.edit import DeleteView
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.core.mail import send_mail

from djangoRT import rtModels, rtUtil
from .forms import ApplianceForm, ApplianceShareForm
from .models import Appliance, Keyword, ApplianceTagging
from .serializers import ApplianceJSONSerializer, KeywordJSONSerializer
Expand Down Expand Up @@ -261,14 +262,14 @@ def app_create(request):
+ str(appliance.id)
)
try:
send_mail(
message,
body,
"[email protected]",
("[email protected]",),
fail_silently=False,
rt = rtUtil.DjangoRt()
ticket = rtModels.Ticket(
subject=message,
problem_description=body,
requestor="[email protected]",
)
except SMTPException as e:
rt.createTicket(ticket)
except Exception as e:
logger.error("Error sending appliance catalog email ", e)

logger.debug("New appliance successfully created. Adding keywords...")
Expand Down Expand Up @@ -329,14 +330,14 @@ def app_create_image(request):
+ str(appliance.id)
)
try:
send_mail(
message,
body,
"[email protected]",
("[email protected]",),
fail_silently=False,
rt = rtUtil.DjangoRt()
ticket = rtModels.Ticket(
subject=message,
problem_description=body,
requestor="[email protected]",
)
except SMTPException as e:
rt.createTicket(ticket)
except Exception as e:
logger.error("Error sending appliance catalog email ", e)

logger.debug("New appliance successfully created. Adding keywords...")
Expand Down
22 changes: 11 additions & 11 deletions projects/pub_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.mail import send_mail
from django.db import transaction
from django.db.models import Max
from django.http import Http404
from django.shortcuts import render
from django.utils.html import strip_tags
from django.core.exceptions import PermissionDenied

from djangoRT import rtModels, rtUtil
from projects.models import Publication, PublicationSource
from projects.user_publication.deduplicate import get_duplicate_pubs
from projects.util import get_project_members
Expand All @@ -33,13 +33,13 @@ def _send_publication_notification(charge_code, pubs):
<ul>{" ".join(formatted_pubs)}</ul>
</p>
"""
send_mail(
rt = rtUtil.DjangoRt()
ticket = rtModels.Ticket(
subject=subject,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[settings.PENDING_ALLOCATION_NOTIFICATION_EMAIL],
message=strip_tags(body),
html_message=body,
problem_description=body,
requestor="[email protected]",
)
rt.createTicket(ticket)


def _send_duplicate_pubs_notification(charge_code, duplicate_pubs):
Expand All @@ -58,13 +58,13 @@ def _send_duplicate_pubs_notification(charge_code, duplicate_pubs):
<ul>{" ".join(formatted_duplicate_pubs)}</ul>
</p>
"""
send_mail(
rt = rtUtil.DjangoRt()
ticket = rtModels.Ticket(
subject=subject,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[settings.PENDING_ALLOCATION_NOTIFICATION_EMAIL],
message=strip_tags(body),
html_message=body,
problem_description=body,
requestor="[email protected]",
)
rt.createTicket(ticket)


@login_required
Expand Down
10 changes: 5 additions & 5 deletions util/project_allocation_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def _send_allocation_request_notification(self, charge_code, host):
<p>Please review the pending allocation request for project {charge_code}
at <a href="https://{host}/admin/allocations/">admin page</a>.</p>
"""
send_mail(
rt = rtUtil.DjangoRt()
ticket = rtModels.Ticket(
subject=subject,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[settings.PENDING_ALLOCATION_NOTIFICATION_EMAIL],
message=strip_tags(body),
html_message=body,
problem_description=body,
requestor="[email protected]",
)
rt.createTicket(ticket)

def _send_allocation_decision_notification(
self, charge_code, requestor_id, status, decision_summary, host
Expand Down
Loading