diff options
| author | 2023-05-24 13:00:52 +0200 | |
|---|---|---|
| committer | 2023-05-24 13:00:52 +0200 | |
| commit | 07b9fa90b20aff96a12cf7a4f3bf8158251b8164 (patch) | |
| tree | 321f0782423eb56560b9c8869006343204fa9528 | |
| parent | Show HTML form code for oneOf polls. (diff) | |
| download | penes-snac2-07b9fa90b20aff96a12cf7a4f3bf8158251b8164.tar.gz penes-snac2-07b9fa90b20aff96a12cf7a4f3bf8158251b8164.tar.xz penes-snac2-07b9fa90b20aff96a12cf7a4f3bf8158251b8164.zip | |
Polls can now be voted.
| -rw-r--r-- | html.c | 22 |
1 files changed, 21 insertions, 1 deletions
| @@ -920,8 +920,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 920 | else { | 920 | else { |
| 921 | /* poll still active */ | 921 | /* poll still active */ |
| 922 | xs *s1 = xs_fmt("<form method=\"post\" action=\"%s/admin/vote\">\n" | 922 | xs *s1 = xs_fmt("<form method=\"post\" action=\"%s/admin/vote\">\n" |
| 923 | "<input type=\"hidden\" name=\"actor\" value= \"%s\">\n" | ||
| 923 | "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n", | 924 | "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n", |
| 924 | snac->actor, id); | 925 | snac->actor, actor, id); |
| 925 | 926 | ||
| 926 | while (xs_list_iter(&p, &v)) { | 927 | while (xs_list_iter(&p, &v)) { |
| 927 | const char *name = xs_dict_get(v, "name"); | 928 | const char *name = xs_dict_get(v, "name"); |
| @@ -1954,6 +1955,25 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1954 | 1955 | ||
| 1955 | status = 303; | 1956 | status = 303; |
| 1956 | } | 1957 | } |
| 1958 | else | ||
| 1959 | if (p_path && strcmp(p_path, "admin/vote") == 0) { /** **/ | ||
| 1960 | char *irt = xs_dict_get(p_vars, "irt"); | ||
| 1961 | const char *opt = xs_dict_get(p_vars, "question"); | ||
| 1962 | const char *actor = xs_dict_get(p_vars, "actor"); | ||
| 1963 | |||
| 1964 | xs *msg = msg_note(&snac, "", actor, irt, NULL, 1); | ||
| 1965 | |||
| 1966 | /* set the option */ | ||
| 1967 | msg = xs_dict_append(msg, "name", opt); | ||
| 1968 | |||
| 1969 | xs *c_msg = msg_create(&snac, msg); | ||
| 1970 | |||
| 1971 | enqueue_message(&snac, c_msg); | ||
| 1972 | |||
| 1973 | timeline_add(&snac, xs_dict_get(msg, "id"), msg); | ||
| 1974 | |||
| 1975 | status = 303; | ||
| 1976 | } | ||
| 1957 | 1977 | ||
| 1958 | if (status == 303) { | 1978 | if (status == 303) { |
| 1959 | char *redir = xs_dict_get(p_vars, "redir"); | 1979 | char *redir = xs_dict_get(p_vars, "redir"); |