Skip to content

Commit

Permalink
Get this stuff into Version control
Browse files Browse the repository at this point in the history
  • Loading branch information
drhenner committed Jul 23, 2012
1 parent cf1251b commit d850884
Show file tree
Hide file tree
Showing 30 changed files with 598 additions and 11 deletions.
11 changes: 10 additions & 1 deletion Gemfile
Expand Up @@ -14,4 +14,13 @@ gem "jquery-rails"
# your gem to rubygems.org.

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
gem 'debugger'
group :development do
#gem 'mysql2'#, '~> 0.3.7'
gem "nifty-generators", :git => 'git://github.com/drhenner/nifty-generators.git'
end

group :test do
gem 'factory_girl_rails', '~> 3.3.0'
gem 'mocha'
end
28 changes: 27 additions & 1 deletion Gemfile.lock
@@ -1,8 +1,14 @@
GIT
remote: git://github.com/drhenner/nifty-generators.git
revision: dc518739e9734be8aaab74281c565a19fbbae458
specs:
nifty-generators (0.4.6)

PATH
remote: .
specs:
validation_issues (0.0.1)
rails (~> 3.2.1)
rails (~> 3.2.6)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -36,7 +42,20 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
columnize (0.3.6)
debugger (1.2.0)
columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1)
debugger-ruby_core_source (~> 1.1.3)
debugger-linecache (1.1.2)
debugger-ruby_core_source (>= 1.1.1)
debugger-ruby_core_source (1.1.3)
erubis (2.7.0)
factory_girl (3.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.3.0)
factory_girl (~> 3.3.0)
railties (>= 3.0.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
Expand All @@ -48,7 +67,10 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.19)
mocha (0.10.5)
metaclass (~> 0.0.1)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
Expand Down Expand Up @@ -92,6 +114,10 @@ PLATFORMS
ruby

DEPENDENCIES
debugger
factory_girl_rails (~> 3.3.0)
jquery-rails
mocha
nifty-generators!
sqlite3
validation_issues!
10 changes: 9 additions & 1 deletion README.rdoc
@@ -1,3 +1,11 @@
= ValidationIssues

This project rocks and uses MIT-LICENSE.
This project rocks and uses MIT-LICENSE.

In your application_controller add this protected method:

def has_validation_issues_admin_privileges
# logic you want to make this true
# Typically this will work
current_user && current_user.admin?
end
2 changes: 2 additions & 0 deletions app/assets/javascripts/validation_issues.js
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffold.css
@@ -0,0 +1,56 @@
body { background-color: #fff; color: #333; }

body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}

a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }

div.field, div.actions {
margin-bottom: 10px;
}

#notice {
color: green;
}

.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
}

#error_explanation h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}

#error_explanation ul li {
font-size: 12px;
list-style: square;
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/validation_issues.css
@@ -0,0 +1,5 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
//= require_tree ./validation_issues
77 changes: 77 additions & 0 deletions app/assets/stylesheets/validation_issues/buttons.css
@@ -0,0 +1,77 @@
.button {
display: inline-block;
zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
*display: inline;
vertical-align: baseline;
margin: 0 2px;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .25em;
-moz-border-radius: .25em;
border-radius: .25em;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 1px rgba(0,0,0,.2);
box-shadow: 0 1px 1px rgba(0,0,0,.2);
}

input[type="submit"].button {border: 0;background-color: transparent;color: #888;}
input[type="submit"].button.dark-orange-button {color:#FFF;}
input[type="submit"].button.small-dark-orange-button {color:#FFF;}

.dark-orange-button {
color: #fef4e9;
border: solid 1px #db3909;
background: #c6481a;
background: -webkit-gradient(linear, left top, left bottom, from(#c8581a), to(#c5441F));
background: -moz-linear-gradient(top, #c8581a, #c5441F);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c8581a', endColorstr='#c5441F');
}
.dark-orange-button:hover {
background: #c4421F;
background: -webkit-gradient(linear, left top, left bottom, from(#c75114), to(#c23415));
background: -moz-linear-gradient(top, #c75114, #c23415);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c75114', endColorstr='#c23415');
}
.dark-orange-button:active {
background: #c4421F;
background: -webkit-gradient(linear, left top, left bottom, from(#c75114), to(#c23415));
background: -moz-linear-gradient(top, #c75114, #c23415);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c75114', endColorstr='#c23415');
}

.small-dark-orange-button {
font-family:'Century Schoolbook Italic', 'Century Schoolbook', Georgia;
color: #fef4e9 !important;
border: solid 1px #db3909;
background: #c6481a;
background: -webkit-gradient(linear, left top, left bottom, from(#c9681a), to(#c6451F));
background: -moz-linear-gradient(top, #c9681a, #c6451F);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c9681a', endColorstr='#c6451F');
font-size: 14px;
font-weight: normal;
padding: 0.2em 0.7em;
&.myriad {
font-family: "MyriadPro","Lucida Sans Unicode", "Lucida Grande", sans-serif;
padding: 0.7em;
padding-top: 0.3em;
padding-bottom: 0.1em;
}
}
.small-dark-orange-button:hover {
color: #fff7ef;
background: #c4421F;
background: -webkit-gradient(linear, left top, left bottom, from(#c65114), to(#c23415));
background: -moz-linear-gradient(top, #c65114, #c23415);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c65114', endColorstr='#c23415');
}
.small-dark-orange-button:active {
background: #c4421F;
background: -webkit-gradient(linear, left top, left bottom, from(#c65114), to(#c23415));
background: -moz-linear-gradient(top, #c65114, #c23415);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c65114', endColorstr='#c23415');
}
44 changes: 44 additions & 0 deletions app/controllers/validation_admin/validation_issues_controller.rb
@@ -0,0 +1,44 @@
class ValidationAdmin::ValidationIssuesController < ApplicationController
before_filter :redirect_if_no_privileges
# has_validation_issues_admin_privileges

# GET /validation_issues
# GET /validation_issues.json
def index
@validation_issues = ValidationIssue.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @validation_issues }
end
end

# GET /validation_issues/1
# GET /validation_issues/1.json
def show
@validation_issue = ValidationIssue.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @validation_issue }
end
end

# DELETE /validation_issues/1
# DELETE /validation_issues/1.json
def destroy
@validation_issue = ValidationIssue.find(params[:id])
@validation_issue.clear_data!

respond_to do |format|
format.html { redirect_to validation_admin_validation_issues_url }
format.json { head :no_content }
end
end

protected

def redirect_if_no_privileges
redirect_to root_url and return unless has_validation_issues_admin_privileges
end
end
26 changes: 26 additions & 0 deletions app/models/validation_issue.rb
@@ -0,0 +1,26 @@
class ValidationIssue < ActiveRecord::Base
attr_accessible :form_name, :issue_count, :issue_hash, :issue_type, :notes
serialize :issue_hash, Hash

validates :form_name, :presence => true, :uniqueness => true

def clear_data!
self.issue_count = 0
self.issue_hash = {}
self.notes = ''
self.save!
end

def increment_issue_count!
increment_with_sql!('issue_count')
end

protected

def increment_with_sql!(attribute, by = 1)
raise ArgumentError("Invalid attribute: #{attribute}") unless attribute_names.include?(attribute.to_s)
original_value_sql = "CASE WHEN `#{attribute}` IS NULL THEN 0 ELSE `#{attribute}` END"
self.class.update_all("`#{attribute}` = #{original_value_sql} + #{by.to_i}", "id = #{id}")
reload
end
end
25 changes: 25 additions & 0 deletions app/views/validation_admin/validation_issues/index.html.erb
@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>

<h1> Validation Issues </h1>

<table>
<tr>
<th>Type</th>
<th>Form Name</th>
<th>Count</th>
<th></th>
<th></th>
</tr>

<% @validation_issues.each do |validation_issue| %>
<tr>
<td><%= validation_issue.issue_type %></td>
<td><%= validation_issue.form_name %></td>
<td><%= validation_issue.issue_count %></td>
<td><%= link_to 'Show', validation_admin_validation_issue_path(validation_issue) %></td>
<td><%= link_to 'Reset!',
validation_admin_validation_issue_path(validation_issue),
method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
22 changes: 22 additions & 0 deletions app/views/validation_admin/validation_issues/show.html.erb
@@ -0,0 +1,22 @@
<p id="notice"><%= notice %></p>

<h2> <%= @validation_issue.issue_type %>: <%= @validation_issue.form_name %> </h2>

<p>
<b>Issues (<%= @validation_issue.issue_count %>):</b>
<ul>
<% @validation_issue.issue_hash.each do |k, v| %>
<li><label> <%= k %>: </label> <%= v %></li>
<% end %>
</ul>

</p>

<% unless @validation_issue.notes.blank? %>
<p>
<b>Notes:</b>
<%= @validation_issue.notes %>
</p>
<% end %>
<%= link_to 'Back', validation_admin_validation_issues_path, :class => 'button small-dark-orange-button' %>
3 changes: 3 additions & 0 deletions config/routes.rb
@@ -1,2 +1,5 @@
Rails.application.routes.draw do
namespace :validation_admin do
resources :validation_issues
end
end
16 changes: 16 additions & 0 deletions db/migrate/20120722204204_create_validation_issues.rb
@@ -0,0 +1,16 @@
class CreateValidationIssues < ActiveRecord::Migration
def change
create_table :validation_issues do |t|
t.string :issue_type
t.string :form_name, :null => false
t.text :issue_hash, :null => false
t.text :notes, :default => ''
t.integer :issue_count

t.timestamps
end
add_index :validation_issues, :form_name# , :length => 10
add_index :validation_issues, :issue_type
add_index :validation_issues, [:form_name, :issue_type], :unique => true
end
end

0 comments on commit d850884

Please sign in to comment.