Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
598 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
44
app/controllers/validation_admin/validation_issues_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
25
app/views/validation_admin/validation_issues/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
22
app/views/validation_admin/validation_issues/show.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
Rails.application.routes.draw do | ||
namespace :validation_admin do | ||
resources :validation_issues | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.