liquid_feedback_frontend
annotate app/main/member_image/show.lua @ 1558:5e7d76a32227
Hide discard vote button after voting is closed
author | bsw |
---|---|
date | Tue Nov 10 20:23:37 2020 +0100 (2020-11-10) |
parents | 8874448bbb7a |
children | dcbe505ddf24 |
rev | line source |
---|---|
bsw/jbe@4 | 1 local image_type = param.get("image_type") |
bsw/jbe@4 | 2 local record = MemberImage:by_pk(param.get_id(), image_type, true) |
bsw/jbe@4 | 3 |
bsw@1148 | 4 local dynamic = param.get("dynamic") |
bsw@1148 | 5 |
bsw@1147 | 6 local data, content_type |
bsw@1147 | 7 |
bsw@1147 | 8 if record then |
bsw@1147 | 9 data = record.data |
bsw@1147 | 10 assert(record.content_type, "No content-type set for image.") |
bsw@1147 | 11 content_type = record.content_type |
bsw@1147 | 12 |
bsw@1147 | 13 else |
bsw@1147 | 14 local default_file = "avatar.jpg" |
bsw@1147 | 15 content_type = "image/jpeg" |
bsw@1147 | 16 if image_type == "photo" then |
bsw@1147 | 17 default_file = "icons/16/lightning.png" |
bsw@1147 | 18 content_type = "image/png" |
bsw@1147 | 19 end |
bsw@1147 | 20 |
bsw@1147 | 21 local filename = WEBMCP_BASE_PATH .. "static/" .. default_file |
bsw@1147 | 22 |
bsw@1147 | 23 local f = assert(io.open(filename), "Cannot open default image file") |
bsw@1147 | 24 data = f:read("*a") |
bsw@1147 | 25 f:close() |
bsw@1147 | 26 |
bsw/jbe@4 | 27 end |
bsw/jbe@4 | 28 |
bsw@1148 | 29 if not dynamic then |
bsw@1148 | 30 request.allow_caching() |
bsw@1148 | 31 end |
bsw/jbe@4 | 32 |
bsw@1147 | 33 slot.set_layout(nil, content_type) |
bsw@1147 | 34 slot.put_into("data", data) |