[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rt-liberation 82f74ff 41/72: Re-write command set and a
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rt-liberation 82f74ff 41/72: Re-write command set and assignment code. |
Date: |
Wed, 5 Aug 2020 11:57:40 -0400 (EDT) |
branch: externals/rt-liberation
commit 82f74ffe65fabfa4f290f0c603cfc3738bb42cfc
Author: Yoni Rabkin <yrk@gnu.org>
Commit: Yoni Rabkin <yrk@gnu.org>
Re-write command set and assignment code.
This removes a lot of cruft along the way, which is a good thing.
---
rt-liberation-rest.el | 9 ++---
rt-liberation.el | 110 ++++++++++++--------------------------------------
2 files changed, 29 insertions(+), 90 deletions(-)
diff --git a/rt-liberation-rest.el b/rt-liberation-rest.el
index d2c8fce..10a5a9f 100644
--- a/rt-liberation-rest.el
+++ b/rt-liberation-rest.el
@@ -264,12 +264,11 @@
(rt-liber-rest-handle-response response-buffer)))
(message "edit command ended at %s" (current-time-string)))
-(defun rt-liber-rest-command-set-status (id status)
+(defun rt-liber-rest-command-set (id field status)
"Set ticket ID status to be STATUS."
- (let ((field (rt-liber-get-field-string 'status)))
- (rt-liber-parse-answer
- (rt-liber-rest-edit-runner id field status)
- 'rt-liber-command-runner-parser-f)))
+ (rt-liber-parse-answer
+ (rt-liber-rest-edit-runner id field status)
+ 'rt-liber-command-runner-parser-f))
(provide 'rt-liberation-rest)
diff --git a/rt-liberation.el b/rt-liberation.el
index 860facc..c8c4904 100644
--- a/rt-liberation.el
+++ b/rt-liberation.el
@@ -182,6 +182,7 @@ server.")
(defvar rt-liber-field-dictionary
'((owner . "Owner")
+ (queue . "Queue")
(status . "Status"))
"Mapping between field symbols and RT field strings.
@@ -199,14 +200,6 @@ The status symbols provide the programmer with a
consistent way
of referring to certain statuses. The status strings are the
server specific strings.")
-(defvar rt-liber-custom-field-dictionary
- '((cf-is-spam . "is-spam"))
- "Mapping between custom field symbols and custom field strings.
-
-The custom field symbols provide the programmer with a consistent
-way of referring to certain custom fields. The custom field
-strings are the server specific strings.")
-
(defvar rt-liber-debug-log-enable nil
"If t then enable logging of communication to a buffer.
@@ -1255,24 +1248,10 @@ string then that will be the name of the new buffer."
(error "could not find the RT binary at: %s" rt-liber-rt-binary))
(error "an unhandled exception occured: %s" excep)))
-;; the user might not see this but at the very least it will leave a
-;; trace in the *Messages* buffer -- yrk
(defun rt-liber-command-runner-parser-f ()
"Display command return status from the server to the user."
(message (buffer-string)))
-;; Depreciated in favor of using the REST interface.
-;;
-;; (defun rt-liber-command-set-cf (id field value)
-;; "Add custom field FIELD with VALUE to ID.
-;; If FIELD already exists, update to VALUE."
-;; (let ((command (rt-liber-command-get-command-string 'edit))
-;; (args
-;; (format "ticket/%s set %s=%s" id field value)))
-;; (rt-liber-parse-answer
-;; (rt-liber-command-runner command args)
-;; 'rt-liber-command-runner-parser-f)))
-
(defun rt-liber-command-set-status (id status)
"Set ticket ID status to be STATUS."
(let ((command (rt-liber-command-get-command-string 'edit))
@@ -1301,53 +1280,38 @@ string then that will be the name of the new buffer."
(defun rt-liber-command-set-status-deleted (id)
"Set the status of ticket ID to `deleted'."
- (rt-liber-rest-command-set-status
- id (rt-liber-command-get-status-string 'deleted)))
+ (rt-liber-rest-command-set
+ id
+ (rt-liber-get-field-string 'status)
+ (rt-liber-com mand-get-status-string 'deleted)))
(defun rt-liber-command-set-status-new (id)
"Set the status of ticket ID to `new'."
- (rt-liber-rest-command-set-status
- id (rt-liber-command-get-status-string 'new)))
+ (rt-liber-rest-command-set
+ id
+ (rt-liber-get-field-string 'status)
+ (rt-liber-command-get-status-string 'new)))
(defun rt-liber-command-set-status-resolved (id)
"Set the status of ticket ID to `resolved'."
- (rt-liber-rest-command-set-status
- id (rt-liber-command-get-status-string 'resolved)))
+ (rt-liber-rest-command-set
+ id
+ (rt-liber-get-field-string 'status)
+ (rt-liber-command-get-status-string 'resolved)))
(defun rt-liber-command-set-status-open (id)
"Set the status of ticket ID to `open'."
- (rt-liber-rest-command-set-status
- id (rt-liber-command-get-status-string 'open)))
-
-;; This is brittle because the server doesn't respond with a code but
-;; with some free text, and we have no guarantee that the text will be
-;; stable from version to version.
-(defun rt-liber-handle-response-set-owner (response)
- "Handle the response from the RT server. Pass on the response."
- (when
- (with-temp-buffer
- (insert response)
- (goto-char (point-min))
- (re-search-forward "That user does not exist" (point-max) t))
- (error "that user does not exist"))
- response)
-
-(defun rt-liber-command-set-owner (id owner)
- "Set the owner of ticket ID to OWNER."
- (rt-liber-handle-response-set-owner
- (rt-liber-parse-answer
- (rt-liber-rest-edit-runner
- id (rt-liber-get-field-string 'owner) owner)
- 'rt-liber-command-runner-parser-f)))
-
-(defun rt-liber-command-set-queue (id queue)
- "Set the queue of ticket ID to QUEUE."
- (let ((command (rt-liber-command-get-command-string 'edit))
- (args
- (format "ticket/%s set queue=%s" id queue)))
- (rt-liber-parse-answer
- (rt-liber-command-runner command args)
- 'rt-liber-command-runner-parser-f)))
+ (rt-liber-rest-command-set
+ id
+ (rt-liber-get-field-string 'status)
+ (rt-liber-command-get-status-string 'open)))
+
+(defun rt-liber-command-set-owner (id new-owner)
+ "Set the owner of ticket in TICKET-ALIST to NEW-OWNER."
+ (rt-liber-rest-command-set
+ id
+ (rt-liber-get-field-string 'owner)
+ new-owner))
(defun rt-liber-browser-prioritize (n)
"Assigng current ticket priority N."
@@ -1404,31 +1368,7 @@ string then that will be the name of the new buffer."
(interactive)
(when (not rt-liber-username)
(error "`rt-liber-username' is nil"))
- (let ((taken-p (rt-liber-ticket-taken-p
- (get-text-property (point) 'rt-ticket))))
- (when (or (not taken-p)
- (and taken-p
- (y-or-n-p "Ticket already taken! Are you sure?")))
- (rt-liber-command-set-owner
- (rt-liber-browser-ticket-id-at-point)
- rt-liber-username)
- (rt-liber-browser-refresh))))
-
-(defun rt-liber-viewer-take-ticket ()
- "Assign the current ticket to `rt-liber-username'."
- (interactive)
- (when (not rt-liber-username)
- (error "`rt-liber-username' is nil"))
- (let ((id (rt-liber-ticket-id-only rt-liber-ticket-local))
- (taken-p (rt-liber-ticket-taken-p rt-liber-ticket-local)))
- (if id
- (progn
- (when (or (not taken-p)
- (and taken-p
- (y-or-n-p "Ticket already taken! Are you sure?")))
- (rt-liber-command-set-owner id rt-liber-username)
- (rt-liber-refresh-ticket-history)))
- (error "no ticket currently in view"))))
+ (rt-liber-browser-assign rt-liber-username))
(provide 'rt-liberation)
- [elpa] externals/rt-liberation c654b30 26/72: * rt-liberation.el: Mark spam feature as very broken., (continued)
- [elpa] externals/rt-liberation c654b30 26/72: * rt-liberation.el: Mark spam feature as very broken., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation b640bb7 25/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e06992e 27/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 3e4a424 29/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 6e75dbb 31/72: * rt-liberation-rest.el: Start work on `show' query., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation f67581b 32/72: Implement and start using REST show query., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 1aa3ed0 33/72: * rt-liberation-rest.el: Show feedback when complete., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 92e78fa 35/72: Integrate rt-liber-rest-edit-runner and add fields., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 5dc7165 36/72: Port status changes to REST interface., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e5fe16e 40/72: Remove more spam related code., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 82f74ff 41/72: Re-write command set and assignment code.,
Stefan Monnier <=
- [elpa] externals/rt-liberation 19dc998 44/72: * doc/rt-liberation.texinfo: Update documentation., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e1c818c 19/72: * rt-liberation-rest.el: New file., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation a315322 21/72: * doc/gpl.texi: Update GPL copy., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation a723939 22/72: * doc/gpl.texi: Downgrade to version 2., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e46e2ad 28/72: * rt-liberation.el: Syntax bug fix., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 447c9f5 30/72: * rt-liberation.el: Move to REST API for ls queries., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 0e6c7ca 34/72: Implement ticket history via REST., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 0f650d0 37/72: * rt-liberation-rest.el: Write to debug if enabled., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 1e7f720 38/72: * rt-liberation-rest.el: Be more verbose., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 46d4ec1 39/72: Remove (too bad)., Stefan Monnier, 2020/08/05