Skip to content

Commit

Permalink
more groups development
Browse files Browse the repository at this point in the history
  • Loading branch information
opencongress committed Jun 13, 2011
1 parent 5c86554 commit 39030db
Show file tree
Hide file tree
Showing 22 changed files with 396 additions and 19 deletions.
16 changes: 5 additions & 11 deletions Gemfile
Expand Up @@ -11,6 +11,7 @@ gem "settingslogic"

# HAML support
gem "haml"
gem "haml-rails"

# RMagick
gem 'rmagick', '2.13.1'
Expand All @@ -27,6 +28,10 @@ gem "govkit"
gem "jammit"
gem "closure-compiler"

# paperclip -- for attaching files to requests
gem 'paperclip'


# notifier for production errors
gem "hoptoad_notifier"

Expand Down Expand Up @@ -66,21 +71,10 @@ gem "okkez-open_id_authentication"

gem "acts-as-taggable-on", :git => 'http://github.com/mbleigh/acts-as-taggable-on.git'

### temp just for showing to drm
gem 'mechanize'
#gem 'formageddon', '0.0.0', :require => 'formageddon', :path => '/Users/aross/pcf-work/gitbranches/formageddon'
gem 'formageddon', :git => 'git://github.com/opencongress/formageddon.git'

gem 'rspec'
gem 'rspec-rails', '~> 2.4'
gem 'cucumber', '0.8.5'
gem 'cucumber-rails'
gem 'webrat'
gem 'selenium-client'

gem 'capybara'
gem 'capybara-envjs'

gem 'autotest'

# Testing
Expand Down
11 changes: 10 additions & 1 deletion Gemfile.lock
Expand Up @@ -140,6 +140,11 @@ GEM
guard (>= 0.2.2)
json (~> 1.5.1)
haml (3.1.1)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
highline (1.6.2)
hoptoad_notifier (2.4.11)
activesupport
Expand Down Expand Up @@ -182,6 +187,9 @@ GEM
okkez-open_id_authentication (1.0.1)
ruby-openid (>= 2.0.4)
open4 (1.0.1)
paperclip (2.3.11)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
pg (0.11.0)
polyglot (0.3.1)
rack (1.2.3)
Expand Down Expand Up @@ -276,6 +284,7 @@ DEPENDENCIES
guard
guard-livereload
haml
haml-rails
hoptoad_notifier
hpricot
htmlentities
Expand All @@ -290,12 +299,12 @@ DEPENDENCIES
nokogiri
oauth
okkez-open_id_authentication
paperclip
pg
rack-openid
rails (= 3.0.7)
rake (= 0.8.7)
rmagick (= 2.13.1)
rspec
rspec-rails (~> 2.4)
ruby-openid
selenium-client
Expand Down
89 changes: 89 additions & 0 deletions app/controllers/group_invites_controller.rb
@@ -0,0 +1,89 @@
class GroupInvitesController < ApplicationController
# GET /group_invites
# GET /group_invites.xml
# def index
# @group_invites = GroupInvite.all
#
# respond_to do |format|
# format.html # index.html.erb
# format.xml { render :xml => @group_invites }
# end
# end
#
# # GET /group_invites/1
# # GET /group_invites/1.xml
# def show
# @group_invite = GroupInvite.find(params[:id])
#
# respond_to do |format|
# format.html # show.html.erb
# format.xml { render :xml => @group_invite }
# end
# end

# GET /group_invites/new
# GET /group_invites/new.xml
def new
@group = Group.find(params[:group_id])
@group_invite = GroupInvite.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @group_invite }
end
end

# GET /group_invites/1/edit
# def edit
# @group_invite = GroupInvite.find(params[:id])
# end
#
# # POST /group_invites
# # POST /group_invites.xml
def create
# do nothing for now
@group = Group.find(params[:group_id])
redirect_to(@group, :notice => 'Your invitations have been sent!')
return

@group_invite = GroupInvite.new(params[:group_invite])

respond_to do |format|
if @group_invite.save
format.html { redirect_to(@group_invite, :notice => 'Group invite was successfully created.') }
format.xml { render :xml => @group_invite, :status => :created, :location => @group_invite }
else
format.html { render :action => "new" }
format.xml { render :xml => @group_invite.errors, :status => :unprocessable_entity }
end
end
end
#
# # PUT /group_invites/1
# # PUT /group_invites/1.xml
# def update
# @group_invite = GroupInvite.find(params[:id])
#
# respond_to do |format|
# if @group_invite.update_attributes(params[:group_invite])
# format.html { redirect_to(@group_invite, :notice => 'Group invite was successfully updated.') }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @group_invite.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /group_invites/1
# # DELETE /group_invites/1.xml
# def destroy
# @group_invite = GroupInvite.find(params[:id])
# @group_invite.destroy
#
# respond_to do |format|
# format.html { redirect_to(group_invites_url) }
# format.xml { head :ok }
# end
# end
end
31 changes: 31 additions & 0 deletions app/controllers/groups_controller.rb
@@ -1,5 +1,36 @@
class GroupsController < ApplicationController
before_filter :login_required, :except => [ :show, :index ]

def new
@page_title = 'Create a New OpenCongress Group'
@group = Group.new
@group.join_type = 'ANYONE'
@group.invite_type = 'ANYONE'
end


def create
@group = Group.new(params[:group])
@group.user = current_user

respond_to do |format|
if @group.save
format.html { redirect_to(new_group_group_invite_path(@group), :notice => 'Group was successfully created.') }
format.xml { render :xml => @group, :status => :created, :location => @group }
else
format.html { render :action => "new" }
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end
end
end

def show
@group = Group.find(params[:id])

@page_title = "#{@group.name} - MyOC Groups"
end

def index
@page_title = 'OpenCongress Groups'
end
end
2 changes: 2 additions & 0 deletions app/helpers/group_invites_helper.rb
@@ -0,0 +1,2 @@
module GroupInvitesHelper
end
19 changes: 19 additions & 0 deletions app/models/group.rb
@@ -1,2 +1,21 @@
class Group < ActiveRecord::Base
has_attached_file :group_image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :path => "#{Settings.group_images_path}/:id/:style/:filename"

validates_presence_of :name
validates_uniqueness_of :name
validates_presence_of :user_id

belongs_to :user
has_many :group_invites
belongs_to :pvs_category

has_many :comments, :as => :commentable

def to_param
"#{id}_#{name.gsub(/[^A-Za-z]+/i, '_').gsub(/\s/, '_')}"
end

def display_object_name
'Group'
end
end
3 changes: 3 additions & 0 deletions app/models/group_invite.rb
@@ -0,0 +1,3 @@
class GroupInvite < ActiveRecord::Base
belongs_to :group
end
2 changes: 2 additions & 0 deletions app/models/user.rb
Expand Up @@ -54,6 +54,8 @@ class User < ActiveRecord::Base
serialize :district_cache
serialize :state_cache

has_many :groups

has_many :api_hits
has_many :comments
has_one :privacy_option
Expand Down
10 changes: 10 additions & 0 deletions app/views/group_invites/_form.html.haml
@@ -0,0 +1,10 @@
= form_for @group_invite, :url => group_group_invites_path(@group) do |f|
= render "shared/error_messages", :target => @group

.actions
%p
= text_area_tag :invites, '', { :class => 'field', :rows => 5, :cols => 70 }

%p
= f.submit 'Invite', :class => 'button huge blue'
= link_to 'Not Now', group_path(@group), :class => 'button huge silver'
7 changes: 7 additions & 0 deletions app/views/group_invites/edit.html.haml
@@ -0,0 +1,7 @@
%h1 Editing group_invite

= render 'form'

= link_to 'Show', @group_invite
\|
= link_to 'Back', group_invites_path
17 changes: 17 additions & 0 deletions app/views/group_invites/index.html.haml
@@ -0,0 +1,17 @@
%h1 Listing group_invites

%table
%tr
%th
%th
%th

- @group_invites.each do |group_invite|
%tr
%td= link_to 'Show', group_invite
%td= link_to 'Edit', edit_group_invite_path(group_invite)
%td= link_to 'Destroy', group_invite, :confirm => 'Are you sure?', :method => :delete

%br

= link_to 'New Group invite', new_group_invite_path
36 changes: 36 additions & 0 deletions app/views/group_invites/new.html.haml
@@ -0,0 +1,36 @@
= render 'groups/heading', :subtitle => 'Send Invitations'

.padding
.instructions
%strong Now that you've created your group, invite some people to join it!
%br
%br
Enter email addresses or OpenCongress usernames in the box below and click "Invite".
- if @facebook_user
You can also invite your friends on Facebook in the selector below.


= render 'form'

- if @facebook_user
- fb_connect_async_js
/
<fb:serverFbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="<URL for post invite action, see fb:request-form docs for details>"
method="POST"
invite="true"
type="XFBML"
content='Join my group on OpenCongress
<fb:req-choice url="#{url_for :controller => 'groups', :only_path => false}"
label="Join!" />
'>
</fb:request-form>
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to join #{@group.name}." />
</fb:fbml>
</script>
</fb:serverFbml>
6 changes: 6 additions & 0 deletions app/views/group_invites/show.html.haml
@@ -0,0 +1,6 @@
%p#notice= notice


= link_to 'Edit', edit_group_invite_path(@group_invite)
\|
= link_to 'Back', group_invites_path
27 changes: 24 additions & 3 deletions app/views/groups/_form.html.haml
@@ -1,11 +1,26 @@
= form_for @group do |f|
.group_help
%strong Creating a group on OpenCongress is easy! Here are a few things to keep in mind.
%ul
%li Your domain will be verified if it matches the email address on your account
%li "Invite only" groups will be private and not appear in listings

= form_for :group, :url => groups_path, :html => { :multipart => true } do |f|
= render "shared/error_messages", :target => @group
%p
= f.label :name
= f.text_field :name, :class => 'field'

%p
= f.label :description
= f.text_area :description, :class => 'field', :rows => 4, :cols => 50

%p
= f.label :website
= f.text_field :website, :class => 'field'

%p
= f.label :pvs_category_id, 'Issue Area of Focus'
= f.select :pvs_category_id, options_for_select(PvsCategory.order('name').all.map { |c| [c.name, c.id] }, @group.pvs_category_id), {:include_blank => true}

%p
= f.label :join_type, "Who can join?"
Expand All @@ -17,9 +32,15 @@
Invite only

%p
= f.label :invite_type, "Who can send invitation?"
= f.label :invite_type, "Who can send invitations?"
= f.radio_button :invite_type, 'ANYONE'
Anyone
= f.radio_button :invite_type, 'ADMIN'
Me only


%p
= f.label :group_image, 'Group image'
= f.file_field :group_image

%p
= f.submit 'Create Group', :class => 'button blue huge'
4 changes: 4 additions & 0 deletions app/views/groups/_heading.html.haml
@@ -0,0 +1,4 @@
- subtitle ||= nil
#heading.group
= image_tag @group.group_image.url(:thumb)
%h2= subtitle.nil? ? @group.name : "#{@group.name} : #{subtitle}"
2 changes: 1 addition & 1 deletion app/views/groups/new.html.haml
@@ -1,5 +1,5 @@
#heading
%h2 Create a new OC Group
%h2 Create a New OpenCongress Group

.padding
= render 'form'

0 comments on commit 39030db

Please sign in to comment.