diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-05-31 15:23:50 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-03 19:36:23 +0200 |
commit | 00e319d4e4eec352830d88eb52f90aa6c14d3188 (patch) | |
tree | 363d2faa2e57e6b37555492a602da755ddf4f206 /site/app | |
parent | Proxy model (diff) | |
download | council-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.tar.gz council-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.tar.bz2 council-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.zip |
Manage proxies with web app
Diffstat (limited to 'site/app')
-rw-r--r-- | site/app/models/agenda.rb | 1 | ||||
-rw-r--r-- | site/app/models/guest.rb | 3 | ||||
-rw-r--r-- | site/app/models/user.rb | 7 | ||||
-rw-r--r-- | site/app/viewhints/agenda_hints.rb | 2 | ||||
-rw-r--r-- | site/app/views/taglibs/application.dryml | 1 | ||||
-rw-r--r-- | site/app/views/taglibs/cards.dryml | 8 | ||||
-rw-r--r-- | site/app/views/users/show.dryml | 10 |
7 files changed, 31 insertions, 1 deletions
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb index 44386e3..f1224ff 100644 --- a/site/app/models/agenda.rb +++ b/site/app/models/agenda.rb @@ -9,6 +9,7 @@ class Agenda < ActiveRecord::Base has_many :agenda_items has_many :participations + has_many :proxies lifecycle do state :open, :default => true diff --git a/site/app/models/guest.rb b/site/app/models/guest.rb index cce1de4..a6b93d5 100644 --- a/site/app/models/guest.rb +++ b/site/app/models/guest.rb @@ -8,4 +8,7 @@ class Guest < Hobo::Model::Guest false end + def can_appoint_a_proxy? + false + end end diff --git a/site/app/models/user.rb b/site/app/models/user.rb index 738165e..0cb75b4 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -52,4 +52,11 @@ class User < ActiveRecord::Base def view_permitted?(field) true end + + def can_appoint_a_proxy?(user) + return false unless council_member? + return false if user.council_member? + return false unless Proxy.council_member_is(self).agenda_is(Agenda.current).count == 0 + true + end end diff --git a/site/app/viewhints/agenda_hints.rb b/site/app/viewhints/agenda_hints.rb index 46daf34..93635b5 100644 --- a/site/app/viewhints/agenda_hints.rb +++ b/site/app/viewhints/agenda_hints.rb @@ -1,5 +1,5 @@ class AgendaHints < Hobo::ViewHints - children :agenda_items, :participations + children :agenda_items, :participations, :proxies end diff --git a/site/app/views/taglibs/application.dryml b/site/app/views/taglibs/application.dryml index 017831f..311631e 100644 --- a/site/app/views/taglibs/application.dryml +++ b/site/app/views/taglibs/application.dryml @@ -7,5 +7,6 @@ <include src="taglibs/auto/rapid/forms"/> <include src="taglibs/main_nav"/> +<include src="taglibs/cards"/> <set-theme name="clean"/> diff --git a/site/app/views/taglibs/cards.dryml b/site/app/views/taglibs/cards.dryml new file mode 100644 index 0000000..cb2a76d --- /dev/null +++ b/site/app/views/taglibs/cards.dryml @@ -0,0 +1,8 @@ +<def tag="card" for="Proxy"> + <card class="proxy" param="default" merge> + <header: param> + <h4 param="heading"><a><name:proxy/> for <name:council_member/></a></h4> + <delete-button label="Un-appoint proxy" if="&this.council_member_is?(current_user)"/> + </header:> + </card> +</def> diff --git a/site/app/views/users/show.dryml b/site/app/views/users/show.dryml new file mode 100644 index 0000000..b8ac059 --- /dev/null +++ b/site/app/views/users/show.dryml @@ -0,0 +1,10 @@ +<show-page> + <append-content-body:> + <form action="&create_proxy_path" if="¤t_user.can_appoint_a_proxy?(this)"> + <input type="hidden" name="proxy[council_member_id]" value="¤t_user.id"/> + <input type="hidden" name="proxy[proxy_id]" value="&this.id"/> + <input type="hidden" name="proxy[agenda_id]" value="&Agenda.current.id"/> + <submit label="Appoint as a proxy for next meeting"/> + </form> + </append-content-body:> +</show-page> |