Skip to content

Commit

Permalink
added captcha to new group form
Browse files Browse the repository at this point in the history
fixed sorting on groups page
added jump to links to bill/major
  • Loading branch information
opencongress committed Sep 14, 2011
1 parent 58828cc commit be88548
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery

include AuthenticatedSystem
# include SimpleCaptcha::ControllerHelpers
include SimpleCaptcha::ControllerHelpers
include Facebooker2::Rails::Controller
include UrlHelper

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/bill_controller.rb
Expand Up @@ -120,9 +120,9 @@ def major
@sort = 'major'
@title_desc = SiteText.find_title_desc('bill_hot')
@types = 'all'
@hot_bill_categories = PvsCategory.find(:all, :order => :name)
@atom = {'link' => "/bill/major.rss", 'title' => "Major Bills"}
@congress = params[:congress].blank? ? Settings.default_congress : params[:congress]
@hot_bill_categories = PvsCategory.includes(:hot_bills).where(["bills.session = ?", @congress]).order("pvs_categories.name")

respond_to do |format|
format.html {}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/groups_controller.rb
Expand Up @@ -18,7 +18,7 @@ def create
@group.user = current_user

respond_to do |format|
if @group.save
if @group.save_with_captcha
format.html { redirect_to(new_group_group_invite_path(@group, :new => true), :notice => 'Group was successfully created.') }
format.xml { render :xml => @group, :status => :created, :location => @group }
else
Expand Down
2 changes: 2 additions & 0 deletions app/models/group.rb
@@ -1,6 +1,8 @@
class Group < ActiveRecord::Base
has_attached_file :group_image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :path => "#{Settings.group_images_path}/:id/:style/:filename"

apply_simple_captcha

validates_presence_of :name
validates_uniqueness_of :name
validates_presence_of :user_id
Expand Down
12 changes: 12 additions & 0 deletions app/views/bill/_hot_bills.html.erb
Expand Up @@ -2,6 +2,18 @@
This page of "Hot Bills" lists 46 issue areas, created and maintained by the non-profit, non-partisan <a href="http://votesmart.org/issue_rating.php">Project Vote Smart</a>. Bills in Congress are then assigned to issue areas by OpenCongress site editors (<a href="/about/staff">about our staff</a>). Bills may be assigned to more than one issue area, where applicable. Of the bills included here, many are actively moving through the legislative process towards becoming law. Some have already been voted on by Congress, and some are not moving in Congress, but have gained a lot of interest from the public and the media. Generally, then, these are the bills that people focus on when considering Congress' recent actions on these issues.
</div>

<div id="major_category_links">
<p>
<strong>Jump to:</strong>
<% @hot_bill_categories.each do |c| %>
<% if c.hot_bills.any? %>
<%= link_to c.name, "##{c.name}" %>
<%= "&bull;".html_safe unless c == @hot_bill_categories.last %>
<% end %>
<% end %>
</p>
</div>

<div class="hot_bill_collection">
<%= render :partial => 'hot_bill_category', :collection => @hot_bill_categories %>
</div>
3 changes: 2 additions & 1 deletion app/views/bill/major.html.erb
@@ -1,5 +1,6 @@
<% @content_for_sortby = render :partial => 'sort_bills', :locals => { :sort => 'hot'} %>


<div id="the-bills">
<%= render :partial => 'hot_bills', :locals => { :hot_bill_categories => @hot_bill_categories } %>
<%= render :partial => 'hot_bills', :locals => { :hot_bill_categories => @hot_bill_categories } %>
</div>
9 changes: 9 additions & 0 deletions app/views/groups/_form.html.haml
Expand Up @@ -50,6 +50,15 @@
= image_tag(@group.group_image.url(:thumb))
= f.label :group_image, 'Group image'
= f.file_field :group_image
- if @group.new_record?
%p
= f.simple_captcha :label => "Spam check"

.clear

:javascript
$j(document).ready(function() {
$j('input#group_captcha').addClass("field");
});
%p
= f.submit @group.new_record? ? 'Create Group' : 'Update Group', :class => 'button blue huge'
2 changes: 1 addition & 1 deletion app/views/groups/_groups_list.html.haml
Expand Up @@ -41,7 +41,7 @@
$j('#group_search_field').change(doSearch);
$j('#group_issue').change(doSearch);

$j('.table_header a').click(function() {
$j('.table_header a').live("click", function(e) {
if (($j(this).attr('class') == '') || ($j(this).attr('class') == 'down')) {
$j('.table_header a').attr('class', '');
$j(this).attr('class', 'up');
Expand Down
43 changes: 3 additions & 40 deletions app/views/simple_captcha/_simple_captcha.erb
@@ -1,42 +1,5 @@
<!-- Copyright (c) 2007 [Sur http://expressica.com] -->

<style type="text/CSS">

#simple_captcha{border: 1px solid #ccc; padding: 5px !important;}
#simple_captcha,
#simple_captcha div{display: table;}
#simple_captcha .simple_captcha_field,
#simple_captcha .simple_captcha_image{
border: 1px solid #ccc;
margin: 0px 0px 2px 0px !important;
padding: 0px !important;
}
#simple_captcha .simple_captcha_image img{
margin: 0px !important;
padding: 0px !important;
width: 110px !important;
}
#simple_captcha .simple_captcha_label{font-size: 12px;}
#simple_captcha .simple_captcha_field input{
width: 150px !important;
font-size: 16px;
border: none;
background-color: #efefef;
}
</style>



<div class='simple_captcha'>
<div class='simple_captcha_image'>
<%= simple_captcha_options[:image] %>
</div>

<div class='simple_captcha_field'>
<%= simple_captcha_options[:field] %>
</div>

<div class='simple_captcha_label'>
<%= simple_captcha_options[:label] %>
</div>
</div>
<label for="simple_captcha">Spam check</label>
<span class="captcha_img"><%= simple_captcha_options[:image] %></span>
<%= simple_captcha_options[:field] %>
4 changes: 3 additions & 1 deletion config/locales/en.yml
Expand Up @@ -6,7 +6,9 @@ en:

simple_captcha:
label: "Enter the text from the image"

message:
group: "The spam check value did not match the text in the image"

errors:
messages:
carrierwave_processing_error: 'Cannot resize image.'
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Expand Up @@ -35,7 +35,9 @@
resources :notebook_files
end
end


resources :simple_captcha, :only => :show

match '/' => 'index#index', :as => :home

# Allow downloading Web Service WSDL as a file with an extension
Expand Down
8 changes: 5 additions & 3 deletions public/stylesheets/bill.css
Expand Up @@ -775,7 +775,7 @@ padding-right: 14px;
display: block;
text-align: center;
font-weight: bold;
font-family: Helvetica, Arial, sans-serif;
font-family: Helvetica, Arial, sans-serif;
color: #879f4e;
height: 44px;
padding-top: 8px;
Expand Down Expand Up @@ -803,7 +803,7 @@ font-size: 10.5px;
margin-top: 25px;
padding-top: 13px;
padding-bottom: 25px;
font-family: Helvetica, Arial, sans-serif;
font-family: Helvetica, Arial, sans-serif;
}

#bill-status-box table {
Expand Down Expand Up @@ -2467,7 +2467,9 @@ color: #888;
font-size: 11px;
}


#major_category_links {
margin-top: 20px;
}



Expand Down
9 changes: 9 additions & 0 deletions public/stylesheets/groups.css
Expand Up @@ -661,3 +661,12 @@ background: url(/images/issue-bg.png) 0 0 no-repeat;
.dummy_div, .dummy_li {
display: none;
}

.captcha_img {
float: left;
margin-bottom: 30px;
}
input#group_captcha {
float: left;
width: 100px;
}

0 comments on commit be88548

Please sign in to comment.