forked from brmlab/brmelect-github
meeting
This commit is contained in:
parent
109afe5eaf
commit
309084870b
1 changed files with 54 additions and 0 deletions
|
|
@ -143,6 +143,60 @@
|
||||||
}))))
|
}))))
|
||||||
;@td{,(->string from)}
|
;@td{,(->string from)}
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; /admin/meeting/:id
|
||||||
|
(define-resource (meeting-votes "admin" "meeting" id params)
|
||||||
|
(let ((meeting-info (query-db "SELECT title FROM brm.meetings WHERE meeting_id = $1" id))
|
||||||
|
(rows (query-db "SELECT vote_id,title,lower(open_time),upper(open_time),is_active FROM brm.votes WHERE meeting_id = $1
|
||||||
|
ORDER BY vote_id" id)))
|
||||||
|
(make-html-response
|
||||||
|
200
|
||||||
|
(layout
|
||||||
|
(string-append "Meeting " (identity id) " - Votes")
|
||||||
|
`@div{
|
||||||
|
@h2{@,(row-fold* (lambda (title x) title) "" meeting-info) - Votes}
|
||||||
|
@form[
|
||||||
|
(action @,(string-append "/admin/meeting/" id "/vote"))
|
||||||
|
(method "POST")]
|
||||||
|
@table{
|
||||||
|
@tr{ @th{"New Vote Title"} @th{}}
|
||||||
|
@tr{ @td{@input[(name "vote-title")]} @td{@input[type="submit" value="Create Vote"]}}}
|
||||||
|
@table{
|
||||||
|
@tr{ @th{ID} @th{Title} @th{Start} @th{End} @th{Active} @th{Actions}}
|
||||||
|
@,@(row-map*
|
||||||
|
(lambda (vote-id title from to is-active)
|
||||||
|
`@tr{
|
||||||
|
@td{@,(number->string vote-id)}
|
||||||
|
@td{@,title}
|
||||||
|
@td{@,from}
|
||||||
|
@td{@,to}
|
||||||
|
@td{@,(if (eq? is-active #t) "Yes" "No")}
|
||||||
|
@td{@a[(href @,(string-append "/admin/vote/" (number->string vote-id)))]{details}}
|
||||||
|
})
|
||||||
|
rows)
|
||||||
|
}
|
||||||
|
}))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; /admin/meeting/:id/vote
|
||||||
|
(define-resource (create-meeting-vote "admin" "meeting" id "vote" params)
|
||||||
|
(if (string=? (resource-context-method (current-resource-context)) "POST")
|
||||||
|
(let ((title (hash-ref params 'vote-title)))
|
||||||
|
(query-db "SELECT brm.create_vote_and_init_status($1, $2)" id title)
|
||||||
|
(make-html-response
|
||||||
|
200
|
||||||
|
(layout
|
||||||
|
"Vote Created"
|
||||||
|
`@div{
|
||||||
|
@p{"Vote successfully created for meeting " (number->string id) "."}
|
||||||
|
@a[(href (string-append "/admin/meeting/" (number->string id)))]{Back to Meeting}
|
||||||
|
})))
|
||||||
|
(make-error-response
|
||||||
|
405 "The access method used to request the document is not supported."
|
||||||
|
#:headers '(("Allow" . "POST")))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; /foo -- debug endpoint
|
;; /foo -- debug endpoint
|
||||||
(define-resource (foo-bar-baz "foo" id params)
|
(define-resource (foo-bar-baz "foo" id params)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue