public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/council-webapp:master commit in: site/app/views/taglibs/, site/features/support/, site/features/, ...
@ 2011-06-05 20:37 Petteri Räty
  0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-06-05 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     00e319d4e4eec352830d88eb52f90aa6c14d3188
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue May 31 13:23:50 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun  3 17:36:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=00e319d4

Manage proxies with web app

---
 site/app/models/agenda.rb                       |    1 +
 site/app/models/guest.rb                        |    3 ++
 site/app/models/user.rb                         |    7 ++++
 site/app/viewhints/agenda_hints.rb              |    2 +-
 site/app/views/taglibs/application.dryml        |    1 +
 site/app/views/taglibs/cards.dryml              |    8 ++++
 site/app/views/users/show.dryml                 |   10 +++++
 site/features/proxies.feature                   |   43 +++++++++++++++++++++++
 site/features/step_definitions/proxies_steps.rb |   28 +++++++++++++++
 site/features/step_definitions/within_steps.rb  |    1 +
 site/features/support/factories.rb              |    2 +
 site/features/support/paths.rb                  |    6 +++-
 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:
     #



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-05 20:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-05 20:37 [gentoo-commits] proj/council-webapp:master commit in: site/app/views/taglibs/, site/features/support/, site/features/, Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox