Browse Source

update archive-entry HTTP POST request (include 'publish' date).

The publish date refers to when the artwork was publish which differs from the
'Created At' date. That refers to when the entry was added to the database.
stable
Craig Oates 2 years ago
parent
commit
b874b3e742
  1. 71
      src/web.lisp

71
src/web.lisp

@ -1045,7 +1045,7 @@
(defroute ("/create/archive-entry" :method :POST) ()
(destructuring-bind
(&key title keywords thumbnail-file page-content
(&key title month year keywords thumbnail-file page-content
authenticity-token &allow-other-keys)
(utils:request-params
(lack.request:request-body-parameters ningle:*request*))
@ -1054,7 +1054,7 @@
(t (hermetic:auth
(:logged-in)
;; Authorised
(cond ((find t (mapcar #'utils:string-is-nil-or-empty? `(,title ,keywords)))
(cond ((find t (mapcar #'utils:string-is-nil-or-empty? `(,title ,month ,year)))
(render
"/user/create-archive.html"
(append (auth:auth-user-data)
@ -1064,6 +1064,8 @@
"sherlock-cat.png"
"Data is missing. Unable to create entry.")
:title ,title
:month ,month
:year ,year
:keywords ,keywords
:data ,page-content))))
@ -1077,6 +1079,8 @@
"confused-cat.png"
"Entry with that title already exists. Unable to create entry.")
:title ,title
:month ,month
:year ,year
:keywords ,keywords
:data ,page-content))))
@ -1088,9 +1092,11 @@
`(:alert
,(utils:build-alert-string
"invalid-data"
"confused-cat-png"
"confused-cat.png"
"File uploaded is not an image. Entry not created.")
:title ,title
:month ,month
:year ,year
:keywords ,keywords
:data ,page-content))))
@ -1100,6 +1106,8 @@
title
search-id
(format nil "~a.html" (utils:slugify title))
month
year
(utils:format-filename (cadr thumbnail-file)) ; File Name
(caddr thumbnail-file) ; File Type
(utils:format-keywords keywords))
@ -1112,7 +1120,8 @@
(utils:slugify title))
(format nil "storage/thumb/archive/~a.html"
(utils:slugify title))
(local-time:now)
month
year
(utils:format-keywords keywords)))
;; Storage File Entry
(storage:store-text
@ -1242,7 +1251,8 @@
(format nil
"storage/thumb/archive/~a.html"
(utils:slugify new-title))
(mito.dao.mixin:object-created-at archive-entry)
(archive::month-of archive-entry)
(archive::year-of archive-entry)
(archive::keywords-of archive-entry)))
(utils:set-alert "Archive entry updated." "success")
(redirect
@ -1256,6 +1266,54 @@
"error")
(redirect "/login")))))))
(defroute ("/edit/archive-publish-date" :method :POST) ()
(destructuring-bind
(&key archive-slug authenticity-token month year &allow-other-keys)
(utils:request-params (lack.request:request-body-parameters ningle:*request*))
(cond ((not (string= authenticity-token (auth:csrf-token)))
`(,+forbidden+ (:content-type "text/plain") ("Denied")))
(t (hermetic:auth
(:administrator)
;; Authorised
(cond ((find t (mapcar #'utils:string-is-nil-or-empty?
`(,archive-slug ,month ,year)))
(utils:set-alert "Full date not provided. Not updated."
"missing-data")
(redirect "/user/archive"))
((null (nera:get-archive-entry :slug archive-slug))
(utils:set-alert
"Cannot file archive entry. Keywords not updated."
"invalid-data")
(redirect "/user/archive"))
(t (let ((archive-entry
(nera:get-archive-entry :slug archive-slug)))
(nera:update-archive-entry-property
:slug archive-slug
:property 'archive::month-of
:value month)
(nera:update-archive-entry-property
:slug archive-slug
:property 'archive::year-of
:value year)
(search:submit-entry
(search:build-payload
(archive::search-id-of archive-entry)
(archive::title-of archive-entry)
(format nil "view/archive/~a"
(archive::slug-of archive-entry))
(format nil "storage/thumb/archive/~a"
(archive::slug-of archive-entry))
month
year
(archive::keywords-of archive-entry)))
(utils:set-alert "Archive entry updated." "success")
(redirect (format nil "/edit/archive/~a" archive-slug)))))
;; Not Authorised
(progn (utils:set-alert
"You are not authorised to delete this archive entry."
"error")
(redirect "/login")))))))
(defroute ("/edit/archive-keywords" :method :POST) ()
(destructuring-bind
(&key archive-slug new-keywords authenticity-token &allow-other-keys)
@ -1289,7 +1347,8 @@
(archive::slug-of archive-entry))
(format nil "storage/thumb/archive/~a"
(archive::slug-of archive-entry))
(mito.dao.mixin:object-created-at archive-entry)
(archive::month-of archive-entry)
(archive::year-of archive-entry)
keywords))
(utils:set-alert "Archive entry updated." "success")
(redirect (format nil "/edit/archive/~a" archive-slug)))))

Loading…
Cancel
Save