def comment_on_ticket(self): caller = self.caller if not self.lhs or not self.rhs: msg = "Usage: <#>=<message>" ticketnumbers = ", ".join( str(ticket.id) for ticket in self.tickets) if ticketnumbers: msg += f"\nYour tickets: {ticketnumbers}" return caller.msg(msg) ticket = self.get_ticket_from_args(self.lhs) if not ticket: return if ticket.status == ticket.CLOSED_STATUS: self.msg("That ticket is already closed. Please make a new one.") return helpdesk_api.add_followup(caller, ticket, self.rhs, mail_player=False) caller.msg("Followup added.") return
def func(self): """Implement the command""" caller = self.caller args = self.args priority = 5 if "followup" in self.switches or "comment" in self.switches: if not self.lhs or not self.rhs: caller.msg("Missing arguments required.") ticketnumbers = ", ".join( str(ticket.id) for ticket in self.tickets) caller.msg("Your tickets: %s" % ticketnumbers) return ticket = self.get_ticket_from_args(self.lhs) if not ticket: return if ticket.status == ticket.CLOSED_STATUS: self.msg("That ticket is already closed. Make a new one.") return helpdesk_api.add_followup(caller, ticket, self.rhs, mail_player=False) caller.msg("Followup added.") return cmdstr = self.cmdstring.lower() if cmdstr == '+911': priority = 1 if not self.lhs: self.list_tickets() return if self.lhs.isdigit(): ticket = self.get_ticket_from_args(self.lhs) if not ticket: return self.display_ticket(ticket) return optional_title = None if self.lhs and self.rhs: args = self.rhs optional_title = self.lhs email = caller.email if email == "*****@*****.**": email = None if cmdstr == "bug": optional_title = "Bug Report" args = self.args queue = settings.BUG_QUEUE_ID elif cmdstr == "typo": optional_title = "Typo found" queue = Queue.objects.get(slug="Typo").id elif cmdstr == "+featurerequest": optional_title = "Features" queue = Queue.objects.get(slug="Code").id elif cmdstr == "+prprequest": optional_title = "PRP" queue = Queue.objects.get(slug="PRP").id else: queue = settings.REQUEST_QUEUE_ID if helpdesk_api.create_ticket(caller, args, priority, queue=queue, send_email=email, optional_title=optional_title): caller.msg( "Thank you for submitting a request to the GM staff. Your ticket has been added " "to the queue.") return else: caller.msg( "Ticket submission has failed for unknown reason. Please inform the administrators." ) return
def func(self): """Implement the command""" caller = self.caller args = self.args switches = self.switches if not args and not switches or (set(switches) & set(self.query_open_switches)): # list all open tickets self.display_open_tickets() return if args and (not switches or 'old' in switches): # list individual ticket specified by args # ticket = [ticket_id, playob, request_string, date_submit, gm_ob, gm_notes, date_answer, optional_title] try: ticknum = int(args) except ValueError: self.display_open_tickets() caller.msg("Usage: Argument must be a ticket number.") return try: ticket = Ticket.objects.get(id=ticknum) except Ticket.DoesNotExist: self.display_open_tickets() caller.msg("No ticket found by that number.") return caller.msg(ticket.display()) return if 'old' in switches and not args: # list closed tickets # closed & resolved tickets, assigned to current user tickets_closed_resolved = Ticket.objects.select_related( 'queue').filter( status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS ]).filter(queue__in=self.queues_from_args) joblist = list(tickets_closed_resolved) if not joblist: caller.msg("No closed tickets.") return # get 20 most recent joblist = joblist[-20:] table = prettytable.PrettyTable( ["{w#", "{wPlayer", "{wRequest", "{wQueue"]) for ticket in joblist: table.add_row([ str(ticket.id), str(ticket.submitting_player), str(ticket.title)[:20], ticket.queue.slug ]) caller.msg("{wClosed Tickets:{n\n%s" % table) return if 'moreold' in switches: # list closed tickets tickets_closed_resolved = Ticket.objects.select_related( 'queue').filter( status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS] ).filter(queue__in=self.queues_from_args).filter( id__gte=self.lhslist[0], id__lte=self.lhslist[1]) joblist = list(tickets_closed_resolved) if not joblist: caller.msg("No closed tickets.") return table = prettytable.PrettyTable( ["{w#", "{wPlayer", "{wRequest", "{wQueue"]) for ticket in joblist: table.add_row([ str(ticket.id), str(ticket.submitting_player), str(ticket.title)[:20], ticket.queue.slug ]) caller.msg("{wClosed Tickets:{n\n%s" % table) return try: ticket = Ticket.objects.get(id=self.lhs) except (ValueError, Ticket.DoesNotExist): self.msg("No ticket found by that number.") return if 'close' in switches: # Closing a ticket. Check formatting first lhs = self.lhs rhs = self.rhs if not args or not lhs or not rhs: caller.msg("Usage: @job/close <#>=<GM Notes>") return try: numticket = int(lhs) except ValueError: caller.msg("Must give a number for the open ticket.") return if helpdesk_api.resolve_ticket(caller, numticket, rhs): caller.msg("Ticket successfully closed.") return else: caller.msg("Ticket closure failed for unknown reason.") return if 'assign' in switches: player = self.caller.search(self.rhs) if not player: return ticket.assigned_to = player ticket.save() inform_staff("{w%s has assigned ticket %s to %s." % (caller, ticket.id, player)) return if 'followup' in switches or 'update' in switches or "follow" in switches: lhs = self.lhs rhs = self.rhs if not lhs or not rhs: caller.msg("Usage: @job/followup <#>=<msg>") return if helpdesk_api.add_followup(caller, ticket, rhs): caller.msg("Followup added.") return caller.msg("Error in followup.") return if 'move' in switches: if not self.lhs or not self.rhs: self.msg("Usage: @job/move <#>=<msg>") return try: queue = Queue.objects.get(slug__iexact=self.rhs) except Queue.DoesNotExist: self.msg("Queue must be one of the following: %s" % ", ".join(ob.slug for ob in Queue.objects.all())) return ticket.queue = queue ticket.save() self.msg("Ticket %s is now in queue %s." % (ticket.id, queue)) return if 'delete' in switches or 'del' in switches: if ticket.queue.slug == "Story": self.msg( "Cannot delete a storyaction. Please move it to a different queue first." ) return ticket.delete() self.msg("Ticket #%s deleted." % self.lhs) return if 'priority' in switches: try: ticket.priority = int(self.rhs) except (TypeError, ValueError): self.msg("Must be a number.") ticket.save() self.msg("Ticket new priority is %s." % self.rhs) return if 'approve' in switches: pass if 'deny' in switches: pass caller.msg("Invalid switch for @job.")
def func(self): """Implement the command""" caller = self.caller priority = 3 if "followup" in self.switches or "comment" in self.switches: if not self.lhs or not self.rhs: msg = "Usage: <#>=<message>" ticketnumbers = ", ".join( str(ticket.id) for ticket in self.tickets) if ticketnumbers: msg += "\nYour tickets: %s" % ticketnumbers return caller.msg(msg) ticket = self.get_ticket_from_args(self.lhs) if not ticket: return if ticket.status == ticket.CLOSED_STATUS: self.msg( "That ticket is already closed. Please make a new one.") return helpdesk_api.add_followup(caller, ticket, self.rhs, mail_player=False) caller.msg("Followup added.") return cmdstr = self.cmdstring.lower() if cmdstr == '+911': priority = 1 if not self.lhs: self.list_tickets() return if self.lhs.isdigit(): ticket = self.get_ticket_from_args(self.lhs) if not ticket: return self.display_ticket(ticket) return optional_title = self.lhs if self.rhs else (self.lhs[:27] + "...") args = self.rhs if self.rhs else self.args email = caller.email if caller.email != "*****@*****.**" else None if cmdstr == "bug": slug = settings.BUG_QUEUE_SLUG elif cmdstr == "typo": priority = 5 slug = "Typo" elif cmdstr == "+featurerequest": priority = 4 slug = "Code" elif cmdstr == "+prprequest": slug = "PRP" else: slug = settings.REQUEST_QUEUE_SLUG new_ticket = helpdesk_api.create_ticket(caller, args, priority, queue_slug=slug, send_email=email, optional_title=optional_title) if new_ticket: caller.msg( "Thank you for submitting a request to the GM staff. Your ticket (#%s) " "has been added to the queue." % new_ticket.id) return else: caller.msg( "Ticket submission has failed for unknown reason. Please inform the administrators." ) return
def add_followup(self, pitch): """Adds followup to a plot pitch""" add_followup(self.caller.player_ob, pitch, self.rhs) self.msg("You have added a followup to Ticket %s." % pitch.id)