git.fiddlerwoaroof.com
Raw Blame History
(in-package :inangulis.tables)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (local-time:set-local-time-cl-postgres-readers))

(defclass user ()
  ((id :col-type serial)
   (uid :initarg :uid :col-type text)
   (email :initarg :email :col-type text)
   (name :initarg :name :col-type text)
   (moderator :initarg :moderator :initform nil :col-type bool))
  (:metaclass dao-class)
  (:keys id))

(deftable user
  (!dao-def))

(defclass submission ()
  ((headline :initarg :headline :col-type text :initform ""  :accessor inangulis::s-headline)
   (url      :initarg :url      :col-type text :initform ""  :accessor inangulis::s-url)
   (date     :initarg :date     :col-type timestamptz :initform "")
   (approved :initarg :approved :col-type text :initform "" :accessor inangulis::s-approved))
  (:metaclass dao-class)
  (:keys headline url))

(deftable submission
  (!dao-def))

;; (ubiquitous:restore :inangulis)

;; (with-connection (ubiquitous:value 'db)
;;   (create-table 'user))

;; (with-connection (ubiquitous:value 'db)
;;   (create-table 'submission))

(defmethod inangulis::s-date ((object submission))
  (with-slots (date) object
    (local-time:format-timestring nil date :format local-time:+rfc-1123-format+)))

(defmethod print-object ((obj submission) s)
  (print-unreadable-object (obj s :type t :identity t)
    (with-slots (headline url approved) obj
      (format s "H: ~s U: ~s A: ~s" headline url approved))))