liquid_feedback_frontend

diff app/main/suggestion/_list.lua @ 51:0849be391140

Public read access; Read-only API for initiatives; Prepared integration of OpenID
author bsw
date Sun Apr 04 22:05:11 2010 +0200 (2010-04-04)
parents 00d1004545f1
children 6a12fb7e4963
line diff
     1.1 --- a/app/main/suggestion/_list.lua	Wed Mar 31 17:50:32 2010 +0200
     1.2 +++ b/app/main/suggestion/_list.lua	Sun Apr 04 22:05:11 2010 +0200
     1.3 @@ -108,104 +108,111 @@
     1.4                label = _"My opinion",
     1.5                content = function(record)
     1.6                  local degree
     1.7 -                local opinion = Opinion:by_pk(app.session.member.id, record.id)
     1.8 +                local opinion
     1.9 +                if app.session.member_id then
    1.10 +                  opinion = Opinion:by_pk(app.session.member.id, record.id)
    1.11 +                end
    1.12                  if opinion then
    1.13                    degree = opinion.degree
    1.14                  end
    1.15                  ui.container{
    1.16                    attr = { class = "suggestion_my_opinion" },
    1.17                    content = function()
    1.18 -                    if initiative.issue.state == "voting" or initiative.issue.state == "closed" then
    1.19 -                      ui.tag{
    1.20 -                        tag = "span",
    1.21 -                        attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
    1.22 -                        content = _"must not"
    1.23 -                      }
    1.24 -                      ui.tag{
    1.25 -                        tag = "span",
    1.26 -                        attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
    1.27 -                        content = _"should not"
    1.28 -                      }
    1.29 -                      ui.tag{
    1.30 -                        tag = "span",
    1.31 -                        attr = { class = "action" .. (degree == nil and " active" or "") },
    1.32 -                        content = _"neutral"
    1.33 -                      }
    1.34 -                      ui.tag{
    1.35 -                        tag = "span",
    1.36 -                        attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
    1.37 -                        content = _"should"
    1.38 -                      }
    1.39 -                      ui.tag{
    1.40 -                        tag = "span",
    1.41 -                        attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
    1.42 -                        content = _"must"
    1.43 -                      }
    1.44 +                    if app.session.member_id then
    1.45 +                      if initiative.issue.state == "voting" or initiative.issue.state == "closed" then
    1.46 +                        ui.tag{
    1.47 +                          tag = "span",
    1.48 +                          attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
    1.49 +                          content = _"must not"
    1.50 +                        }
    1.51 +                        ui.tag{
    1.52 +                          tag = "span",
    1.53 +                          attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
    1.54 +                          content = _"should not"
    1.55 +                        }
    1.56 +                        ui.tag{
    1.57 +                          tag = "span",
    1.58 +                          attr = { class = "action" .. (degree == nil and " active" or "") },
    1.59 +                          content = _"neutral"
    1.60 +                        }
    1.61 +                        ui.tag{
    1.62 +                          tag = "span",
    1.63 +                          attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
    1.64 +                          content = _"should"
    1.65 +                        }
    1.66 +                        ui.tag{
    1.67 +                          tag = "span",
    1.68 +                          attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
    1.69 +                          content = _"must"
    1.70 +                        }
    1.71 +                      else
    1.72 +                        ui.link{
    1.73 +                          attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
    1.74 +                          text = _"must not",
    1.75 +                          module = "opinion",
    1.76 +                          action = "update",
    1.77 +                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
    1.78 +                          params = {
    1.79 +                            suggestion_id = record.id,
    1.80 +                            degree = -2
    1.81 +                          },
    1.82 +                          partial = partial
    1.83 +                        }
    1.84 +                        slot.put(" ")
    1.85 +                        ui.link{
    1.86 +                          attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
    1.87 +                          text = _"should not",
    1.88 +                          module = "opinion",
    1.89 +                          action = "update",
    1.90 +                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
    1.91 +                          params = {
    1.92 +                            suggestion_id = record.id,
    1.93 +                            degree = -1
    1.94 +                          },
    1.95 +                          partial = partial
    1.96 +                        }
    1.97 +                        slot.put(" ")
    1.98 +                        ui.link{
    1.99 +                          attr = { class = "action" .. (degree == nil and " active" or "") },
   1.100 +                          text = _"neutral",
   1.101 +                          module = "opinion",
   1.102 +                          action = "update",
   1.103 +                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.104 +                          params = {
   1.105 +                            suggestion_id = record.id,
   1.106 +                            delete = true
   1.107 +                          },
   1.108 +                          partial = partial
   1.109 +                        }
   1.110 +                        slot.put(" ")
   1.111 +                        ui.link{
   1.112 +                          attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
   1.113 +                          text = _"should",
   1.114 +                          module = "opinion",
   1.115 +                          action = "update",
   1.116 +                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.117 +                          params = {
   1.118 +                            suggestion_id = record.id,
   1.119 +                            degree = 1
   1.120 +                          },
   1.121 +                          partial = partial
   1.122 +                        }
   1.123 +                        slot.put(" ")
   1.124 +                        ui.link{
   1.125 +                          attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
   1.126 +                          text = _"must",
   1.127 +                          module = "opinion",
   1.128 +                          action = "update",
   1.129 +                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.130 +                          params = {
   1.131 +                            suggestion_id = record.id,
   1.132 +                            degree = 2
   1.133 +                          },
   1.134 +                          partial = partial
   1.135 +                        }
   1.136 +                      end
   1.137                      else
   1.138 -                      ui.link{
   1.139 -                        attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
   1.140 -                        text = _"must not",
   1.141 -                        module = "opinion",
   1.142 -                        action = "update",
   1.143 -                        routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.144 -                        params = {
   1.145 -                          suggestion_id = record.id,
   1.146 -                          degree = -2
   1.147 -                        },
   1.148 -                        partial = partial
   1.149 -                      }
   1.150 -                      slot.put(" ")
   1.151 -                      ui.link{
   1.152 -                        attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
   1.153 -                        text = _"should not",
   1.154 -                        module = "opinion",
   1.155 -                        action = "update",
   1.156 -                        routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.157 -                        params = {
   1.158 -                          suggestion_id = record.id,
   1.159 -                          degree = -1
   1.160 -                        },
   1.161 -                        partial = partial
   1.162 -                      }
   1.163 -                      slot.put(" ")
   1.164 -                      ui.link{
   1.165 -                        attr = { class = "action" .. (degree == nil and " active" or "") },
   1.166 -                        text = _"neutral",
   1.167 -                        module = "opinion",
   1.168 -                        action = "update",
   1.169 -                        routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.170 -                        params = {
   1.171 -                          suggestion_id = record.id,
   1.172 -                          delete = true
   1.173 -                        },
   1.174 -                        partial = partial
   1.175 -                      }
   1.176 -                      slot.put(" ")
   1.177 -                      ui.link{
   1.178 -                        attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
   1.179 -                        text = _"should",
   1.180 -                        module = "opinion",
   1.181 -                        action = "update",
   1.182 -                        routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.183 -                        params = {
   1.184 -                          suggestion_id = record.id,
   1.185 -                          degree = 1
   1.186 -                        },
   1.187 -                        partial = partial
   1.188 -                      }
   1.189 -                      slot.put(" ")
   1.190 -                      ui.link{
   1.191 -                        attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
   1.192 -                        text = _"must",
   1.193 -                        module = "opinion",
   1.194 -                        action = "update",
   1.195 -                        routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.196 -                        params = {
   1.197 -                          suggestion_id = record.id,
   1.198 -                          degree = 2
   1.199 -                        },
   1.200 -                        partial = partial
   1.201 -                      }
   1.202 +                      ui.field.text{ value = _"[Registered members only]" }
   1.203                      end
   1.204                    end
   1.205                  }
   1.206 @@ -213,7 +220,10 @@
   1.207              },
   1.208              {
   1.209                content = function(record)
   1.210 -                local opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.211 +                local opinion
   1.212 +                if app.session.member_id then
   1.213 +                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.214 +                end
   1.215                  if opinion and not opinion.fulfilled then
   1.216                    ui.image{ static = "icons/16/cross.png" }
   1.217                  end
   1.218 @@ -242,7 +252,10 @@
   1.219              },
   1.220              {
   1.221                content = function(record)
   1.222 -                local opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.223 +                local opinion
   1.224 +                if app.session.member_id then
   1.225 +                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.226 +                end
   1.227                  if opinion and opinion.fulfilled then
   1.228                      ui.image{ static = "icons/16/tick.png" }
   1.229                  end
   1.230 @@ -273,7 +286,10 @@
   1.231                label_attr = { style = "width: 200px;" },
   1.232                content = function(record)
   1.233                  local degree
   1.234 -                local opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.235 +                local opinion
   1.236 +                if app.session.member_id then
   1.237 +                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.238 +                end
   1.239                  if opinion then
   1.240                    degree = opinion.degree
   1.241                  end
   1.242 @@ -321,7 +337,10 @@
   1.243              },
   1.244              {
   1.245                content = function(record)
   1.246 -                local opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.247 +                local opinion
   1.248 +                if app.session.member_id then
   1.249 +                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.250 +                end
   1.251                  if opinion then
   1.252                    if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
   1.253                      ui.image{ static = "icons/16/thumb_up_green.png" }

Impressum / About Us