liquid_feedback_frontend

diff app/main/timeline/index.lua @ 10:72c5e0ee7c98

Version beta6

Bugfixes:
- Security fix: Every user was able to change the discussion URL of an initiative
- Creation of new issues in areas without default policies is now possible
- Members can now be sorted in different ways
- No error when trying to compare a draft with itself
- Added missing local statement to variable initialization in app/main/delegation/new.lua
- CSS flaw in initiative action bar fixed

New features:
- Possiblity to invite other users to become initiator
- Revokation of initiatives implemented
- Number of suggestions, supporters, etc. is shown on corresponding tabs of initiative view
- Members can now be sorted by account creation (default sorting is "newest first")
- Configuration option to create an automatic discussion link for all issues
- First draft of global timeline feature (not accessible via link yet)
- Custom stylesheet URL for users marked as developers

In area listing the number of closed issues is shown too

Renamed "author" field of initiative to "last author"

Removed wrongly included file app/main/member/_show_thumb.lua.orig in the distribution

Help texts updated
author bsw
date Sun Jan 10 12:00:00 2010 +0100 (2010-01-10)
parents
children 77d58efe99fd
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/timeline/index.lua	Sun Jan 10 12:00:00 2010 +0100
     1.3 @@ -0,0 +1,151 @@
     1.4 +
     1.5 +local function format_dow(dow)
     1.6 +  local dows = {
     1.7 +    _"Monday",
     1.8 +    _"Tuesday",
     1.9 +    _"Wednesday",
    1.10 +    _"Thursday",
    1.11 +    _"Friday",
    1.12 +    _"Saturday",
    1.13 +    _"Sunday"
    1.14 +  }
    1.15 +  return dows[dow+1]
    1.16 +end
    1.17 +
    1.18 +slot.put_into("title", _"Global timeline")
    1.19 +
    1.20 +
    1.21 +ui.form{
    1.22 +  attr = { class = "vertical" },
    1.23 +  module = "timeline",
    1.24 +  view = "index",
    1.25 +  method = "get",
    1.26 +  content = function()
    1.27 +    local tmp = db:query("select EXTRACT(DOW FROM date) as dow, date FROM (SELECT (now() - (to_char(days_before, '0') || ' days')::interval)::date as date from (select generate_series(0,7) as days_before) as series) as date; ")
    1.28 +    local today = tmp[1].date
    1.29 +    for i, record in ipairs(tmp) do
    1.30 +      local content
    1.31 +      if i == 1 then
    1.32 +        content = _"Today"
    1.33 +      elseif i == 2 then
    1.34 +        content = _"Yesterday"
    1.35 +      else
    1.36 +        content = format_dow(record.dow)
    1.37 +      end
    1.38 +      ui.link{
    1.39 +        content = content,
    1.40 +        attr = { onclick = "el = document.getElementById('timeline_search_date'); el.value = '" .. tostring(record.date) .. "'; el.form.submit(); return(false);" },
    1.41 +        module = "timeline",
    1.42 +        view = "index",
    1.43 +        params = { date = record.date }
    1.44 +      }
    1.45 +      slot.put(" ")
    1.46 +    end
    1.47 +    ui.field.hidden{
    1.48 +      attr = { id = "timeline_search_date" },
    1.49 +      name = "date",
    1.50 +      value = param.get("date") or today
    1.51 +    }
    1.52 +    ui.field.select{
    1.53 +      attr = { onchange = "this.form.submit();" },
    1.54 +      name = "per_page",
    1.55 +      label = _"Issues per page",
    1.56 +      foreign_records = {
    1.57 +        { id = "10",  name = "10"   },
    1.58 +        { id = "25",  name = "25"   },
    1.59 +        { id = "50",  name = "50"   },
    1.60 +        { id = "100", name = "100"  },
    1.61 +        { id = "250", name = "250"  },
    1.62 +        { id = "all", name = _"All" },
    1.63 +      },
    1.64 +      foreign_id = "id",
    1.65 +      foreign_name = "name",
    1.66 +      value = param.get("per_page")
    1.67 +    }
    1.68 +    local initiatives_per_page = param.get("initiatives_per_page", atom.integer) or 3
    1.69 +
    1.70 +    ui.field.select{
    1.71 +      attr = { onchange = "this.form.submit();" },
    1.72 +      name = "initiatives_per_page",
    1.73 +      label = _"Initiatives per page",
    1.74 +      foreign_records = {
    1.75 +        { id = 1,   name = "1"  },
    1.76 +        { id = 3,   name = "3"  },
    1.77 +        { id = 5,   name = "5"  },
    1.78 +        { id = 10,  name = "10" },
    1.79 +        { id = 25,  name = "25" },
    1.80 +        { id = 50,  name = "50" },
    1.81 +      },
    1.82 +      foreign_id = "id",
    1.83 +      foreign_name = "name",
    1.84 +      value = initiatives_per_page
    1.85 +    }
    1.86 +  end
    1.87 +}
    1.88 +
    1.89 +local date = param.get("date")
    1.90 +if not date then
    1.91 +  date = "today"
    1.92 +end
    1.93 +local issues_selector = db:new_selector()
    1.94 +issues_selector._class = Issue
    1.95 +
    1.96 +issues_selector
    1.97 +  :add_field("*")
    1.98 +  :add_where{ "sort::date = ?", date }
    1.99 +  :add_from{ "($) as issue", {
   1.100 +    Issue:new_selector()
   1.101 +      :add_field("''", "old_state")
   1.102 +      :add_field("'new'", "new_state")
   1.103 +      :add_field("created", "sort")
   1.104 +    :union(Issue:new_selector()
   1.105 +      :add_field("'new'", "old_state")
   1.106 +      :add_field("'accepted'", "new_state")
   1.107 +      :add_field("accepted", "sort")
   1.108 +      :add_where("accepted NOTNULL")
   1.109 +    ):union(Issue:new_selector()
   1.110 +      :add_field("'accepted'", "old_state")
   1.111 +      :add_field("'frozen'", "new_state")
   1.112 +      :add_field("half_frozen", "sort")
   1.113 +      :add_where("half_frozen NOTNULL")
   1.114 +    ):union(Issue:new_selector()
   1.115 +      :add_field("'frozen'", "old_state")
   1.116 +      :add_field("'voting'", "new_state")
   1.117 +      :add_field("fully_frozen", "sort")
   1.118 +      :add_where("fully_frozen NOTNULL")
   1.119 +    ):union(Issue:new_selector()
   1.120 +      :add_field("'new'", "old_state")
   1.121 +      :add_field("'cancelled'", "new_state")
   1.122 +      :add_field("closed", "sort")
   1.123 +      :add_where("closed NOTNULL AND accepted ISNULL")
   1.124 +    ):union(Issue:new_selector()
   1.125 +      :add_field("'accepted'", "old_state")
   1.126 +      :add_field("'cancelled'", "new_state")
   1.127 +      :add_field("closed", "sort")
   1.128 +      :add_where("closed NOTNULL AND half_frozen ISNULL AND accepted NOTNULL")
   1.129 +    ):union(Issue:new_selector()
   1.130 +      :add_field("'frozen'", "old_state")
   1.131 +      :add_field("'cancelled'", "new_state")
   1.132 +      :add_field("closed", "sort")
   1.133 +      :add_where("closed NOTNULL AND fully_frozen ISNULL AND half_frozen NOTNULL")
   1.134 +    ):union(Issue:new_selector()
   1.135 +      :add_field("'voting'", "old_state")
   1.136 +      :add_field("'finished'", "new_state")
   1.137 +      :add_field("closed", "sort")
   1.138 +      :add_where("closed NOTNULL AND fully_frozen NOTNULL AND half_frozen ISNULL")
   1.139 +    )
   1.140 +  }
   1.141 +}
   1.142 +
   1.143 +execute.view{
   1.144 +  module = "issue",
   1.145 +  view = "_list",
   1.146 +  params = {
   1.147 +    issues_selector = issues_selector,
   1.148 +    initiatives_per_page = param.get("initiatives_per_page", atom.number),
   1.149 +    initiatives_no_sort = true,
   1.150 +    no_filter = true,
   1.151 +    no_sort = true,
   1.152 +    per_page = param.get("per_page"),
   1.153 +  }
   1.154 +}

Impressum / About Us