bsw/jbe@1309: local verification = Verification:by_id(param.get_id()) bsw/jbe@1309: local data = verification.verification_data or verification.request_data bsw/jbe@1309: bsw/jbe@1309: local identification = config.self_registration.identification_func(data) bsw/jbe@1309: local member bsw/jbe@1309: if verification.verified_member_id then bsw/jbe@1309: member = Member:by_id(verification.verified_member_id) bsw/jbe@1309: identification = member.identification bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: local group, title, view bsw/jbe@1309: if verification.verified_member_id then bsw/jbe@1309: if member.deleted then bsw/jbe@1309: group = _"Cancelled accounts" bsw/jbe@1309: title = _"Cancelled account" bsw/jbe@1309: view = "verification_cancelled" bsw/jbe@1309: else bsw/jbe@1309: group = _"Accredited users" bsw/jbe@1309: title = member.identification bsw/jbe@1309: view = "verification_accredited" bsw/jbe@1309: end bsw/jbe@1309: elseif verification.denied then bsw/jbe@1309: group = "Rejected requests" bsw/jbe@1309: title = _"Rejected request" bsw/jbe@1309: view = "verification_rejected" bsw/jbe@1309: else bsw/jbe@1309: group = "Open requests" bsw/jbe@1309: title = _"Open request" bsw/jbe@1309: view = "verification_requests" bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: bsw/jbe@1309: ui.title(function() bsw@1326: ui.link { module = "registration_admin", view = "index", content = _"User management" } bsw/jbe@1309: slot.put ( " » " ) bsw/jbe@1309: ui.link { module = "registration_admin", view = view, content = group } bsw/jbe@1309: slot.put ( " » " ) bsw/jbe@1309: ui.tag { tag = "span", content = title } bsw/jbe@1309: end) bsw@1326: app.html_title.title = _"User management" bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-grid" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw/jbe@1309: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = title } bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: bsw/jbe@1309: ui.form{ bsw/jbe@1309: module = "registration_admin", action = "update_verification", id = verification.id, bsw/jbe@1309: routing = { ok = { mode = "redirect", module = "registration_admin", view = view } }, bsw/jbe@1309: record = data, bsw/jbe@1309: content = function() bsw/jbe@1309: bsw/jbe@1309: if not verification.verified_member_id then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() bsw/jbe@1309: ui.container{ content = verification.comment and verification.comment:gsub("///", " / ") or ""} bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content" }, content = function() bsw/jbe@1309: bsw/jbe@1309: for i, field in ipairs(config.self_registration.fields) do bsw/jbe@1309: ui.container{ content = function() bsw@1335: if field.type == "image" then bsw@1345: ui.link{ content = field.label, module = "registration_admin", view = "verification_image", id = verification.request_data[field.name], params = { field = i }, attr = { target = "_blank" } } bsw@1347: elseif field.name == "unit" then bsw@1347: local units_selector = Unit:new_selector() bsw@1347: :add_where{ "active" } bsw@1347: if field.where then bsw@1347: units_selector:add_where(field.where) bsw@1347: end bsw@1350: local units = {} bsw@1347: if field.optional then bsw@1347: table.insert(units, { bsw@1347: id = "", bsw@1347: name = _"None" bsw@1347: }) bsw@1347: end bsw@1351: for i_unit, unit in ipairs(units_selector:exec()) do bsw@1350: table.insert(units, unit) bsw@1350: end bsw@1347: ui.field.select{ bsw@1347: label = field.label, bsw@1347: foreign_records = units, bsw@1347: foreign_id = "id", bsw@1347: foreign_name = "name", bsw@1350: name = field.name, bsw@1350: value = tonumber(data[field.name]) bsw@1347: } bsw@1360: elseif field.name == "sequential_number" then bsw@1361: ui.tag{ tag = "label", content = field.label } bsw@1361: ui.tag{ tag = "span", content = data.sequential_number or _"None yet" } bsw@1335: else bsw@1335: ui.field.text{ bsw@1335: container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, bsw@1335: attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" }, bsw@1335: label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name }, bsw@1335: label = field.label, bsw@1335: name = field.name bsw@1335: } bsw@1338: ui.tag{ content = verification.request_data[field.name] } bsw@1335: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: ui.field.text{ bsw/jbe@1309: container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label", style = "width: 30em;" }, bsw/jbe@1309: attr = { id = "lf-register__data_identification", class = "mdl-textfield__input" }, bsw/jbe@1309: label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data_identification" }, bsw/jbe@1309: label = "Identification", bsw/jbe@1309: name = "identification", bsw/jbe@1309: value = identification bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function() bsw/jbe@1309: bsw/jbe@1309: if verification.denied then bsw/jbe@1309: ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } bsw/jbe@1309: elseif verification.verified_member_id then bsw/jbe@1309: ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save personal data" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: if not member.activated then bsw/jbe@1309: ui.submit{ name = "invite", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Send email invitation again" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: end bsw/jbe@1309: ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: ui.submit{ name = "cancel", attr = { class = "mdl-button mdl-js-button" }, value = _"Delete account" } bsw/jbe@1309: else bsw/jbe@1309: ui.submit{ name = "accredit", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Accredit user" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save personal data" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: ui.submit{ name = "drop", attr = { class = "mdl-button mdl-js-button" }, value = "Reject request" } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: local verifications = Verification:new_selector() bsw/jbe@1309: :join("member", nil, "member.id = verification.verified_member_id") bsw/jbe@1309: :add_where{ "member.identification = ?", identification } bsw/jbe@1309: :add_where{ "verification.id <> ?", verification.id } bsw/jbe@1309: :exec() bsw/jbe@1309: bsw/jbe@1309: if #verifications > 0 then bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw/jbe@1309: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function() bsw/jbe@1309: ui.tag{ content = _"Same identification" } bsw/jbe@1309: end } bsw/jbe@1309: end } bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() bsw/jbe@1309: execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } } bsw/jbe@1309: end } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: for i, field_name in ipairs(config.self_registration.match_fields) do bsw/jbe@1309: local field bsw/jbe@1309: for j, f in ipairs(config.self_registration.fields) do bsw/jbe@1309: if f.name == field_name then bsw/jbe@1309: field = f bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: local verifications = Verification:new_selector() bsw/jbe@1309: :add_where("verified_member_id NOTNULL") bsw/jbe@1309: :add_where{ "lower(request_data->>'" .. field.name .. "') = lower(?)", data[field.name] } bsw/jbe@1309: :add_where{ "verification.id <> ?", verification.id } bsw/jbe@1309: :exec() bsw/jbe@1309: bsw/jbe@1309: if #verifications > 0 then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw/jbe@1309: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function() bsw/jbe@1309: ui.tag{ content = _"Same " .. field.label } bsw/jbe@1309: end } bsw/jbe@1309: end } bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() bsw/jbe@1309: execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } } bsw/jbe@1309: end } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: end } bsw/jbe@1309: end } bsw/jbe@1309: