liquid_feedback_frontend

changeset 148:034f96181e59

gui part for autosupport

autosupport lets you automaticly support any new draft of an initiative
author Daniel Poelzleithner <poelzi@poelzi.org>
date Fri Oct 08 02:49:53 2010 +0200 (2010-10-08)
parents f5692aafc85b
children d87097d3b6ec
files app/main/initiative/_action/add_support.lua app/main/member_image/show.lua app/main/supporter/_show_box.lua config/default.lua
line diff
     1.1 --- a/app/main/initiative/_action/add_support.lua	Thu Oct 07 04:45:06 2010 +0200
     1.2 +++ b/app/main/initiative/_action/add_support.lua	Fri Oct 08 02:49:53 2010 +0200
     1.3 @@ -1,4 +1,5 @@
     1.4  local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
     1.5 +local auto_support = param.get("auto_support", atom.boolean)
     1.6  
     1.7  -- TODO important m1 selectors returning result _SET_!
     1.8  local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
     1.9 @@ -32,12 +33,26 @@
    1.10    supporter.member_id = member.id
    1.11    supporter.initiative_id = initiative.id
    1.12    supporter.draft_id = last_draft.id
    1.13 +  supporter.auto_support = auto_support
    1.14    supporter:save()
    1.15    slot.put_into("notice", _"Your support has been added to this initiative")
    1.16 +  if supporter.auto_active then
    1.17 +    slot.put_into("notice", _"Auto support is now enabled")
    1.18 +  end
    1.19 +elseif (auto_support ~= nil and supporter.auto_support ~= auto_support) and config.auto_support then
    1.20 +  supporter.auto_support = auto_support
    1.21 +  if auto_support then
    1.22 +    slot.put_into("notice", _"Auto support is now enabled")
    1.23 +  else
    1.24 +    slot.put_into("notice", _"Auto support is now disabled")
    1.25 +  end
    1.26 +  supporter.draft_id = last_draft.id
    1.27 +  supporter:save()
    1.28  elseif supporter.draft_id ~= last_draft.id then
    1.29    supporter.draft_id = last_draft.id
    1.30    supporter:save()
    1.31    slot.put_into("notice", _"Your support has been updated to the latest draft")
    1.32  else
    1.33    slot.put_into("notice", _"You are already supporting the latest draft")
    1.34 -end
    1.35 \ No newline at end of file
    1.36 +end
    1.37 +
     2.1 --- a/app/main/member_image/show.lua	Thu Oct 07 04:45:06 2010 +0200
     2.2 +++ b/app/main/member_image/show.lua	Fri Oct 08 02:49:53 2010 +0200
     2.3 @@ -1,6 +1,8 @@
     2.4  local image_type = param.get("image_type")
     2.5  local record = MemberImage:by_pk(param.get_id(), image_type, true)
     2.6  
     2.7 +print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes
     2.8 +
     2.9  if record == nil then
    2.10    local default_file = config.member_image_default_file[image_type]
    2.11    if default_file then
     3.1 --- a/app/main/supporter/_show_box.lua	Thu Oct 07 04:45:06 2010 +0200
     3.2 +++ b/app/main/supporter/_show_box.lua	Fri Oct 08 02:49:53 2010 +0200
     3.3 @@ -39,7 +39,11 @@
     3.4            ui.image{
     3.5              static = "icons/16/thumb_up_green.png"
     3.6            }
     3.7 -          slot.put(_"Your are supporter")
     3.8 +          if supporter.auto_support then
     3.9 +            slot.put(_"Your are supporter (Autosupport enabled)")
    3.10 +          else
    3.11 +            slot.put(_"Your are supporter")
    3.12 +          end
    3.13            ui.image{
    3.14              static = "icons/16/dropdown.png"
    3.15            }
    3.16 @@ -56,7 +60,11 @@
    3.17            ui.image{
    3.18              static = "icons/16/thumb_up.png"
    3.19            }
    3.20 -          slot.put(_"Your are potential supporter")
    3.21 +          if supporter.auto_support then
    3.22 +            slot.put(_"Your are potential supporter (WARNING: Autosupport enabled)")
    3.23 +          else
    3.24 +            slot.put(_"Your are potential supporter")
    3.25 +          end
    3.26            ui.image{
    3.27              static = "icons/16/dropdown.png"
    3.28            }
    3.29 @@ -77,6 +85,31 @@
    3.30            end
    3.31          }
    3.32          if supporter then
    3.33 +          if config.auto_support then
    3.34 +            if supporter.auto_support then
    3.35 +              ui.link{
    3.36 +                image   = { static = "icons/16/cancel.png" },
    3.37 +                text    = _"Disable autosupport for this initiative",
    3.38 +                module  = "initiative",
    3.39 +                action  = "add_support",
    3.40 +                id      = initiative.id,
    3.41 +                routing = routing,
    3.42 +                partial = partial,
    3.43 +                params = { auto_support = false }
    3.44 +              }
    3.45 +            else
    3.46 +              ui.link{
    3.47 +                image   = { static = "icons/16/tick.png" },
    3.48 +                text    = _"Enable autosupport for this initiative",
    3.49 +                module  = "initiative",
    3.50 +                action  = "add_support",
    3.51 +                id      = initiative.id,
    3.52 +                routing = routing,
    3.53 +                partial = partial,
    3.54 +                params = { auto_support = true }
    3.55 +              }
    3.56 +            end
    3.57 +          end
    3.58            ui.link{
    3.59              image   = { static = "icons/16/thumb_down_red.png" },
    3.60              text    = _"Remove my support from this initiative",
     4.1 --- a/config/default.lua	Thu Oct 07 04:45:06 2010 +0200
     4.2 +++ b/config/default.lua	Fri Oct 08 02:49:53 2010 +0200
     4.3 @@ -32,6 +32,8 @@
     4.4    photo = nil
     4.5  }
     4.6  
     4.7 +config.auto_support = true
     4.8 +
     4.9  config.mail_subject_prefix = "[LiquidFeedback] "
    4.10  
    4.11  config.fastpath_url_func = nil

Impressum / About Us