liquid_feedback_frontend
changeset 79:26c8177ef348 beta21
Support for multiple usage terms accept checkboxes
(including neccessary bugfix in member model)
(including neccessary bugfix in member model)
author | bsw |
---|---|
date | Thu Jul 15 18:27:47 2010 +0200 (2010-07-15) |
parents | 5ba4eff4bb5f |
children | d898c9058d2d |
files | app/main/index/_action/register.lua app/main/index/register.lua config/default.lua model/member.lua |
line diff
1.1 --- a/app/main/index/_action/register.lua Wed Jul 14 13:59:54 2010 +0200 1.2 +++ b/app/main/index/_action/register.lua Thu Jul 15 18:27:47 2010 +0200 1.3 @@ -126,9 +126,7 @@ 1.4 return false 1.5 end 1.6 1.7 -local use_terms_accepted = param.get("use_terms_accepted", atom.boolean) 1.8 - 1.9 -if login and use_terms_accepted == nil then 1.10 +if login and param.get("step") ~= "5" then 1.11 request.redirect{ 1.12 mode = "redirect", 1.13 module = "index", 1.14 @@ -143,21 +141,13 @@ 1.15 return false 1.16 end 1.17 1.18 -if use_terms_accepted ~= true then 1.19 - slot.put_into("error", _"You have to accept the terms of use to complete registration.") 1.20 - request.redirect{ 1.21 - mode = "redirect", 1.22 - module = "index", 1.23 - view = "register", 1.24 - params = { 1.25 - code = invite_code.code, 1.26 - notify_email = notify_email, 1.27 - name = name, 1.28 - login = login 1.29 - } 1.30 - } 1.31 - return false 1.32 -end 1.33 +for i, checkbox in ipairs(config.use_terms_checkboxes) do 1.34 + local accepted = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) 1.35 + if not accepted then 1.36 + slot.put_into("error", checkbox.not_accepted_error) 1.37 + return false 1.38 + end 1.39 +end 1.40 1.41 local password1 = param.get("password1") 1.42 local password2 = param.get("password2") 1.43 @@ -174,38 +164,17 @@ 1.44 login = login 1.45 } 1.46 } 1.47 +--]] 1.48 return false 1.49 end 1.50 1.51 if password1 ~= password2 then 1.52 slot.put_into("error", _"Passwords don't match!") 1.53 - request.redirect{ 1.54 - mode = "redirect", 1.55 - module = "index", 1.56 - view = "register", 1.57 - params = { 1.58 - code = invite_code.code, 1.59 - notify_email = notify_email, 1.60 - name = name, 1.61 - login = login 1.62 - } 1.63 - } 1.64 return false 1.65 end 1.66 1.67 if #password1 < 8 then 1.68 slot.put_into("error", _"Passwords must consist of at least 8 characters!") 1.69 - request.redirect{ 1.70 - mode = "redirect", 1.71 - module = "index", 1.72 - view = "register", 1.73 - params = { 1.74 - code = invite_code.code, 1.75 - notify_email = notify_email, 1.76 - name = name, 1.77 - login = login 1.78 - } 1.79 - } 1.80 return false 1.81 end 1.82 1.83 @@ -217,23 +186,17 @@ 1.84 local success = member:set_notify_email(notify_email) 1.85 if not success then 1.86 slot.put_into("error", _"Can't send confirmation email") 1.87 - request.redirect{ 1.88 - mode = "redirect", 1.89 - module = "index", 1.90 - view = "register", 1.91 - params = { 1.92 - code = invite_code.code, 1.93 - notify_email = notify_email, 1.94 - name = name, 1.95 - login = login 1.96 - } 1.97 - } 1.98 return 1.99 end 1.100 1.101 member:set_password(password1) 1.102 member:save() 1.103 1.104 +for i, checkbox in ipairs(config.use_terms_checkboxes) do 1.105 + local accepted = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) 1.106 + member:set_setting("use_terms_checkbox_" .. checkbox.name, "accepted") 1.107 +end 1.108 + 1.109 invite_code.member_id = member.id 1.110 invite_code.used = "now" 1.111 invite_code:save()
2.1 --- a/app/main/index/register.lua Wed Jul 14 13:59:54 2010 +0200 2.2 +++ b/app/main/index/register.lua Thu Jul 15 18:27:47 2010 +0200 2.3 @@ -107,6 +107,7 @@ 2.4 } 2.5 2.6 else 2.7 + ui.field.hidden{ name = "step", value = "5" } 2.8 slot.put_into("title", _"Step 5/5: Terms of use and password") 2.9 slot.select("actions", function() 2.10 ui.link{ 2.11 @@ -126,10 +127,37 @@ 2.12 ui.container{ 2.13 attr = { class = "wiki use_terms" }, 2.14 content = function() 2.15 - slot.put(format.wiki_text(config.use_terms)) 2.16 + if config.use_terms_html then 2.17 + slot.put(config.use_terms_html) 2.18 + else 2.19 + slot.put(format.wiki_text(config.use_terms)) 2.20 + end 2.21 end 2.22 } 2.23 + 2.24 + for i, checkbox in ipairs(config.use_terms_checkboxes) do 2.25 + slot.put("<br />") 2.26 + ui.tag{ 2.27 + tag = "div", 2.28 + content = function() 2.29 + ui.tag{ 2.30 + tag = "input", 2.31 + attr = { 2.32 + type = "checkbox", 2.33 + name = "use_terms_checkbox_" .. checkbox.name, 2.34 + value = "1", 2.35 + style = "float: left;", 2.36 + checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil 2.37 + } 2.38 + } 2.39 + slot.put(" ") 2.40 + slot.put(checkbox.html) 2.41 + end 2.42 + } 2.43 + end 2.44 + 2.45 slot.put("<br />") 2.46 + 2.47 ui.field.text{ 2.48 label = _'Email address', 2.49 value = param.get("notify_email"), 2.50 @@ -148,15 +176,6 @@ 2.51 2.52 ui.tag{ 2.53 tag = "p", 2.54 - content = _"I accept the terms of use by checking the following checkbox:" 2.55 - } 2.56 - ui.field.boolean{ 2.57 - label = _"Terms accepted", 2.58 - name = "use_terms_accepted", 2.59 - } 2.60 - 2.61 - ui.tag{ 2.62 - tag = "p", 2.63 content = _"Please choose a password and enter it twice. The password is case sensitive." 2.64 } 2.65 ui.field.password{
3.1 --- a/config/default.lua Wed Jul 14 13:59:54 2010 +0200 3.2 +++ b/config/default.lua Thu Jul 15 18:27:47 2010 +0200 3.3 @@ -1,5 +1,5 @@ 3.4 config.app_name = "LiquidFeedback" 3.5 -config.app_version = "beta20" 3.6 +config.app_version = "beta21" 3.7 3.8 config.app_title = config.app_name .. " (" .. request.get_config_name() .. " environment)" 3.9 3.10 @@ -8,6 +8,16 @@ 3.11 config.app_service_provider = "Snake Oil<br/>10000 Berlin<br/>Germany" 3.12 3.13 config.use_terms = "=== Nutzungsbedingungen ===\nAlles ist verboten" 3.14 +--config.use_terms_html = "" 3.15 + 3.16 +config.use_terms_checkboxes = { 3.17 + { 3.18 + name = "nutzungsbedingungen_v1", 3.19 + html = "Ich akzeptiere die Bedingungen.", 3.20 + not_accepted_error = "Du musst die Bedingungen akzeptieren, um dich zu registrieren." 3.21 + } 3.22 +} 3.23 + 3.24 3.25 config.member_image_content_type = "image/jpeg" 3.26 config.member_image_convert_func = {
4.1 --- a/model/member.lua Wed Jul 14 13:59:54 2010 +0200 4.2 +++ b/model/member.lua Thu Jul 15 18:27:47 2010 +0200 4.3 @@ -317,11 +317,11 @@ 4.4 end 4.5 4.6 function Member.object:get_setting(key) 4.7 - return Setting:by_pk(app.session.member.id, key) 4.8 + return Setting:by_pk(self.id, key) 4.9 end 4.10 4.11 function Member.object:get_setting_value(key) 4.12 - local setting = Setting:by_pk(app.session.member.id, key) 4.13 + local setting = Setting:by_pk(self.id, key) 4.14 if setting then 4.15 return setting.value 4.16 end 4.17 @@ -331,7 +331,7 @@ 4.18 local setting = self:get_setting(key) 4.19 if not setting then 4.20 setting = Setting:new() 4.21 - setting.member_id = app.session.member_id 4.22 + setting.member_id = self.id 4.23 setting.key = key 4.24 end 4.25 setting.value = value