liquid_feedback_frontend
view model/initiative.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
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 | 8d91bccab0bf | 
| children | 00d1004545f1 | 
 line source
     1 Initiative = mondelefant.new_class()
     2 Initiative.table = 'initiative'
     4 Initiative:add_reference{
     5   mode          = 'm1',
     6   to            = "Issue",
     7   this_key      = 'issue_id',
     8   that_key      = 'id',
     9   ref           = 'issue',
    10 }
    12 Initiative:add_reference{
    13   mode          = '1m',
    14   to            = "Draft",
    15   this_key      = 'id',
    16   that_key      = 'initiative_id',
    17   ref           = 'drafts',
    18   back_ref      = 'initiative',
    19   default_order = '"id"'
    20 }
    22 Initiative:add_reference{
    23   mode          = '1m',
    24   to            = "Suggestion",
    25   this_key      = 'id',
    26   that_key      = 'initiative_id',
    27   ref           = 'suggestions',
    28   back_ref      = 'initiative',
    29 }
    31 Initiative:add_reference{
    32   mode          = '1m',
    33   to            = "Initiator",
    34   this_key      = 'id',
    35   that_key      = 'initiative_id',
    36   ref           = 'initiators',
    37   back_ref      = 'initiative'
    38 }
    40 Initiative:add_reference{
    41   mode          = '1m',
    42   to            = "Supporter",
    43   this_key      = 'id',
    44   that_key      = 'initiative_id',
    45   ref           = 'supporters',
    46   back_ref      = 'initiative',
    47   default_order = '"id"'
    48 }
    50 Initiative:add_reference{
    51   mode          = '1m',
    52   to            = "Opinion",
    53   this_key      = 'id',
    54   that_key      = 'initiative_id',
    55   ref           = 'opinions',
    56   back_ref      = 'initiative',
    57   default_order = '"id"'
    58 }
    60 Initiative:add_reference{
    61   mode          = '1m',
    62   to            = "Vote",
    63   this_key      = 'id',
    64   that_key      = 'initiative_id',
    65   ref           = 'votes',
    66   back_ref      = 'initiative',
    67   default_order = '"member_id"'
    68 }
    70 Initiative:add_reference{
    71   mode          = 'm1',
    72   to            = "Initiative",
    73   this_key      = 'suggested_initiative_id',
    74   that_key      = 'id',
    75   ref           = 'suggested_initiative',
    76 }
    78 Initiative:add_reference{
    79   mode                  = 'mm',
    80   to                    = "Member",
    81   this_key              = 'id',
    82   that_key              = 'id',
    83   connected_by_table    = '"initiator"',
    84   connected_by_this_key = 'initiative_id',
    85   connected_by_that_key = 'member_id',
    86   ref                   = 'initiating_members'
    87 }
    89 Initiative:add_reference{
    90   mode                  = 'mm',
    91   to                    = "Member",
    92   this_key              = 'id',
    93   that_key              = 'id',
    94   connected_by_table    = '"supporter"',
    95   connected_by_this_key = 'initiative_id',
    96   connected_by_that_key = 'member_id',
    97   ref                   = 'supporting_members'
    98 }
   100 Initiative:add_reference{
   101   mode                  = 'mm',
   102   to                    = "Member",
   103   this_key              = 'id',
   104   that_key              = 'id',
   105   connected_by_table    = 'direct_supporter_snapshot',
   106   connected_by_this_key = 'initiative_id',
   107   connected_by_that_key = 'member_id',
   108   ref                   = 'supporting_members_snapshot'
   109 }
   112 function Initiative:get_search_selector(search_string)
   113   return self:new_selector()
   114     :join("draft", nil, "draft.initiative_id = initiative.id")
   115     :add_field( {'"highlight"("initiative"."name", ?)', search_string }, "name_highlighted")
   116     :add_where{ '"initiative"."text_search_data" @@ "text_search_query"(?) OR "draft"."text_search_data" @@ "text_search_query"(?)', search_string, search_string }
   117     :add_group_by('"initiative"."id"')
   118     :add_group_by('"initiative"."issue_id"')
   119     :add_group_by('"initiative"."name"')
   120     :add_group_by('"initiative"."discussion_url"')
   121     :add_group_by('"initiative"."created"')
   122     :add_group_by('"initiative"."revoked"')
   123     :add_group_by('"initiative"."admitted"')
   124     :add_group_by('"initiative"."supporter_count"')
   125     :add_group_by('"initiative"."informed_supporter_count"')
   126     :add_group_by('"initiative"."satisfied_supporter_count"')
   127     :add_group_by('"initiative"."satisfied_informed_supporter_count"')
   128     :add_group_by('"initiative"."positive_votes"')
   129     :add_group_by('"initiative"."negative_votes"')
   130     :add_group_by('"initiative"."agreed"')
   131     :add_group_by('"initiative"."rank"')
   132     :add_group_by('"initiative"."text_search_data"')
   133     :add_group_by('"issue"."population"')
   134 end
   136 function Member:get_search_selector(search_string)
   137   return self:new_selector()
   138     :add_where("active")
   139 end
   142 function Initiative.object_get:current_draft()
   143   return Draft:new_selector()
   144     :add_where{ '"initiative_id" = ?', self.id }
   145     :add_order_by('"id" DESC')
   146     :single_object_mode()
   147     :exec()
   148 end
   150 function Initiative.object_get:shortened_name()
   151   local name = self.name
   152   if #name > 100 then
   153     name = name:sub(1,100) .. "..."
   154   end
   155   return name
   156 end
