| rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 local verification = RoleVerification:by_id(param.get_id())
 | 
| 
bsw/jbe@1309
 | 
     2 local data = verification.verification_data or verification.request_data
 | 
| 
bsw/jbe@1309
 | 
     3 
 | 
| 
bsw/jbe@1309
 | 
     4 local identification = config.role_registration.identification_func(data)
 | 
| 
bsw/jbe@1309
 | 
     5 local member
 | 
| 
bsw/jbe@1309
 | 
     6 if verification.verified_member_id then
 | 
| 
bsw/jbe@1309
 | 
     7   member = Member:by_id(verification.verified_member_id)
 | 
| 
bsw/jbe@1309
 | 
     8   identification = member.identification
 | 
| 
bsw/jbe@1309
 | 
     9 end
 | 
| 
bsw/jbe@1309
 | 
    10 
 | 
| 
bsw/jbe@1309
 | 
    11 local group, title, view
 | 
| 
bsw/jbe@1309
 | 
    12 if verification.verified then
 | 
| 
bsw/jbe@1309
 | 
    13   if member.deleted then
 | 
| 
bsw/jbe@1309
 | 
    14     group = _"Cancelled accounts"
 | 
| 
bsw/jbe@1309
 | 
    15     title = _"Cancelled account"
 | 
| 
bsw/jbe@1309
 | 
    16     view = "role_verification_cancelled"
 | 
| 
bsw/jbe@1309
 | 
    17   else
 | 
| 
bsw/jbe@1309
 | 
    18     group = _"Accredited users"
 | 
| 
bsw/jbe@1309
 | 
    19     title = member.identification
 | 
| 
bsw/jbe@1309
 | 
    20     view = "role_verification_accredited"
 | 
| 
bsw/jbe@1309
 | 
    21   end
 | 
| 
bsw/jbe@1309
 | 
    22 elseif verification.denied then
 | 
| 
bsw/jbe@1309
 | 
    23   group = "Rejected requests"
 | 
| 
bsw/jbe@1309
 | 
    24   title = _"Rejected request"
 | 
| 
bsw/jbe@1309
 | 
    25   view = "role_verification_rejected"
 | 
| 
bsw/jbe@1309
 | 
    26 else
 | 
| 
bsw/jbe@1309
 | 
    27   group = "Open requests"
 | 
| 
bsw/jbe@1309
 | 
    28   title = _"Open request"
 | 
| 
bsw/jbe@1309
 | 
    29   view = "role_verification_requests"
 | 
| 
bsw/jbe@1309
 | 
    30 end
 | 
| 
bsw/jbe@1309
 | 
    31 
 | 
| 
bsw/jbe@1309
 | 
    32 
 | 
| 
bsw/jbe@1309
 | 
    33 ui.title(function()
 | 
| 
bsw@1326
 | 
    34   ui.link { module = "registration_admin", view = "index", content = _"Role management" }
 | 
| 
bsw/jbe@1309
 | 
    35   slot.put ( " » " )
 | 
| 
bsw/jbe@1309
 | 
    36   ui.link { module = "registration_admin", view = view, content = group }
 | 
| 
bsw/jbe@1309
 | 
    37   slot.put ( " » " )
 | 
| 
bsw/jbe@1309
 | 
    38   ui.tag { tag = "span", content = title }
 | 
| 
bsw/jbe@1309
 | 
    39 end)
 | 
| 
bsw@1326
 | 
    40 app.html_title.title = _"Role management"
 | 
| 
bsw/jbe@1309
 | 
    41 
 | 
| 
bsw/jbe@1309
 | 
    42 ui.container{ attr = { class = "mdl-grid" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    43   ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    44     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    45       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    46         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = title }
 | 
| 
bsw/jbe@1309
 | 
    47       end }
 | 
| 
bsw/jbe@1309
 | 
    48 
 | 
| 
bsw/jbe@1309
 | 
    49 
 | 
| 
bsw/jbe@1309
 | 
    50       ui.form{
 | 
| 
bsw/jbe@1309
 | 
    51         module = "registration_admin", action = "update_role_verification", id = verification.id,
 | 
| 
bsw/jbe@1309
 | 
    52         routing = { ok = { mode = "redirect", module = "registration_admin", view = view } },
 | 
| 
bsw/jbe@1309
 | 
    53         record = data,
 | 
| 
bsw/jbe@1309
 | 
    54         content = function()
 | 
| 
bsw/jbe@1309
 | 
    55             
 | 
| 
bsw/jbe@1309
 | 
    56           ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    57 
 | 
| 
bsw/jbe@1309
 | 
    58             for i, field in ipairs(config.role_registration.fields) do
 | 
| 
bsw/jbe@1309
 | 
    59               ui.container{ content = function()
 | 
| 
bsw/jbe@1309
 | 
    60                 ui.field.text{
 | 
| 
bsw/jbe@1309
 | 
    61                   container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
 | 
| 
bsw/jbe@1309
 | 
    62                   attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
 | 
| 
bsw/jbe@1309
 | 
    63                   label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
 | 
| 
bsw/jbe@1309
 | 
    64                   label = field.label,
 | 
| 
bsw/jbe@1309
 | 
    65                   name = field.name
 | 
| 
bsw/jbe@1309
 | 
    66                 }
 | 
| 
bsw/jbe@1309
 | 
    67                 
 | 
| 
bsw/jbe@1309
 | 
    68                 ui.tag{ content = verification.request_data[field.name] }
 | 
| 
bsw/jbe@1309
 | 
    69               end }
 | 
| 
bsw/jbe@1309
 | 
    70             end
 | 
| 
bsw/jbe@1309
 | 
    71             
 | 
| 
bsw/jbe@1309
 | 
    72             ui.field.text{
 | 
| 
bsw/jbe@1309
 | 
    73               container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label", style = "width: 30em;" },
 | 
| 
bsw/jbe@1309
 | 
    74               attr = { id = "lf-register__data_identification", class = "mdl-textfield__input" },
 | 
| 
bsw/jbe@1309
 | 
    75               label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data_identification" },
 | 
| 
bsw/jbe@1309
 | 
    76               label = "Identification",
 | 
| 
bsw/jbe@1309
 | 
    77               name = "identification",
 | 
| 
bsw/jbe@1309
 | 
    78               value = identification
 | 
| 
bsw/jbe@1309
 | 
    79             }
 | 
| 
bsw/jbe@1309
 | 
    80             
 | 
| 
bsw/jbe@1309
 | 
    81           end }
 | 
| 
bsw/jbe@1309
 | 
    82           
 | 
| 
bsw/jbe@1309
 | 
    83           local member = Member:by_id(verification.requesting_member_id)
 | 
| 
bsw/jbe@1309
 | 
    84           ui.container{ attr = { class = "mdl-card__content" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    85             ui.tag{ content = _"Requested by:" }
 | 
| 
bsw/jbe@1309
 | 
    86             slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
    87             ui.link{ content = member.name, module = "member", view = "show", id = member.id }
 | 
| 
bsw/jbe@1309
 | 
    88           end }
 | 
| 
bsw/jbe@1309
 | 
    89 
 | 
| 
bsw/jbe@1309
 | 
    90           ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    91             
 | 
| 
bsw/jbe@1309
 | 
    92             if verification.denied then
 | 
| 
bsw/jbe@1309
 | 
    93               ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
 | 
| 
bsw/jbe@1309
 | 
    94             elseif verification.verified then
 | 
| 
bsw/jbe@1309
 | 
    95               ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save role data" }
 | 
| 
bsw/jbe@1309
 | 
    96               slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
    97               if not member.activated then
 | 
| 
bsw/jbe@1309
 | 
    98                 ui.submit{ name = "invite", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Send email invitation again" }
 | 
| 
bsw/jbe@1309
 | 
    99                 slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   100               end
 | 
| 
bsw/jbe@1309
 | 
   101               ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
 | 
| 
bsw/jbe@1309
 | 
   102               slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   103               ui.submit{ name = "cancel", attr = { class = "mdl-button mdl-js-button" }, value = _"Delete account" }
 | 
| 
bsw/jbe@1309
 | 
   104             else
 | 
| 
bsw/jbe@1309
 | 
   105               ui.submit{ name = "accredit", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Accredit role" }
 | 
| 
bsw/jbe@1309
 | 
   106               slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   107               ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save role data" }
 | 
| 
bsw/jbe@1309
 | 
   108               slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   109               ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
 | 
| 
bsw/jbe@1309
 | 
   110               slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   111               ui.submit{ name = "drop", attr = { class = "mdl-button mdl-js-button" }, value = "Reject request" }
 | 
| 
bsw/jbe@1309
 | 
   112             end
 | 
| 
bsw/jbe@1309
 | 
   113           end }
 | 
| 
bsw/jbe@1309
 | 
   114       
 | 
| 
bsw/jbe@1309
 | 
   115         end 
 | 
| 
bsw/jbe@1309
 | 
   116       }
 | 
| 
bsw/jbe@1309
 | 
   117     end }
 | 
| 
bsw/jbe@1309
 | 
   118       
 | 
| 
bsw/jbe@1309
 | 
   119     local verifications = RoleVerification:new_selector()
 | 
| 
bsw/jbe@1309
 | 
   120       :join("member", nil, "member.id = role_verification.verified_member_id")
 | 
| 
bsw/jbe@1309
 | 
   121       :add_where{ "member.identification = ?", identification }
 | 
| 
bsw/jbe@1309
 | 
   122       :add_where{ "role_verification.id <> ?", verification.id }
 | 
| 
bsw/jbe@1309
 | 
   123       :exec()
 | 
| 
bsw/jbe@1309
 | 
   124       
 | 
| 
bsw/jbe@1309
 | 
   125     if #verifications > 0 then
 | 
| 
bsw/jbe@1309
 | 
   126           
 | 
| 
bsw/jbe@1309
 | 
   127       ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   128         ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   129           ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
 | 
| 
bsw/jbe@1309
 | 
   130             ui.tag{ content = _"Same identification" }
 | 
| 
bsw/jbe@1309
 | 
   131           end }
 | 
| 
bsw/jbe@1309
 | 
   132         end }
 | 
| 
bsw/jbe@1309
 | 
   133         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   134           execute.view{ module = "registration_admin", view = "_role_verification_list", params = { verifications = verifications } }
 | 
| 
bsw/jbe@1309
 | 
   135         end }
 | 
| 
bsw/jbe@1309
 | 
   136       end }
 | 
| 
bsw/jbe@1309
 | 
   137     end
 | 
| 
bsw/jbe@1309
 | 
   138     
 | 
| 
bsw/jbe@1309
 | 
   139     for i, field_name in ipairs(config.role_registration.match_fields) do
 | 
| 
bsw/jbe@1309
 | 
   140       local field
 | 
| 
bsw/jbe@1309
 | 
   141       for j, f in ipairs(config.role_registration.fields) do
 | 
| 
bsw/jbe@1309
 | 
   142         if f.name == field_name then
 | 
| 
bsw/jbe@1309
 | 
   143           field = f
 | 
| 
bsw/jbe@1309
 | 
   144         end
 | 
| 
bsw/jbe@1309
 | 
   145       end
 | 
| 
bsw/jbe@1309
 | 
   146       local verifications = Verification:new_selector()
 | 
| 
bsw/jbe@1309
 | 
   147         :add_where("verified NOTNULL")
 | 
| 
bsw/jbe@1309
 | 
   148         :add_where{ "lower(request_data->>'" .. field.name .. "') = lower(?)", data[field.name] }
 | 
| 
bsw/jbe@1309
 | 
   149         :add_where{ "verification.id <> ?", verification.id }
 | 
| 
bsw/jbe@1309
 | 
   150         :exec()
 | 
| 
bsw/jbe@1309
 | 
   151         
 | 
| 
bsw/jbe@1309
 | 
   152       if #verifications > 0 then
 | 
| 
bsw/jbe@1309
 | 
   153         ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   154           ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   155             ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
 | 
| 
bsw/jbe@1309
 | 
   156               ui.tag{ content = _"Same " .. field.label }
 | 
| 
bsw/jbe@1309
 | 
   157             end }
 | 
| 
bsw/jbe@1309
 | 
   158           end }
 | 
| 
bsw/jbe@1309
 | 
   159           ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   160             execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } }
 | 
| 
bsw/jbe@1309
 | 
   161           end }
 | 
| 
bsw/jbe@1309
 | 
   162         end }
 | 
| 
bsw/jbe@1309
 | 
   163       end
 | 
| 
bsw/jbe@1309
 | 
   164     end
 | 
| 
bsw/jbe@1309
 | 
   165     
 | 
| 
bsw/jbe@1309
 | 
   166   end }
 | 
| 
bsw/jbe@1309
 | 
   167 end }
 | 
| 
bsw/jbe@1309
 | 
   168 
 |