| rev |
line source |
|
bsw@11
|
1 execute.view{
|
|
bsw@11
|
2 module = "timeline",
|
|
bsw@11
|
3 view = "_constants"
|
|
bsw@11
|
4 }
|
|
bsw@11
|
5
|
|
bsw@11
|
6 local options_string = param.get("options_string")
|
|
bsw@11
|
7
|
|
bsw@11
|
8 if not options_string then
|
|
bsw@11
|
9 local active_options = ""
|
|
bsw@11
|
10 for event_ident, event_name in pairs(event_names) do
|
|
bsw@11
|
11 if param.get("option_" .. event_ident, atom.boolean) then
|
|
bsw@11
|
12 active_options = active_options .. event_ident .. ":"
|
|
bsw@11
|
13 local filter_idents = {}
|
|
bsw@11
|
14 for filter_ident, filter_name in pairs(filter_names) do
|
|
bsw@11
|
15 if param.get("option_" .. event_ident .. "_" .. filter_ident, atom.boolean) then
|
|
bsw@11
|
16 filter_idents[#filter_idents+1] = filter_ident
|
|
bsw@11
|
17 end
|
|
bsw@11
|
18 end
|
|
bsw@11
|
19 if #filter_idents > 0 then
|
|
bsw@11
|
20 active_options = active_options .. table.concat(filter_idents, "|") .. " "
|
|
bsw@11
|
21 else
|
|
bsw@11
|
22 active_options = active_options .. "* "
|
|
bsw@11
|
23 end
|
|
bsw@11
|
24 end
|
|
bsw@11
|
25 end
|
|
bsw@11
|
26 if #active_options > 0 then
|
|
bsw@11
|
27 options_string = active_options
|
|
bsw@11
|
28 end
|
|
bsw@11
|
29 end
|
|
bsw@11
|
30
|
|
bsw@11
|
31 if not options_string then
|
|
bsw@11
|
32 options_string = "issue_created:* issue_finished_after_voting:* issue_accepted:* issue_voting_started:* suggestion_created:* issue_canceled:* initiative_created:* issue_finished_without_voting:* draft_created:* initiative_revoked:* issue_half_frozen:* "
|
|
bsw@11
|
33 end
|
|
bsw@11
|
34
|
|
bsw@11
|
35 local setting_key = "liquidfeedback_frontend_timeline_current_options"
|
|
bsw@11
|
36 local setting = Setting:by_pk(app.session.member.id, setting_key)
|
|
bsw@11
|
37
|
|
bsw@11
|
38 if not setting or setting.value ~= options_string then
|
|
bsw@11
|
39 if not setting then
|
|
bsw@11
|
40 setting = Setting:new()
|
|
bsw@11
|
41 setting.member_id = app.session.member_id
|
|
bsw@11
|
42 setting.key = setting_key
|
|
bsw@11
|
43 end
|
|
bsw@11
|
44 if options_string then
|
|
bsw@11
|
45 setting.value = options_string
|
|
bsw@11
|
46 setting:save()
|
|
bsw@11
|
47 end
|
|
bsw@11
|
48 end
|
|
bsw@11
|
49
|
|
bsw@11
|
50 local date = param.get("date")
|
|
bsw@11
|
51
|
|
bsw@11
|
52 if date and #date > 0 then
|
|
bsw@11
|
53 local setting_key = "liquidfeedback_frontend_timeline_current_date"
|
|
bsw@11
|
54 local setting = Setting:by_pk(app.session.member.id, setting_key)
|
|
bsw@11
|
55 if not setting or setting.value ~= date then
|
|
bsw@11
|
56 if not setting then
|
|
bsw@11
|
57 setting = Setting:new()
|
|
bsw@11
|
58 setting.member_id = app.session.member.id
|
|
bsw@11
|
59 setting.key = setting_key
|
|
bsw@11
|
60 end
|
|
bsw@11
|
61 setting.value = date
|
|
bsw@11
|
62 setting:save()
|
|
bsw@11
|
63 end
|
|
bsw@11
|
64 end
|
|
bsw@11
|
65
|
|
bsw@11
|
66 local setting_key = "liquidfeedback_frontend_timeline_current_options"
|
|
bsw@11
|
67 local setting = Setting:by_pk(app.session.member.id, setting_key)
|
|
bsw@11
|
68
|
|
bsw@11
|
69 local timeline_params = {}
|
|
bsw@11
|
70 if setting and setting.value then
|
|
bsw@11
|
71 for event_ident, filter_idents in setting.value:gmatch("(%S+):(%S+)") do
|
|
bsw@11
|
72 timeline_params["option_" .. event_ident] = true
|
|
bsw@11
|
73 if filter_idents ~= "*" then
|
|
bsw@11
|
74 for filter_ident in filter_idents:gmatch("([^\|]+)") do
|
|
bsw@11
|
75 timeline_params["option_" .. event_ident .. "_" .. filter_ident] = true
|
|
bsw@11
|
76 end
|
|
bsw@11
|
77 end
|
|
bsw@11
|
78 end
|
|
bsw@11
|
79 end
|
|
bsw@11
|
80
|
|
bsw@11
|
81 local setting_key = "liquidfeedback_frontend_timeline_current_date"
|
|
bsw@11
|
82 local setting = Setting:by_pk(app.session.member.id, setting_key)
|
|
bsw@11
|
83
|
|
bsw@11
|
84 if setting then
|
|
bsw@11
|
85 timeline_params.date = setting.value
|
|
bsw@11
|
86 end
|
|
bsw@11
|
87
|
|
bsw@11
|
88 timeline_params.show_options = param.get("show_options", atom.boolean)
|
|
bsw@11
|
89
|
|
bsw@11
|
90 if param.get("save", atom.boolean) then
|
|
bsw@11
|
91 request.redirect{
|
|
bsw@11
|
92 module = "timeline",
|
|
bsw@11
|
93 view = "save_filter"
|
|
bsw@11
|
94 }
|
|
bsw@11
|
95 else
|
|
bsw@11
|
96 request.redirect{
|
|
bsw@11
|
97 module = "timeline",
|
|
bsw@11
|
98 view = "index",
|
|
bsw@11
|
99 params = timeline_params
|
|
bsw@11
|
100 }
|
|
bsw@11
|
101 end |