# HG changeset patch # User Daniel Poelzleithner # Date 1286498993 -7200 # Node ID 034f96181e59e710ae92624606e9b2cbe76fd228 # Parent f5692aafc85bb1c5eb68f1405ef431f9c06630a3 gui part for autosupport autosupport lets you automaticly support any new draft of an initiative diff -r f5692aafc85b -r 034f96181e59 app/main/initiative/_action/add_support.lua --- a/app/main/initiative/_action/add_support.lua Thu Oct 07 04:45:06 2010 +0200 +++ b/app/main/initiative/_action/add_support.lua Fri Oct 08 02:49:53 2010 +0200 @@ -1,4 +1,5 @@ local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() +local auto_support = param.get("auto_support", atom.boolean) -- TODO important m1 selectors returning result _SET_! local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec() @@ -32,12 +33,26 @@ supporter.member_id = member.id supporter.initiative_id = initiative.id supporter.draft_id = last_draft.id + supporter.auto_support = auto_support supporter:save() slot.put_into("notice", _"Your support has been added to this initiative") + if supporter.auto_active then + slot.put_into("notice", _"Auto support is now enabled") + end +elseif (auto_support ~= nil and supporter.auto_support ~= auto_support) and config.auto_support then + supporter.auto_support = auto_support + if auto_support then + slot.put_into("notice", _"Auto support is now enabled") + else + slot.put_into("notice", _"Auto support is now disabled") + end + supporter.draft_id = last_draft.id + supporter:save() elseif supporter.draft_id ~= last_draft.id then supporter.draft_id = last_draft.id supporter:save() slot.put_into("notice", _"Your support has been updated to the latest draft") else slot.put_into("notice", _"You are already supporting the latest draft") -end \ No newline at end of file +end + diff -r f5692aafc85b -r 034f96181e59 app/main/member_image/show.lua --- a/app/main/member_image/show.lua Thu Oct 07 04:45:06 2010 +0200 +++ b/app/main/member_image/show.lua Fri Oct 08 02:49:53 2010 +0200 @@ -1,6 +1,8 @@ local image_type = param.get("image_type") local record = MemberImage:by_pk(param.get_id(), image_type, true) +print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes + if record == nil then local default_file = config.member_image_default_file[image_type] if default_file then diff -r f5692aafc85b -r 034f96181e59 app/main/supporter/_show_box.lua --- a/app/main/supporter/_show_box.lua Thu Oct 07 04:45:06 2010 +0200 +++ b/app/main/supporter/_show_box.lua Fri Oct 08 02:49:53 2010 +0200 @@ -39,7 +39,11 @@ ui.image{ static = "icons/16/thumb_up_green.png" } - slot.put(_"Your are supporter") + if supporter.auto_support then + slot.put(_"Your are supporter (Autosupport enabled)") + else + slot.put(_"Your are supporter") + end ui.image{ static = "icons/16/dropdown.png" } @@ -56,7 +60,11 @@ ui.image{ static = "icons/16/thumb_up.png" } - slot.put(_"Your are potential supporter") + if supporter.auto_support then + slot.put(_"Your are potential supporter (WARNING: Autosupport enabled)") + else + slot.put(_"Your are potential supporter") + end ui.image{ static = "icons/16/dropdown.png" } @@ -77,6 +85,31 @@ end } if supporter then + if config.auto_support then + if supporter.auto_support then + ui.link{ + image = { static = "icons/16/cancel.png" }, + text = _"Disable autosupport for this initiative", + module = "initiative", + action = "add_support", + id = initiative.id, + routing = routing, + partial = partial, + params = { auto_support = false } + } + else + ui.link{ + image = { static = "icons/16/tick.png" }, + text = _"Enable autosupport for this initiative", + module = "initiative", + action = "add_support", + id = initiative.id, + routing = routing, + partial = partial, + params = { auto_support = true } + } + end + end ui.link{ image = { static = "icons/16/thumb_down_red.png" }, text = _"Remove my support from this initiative", diff -r f5692aafc85b -r 034f96181e59 config/default.lua --- a/config/default.lua Thu Oct 07 04:45:06 2010 +0200 +++ b/config/default.lua Fri Oct 08 02:49:53 2010 +0200 @@ -32,6 +32,8 @@ photo = nil } +config.auto_support = true + config.mail_subject_prefix = "[LiquidFeedback] " config.fastpath_url_func = nil