spud_reports 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/jobs.js +2 -0
- data/app/assets/javascripts/spud/admin/printers.js +2 -0
- data/app/assets/javascripts/spud/admin/printers/jobs.js +2 -0
- data/app/assets/javascripts/spud_reports/application.js +15 -0
- data/app/assets/stylesheets/jobs.css +4 -0
- data/app/assets/stylesheets/spud/admin/printers.css +4 -0
- data/app/assets/stylesheets/spud/admin/printers/jobs.css +4 -0
- data/app/assets/stylesheets/spud_reports/application.css +13 -0
- data/app/controllers/jobs_controller.rb +9 -0
- data/app/controllers/spud/admin/printers/jobs_controller.rb +43 -0
- data/app/controllers/spud/admin/printers_controller.rb +64 -0
- data/app/controllers/spud_reports/application_controller.rb +4 -0
- data/app/helpers/jobs_helper.rb +2 -0
- data/app/helpers/spud/admin/printers/jobs_helper.rb +2 -0
- data/app/helpers/spud/admin/printers_helper.rb +2 -0
- data/app/helpers/spud_reports/application_helper.rb +4 -0
- data/app/models/spud_print_job.rb +4 -0
- data/app/models/spud_printer.rb +15 -0
- data/app/views/jobs/index.rabl +5 -0
- data/app/views/layouts/spud_reports/application.html.erb +14 -0
- data/app/views/spud/admin/printers/_form.html.erb +15 -0
- data/app/views/spud/admin/printers/edit.html.erb +12 -0
- data/app/views/spud/admin/printers/index.html.erb +39 -0
- data/app/views/spud/admin/printers/jobs/index.html.erb +39 -0
- data/app/views/spud/admin/printers/new.html.erb +12 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20120317135556_create_spud_printers.rb +12 -0
- data/db/migrate/20120317135827_create_spud_print_jobs.rb +16 -0
- data/lib/spud_reports.rb +6 -0
- data/lib/spud_reports/configuration.rb +9 -0
- data/lib/spud_reports/engine.rb +18 -0
- data/lib/spud_reports/version.rb +5 -0
- data/lib/tasks/spud_reports_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +15 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/spud_print_jobs.yml +21 -0
- data/test/fixtures/spud_printers.yml +11 -0
- data/test/functional/jobs_controller_test.rb +7 -0
- data/test/functional/spud/admin/printers/jobs_controller_test.rb +7 -0
- data/test/functional/spud/admin/printers_controller_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/spud_reports_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/helpers/jobs_helper_test.rb +4 -0
- data/test/unit/helpers/spud/admin/printers/jobs_helper_test.rb +4 -0
- data/test/unit/helpers/spud/admin/printers_helper_test.rb +4 -0
- data/test/unit/spud_print_job_test.rb +7 -0
- data/test/unit/spud_printer_test.rb +7 -0
- metadata +260 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'SpudReports'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Spud::Admin::Printers::JobsController < Spud::Admin::ApplicationController
|
2
|
+
layout '/spud/admin/detail'
|
3
|
+
belongs_to_spud_app :printers
|
4
|
+
before_filter :load_printer
|
5
|
+
before_filter :load_job,:only => [:show,:edit,:update,:destroy]
|
6
|
+
add_breadcrumb "Printers", :spud_admin_printers_path
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
def index
|
11
|
+
add_breadcrumb "#{@printer.name}", :spud_admin_printer_jobs_path
|
12
|
+
@page_name = "Print Jobs For - #{@printer.name}"
|
13
|
+
@jobs = @printer.spud_print_jobs.paginate(:page => params[:page])
|
14
|
+
respond_with @jobs
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy
|
24
|
+
flash[:notice] = "Job removed successfully!" if @job.destroy
|
25
|
+
respond_with @job,:location => spud_admin_printer_jobs_path()
|
26
|
+
end
|
27
|
+
private
|
28
|
+
|
29
|
+
def load_printer
|
30
|
+
if !params[:printer_id].blank?
|
31
|
+
@printer = SpudPrinter.find(params[:printer_id])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_job
|
36
|
+
@job = SpudPrintJob.find(params[:id])
|
37
|
+
if @job.blank?
|
38
|
+
flash[:error] = "Unable to load spud print job"
|
39
|
+
redirect_to :back and return
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Spud::Admin::PrintersController < Spud::Admin::ApplicationController
|
2
|
+
layout '/spud/admin/detail'
|
3
|
+
belongs_to_spud_app :printers
|
4
|
+
add_breadcrumb "Printers", :spud_admin_printers_path
|
5
|
+
|
6
|
+
before_filter :load_printer,:only => [:edit,:update,:show,:destroy]
|
7
|
+
def index
|
8
|
+
@printers = SpudPrinter.order(:name).paginate :page => params[:page]
|
9
|
+
respond_with @printers
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
add_breadcrumb "New", :new_spud_admin_printer_path
|
14
|
+
@printer = SpudPrinter.new
|
15
|
+
respond_with @printer
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
add_breadcrumb "New", :new_spud_admin_printer_path
|
20
|
+
|
21
|
+
@printer = SpudPrinter.new(params[:spud_printer])
|
22
|
+
|
23
|
+
if @printer.save
|
24
|
+
flash[:notice] = "Printer added successfully!"
|
25
|
+
else
|
26
|
+
flash[:error] = "Error saving printer!"
|
27
|
+
end
|
28
|
+
|
29
|
+
respond_with @printer,:location => spud_admin_printers_url
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
add_breadcrumb "Edit", :edit_spud_admin_printer_path
|
34
|
+
|
35
|
+
respond_with @printer
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
add_breadcrumb "Edit", :edit_spud_admin_printer_path
|
40
|
+
|
41
|
+
if @printer.update_attributes(params[:spud_printer])
|
42
|
+
flash[:notice] = "Printer updated successfully!"
|
43
|
+
else
|
44
|
+
flash[:error] = "Error saving printer!"
|
45
|
+
end
|
46
|
+
respond_with @printer,:location => spud_admin_printers_url
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
|
51
|
+
flash[:notice] = "Printer removed!" if @printer.destroy
|
52
|
+
|
53
|
+
respond_with @printer,:location => spud_admin_printers_url
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def load_printer
|
58
|
+
@printer = SpudPrinter.find(params[:id])
|
59
|
+
if @printer.blank?
|
60
|
+
flash[:error] = "Printer not found!"
|
61
|
+
redirect_to spud_admin_printers_url and return
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
class SpudPrinter < ActiveRecord::Base
|
3
|
+
has_many :spud_print_jobs
|
4
|
+
has_many :active_jobs,:class_name => "SpudPrintJob",:foreign_key => :spud_printer_id,:conditions => "spud_print_jobs.status = 0"
|
5
|
+
validates :name, :presence => true, :uniqueness => true
|
6
|
+
validates :access_token, :presence=>true, :uniqueness=>true
|
7
|
+
|
8
|
+
before_validation :generate_access_token
|
9
|
+
|
10
|
+
private
|
11
|
+
def generate_access_token
|
12
|
+
return if !self.access_token.blank?
|
13
|
+
self.access_token = Digest::SHA1.hexdigest(Time.now.to_s)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>SpudReports</title>
|
5
|
+
<%= stylesheet_link_tag "spud_reports/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "spud_reports/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%=error_messages_for(f.object)%>
|
2
|
+
<fieldset>
|
3
|
+
<div class="control-group">
|
4
|
+
<%=f.label :name, :required=>true,:class => "control-label"%>
|
5
|
+
<div class="controls">
|
6
|
+
<%=f.text_field :name,:title => "",:size=>40%>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
</div>
|
10
|
+
|
11
|
+
|
12
|
+
</fieldset>
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
<%=form_for @printer,:url => spud_admin_printer_path(:id => @printer.id),:html=>{:class=>"form-horizontal"} do |f|%>
|
5
|
+
<%=render :partial => "form",:locals => {:f => f}%>
|
6
|
+
<div class="form-actions">
|
7
|
+
<%=f.submit "Save Printer", :class=>"btn btn-primary"%> or <%=link_to "cancel",spud_admin_printers_path,:class => "btn"%>
|
8
|
+
</div>
|
9
|
+
<%end%>
|
10
|
+
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%=content_for :data_controls do%>
|
2
|
+
<%=link_to "New Printer",new_spud_admin_printer_path(),:class => "btn btn-primary",:title => "New Printer"%>
|
3
|
+
<%end%>
|
4
|
+
<%=content_for :detail do%>
|
5
|
+
<table class="admin-table data-table" id="printertable">
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
|
9
|
+
<th>Name</th>
|
10
|
+
<th>Status</th>
|
11
|
+
<th>Jobs</th>
|
12
|
+
<th>Access Token</th>
|
13
|
+
<th></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
<%@printers.each do |printer|%>
|
18
|
+
<tr id="row_printer_<%=printer.id%>">
|
19
|
+
|
20
|
+
<td><%=link_to printer.name,edit_spud_admin_printer_path(:id => printer.id)%></td>
|
21
|
+
<td><%=printer.status%></td>
|
22
|
+
<td><%=link_to printer.spud_print_jobs.count, spud_admin_printer_jobs_path(:printer_id => printer.id)%></td>
|
23
|
+
|
24
|
+
<td><%=printer.access_token%></td>
|
25
|
+
|
26
|
+
<td align="right"><%=link_to "Remove",spud_admin_printer_path(:id => printer.id),:method => :delete,:confirm => "Are you sure you want to remove this printer?",:class => "btn btn-danger"%></td>
|
27
|
+
</tr>
|
28
|
+
<%end%>
|
29
|
+
</tbody>
|
30
|
+
<tfoot>
|
31
|
+
<tr>
|
32
|
+
<td colspan="6">
|
33
|
+
<%=will_paginate @printers%>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
</tfoot>
|
37
|
+
</table>
|
38
|
+
|
39
|
+
<%end%>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<%=content_for :detail do%>
|
4
|
+
<table class="admin-table data-table" id="printertable">
|
5
|
+
<thead>
|
6
|
+
<tr>
|
7
|
+
|
8
|
+
<th>Name</th>
|
9
|
+
<th>Status</th>
|
10
|
+
<th>Pages</th>
|
11
|
+
<th>User</th>
|
12
|
+
<th>Created At</th>
|
13
|
+
<th></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
<%@jobs.each do |job|%>
|
18
|
+
<tr id="row_printer_<%=printer.id%>">
|
19
|
+
|
20
|
+
<td><%=job.name%></td>
|
21
|
+
<td><%=job.status%></td>
|
22
|
+
<td><%=job.pages%></td>
|
23
|
+
|
24
|
+
<td><%=job.user.login if !job.user.blank?%></td>
|
25
|
+
<td><%=timestamp job.created_at%>
|
26
|
+
<td align="right"><%=link_to "Cancel",spud_admin_printer_job_path(:id => job.id),:method => :delete,:confirm => "Are you sure you want to cancel this print job?",:class => "btn btn-danger"%></td>
|
27
|
+
</tr>
|
28
|
+
<%end%>
|
29
|
+
</tbody>
|
30
|
+
<tfoot>
|
31
|
+
<tr>
|
32
|
+
<td colspan="6">
|
33
|
+
<%=will_paginate @jobs%>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
</tfoot>
|
37
|
+
</table>
|
38
|
+
|
39
|
+
<%end%>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
<%=form_for @printer,:url => spud_admin_printers_path,:html=>{:class=>"form-horizontal"} do |f|%>
|
5
|
+
<%=render :partial => "form",:locals => {:f => f}%>
|
6
|
+
<div class="form-actions">
|
7
|
+
<%=f.submit "Create Printer", :class=>"btn btn-primary"%> or <%=link_to "cancel",spud_admin_printers_path,:class => "btn"%>
|
8
|
+
</div>
|
9
|
+
<%end%>
|
10
|
+
|
11
|
+
|
12
|
+
|