An open source, stand-alone, customisable public spending data web app.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

78 řádky
2.0 KiB

  1. require 'rubygems'
  2. require 'dm-core'
  3. require 'dm-validations'
  4. require 'dm-timestamps'
  5. require 'dm-aggregates'
  6. SITE_URL = 'http://armchairauditor.co.uk/'
  7. class Payment
  8. include DataMapper::Resource
  9. property :id, Serial
  10. property :trans_no, Integer, :required => false # "TransNo" in RBWM CSV files
  11. property :directorate_id, Integer, :required => true
  12. property :service_id, Integer, :required => true
  13. property :supplier_id, Integer, :required => true
  14. property :cost_centre, String, :required => false
  15. property :amount, BigDecimal, :precision => 10, :scale => 2, :required => true # ex VAT
  16. property :d, Date, :required => true # "Updated" in RBWM CSV files
  17. property :tyype, String, :required => true # Capital or Revenue
  18. belongs_to :directorate
  19. belongs_to :service
  20. belongs_to :supplier
  21. def url
  22. SITE_URL + "payments/" + @id.to_s
  23. end
  24. end
  25. class Directorate
  26. include DataMapper::Resource
  27. property :id, Serial
  28. property :name, String, :length => 255, :required => true
  29. property :slug, String, :length => 255
  30. has n, :payments, :order => ['d']
  31. def self.slugify(name)
  32. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  33. end
  34. end
  35. class Service
  36. include DataMapper::Resource
  37. property :id, Serial
  38. property :name, String, :length => 255, :required => true
  39. property :slug, String, :length => 255
  40. has n, :payments, :order => ['d']
  41. def self.slugify(name)
  42. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  43. end
  44. end
  45. class Supplier
  46. include DataMapper::Resource
  47. property :id, Serial
  48. property :name, String, :length => 255, :required => true
  49. property :slug, String, :length => 255
  50. has n, :payments, :order => ['d']
  51. def self.slugify(name)
  52. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  53. end
  54. end
  55. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  56. DataMapper.auto_upgrade!