Skip to content

Instantly share code, notes, and snippets.

@ornerymoose

ornerymoose/something.py

Last active Nov 15, 2018
Embed
What would you like to do?
def submit(self, form):
""" create SIs """
tickets = []
if form.id == 1:
tts_obj = Tts(
source='Raven',
region='Mountain West',
element='test_element120',
element_type='CMTS',
problem_code='99999'
)
# create first SI
tts_obj.get_nsd_ticket_params()
si = self.ticket_handler.create_tts_ticket(tts_obj)
self.ticket_handler.add_worklog(si, form)
self.send_slack_notification(si)
tickets.append(si)
# create second SI
tts_obj.get_vrq_ticket_params()
si = self.ticket_handler.create_tts_ticket(tts_obj)
self.ticket_handler.add_worklog(si, form)
self.send_slack_notification(si)
tickets.append(si)
return tickets
# initial refactor
# create new method
def handle_tts_steps(self, switch, tts_obj, form):
tts_obj.get_nsd_ticket_params() if switch == "nsd" else tts_obj.get_vrq_ticket_params()
si = self.ticket_handler.create_tts_ticket(tts_obj)
self.ticket_handler.add_worklog(si, form)
self.send_slack_notification(si)
return si
# then call that method in the submit() method below, twice:
nsd_si = self.handle_tts_steps("nsd", tts_obj, form)
tickets.append(nsd_si)
# create second SI
vrq_si = self.handle_tts_steps("vrq", tts_obj, form)
tickets.append(vrq_si)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment