liquid_feedback_frontend

diff app/main/index/register.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 aefef1556d55
children
line diff
     1.1 --- a/app/main/index/register.lua	Thu Jun 23 03:30:57 2016 +0200
     1.2 +++ b/app/main/index/register.lua	Sun Jul 15 14:07:29 2018 +0200
     1.3 @@ -5,7 +5,7 @@
     1.4  end
     1.5  
     1.6  if config.registration_disabled and not ldap_uid then
     1.7 -  error("registration disabled")
     1.8 +  return execute.view { module = "index", view = "404" }
     1.9  end
    1.10  
    1.11  execute.view{ module = "index", view = "_lang_chooser" }
    1.12 @@ -33,28 +33,21 @@
    1.13  
    1.14  
    1.15  
    1.16 -ui.section( function()
    1.17 -
    1.18 +ui.container{ attr = { class = "mdl-grid" }, content = function()
    1.19 +  ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
    1.20 +  ui.heading{ level = 1, content = _"Account registration" }
    1.21 +--[[
    1.22    if not code and not ldap_uid then
    1.23 -    ui.title(_"Registration (step 1 of 3: Invite code)")
    1.24 -    ui.sectionHead( function()
    1.25 -      ui.heading { level = 1, content = _"Invite code" }
    1.26 -    end )
    1.27 +    ui.heading{ level = 1, content = _"Registration (step 1 of 3: Invite code)" }
    1.28    elseif (not member.notify_email and not notify_email)
    1.29           or (not member.name and not name)
    1.30           or (not member.login and not login and not member.authority)
    1.31           or step == 1 then
    1.32 -    ui.title(_"Registration (step 2 of 3: Personal information)")
    1.33 -    ui.sectionHead( function()
    1.34 -      ui.heading { level = 1, content = _"Check and enter personal data" }
    1.35 -    end )
    1.36 +    ui.heading { level = 1, content = _"Registration (step 2 of 3: Personal information)" }
    1.37    else
    1.38 -    ui.title(_"Registration (step 3 of 3: Terms of use and password)")
    1.39 -    ui.sectionHead( function()
    1.40 -      ui.heading { level = 1, content = _"Read and accept the terms and choose a password" }
    1.41 -    end )
    1.42 +    ui.heading { level = 1, content = _"Registration (step 3 of 3: Terms of use and password)" }
    1.43    end
    1.44 -
    1.45 +--]]
    1.46    ui.sectionRow( function()
    1.47      ui.form{
    1.48        attr = { class = "wide" },
    1.49 @@ -64,20 +57,34 @@
    1.50          code = code,
    1.51          notify_email = notify_email,
    1.52          name = name,
    1.53 -        login = login
    1.54 +        login = login,
    1.55 +        skip = param.get("skip"),
    1.56 +        redirect_module = param.get("redirect_module"),
    1.57 +        redirect_view = param.get("redirect_view"),
    1.58 +        redirect_id = param.get("redirect_id"),
    1.59 +        redirect_params = param.get("redirect_params")
    1.60        },
    1.61        content = function()
    1.62  
    1.63          if not code and not ldap_uid then
    1.64            ui.field.hidden{ name = "step", value = 1 }
    1.65 -          ui.heading { level = 2, content = _"Please enter the invite code you've received" }
    1.66 +          ui.tag { tag = "p", content = _"Please enter the invite code you've received" }
    1.67            ui.field.text{
    1.68 -            name  = 'code',
    1.69 -            value = param.get("invite")
    1.70 +            container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
    1.71 +            attr = { id = "lf-register__code", class = "mdl-textfield__input" },
    1.72 +            label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
    1.73 +            label     = _'Invite code',
    1.74 +            name = 'code',
    1.75 +            value     = ''
    1.76            }
    1.77 -          ui.submit{
    1.78 -            text = _'proceed with registration',
    1.79 -              attr = { class = "btn btn-default" }
    1.80 +          slot.put("<br /><br />")
    1.81 +          ui.tag{
    1.82 +            tag = "input",
    1.83 +            attr = {
    1.84 +              type = "submit",
    1.85 +              class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
    1.86 +              value = _'proceed with registration'
    1.87 +            }
    1.88            }
    1.89            slot.put(" ")
    1.90          else
    1.91 @@ -94,125 +101,182 @@
    1.92              
    1.93              execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
    1.94  
    1.95 -            if not util.is_profile_field_locked(member, "notify_email") then
    1.96 -              ui.heading { level = 2, content = _'Email address' }
    1.97 +            slot.put("<br /><br />")
    1.98 +            
    1.99 +            if not util.is_profile_field_locked(member, "notify_email") and not member.notify_email then
   1.100                ui.tag{
   1.101                  tag = "p",
   1.102                  content = _"Please enter your email address. This address will be used for automatic notifications (if you request them) and in case you've lost your password. This address will not be published. After registration you will receive an email with a confirmation link."
   1.103                }
   1.104                ui.field.text{
   1.105 -                name      = 'notify_email',
   1.106 +                container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
   1.107 +                attr = { id = "lf-register__code", class = "mdl-textfield__input" },
   1.108 +                label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
   1.109 +                label     = _'Email address',
   1.110 +                name = 'notify_email',
   1.111                  value     = param.get("notify_email") or member.notify_email
   1.112                }
   1.113              end
   1.114              if not util.is_profile_field_locked(member, "name") then
   1.115 -              ui.heading { level = 2, content = _'Screen name' }
   1.116                ui.tag{
   1.117                  tag = "p",
   1.118                  content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
   1.119                }
   1.120                ui.field.text{
   1.121 +                container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
   1.122 +                attr = { id = "lf-register__code", class = "mdl-textfield__input" },
   1.123 +                label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
   1.124 +                label     = _'Screen name',
   1.125                  name      = 'name',
   1.126                  value     = param.get("name") or member.name
   1.127                }
   1.128              end
   1.129              if not util.is_profile_field_locked(member, "login") then
   1.130 -              ui.heading { level = 2, content = _'Login name' }
   1.131                ui.tag{
   1.132                  tag = "p",
   1.133                  content = _"Please choose a login name. This name will not be shown to others and is used only by you to login into the system. The login name is case sensitive."
   1.134                }
   1.135                ui.field.text{
   1.136 +                container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
   1.137 +                attr = { id = "lf-register__code", class = "mdl-textfield__input" },
   1.138 +                label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
   1.139 +                label     = _'Login name',
   1.140                  name      = 'login',
   1.141                  value     = param.get("login") or member.login
   1.142                }
   1.143              end
   1.144 -            ui.submit{
   1.145 -              text = _'proceed with registration',
   1.146 -              attr = { class = "btn btn-default" }
   1.147 -            }
   1.148 -            slot.put(" ")
   1.149 -            ui.link{
   1.150 -              content = _"one step back",
   1.151 -              module = "index",
   1.152 -              view = "register",
   1.153 -              params = {
   1.154 -                invite = code
   1.155 +            slot.put("<br /><br />")
   1.156 +            ui.tag{
   1.157 +              tag = "input",
   1.158 +              attr = {
   1.159 +                type = "submit",
   1.160 +                class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
   1.161 +                value = _'proceed with registration'
   1.162                }
   1.163              }
   1.164 -          else
   1.165 -
   1.166 +            if param.get("skip") ~= "1" then
   1.167 +              slot.put(" ")
   1.168 +              ui.link{
   1.169 +                attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   1.170 +                content = _"one step back",
   1.171 +                module = "index",
   1.172 +                view = "register",
   1.173 +                params = {
   1.174 +                  invite = code,
   1.175 +                  redirect_module = param.get("redirect_module"),
   1.176 +                  redirect_view = param.get("redirect_view"),
   1.177 +                  redirect_id = param.get("redirect_id"),
   1.178 +                  redirect_params = param.get("redirect_params")
   1.179 +                }
   1.180 +              }
   1.181 +              end
   1.182 +            else
   1.183              ui.field.hidden{ name = "step", value = "3" }
   1.184 -            ui.container{
   1.185 -              attr = { class = "wiki use_terms" },
   1.186 -              content = function()
   1.187 -                slot.put(config.use_terms)
   1.188 -              end
   1.189 -            }
   1.190 +
   1.191 +            local need_to_accept_terms = false
   1.192  
   1.193              for i, checkbox in ipairs(config.use_terms_checkboxes) do
   1.194 -              slot.put("<br />")
   1.195 -              ui.tag{
   1.196 -                tag = "div",
   1.197 +              local member_useterms = MemberUseterms:new_selector()
   1.198 +                :add_where{ "member_id = ?", member.id }
   1.199 +                :add_where{ "contract_identifier = ?", checkbox.name }
   1.200 +                :exec()
   1.201 +              if #member_useterms == 0 then
   1.202 +                need_to_accept_terms = true
   1.203 +              end
   1.204 +            end
   1.205 +            
   1.206 +            if need_to_accept_terms then
   1.207 +              ui.container{
   1.208 +                attr = { class = "wiki use_terms" },
   1.209                  content = function()
   1.210 +                  slot.put(config.use_terms)
   1.211 +                end
   1.212 +              }
   1.213 +
   1.214 +              for i, checkbox in ipairs(config.use_terms_checkboxes) do
   1.215 +                local member_useterms = MemberUseterms:new_selector()
   1.216 +                  :add_where{ "member_id = ?", member.id }
   1.217 +                  :add_where{ "contract_identifier = ?", checkbox.name }
   1.218 +                  :exec()
   1.219 +                if #member_useterms == 0 then
   1.220 +                  slot.put("<br />")
   1.221                    ui.tag{
   1.222 -                    tag = "input",
   1.223 -                    attr = {
   1.224 -                      type = "checkbox",
   1.225 -                      id = "use_terms_checkbox_" .. checkbox.name,
   1.226 -                      name = "use_terms_checkbox_" .. checkbox.name,
   1.227 -                      value = "1",
   1.228 -                      style = "float: left;",
   1.229 -                      checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
   1.230 -                    }
   1.231 -                  }
   1.232 -                  slot.put("&nbsp;")
   1.233 -                  ui.tag{
   1.234 -                    tag = "label",
   1.235 -                    attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
   1.236 -                    content = function() slot.put(checkbox.html) end
   1.237 +                    tag = "div",
   1.238 +                    content = function()
   1.239 +                      ui.tag{
   1.240 +                        tag = "input",
   1.241 +                        attr = {
   1.242 +                          type = "checkbox",
   1.243 +                          id = "use_terms_checkbox_" .. checkbox.name,
   1.244 +                          name = "use_terms_checkbox_" .. checkbox.name,
   1.245 +                          value = "1",
   1.246 +                          style = "float: left;",
   1.247 +                          checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
   1.248 +                        }
   1.249 +                      }
   1.250 +                      slot.put("&nbsp;")
   1.251 +                      ui.tag{
   1.252 +                        tag = "label",
   1.253 +                        attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
   1.254 +                        content = function() slot.put(checkbox.html) end
   1.255 +                      }
   1.256 +                    end
   1.257                    }
   1.258                  end
   1.259 -              }
   1.260 -            end
   1.261 +              end
   1.262  
   1.263 -            slot.put("<br />")
   1.264 -
   1.265 +              slot.put("<br />")
   1.266 +            end
   1.267 +        
   1.268              member.notify_email = notify_email or member.notify_email
   1.269              member.name = name or member.name
   1.270              member.login = login or member.login
   1.271              
   1.272 -            ui.heading { level = 2, content = _"Personal information" }
   1.273 -            execute.view{ module = "member", view = "_profile", params = {
   1.274 -              member = member, include_private_data = true
   1.275 -            } }
   1.276 -            ui.field.text{
   1.277 -              readonly  = true,
   1.278 -              label     = _'Login name',
   1.279 -              name      = 'login',
   1.280 -              value     = member.login
   1.281 -            }
   1.282 +--            ui.heading { level = 2, content = _"Personal information" }
   1.283 +--            execute.view{ module = "member", view = "_profile", params = {
   1.284 +--              member = member, include_private_data = true
   1.285 +--            } }
   1.286 +--            ui.field.text{
   1.287 +--              readonly  = true,
   1.288 +--              label     = _'Login name',
   1.289 +--              name      = 'login',
   1.290 +--              value     = member.login
   1.291 +--            }
   1.292              
   1.293              if not (member.authority == "ldap") then
   1.294 -              ui.heading { level = 2, content = _'Password' }
   1.295                ui.tag{
   1.296                  tag = "p",
   1.297                  content = _"Please choose a password and enter it twice. The password is case sensitive."
   1.298                }
   1.299                ui.field.password{
   1.300 +                container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
   1.301 +                attr = { id = "lf-register__code", class = "mdl-textfield__input" },
   1.302 +                label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
   1.303 +                label     = _'Password',
   1.304                  name      = 'password1',
   1.305                }
   1.306 +              slot.put("<br />")
   1.307                ui.field.password{
   1.308 +                container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
   1.309 +                attr = { id = "lf-register__code", class = "mdl-textfield__input" },
   1.310 +                label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
   1.311 +                label     = _'Repeat password',
   1.312                  name      = 'password2',
   1.313                }
   1.314              end
   1.315              
   1.316 -            ui.submit{
   1.317 -              text = _'activate account',
   1.318 -              attr = { class = "btn btn-default" }
   1.319 +            slot.put("<br /><br />")
   1.320 +            ui.tag{
   1.321 +              tag = "input",
   1.322 +              attr = {
   1.323 +                type = "submit",
   1.324 +                class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
   1.325 +                value = _'activate account'
   1.326 +              }
   1.327              }
   1.328              slot.put(" ")
   1.329              ui.link{
   1.330 +              attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   1.331                content = _"one step back",
   1.332                module = "index",
   1.333                view = "register",
   1.334 @@ -220,8 +284,13 @@
   1.335                  code = code,
   1.336                  notify_email = notify_email,
   1.337                  name = name,
   1.338 -                login = login, 
   1.339 -                step = 1
   1.340 +                login = login,
   1.341 +                skip = param.get("skip"),
   1.342 +                step = 1,
   1.343 +                redirect_module = param.get("redirect_module"),
   1.344 +                redirect_view = param.get("redirect_view"),
   1.345 +                redirect_id = param.get("redirect_id"),
   1.346 +                redirect_params = param.get("redirect_params")
   1.347                }
   1.348              }
   1.349            end
   1.350 @@ -232,13 +301,20 @@
   1.351      slot.put("<br /><br />")
   1.352  
   1.353      ui.link{
   1.354 -      content = _"cancel registration",
   1.355 +      attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" },
   1.356 +      content = _"cancel",
   1.357        module = "index",
   1.358        action = "cancel_register",
   1.359        routing = { default = {
   1.360 -        mode = "redirect", module = "index", view = "index"
   1.361 +        mode = "redirect", module = "index", view = "login", params = {
   1.362 +          redirect_module = param.get("redirect_module"),
   1.363 +          redirect_view = param.get("redirect_view"),
   1.364 +          redirect_id = param.get("redirect_id"),
   1.365 +          redirect_params = param.get("redirect_params")
   1.366 +        }
   1.367        } }
   1.368      }
   1.369    end )
   1.370 -end )
   1.371 +  end }
   1.372 +end }
   1.373  

Impressum / About Us