liquid_feedback_frontend
diff app/main/registration_admin/role_verification.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | |
children | 7e328a78da93 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/registration_admin/role_verification.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -0,0 +1,168 @@ 1.4 +local verification = RoleVerification:by_id(param.get_id()) 1.5 +local data = verification.verification_data or verification.request_data 1.6 + 1.7 +local identification = config.role_registration.identification_func(data) 1.8 +local member 1.9 +if verification.verified_member_id then 1.10 + member = Member:by_id(verification.verified_member_id) 1.11 + identification = member.identification 1.12 +end 1.13 + 1.14 +local group, title, view 1.15 +if verification.verified then 1.16 + if member.deleted then 1.17 + group = _"Cancelled accounts" 1.18 + title = _"Cancelled account" 1.19 + view = "role_verification_cancelled" 1.20 + else 1.21 + group = _"Accredited users" 1.22 + title = member.identification 1.23 + view = "role_verification_accredited" 1.24 + end 1.25 +elseif verification.denied then 1.26 + group = "Rejected requests" 1.27 + title = _"Rejected request" 1.28 + view = "role_verification_rejected" 1.29 +else 1.30 + group = "Open requests" 1.31 + title = _"Open request" 1.32 + view = "role_verification_requests" 1.33 +end 1.34 + 1.35 + 1.36 +ui.title(function() 1.37 + ui.link { module = "registration_admin", view = "index", content = _"Rolemanagement" } 1.38 + slot.put ( " » " ) 1.39 + ui.link { module = "registration_admin", view = view, content = group } 1.40 + slot.put ( " » " ) 1.41 + ui.tag { tag = "span", content = title } 1.42 +end) 1.43 +app.html_title.title = _"Rolemanagement" 1.44 + 1.45 +ui.container{ attr = { class = "mdl-grid" }, content = function() 1.46 + ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function() 1.47 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.48 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.49 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = title } 1.50 + end } 1.51 + 1.52 + 1.53 + ui.form{ 1.54 + module = "registration_admin", action = "update_role_verification", id = verification.id, 1.55 + routing = { ok = { mode = "redirect", module = "registration_admin", view = view } }, 1.56 + record = data, 1.57 + content = function() 1.58 + 1.59 + ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() 1.60 + 1.61 + for i, field in ipairs(config.role_registration.fields) do 1.62 + ui.container{ content = function() 1.63 + ui.field.text{ 1.64 + container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, 1.65 + attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" }, 1.66 + label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name }, 1.67 + label = field.label, 1.68 + name = field.name 1.69 + } 1.70 + 1.71 + ui.tag{ content = verification.request_data[field.name] } 1.72 + end } 1.73 + end 1.74 + 1.75 + ui.field.text{ 1.76 + container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label", style = "width: 30em;" }, 1.77 + attr = { id = "lf-register__data_identification", class = "mdl-textfield__input" }, 1.78 + label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data_identification" }, 1.79 + label = "Identification", 1.80 + name = "identification", 1.81 + value = identification 1.82 + } 1.83 + 1.84 + end } 1.85 + 1.86 + local member = Member:by_id(verification.requesting_member_id) 1.87 + ui.container{ attr = { class = "mdl-card__content" }, content = function() 1.88 + ui.tag{ content = _"Requested by:" } 1.89 + slot.put(" ") 1.90 + ui.link{ content = member.name, module = "member", view = "show", id = member.id } 1.91 + end } 1.92 + 1.93 + ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function() 1.94 + 1.95 + if verification.denied then 1.96 + ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } 1.97 + elseif verification.verified then 1.98 + ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save role data" } 1.99 + slot.put(" ") 1.100 + if not member.activated then 1.101 + ui.submit{ name = "invite", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Send email invitation again" } 1.102 + slot.put(" ") 1.103 + end 1.104 + ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } 1.105 + slot.put(" ") 1.106 + ui.submit{ name = "cancel", attr = { class = "mdl-button mdl-js-button" }, value = _"Delete account" } 1.107 + else 1.108 + ui.submit{ name = "accredit", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Accredit role" } 1.109 + slot.put(" ") 1.110 + ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save role data" } 1.111 + slot.put(" ") 1.112 + ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" } 1.113 + slot.put(" ") 1.114 + ui.submit{ name = "drop", attr = { class = "mdl-button mdl-js-button" }, value = "Reject request" } 1.115 + end 1.116 + end } 1.117 + 1.118 + end 1.119 + } 1.120 + end } 1.121 + 1.122 + local verifications = RoleVerification:new_selector() 1.123 + :join("member", nil, "member.id = role_verification.verified_member_id") 1.124 + :add_where{ "member.identification = ?", identification } 1.125 + :add_where{ "role_verification.id <> ?", verification.id } 1.126 + :exec() 1.127 + 1.128 + if #verifications > 0 then 1.129 + 1.130 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.131 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.132 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function() 1.133 + ui.tag{ content = _"Same identification" } 1.134 + end } 1.135 + end } 1.136 + ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() 1.137 + execute.view{ module = "registration_admin", view = "_role_verification_list", params = { verifications = verifications } } 1.138 + end } 1.139 + end } 1.140 + end 1.141 + 1.142 + for i, field_name in ipairs(config.role_registration.match_fields) do 1.143 + local field 1.144 + for j, f in ipairs(config.role_registration.fields) do 1.145 + if f.name == field_name then 1.146 + field = f 1.147 + end 1.148 + end 1.149 + local verifications = Verification:new_selector() 1.150 + :add_where("verified NOTNULL") 1.151 + :add_where{ "lower(request_data->>'" .. field.name .. "') = lower(?)", data[field.name] } 1.152 + :add_where{ "verification.id <> ?", verification.id } 1.153 + :exec() 1.154 + 1.155 + if #verifications > 0 then 1.156 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.157 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.158 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function() 1.159 + ui.tag{ content = _"Same " .. field.label } 1.160 + end } 1.161 + end } 1.162 + ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() 1.163 + execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } } 1.164 + end } 1.165 + end } 1.166 + end 1.167 + end 1.168 + 1.169 + end } 1.170 +end } 1.171 +