aboutsummaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-05-31 15:23:50 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-03 19:36:23 +0200
commit00e319d4e4eec352830d88eb52f90aa6c14d3188 (patch)
tree363d2faa2e57e6b37555492a602da755ddf4f206 /site
parentProxy model (diff)
downloadcouncil-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.tar.gz
council-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.tar.bz2
council-webapp-00e319d4e4eec352830d88eb52f90aa6c14d3188.zip
Manage proxies with web app
Diffstat (limited to 'site')
-rw-r--r--site/app/models/agenda.rb1
-rw-r--r--site/app/models/guest.rb3
-rw-r--r--site/app/models/user.rb7
-rw-r--r--site/app/viewhints/agenda_hints.rb2
-rw-r--r--site/app/views/taglibs/application.dryml1
-rw-r--r--site/app/views/taglibs/cards.dryml8
-rw-r--r--site/app/views/users/show.dryml10
-rw-r--r--site/features/proxies.feature43
-rw-r--r--site/features/step_definitions/proxies_steps.rb28
-rw-r--r--site/features/step_definitions/within_steps.rb1
-rw-r--r--site/features/support/factories.rb2
-rw-r--r--site/features/support/paths.rb6
12 files changed, 110 insertions, 2 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="&current_user.can_appoint_a_proxy?(this)">
+ <input type="hidden" name="proxy[council_member_id]" value="&current_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>
diff --git a/site/features/proxies.feature b/site/features/proxies.feature
new file mode 100644
index 0000000..a160e6e
--- /dev/null
+++ b/site/features/proxies.feature
@@ -0,0 +1,43 @@
+Feature: Proxies
+ In order to check presence properly
+ I want the web application
+ To support proxies for council members
+
+ Scenario: Appoint then un-appoint proxy
+ Given I am logged in as a council member
+ And an agenda
+ When I view profile of a regular user
+ And I press "Appoint as a proxy for next meeting"
+
+ When I am on the current agenda page
+ Then I should see "User for Example" as proxy
+
+ When I press "Un-appoint proxy"
+ And I confirm
+ And I am on the current agenda page
+ Then I should not see "User for Example"
+
+ Scenario: Don't see useles proxy-management buttons as user who isn't a council member
+ Given I am logged in as example user
+ And an agenda
+ When I view profile of a regular user
+ Then I should not see "Appoint as a proxy" button
+
+ Given someone appointed a proxy
+ When I am on the current agenda page
+ Then I should not see "Un-appoint prox" button
+
+ Scenario: Don't see useles proxy-management buttons as user who is a council member
+ Given I am logged in as a council member
+ And an agenda
+ And a regular user
+ And someone appointed a proxy
+
+ When I am on the "Member-who-appointed" show page
+ Then I should not see "Appoint as a proxy" button
+
+ When I am on the current agenda page
+ Then I should not see "Un-appoint prox" button
+
+ When I view old meeting for which I appointed a proxy
+ Then I should not see "Un-appoint prox" button
diff --git a/site/features/step_definitions/proxies_steps.rb b/site/features/step_definitions/proxies_steps.rb
new file mode 100644
index 0000000..44f27c0
--- /dev/null
+++ b/site/features/step_definitions/proxies_steps.rb
@@ -0,0 +1,28 @@
+Given /^a regular user$/ do
+ Factory(:user, :name => "User")
+end
+
+When /^I view profile of a regular user$/ do
+ Given 'a regular user'
+ When 'I am on the "User" show page'
+end
+
+Then /^I confirm$/ do
+ page.driver.browser.switch_to.alert.accept
+end
+
+Then /^I should not see "([^"]*)" button$/ do |arg1|
+ page.all(:xpath, "//input[@type='submit'][@value='#{arg1}']").should be_empty
+end
+
+Given /^someone appointed a proxy$/ do
+ Factory(:user, :council_member => true, :name => 'Member-who-appointed')
+ Factory(:proxy, :agenda => Agenda.current)
+end
+
+When /^I view old meeting for which I appointed a proxy$/ do
+ a = Factory(:agenda, :state => 'old')
+ Factory(:proxy, :council_member => User.council_member_is(true).first, :agenda => a)
+ When "I am on #{a.id}th agenda page"
+end
+
diff --git a/site/features/step_definitions/within_steps.rb b/site/features/step_definitions/within_steps.rb
index 57bf030..821eb61 100644
--- a/site/features/step_definitions/within_steps.rb
+++ b/site/features/step_definitions/within_steps.rb
@@ -9,6 +9,7 @@
'in the agendas collection' => '.collection.agendas',
'as empty collection message' => '.empty-collection-message',
'as meeting time' => '.meeting-time-view',
+ 'as proxy' => '.collection.proxies.proxies-collection',
'as the user nick' => '.user-irc-nick',
'as voting option' => '.collection.voting-options',
'as voting option description' => '.voting-option-description'
diff --git a/site/features/support/factories.rb b/site/features/support/factories.rb
new file mode 100644
index 0000000..300fee7
--- /dev/null
+++ b/site/features/support/factories.rb
@@ -0,0 +1,2 @@
+require File.expand_path("../../../spec/factories.rb", __FILE__)
+require File.expand_path("../../../spec/support/users_factory.rb", __FILE__)
diff --git a/site/features/support/paths.rb b/site/features/support/paths.rb
index 6f8dad8..18d72ca 100644
--- a/site/features/support/paths.rb
+++ b/site/features/support/paths.rb
@@ -29,7 +29,11 @@ module NavigationHelpers
when /the current items page/
current_items_path
- # Add more mappings here.
+ when /the "([^\"]*)" show page/
+ user_path(User.find_by_name($1))
+
+ when /([1-9]*)th agenda page/
+ agenda_path(Agenda.find $1)
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#